Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a0fcc9a2
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
a0fcc9a2
编写于
4月 27, 2022
作者:
P
Ping Xiao
浏览文件
操作
浏览文件
下载
差异文件
Merge branch '3.0' into xiaoping/3.0
上级
ccffe945
a558b445
变更
86
显示空白变更内容
内联
并排
Showing
86 changed file
with
927 addition
and
1007 deletion
+927
-1007
.devcontainer/Dockerfile
.devcontainer/Dockerfile
+1
-1
include/common/tmsg.h
include/common/tmsg.h
+3
-51
include/libs/function/functionMgt.h
include/libs/function/functionMgt.h
+6
-5
include/libs/nodes/plannodes.h
include/libs/nodes/plannodes.h
+142
-153
include/libs/nodes/querynodes.h
include/libs/nodes/querynodes.h
+4
-1
include/libs/transport/trpc.h
include/libs/transport/trpc.h
+6
-2
include/libs/wal/wal.h
include/libs/wal/wal.h
+0
-2
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+6
-0
source/client/src/tmq.c
source/client/src/tmq.c
+50
-57
source/common/src/tmsg.c
source/common/src/tmsg.c
+5
-24
source/dnode/mnode/impl/inc/mndDef.h
source/dnode/mnode/impl/inc/mndDef.h
+0
-2
source/dnode/mnode/impl/inc/mndInt.h
source/dnode/mnode/impl/inc/mndInt.h
+28
-28
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+5
-54
source/dnode/mnode/impl/src/mndSync.c
source/dnode/mnode/impl/src/mndSync.c
+27
-25
source/dnode/mnode/impl/src/mndTelem.c
source/dnode/mnode/impl/src/mndTelem.c
+0
-1
source/dnode/mnode/impl/src/mndUser.c
source/dnode/mnode/impl/src/mndUser.c
+16
-16
source/dnode/mnode/impl/test/sma/sma.cpp
source/dnode/mnode/impl/test/sma/sma.cpp
+4
-7
source/dnode/mnode/sdb/src/sdb.c
source/dnode/mnode/sdb/src/sdb.c
+1
-4
source/dnode/mnode/sdb/src/sdbFile.c
source/dnode/mnode/sdb/src/sdbFile.c
+1
-1
source/dnode/vnode/CMakeLists.txt
source/dnode/vnode/CMakeLists.txt
+0
-2
source/dnode/vnode/inc/vnode.h
source/dnode/vnode/inc/vnode.h
+4
-4
source/dnode/vnode/src/inc/meta.h
source/dnode/vnode/src/inc/meta.h
+6
-28
source/dnode/vnode/src/inc/tq.h
source/dnode/vnode/src/inc/tq.h
+8
-16
source/dnode/vnode/src/inc/tsdb.h
source/dnode/vnode/src/inc/tsdb.h
+2
-14
source/dnode/vnode/src/inc/tsdbSma.h
source/dnode/vnode/src/inc/tsdbSma.h
+1
-9
source/dnode/vnode/src/inc/vnd.h
source/dnode/vnode/src/inc/vnd.h
+21
-5
source/dnode/vnode/src/inc/vnodeInt.h
source/dnode/vnode/src/inc/vnodeInt.h
+55
-12
source/dnode/vnode/src/inc/vnodeSync.h
source/dnode/vnode/src/inc/vnodeSync.h
+0
-44
source/dnode/vnode/src/meta/metaCommit.c
source/dnode/vnode/src/meta/metaCommit.c
+1
-1
source/dnode/vnode/src/meta/metaEntry.c
source/dnode/vnode/src/meta/metaEntry.c
+1
-1
source/dnode/vnode/src/meta/metaIdx.c
source/dnode/vnode/src/meta/metaIdx.c
+1
-1
source/dnode/vnode/src/meta/metaOpen.c
source/dnode/vnode/src/meta/metaOpen.c
+1
-1
source/dnode/vnode/src/meta/metaQuery.c
source/dnode/vnode/src/meta/metaQuery.c
+9
-6
source/dnode/vnode/src/meta/metaTable.c
source/dnode/vnode/src/meta/metaTable.c
+3
-3
source/dnode/vnode/src/tq/tq.c
source/dnode/vnode/src/tq/tq.c
+29
-58
source/dnode/vnode/src/tq/tqCommit.c
source/dnode/vnode/src/tq/tqCommit.c
+1
-1
source/dnode/vnode/src/tq/tqMetaStore.c
source/dnode/vnode/src/tq/tqMetaStore.c
+2
-2
source/dnode/vnode/src/tq/tqOffset.c
source/dnode/vnode/src/tq/tqOffset.c
+1
-1
source/dnode/vnode/src/tq/tqRead.c
source/dnode/vnode/src/tq/tqRead.c
+1
-1
source/dnode/vnode/src/tsdb/tsdbCommit.c
source/dnode/vnode/src/tsdb/tsdbCommit.c
+1
-1
source/dnode/vnode/src/tsdb/tsdbCommit2.c
source/dnode/vnode/src/tsdb/tsdbCommit2.c
+1
-1
source/dnode/vnode/src/tsdb/tsdbCompact.c
source/dnode/vnode/src/tsdb/tsdbCompact.c
+5
-6
source/dnode/vnode/src/tsdb/tsdbFS.c
source/dnode/vnode/src/tsdb/tsdbFS.c
+1
-1
source/dnode/vnode/src/tsdb/tsdbFile.c
source/dnode/vnode/src/tsdb/tsdbFile.c
+1
-1
source/dnode/vnode/src/tsdb/tsdbMain.c
source/dnode/vnode/src/tsdb/tsdbMain.c
+1
-1
source/dnode/vnode/src/tsdb/tsdbMemTable.c
source/dnode/vnode/src/tsdb/tsdbMemTable.c
+1
-1
source/dnode/vnode/src/tsdb/tsdbOptions.c
source/dnode/vnode/src/tsdb/tsdbOptions.c
+0
-34
source/dnode/vnode/src/tsdb/tsdbRead.c
source/dnode/vnode/src/tsdb/tsdbRead.c
+4
-5
source/dnode/vnode/src/tsdb/tsdbReadImpl.c
source/dnode/vnode/src/tsdb/tsdbReadImpl.c
+1
-1
source/dnode/vnode/src/tsdb/tsdbScan.c
source/dnode/vnode/src/tsdb/tsdbScan.c
+1
-2
source/dnode/vnode/src/tsdb/tsdbSma.c
source/dnode/vnode/src/tsdb/tsdbSma.c
+2
-2
source/dnode/vnode/src/tsdb/tsdbTDBImpl.c
source/dnode/vnode/src/tsdb/tsdbTDBImpl.c
+3
-3
source/dnode/vnode/src/tsdb/tsdbWrite.c
source/dnode/vnode/src/tsdb/tsdbWrite.c
+1
-1
source/dnode/vnode/src/vnd/vnodeBufPool.c
source/dnode/vnode/src/vnd/vnodeBufPool.c
+1
-1
source/dnode/vnode/src/vnd/vnodeCfg.c
source/dnode/vnode/src/vnd/vnodeCfg.c
+1
-1
source/dnode/vnode/src/vnd/vnodeCommit.c
source/dnode/vnode/src/vnd/vnodeCommit.c
+2
-2
source/dnode/vnode/src/vnd/vnodeInt.c
source/dnode/vnode/src/vnd/vnodeInt.c
+1
-1
source/dnode/vnode/src/vnd/vnodeModule.c
source/dnode/vnode/src/vnd/vnodeModule.c
+1
-1
source/dnode/vnode/src/vnd/vnodeOpen.c
source/dnode/vnode/src/vnd/vnodeOpen.c
+1
-2
source/dnode/vnode/src/vnd/vnodeQuery.c
source/dnode/vnode/src/vnd/vnodeQuery.c
+7
-6
source/dnode/vnode/src/vnd/vnodeSvr.c
source/dnode/vnode/src/vnd/vnodeSvr.c
+1
-5
source/dnode/vnode/src/vnd/vnodeSync.c
source/dnode/vnode/src/vnd/vnodeSync.c
+6
-5
source/libs/function/inc/functionMgtInt.h
source/libs/function/inc/functionMgtInt.h
+2
-1
source/libs/function/src/builtins.c
source/libs/function/src/builtins.c
+1
-1
source/libs/function/src/functionMgt.c
source/libs/function/src/functionMgt.c
+24
-35
source/libs/nodes/src/nodesCloneFuncs.c
source/libs/nodes/src/nodesCloneFuncs.c
+1
-0
source/libs/nodes/src/nodesCodeFuncs.c
source/libs/nodes/src/nodesCodeFuncs.c
+14
-0
source/libs/nodes/src/nodesUtilFuncs.c
source/libs/nodes/src/nodesUtilFuncs.c
+22
-11
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+3
-19
source/libs/planner/src/planLogicCreater.c
source/libs/planner/src/planLogicCreater.c
+72
-84
source/libs/planner/src/planPhysiCreater.c
source/libs/planner/src/planPhysiCreater.c
+22
-4
source/libs/planner/test/planSTableTest.cpp
source/libs/planner/test/planSTableTest.cpp
+1
-1
source/libs/transport/inc/transComm.h
source/libs/transport/inc/transComm.h
+7
-8
source/libs/transport/inc/transportInt.h
source/libs/transport/inc/transportInt.h
+1
-2
source/libs/transport/src/trans.c
source/libs/transport/src/trans.c
+3
-10
source/libs/transport/src/transCli.c
source/libs/transport/src/transCli.c
+87
-50
source/libs/transport/src/transComm.c
source/libs/transport/src/transComm.c
+0
-11
source/libs/transport/src/transSrv.c
source/libs/transport/src/transSrv.c
+4
-1
source/os/src/osMemory.c
source/os/src/osMemory.c
+25
-28
tests/script/jenkins/basic.txt
tests/script/jenkins/basic.txt
+1
-0
tests/script/sh/deploy.sh
tests/script/sh/deploy.sh
+1
-0
tests/script/tsim/db/alter_option.sim
tests/script/tsim/db/alter_option.sim
+43
-0
tests/script/tsim/db/taosdlog.sim
tests/script/tsim/db/taosdlog.sim
+31
-0
tests/system-test/0-others/taosdlog.py
tests/system-test/0-others/taosdlog.py
+65
-0
tools/shell/inc/shellInt.h
tools/shell/inc/shellInt.h
+0
-1
tools/shell/src/shellEngine.c
tools/shell/src/shellEngine.c
+1
-12
未找到文件。
.devcontainer/Dockerfile
浏览文件 @
a0fcc9a2
...
@@ -7,4 +7,4 @@ FROM mcr.microsoft.com/vscode/devcontainers/cpp:0-${VARIANT}
...
@@ -7,4 +7,4 @@ FROM mcr.microsoft.com/vscode/devcontainers/cpp:0-${VARIANT}
# [Optional] Uncomment this section to install additional packages.
# [Optional] Uncomment this section to install additional packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>
# && apt-get -y install --no-install-recommends <your-package-list-here>
RUN
apt-get update
&&
apt-get
-y
install
tree vim tmux
RUN
apt-get update
&&
apt-get
-y
install
tree vim tmux
python3-pip
include/common/tmsg.h
浏览文件 @
a0fcc9a2
...
@@ -177,6 +177,7 @@ typedef struct SField {
...
@@ -177,6 +177,7 @@ typedef struct SField {
char
name
[
TSDB_COL_NAME_LEN
];
char
name
[
TSDB_COL_NAME_LEN
];
uint8_t
type
;
uint8_t
type
;
int32_t
bytes
;
int32_t
bytes
;
int8_t
flags
;
}
SField
;
}
SField
;
typedef
struct
SRetention
{
typedef
struct
SRetention
{
...
@@ -302,13 +303,11 @@ typedef struct {
...
@@ -302,13 +303,11 @@ typedef struct {
int32_t
ttl
;
int32_t
ttl
;
int32_t
numOfColumns
;
int32_t
numOfColumns
;
int32_t
numOfTags
;
int32_t
numOfTags
;
int32_t
numOfSmas
;
int32_t
commentLen
;
int32_t
commentLen
;
int32_t
ast1Len
;
int32_t
ast1Len
;
int32_t
ast2Len
;
int32_t
ast2Len
;
SArray
*
pColumns
;
// array of SField
SArray
*
pColumns
;
// array of SField
SArray
*
pTags
;
// array of SField
SArray
*
pTags
;
// array of SField
SArray
*
pSmas
;
// array of SField
char
*
comment
;
char
*
comment
;
char
*
pAst1
;
char
*
pAst1
;
char
*
pAst2
;
char
*
pAst2
;
...
@@ -2384,9 +2383,9 @@ typedef struct {
...
@@ -2384,9 +2383,9 @@ typedef struct {
int32_t
epoch
;
int32_t
epoch
;
uint64_t
reqId
;
uint64_t
reqId
;
int64_t
consumerId
;
int64_t
consumerId
;
int64_t
blocking
Time
;
int64_t
wait
Time
;
int64_t
currentOffset
;
int64_t
currentOffset
;
}
SMqPollReq
V2
;
}
SMqPollReq
;
typedef
struct
{
typedef
struct
{
int32_t
vgId
;
int32_t
vgId
;
...
@@ -2401,53 +2400,6 @@ typedef struct {
...
@@ -2401,53 +2400,6 @@ typedef struct {
SSchemaWrapper
schema
;
SSchemaWrapper
schema
;
}
SMqSubTopicEp
;
}
SMqSubTopicEp
;
typedef
struct
{
SMqRspHead
head
;
int64_t
reqOffset
;
int64_t
rspOffset
;
int32_t
skipLogNum
;
int32_t
dataLen
;
SArray
*
blockPos
;
// beginning pos for each SRetrieveTableRsp
void
*
blockData
;
// serialized batched SRetrieveTableRsp
}
SMqPollRspV2
;
static
FORCE_INLINE
int32_t
tEncodeSMqPollRspV2
(
void
**
buf
,
const
SMqPollRspV2
*
pRsp
)
{
int32_t
tlen
=
0
;
tlen
+=
taosEncodeFixedI64
(
buf
,
pRsp
->
reqOffset
);
tlen
+=
taosEncodeFixedI64
(
buf
,
pRsp
->
rspOffset
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pRsp
->
skipLogNum
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pRsp
->
dataLen
);
if
(
pRsp
->
dataLen
!=
0
)
{
int32_t
sz
=
taosArrayGetSize
(
pRsp
->
blockPos
);
tlen
+=
taosEncodeFixedI32
(
buf
,
sz
);
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
int32_t
blockPos
=
*
(
int32_t
*
)
taosArrayGet
(
pRsp
->
blockPos
,
i
);
tlen
+=
taosEncodeFixedI32
(
buf
,
blockPos
);
}
tlen
+=
taosEncodeBinary
(
buf
,
pRsp
->
blockData
,
pRsp
->
dataLen
);
}
return
tlen
;
}
static
FORCE_INLINE
void
*
tDecodeSMqPollRspV2
(
const
void
*
buf
,
SMqPollRspV2
*
pRsp
)
{
buf
=
taosDecodeFixedI64
(
buf
,
&
pRsp
->
reqOffset
);
buf
=
taosDecodeFixedI64
(
buf
,
&
pRsp
->
rspOffset
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pRsp
->
skipLogNum
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pRsp
->
dataLen
);
if
(
pRsp
->
dataLen
!=
0
)
{
int32_t
sz
;
buf
=
taosDecodeFixedI32
(
buf
,
&
sz
);
pRsp
->
blockPos
=
taosArrayInit
(
sz
,
sizeof
(
int32_t
));
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
int32_t
blockPos
;
buf
=
taosDecodeFixedI32
(
buf
,
&
blockPos
);
taosArrayPush
(
pRsp
->
blockPos
,
&
blockPos
);
}
buf
=
taosDecodeBinary
(
buf
,
&
pRsp
->
blockData
,
pRsp
->
dataLen
);
}
return
(
void
*
)
buf
;
}
typedef
struct
{
typedef
struct
{
SMqRspHead
head
;
SMqRspHead
head
;
int64_t
reqOffset
;
int64_t
reqOffset
;
...
...
include/libs/function/functionMgt.h
浏览文件 @
a0fcc9a2
...
@@ -20,8 +20,8 @@
...
@@ -20,8 +20,8 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
#include "querynodes.h"
#include "function.h"
#include "function.h"
#include "querynodes.h"
typedef
enum
EFunctionType
{
typedef
enum
EFunctionType
{
// aggregate function
// aggregate function
...
@@ -123,7 +123,7 @@ struct SCatalog;
...
@@ -123,7 +123,7 @@ struct SCatalog;
typedef
struct
SFmGetFuncInfoParam
{
typedef
struct
SFmGetFuncInfoParam
{
struct
SCatalog
*
pCtg
;
struct
SCatalog
*
pCtg
;
void
*
pRpc
;
void
*
pRpc
;
const
SEpSet
*
pMgmtEps
;
const
SEpSet
*
pMgmtEps
;
char
*
pErrBuf
;
char
*
pErrBuf
;
int32_t
errBufLen
;
int32_t
errBufLen
;
...
@@ -143,6 +143,7 @@ bool fmIsDatetimeFunc(int32_t funcId);
...
@@ -143,6 +143,7 @@ bool fmIsDatetimeFunc(int32_t funcId);
bool
fmIsTimelineFunc
(
int32_t
funcId
);
bool
fmIsTimelineFunc
(
int32_t
funcId
);
bool
fmIsTimeorderFunc
(
int32_t
funcId
);
bool
fmIsTimeorderFunc
(
int32_t
funcId
);
bool
fmIsPseudoColumnFunc
(
int32_t
funcId
);
bool
fmIsPseudoColumnFunc
(
int32_t
funcId
);
bool
fmIsScanPseudoColumnFunc
(
int32_t
funcId
);
bool
fmIsWindowPseudoColumnFunc
(
int32_t
funcId
);
bool
fmIsWindowPseudoColumnFunc
(
int32_t
funcId
);
bool
fmIsWindowClauseFunc
(
int32_t
funcId
);
bool
fmIsWindowClauseFunc
(
int32_t
funcId
);
bool
fmIsSpecialDataRequiredFunc
(
int32_t
funcId
);
bool
fmIsSpecialDataRequiredFunc
(
int32_t
funcId
);
...
...
include/libs/nodes/plannodes.h
浏览文件 @
a0fcc9a2
...
@@ -20,8 +20,8 @@
...
@@ -20,8 +20,8 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
#include "querynodes.h"
#include "query.h"
#include "query.h"
#include "querynodes.h"
#include "tname.h"
#include "tname.h"
typedef
struct
SLogicNode
{
typedef
struct
SLogicNode
{
...
@@ -33,16 +33,12 @@ typedef struct SLogicNode {
...
@@ -33,16 +33,12 @@ typedef struct SLogicNode {
int32_t
optimizedFlag
;
int32_t
optimizedFlag
;
}
SLogicNode
;
}
SLogicNode
;
typedef
enum
EScanType
{
typedef
enum
EScanType
{
SCAN_TYPE_TAG
=
1
,
SCAN_TYPE_TABLE
,
SCAN_TYPE_SYSTEM_TABLE
,
SCAN_TYPE_STREAM
}
EScanType
;
SCAN_TYPE_TAG
,
SCAN_TYPE_TABLE
,
SCAN_TYPE_SYSTEM_TABLE
,
SCAN_TYPE_STREAM
}
EScanType
;
typedef
struct
SScanLogicNode
{
typedef
struct
SScanLogicNode
{
SLogicNode
node
;
SLogicNode
node
;
SNodeList
*
pScanCols
;
SNodeList
*
pScanCols
;
SNodeList
*
pScanPseudoCols
;
struct
STableMeta
*
pMeta
;
struct
STableMeta
*
pMeta
;
SVgroupsInfo
*
pVgroupList
;
SVgroupsInfo
*
pVgroupList
;
EScanType
scanType
;
EScanType
scanType
;
...
@@ -95,11 +91,7 @@ typedef struct SExchangeLogicNode {
...
@@ -95,11 +91,7 @@ typedef struct SExchangeLogicNode {
uint8_t
precision
;
uint8_t
precision
;
}
SExchangeLogicNode
;
}
SExchangeLogicNode
;
typedef
enum
EWindowType
{
typedef
enum
EWindowType
{
WINDOW_TYPE_INTERVAL
=
1
,
WINDOW_TYPE_SESSION
,
WINDOW_TYPE_STATE
}
EWindowType
;
WINDOW_TYPE_INTERVAL
=
1
,
WINDOW_TYPE_SESSION
,
WINDOW_TYPE_STATE
}
EWindowType
;
typedef
struct
SWindowLogicNode
{
typedef
struct
SWindowLogicNode
{
SLogicNode
node
;
SLogicNode
node
;
...
@@ -187,6 +179,7 @@ typedef struct SPhysiNode {
...
@@ -187,6 +179,7 @@ typedef struct SPhysiNode {
typedef
struct
SScanPhysiNode
{
typedef
struct
SScanPhysiNode
{
SPhysiNode
node
;
SPhysiNode
node
;
SNodeList
*
pScanCols
;
SNodeList
*
pScanCols
;
SNodeList
*
pScanPseudoCols
;
uint64_t
uid
;
// unique id of the table
uint64_t
uid
;
// unique id of the table
int8_t
tableType
;
int8_t
tableType
;
SName
tableName
;
SName
tableName
;
...
@@ -315,7 +308,7 @@ typedef struct SDataInserterNode {
...
@@ -315,7 +308,7 @@ typedef struct SDataInserterNode {
SDataSinkNode
sink
;
SDataSinkNode
sink
;
int32_t
numOfTables
;
int32_t
numOfTables
;
uint32_t
size
;
uint32_t
size
;
char
*
pData
;
char
*
pData
;
}
SDataInserterNode
;
}
SDataInserterNode
;
typedef
struct
SSubplan
{
typedef
struct
SSubplan
{
...
@@ -333,11 +326,7 @@ typedef struct SSubplan {
...
@@ -333,11 +326,7 @@ typedef struct SSubplan {
SDataSinkNode
*
pDataSink
;
// data of the subplan flow into the datasink
SDataSinkNode
*
pDataSink
;
// data of the subplan flow into the datasink
}
SSubplan
;
}
SSubplan
;
typedef
enum
EExplainMode
{
typedef
enum
EExplainMode
{
EXPLAIN_MODE_DISABLE
=
1
,
EXPLAIN_MODE_STATIC
,
EXPLAIN_MODE_ANALYZE
}
EExplainMode
;
EXPLAIN_MODE_DISABLE
=
1
,
EXPLAIN_MODE_STATIC
,
EXPLAIN_MODE_ANALYZE
}
EExplainMode
;
typedef
struct
SExplainInfo
{
typedef
struct
SExplainInfo
{
EExplainMode
mode
;
EExplainMode
mode
;
...
...
include/libs/nodes/querynodes.h
浏览文件 @
a0fcc9a2
...
@@ -293,7 +293,10 @@ typedef struct SExplainStmt {
...
@@ -293,7 +293,10 @@ typedef struct SExplainStmt {
void
nodesWalkSelectStmt
(
SSelectStmt
*
pSelect
,
ESqlClause
clause
,
FNodeWalker
walker
,
void
*
pContext
);
void
nodesWalkSelectStmt
(
SSelectStmt
*
pSelect
,
ESqlClause
clause
,
FNodeWalker
walker
,
void
*
pContext
);
void
nodesRewriteSelectStmt
(
SSelectStmt
*
pSelect
,
ESqlClause
clause
,
FNodeRewriter
rewriter
,
void
*
pContext
);
void
nodesRewriteSelectStmt
(
SSelectStmt
*
pSelect
,
ESqlClause
clause
,
FNodeRewriter
rewriter
,
void
*
pContext
);
int32_t
nodesCollectColumns
(
SSelectStmt
*
pSelect
,
ESqlClause
clause
,
const
char
*
pTableAlias
,
SNodeList
**
pCols
);
typedef
enum
ECollectColType
{
COLLECT_COL_TYPE_COL
=
1
,
COLLECT_COL_TYPE_TAG
,
COLLECT_COL_TYPE_ALL
}
ECollectColType
;
int32_t
nodesCollectColumns
(
SSelectStmt
*
pSelect
,
ESqlClause
clause
,
const
char
*
pTableAlias
,
ECollectColType
type
,
SNodeList
**
pCols
);
typedef
bool
(
*
FFuncClassifier
)(
int32_t
funcId
);
typedef
bool
(
*
FFuncClassifier
)(
int32_t
funcId
);
int32_t
nodesCollectFuncs
(
SSelectStmt
*
pSelect
,
FFuncClassifier
classifier
,
SNodeList
**
pFuncs
);
int32_t
nodesCollectFuncs
(
SSelectStmt
*
pSelect
,
FFuncClassifier
classifier
,
SNodeList
**
pFuncs
);
...
...
include/libs/transport/trpc.h
浏览文件 @
a0fcc9a2
...
@@ -59,9 +59,13 @@ typedef struct {
...
@@ -59,9 +59,13 @@ typedef struct {
void
*
pNode
;
void
*
pNode
;
}
SNodeMsg
;
}
SNodeMsg
;
typedef
void
(
*
RpcCfp
)(
void
*
parent
,
SRpcMsg
*
,
SEpSet
*
);
typedef
void
(
*
RpcCfp
)(
void
*
parent
,
SRpcMsg
*
,
SEpSet
*
rf
);
typedef
int
(
*
RpcAfp
)(
void
*
parent
,
char
*
tableId
,
char
*
spi
,
char
*
encrypt
,
char
*
secret
,
char
*
ckey
);
typedef
int
(
*
RpcAfp
)(
void
*
parent
,
char
*
tableId
,
char
*
spi
,
char
*
encrypt
,
char
*
secret
,
char
*
ckey
);
typedef
int
(
*
RpcRfp
)(
void
*
parent
,
SRpcMsg
*
,
SEpSet
*
);
///
// // SRpcMsg code
// REDIERE,
// NOT READY, EpSet
typedef
bool
(
*
RpcRfp
)(
int32_t
code
);
typedef
struct
SRpcInit
{
typedef
struct
SRpcInit
{
uint16_t
localPort
;
// local port
uint16_t
localPort
;
// local port
...
...
include/libs/wal/wal.h
浏览文件 @
a0fcc9a2
...
@@ -72,8 +72,6 @@ extern "C" {
...
@@ -72,8 +72,6 @@ extern "C" {
#define WAL_FILE_LEN (WAL_PATH_LEN + 32)
#define WAL_FILE_LEN (WAL_PATH_LEN + 32)
#define WAL_MAGIC 0xFAFBFCFDULL
#define WAL_MAGIC 0xFAFBFCFDULL
#define WAL_CUR_FAILED 1
#pragma pack(push, 1)
#pragma pack(push, 1)
typedef
enum
{
typedef
enum
{
TAOS_WAL_NOLOG
=
0
,
TAOS_WAL_NOLOG
=
0
,
...
...
source/client/src/clientImpl.c
浏览文件 @
a0fcc9a2
...
@@ -246,6 +246,12 @@ void setResSchemaInfo(SReqResultInfo* pResInfo, const SSchema* pSchema, int32_t
...
@@ -246,6 +246,12 @@ void setResSchemaInfo(SReqResultInfo* pResInfo, const SSchema* pSchema, int32_t
pResInfo
->
numOfCols
=
numOfCols
;
pResInfo
->
numOfCols
=
numOfCols
;
// TODO handle memory leak
// TODO handle memory leak
if
(
pResInfo
->
fields
!=
NULL
)
{
taosMemoryFree
(
pResInfo
->
fields
);
}
if
(
pResInfo
->
userFields
!=
NULL
)
{
taosMemoryFree
(
pResInfo
->
userFields
);
}
pResInfo
->
fields
=
taosMemoryCalloc
(
numOfCols
,
sizeof
(
TAOS_FIELD
));
pResInfo
->
fields
=
taosMemoryCalloc
(
numOfCols
,
sizeof
(
TAOS_FIELD
));
pResInfo
->
userFields
=
taosMemoryCalloc
(
numOfCols
,
sizeof
(
TAOS_FIELD
));
pResInfo
->
userFields
=
taosMemoryCalloc
(
numOfCols
,
sizeof
(
TAOS_FIELD
));
...
...
source/client/src/tmq.c
浏览文件 @
a0fcc9a2
...
@@ -16,7 +16,6 @@
...
@@ -16,7 +16,6 @@
#include "clientInt.h"
#include "clientInt.h"
#include "clientLog.h"
#include "clientLog.h"
#include "parser.h"
#include "parser.h"
#include "planner.h"
#include "tdatablock.h"
#include "tdatablock.h"
#include "tdef.h"
#include "tdef.h"
#include "tglobal.h"
#include "tglobal.h"
...
@@ -68,7 +67,7 @@ struct tmq_conf_t {
...
@@ -68,7 +67,7 @@ struct tmq_conf_t {
char
*
user
;
char
*
user
;
char
*
pass
;
char
*
pass
;
char
*
db
;
char
*
db
;
tmq_commit_cb
*
commit
_c
b
;
tmq_commit_cb
*
commit
C
b
;
};
};
struct
tmq_t
{
struct
tmq_t
{
...
@@ -115,8 +114,8 @@ enum {
...
@@ -115,8 +114,8 @@ enum {
enum
{
enum
{
TMQ_CONSUMER_STATUS__INIT
=
0
,
TMQ_CONSUMER_STATUS__INIT
=
0
,
TMQ_CONSUMER_STATUS__SUBSCRIBED
,
TMQ_CONSUMER_STATUS__READY
,
TMQ_CONSUMER_STATUS__READY
,
TMQ_CONSUMER_STATUS__NO_TOPIC
,
};
};
enum
{
enum
{
...
@@ -175,7 +174,6 @@ typedef struct {
...
@@ -175,7 +174,6 @@ typedef struct {
int32_t
epoch
;
int32_t
epoch
;
int32_t
vgId
;
int32_t
vgId
;
tsem_t
rspSem
;
tsem_t
rspSem
;
int32_t
sync
;
}
SMqPollCbParam
;
}
SMqPollCbParam
;
typedef
struct
{
typedef
struct
{
...
@@ -300,6 +298,7 @@ void tmqAssignDelayedHbTask(void* param, void* tmrId) {
...
@@ -300,6 +298,7 @@ void tmqAssignDelayedHbTask(void* param, void* tmrId) {
int8_t
*
pTaskType
=
taosAllocateQitem
(
sizeof
(
int8_t
));
int8_t
*
pTaskType
=
taosAllocateQitem
(
sizeof
(
int8_t
));
*
pTaskType
=
TMQ_DELAYED_TASK__HB
;
*
pTaskType
=
TMQ_DELAYED_TASK__HB
;
taosWriteQitem
(
tmq
->
delayedTask
,
pTaskType
);
taosWriteQitem
(
tmq
->
delayedTask
,
pTaskType
);
tsem_post
(
&
tmq
->
rspSem
);
}
}
void
tmqAssignDelayedCommitTask
(
void
*
param
,
void
*
tmrId
)
{
void
tmqAssignDelayedCommitTask
(
void
*
param
,
void
*
tmrId
)
{
...
@@ -307,6 +306,7 @@ void tmqAssignDelayedCommitTask(void* param, void* tmrId) {
...
@@ -307,6 +306,7 @@ void tmqAssignDelayedCommitTask(void* param, void* tmrId) {
int8_t
*
pTaskType
=
taosAllocateQitem
(
sizeof
(
int8_t
));
int8_t
*
pTaskType
=
taosAllocateQitem
(
sizeof
(
int8_t
));
*
pTaskType
=
TMQ_DELAYED_TASK__COMMIT
;
*
pTaskType
=
TMQ_DELAYED_TASK__COMMIT
;
taosWriteQitem
(
tmq
->
delayedTask
,
pTaskType
);
taosWriteQitem
(
tmq
->
delayedTask
,
pTaskType
);
tsem_post
(
&
tmq
->
rspSem
);
}
}
void
tmqAssignDelayedReportTask
(
void
*
param
,
void
*
tmrId
)
{
void
tmqAssignDelayedReportTask
(
void
*
param
,
void
*
tmrId
)
{
...
@@ -314,6 +314,7 @@ void tmqAssignDelayedReportTask(void* param, void* tmrId) {
...
@@ -314,6 +314,7 @@ void tmqAssignDelayedReportTask(void* param, void* tmrId) {
int8_t
*
pTaskType
=
taosAllocateQitem
(
sizeof
(
int8_t
));
int8_t
*
pTaskType
=
taosAllocateQitem
(
sizeof
(
int8_t
));
*
pTaskType
=
TMQ_DELAYED_TASK__REPORT
;
*
pTaskType
=
TMQ_DELAYED_TASK__REPORT
;
taosWriteQitem
(
tmq
->
delayedTask
,
pTaskType
);
taosWriteQitem
(
tmq
->
delayedTask
,
pTaskType
);
tsem_post
(
&
tmq
->
rspSem
);
}
}
int32_t
tmqHandleAllDelayedTask
(
tmq_t
*
tmq
)
{
int32_t
tmqHandleAllDelayedTask
(
tmq_t
*
tmq
)
{
...
@@ -364,7 +365,6 @@ int32_t tmqSubscribeCb(void* param, const SDataBuf* pMsg, int32_t code) {
...
@@ -364,7 +365,6 @@ int32_t tmqSubscribeCb(void* param, const SDataBuf* pMsg, int32_t code) {
SMqSubscribeCbParam
*
pParam
=
(
SMqSubscribeCbParam
*
)
param
;
SMqSubscribeCbParam
*
pParam
=
(
SMqSubscribeCbParam
*
)
param
;
pParam
->
rspErr
=
code
;
pParam
->
rspErr
=
code
;
tmq_t
*
tmq
=
pParam
->
tmq
;
tmq_t
*
tmq
=
pParam
->
tmq
;
atomic_store_8
(
&
tmq
->
status
,
TMQ_CONSUMER_STATUS__SUBSCRIBED
);
tsem_post
(
&
pParam
->
rspSem
);
tsem_post
(
&
pParam
->
rspSem
);
return
0
;
return
0
;
}
}
...
@@ -385,14 +385,16 @@ tmq_resp_err_t tmq_subscription(tmq_t* tmq, tmq_list_t** topics) {
...
@@ -385,14 +385,16 @@ tmq_resp_err_t tmq_subscription(tmq_t* tmq, tmq_list_t** topics) {
}
}
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
tmq
->
clientTopics
);
i
++
)
{
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
tmq
->
clientTopics
);
i
++
)
{
SMqClientTopic
*
topic
=
taosArrayGetP
(
tmq
->
clientTopics
,
i
);
SMqClientTopic
*
topic
=
taosArrayGetP
(
tmq
->
clientTopics
,
i
);
tmq_list_append
(
*
topics
,
strdup
(
topic
->
topicName
)
);
tmq_list_append
(
*
topics
,
topic
->
topicName
);
}
}
return
TMQ_RESP_ERR__SUCCESS
;
return
TMQ_RESP_ERR__SUCCESS
;
}
}
tmq_resp_err_t
tmq_unsubscribe
(
tmq_t
*
tmq
)
{
tmq_resp_err_t
tmq_unsubscribe
(
tmq_t
*
tmq
)
{
tmq_list_t
*
lst
=
tmq_list_new
();
tmq_list_t
*
lst
=
tmq_list_new
();
return
tmq_subscribe
(
tmq
,
lst
);
tmq_resp_err_t
rsp
=
tmq_subscribe
(
tmq
,
lst
);
tmq_list_destroy
(
lst
);
return
rsp
;
}
}
#if 0
#if 0
...
@@ -475,7 +477,7 @@ tmq_t* tmq_consumer_new(tmq_conf_t* conf, char* errstr, int32_t errstrLen) {
...
@@ -475,7 +477,7 @@ tmq_t* tmq_consumer_new(tmq_conf_t* conf, char* errstr, int32_t errstrLen) {
strcpy
(
pTmq
->
groupId
,
conf
->
groupId
);
strcpy
(
pTmq
->
groupId
,
conf
->
groupId
);
pTmq
->
autoCommit
=
conf
->
autoCommit
;
pTmq
->
autoCommit
=
conf
->
autoCommit
;
pTmq
->
autoCommitInterval
=
conf
->
autoCommitInterval
;
pTmq
->
autoCommitInterval
=
conf
->
autoCommitInterval
;
pTmq
->
commit_cb
=
conf
->
commit
_c
b
;
pTmq
->
commit_cb
=
conf
->
commit
C
b
;
pTmq
->
resetOffsetCfg
=
conf
->
resetOffset
;
pTmq
->
resetOffsetCfg
=
conf
->
resetOffset
;
// assign consumerId
// assign consumerId
...
@@ -655,6 +657,9 @@ tmq_resp_err_t tmq_subscribe(tmq_t* tmq, const tmq_list_t* topic_list) {
...
@@ -655,6 +657,9 @@ tmq_resp_err_t tmq_subscribe(tmq_t* tmq, const tmq_list_t* topic_list) {
int64_t
transporterId
=
0
;
int64_t
transporterId
=
0
;
asyncSendMsgToServer
(
tmq
->
pTscObj
->
pAppInfo
->
pTransporter
,
&
epSet
,
&
transporterId
,
sendInfo
);
asyncSendMsgToServer
(
tmq
->
pTscObj
->
pAppInfo
->
pTransporter
,
&
epSet
,
&
transporterId
,
sendInfo
);
// avoid double free if msg is sent
buf
=
NULL
;
tsem_wait
(
&
param
.
rspSem
);
tsem_wait
(
&
param
.
rspSem
);
tsem_destroy
(
&
param
.
rspSem
);
tsem_destroy
(
&
param
.
rspSem
);
...
@@ -686,7 +691,7 @@ FAIL:
...
@@ -686,7 +691,7 @@ FAIL:
void
tmq_conf_set_offset_commit_cb
(
tmq_conf_t
*
conf
,
tmq_commit_cb
*
cb
)
{
void
tmq_conf_set_offset_commit_cb
(
tmq_conf_t
*
conf
,
tmq_commit_cb
*
cb
)
{
//
//
conf
->
commit
_c
b
=
cb
;
conf
->
commit
C
b
=
cb
;
}
}
TAOS_RES
*
tmq_create_stream
(
TAOS
*
taos
,
const
char
*
streamName
,
const
char
*
tbName
,
const
char
*
sql
)
{
TAOS_RES
*
tmq_create_stream
(
TAOS
*
taos
,
const
char
*
streamName
,
const
char
*
tbName
,
const
char
*
sql
)
{
...
@@ -798,7 +803,7 @@ int32_t tmqPollCb(void* param, const SDataBuf* pMsg, int32_t code) {
...
@@ -798,7 +803,7 @@ int32_t tmqPollCb(void* param, const SDataBuf* pMsg, int32_t code) {
// do not write into queue since updating epoch reset
// do not write into queue since updating epoch reset
tscWarn
(
"msg discard from vg %d since from earlier epoch, rsp epoch %d, current epoch %d"
,
pParam
->
vgId
,
msgEpoch
,
tscWarn
(
"msg discard from vg %d since from earlier epoch, rsp epoch %d, current epoch %d"
,
pParam
->
vgId
,
msgEpoch
,
tmqEpoch
);
tmqEpoch
);
/*tsem_post(&tmq->rspSem);*/
tsem_post
(
&
tmq
->
rspSem
);
return
0
;
return
0
;
}
}
...
@@ -806,25 +811,6 @@ int32_t tmqPollCb(void* param, const SDataBuf* pMsg, int32_t code) {
...
@@ -806,25 +811,6 @@ int32_t tmqPollCb(void* param, const SDataBuf* pMsg, int32_t code) {
tscWarn
(
"mismatch rsp from vg %d, epoch %d, current epoch %d"
,
pParam
->
vgId
,
msgEpoch
,
tmqEpoch
);
tscWarn
(
"mismatch rsp from vg %d, epoch %d, current epoch %d"
,
pParam
->
vgId
,
msgEpoch
,
tmqEpoch
);
}
}
#if 0
if (pParam->sync == 1) {
/**pParam->msg = taosMemoryMalloc(sizeof(tmq_message_t));*/
*pParam->msg = taosAllocateQitem(sizeof(tmq_message_t));
if (*pParam->msg) {
memcpy(*pParam->msg, pMsg->pData, sizeof(SMqRspHead));
tDecodeSMqConsumeRsp(POINTER_SHIFT(pMsg->pData, sizeof(SMqRspHead)), &((*pParam->msg)->consumeRsp));
if ((*pParam->msg)->consumeRsp.numOfTopics != 0) {
pVg->currentOffset = (*pParam->msg)->consumeRsp.rspOffset;
}
taosWriteQitem(tmq->mqueue, *pParam->msg);
tsem_post(&pParam->rspSem);
return 0;
}
tsem_post(&pParam->rspSem);
return -1;
}
#endif
SMqPollRspWrapper
*
pRspWrapper
=
taosAllocateQitem
(
sizeof
(
SMqPollRspWrapper
));
SMqPollRspWrapper
*
pRspWrapper
=
taosAllocateQitem
(
sizeof
(
SMqPollRspWrapper
));
if
(
pRspWrapper
==
NULL
)
{
if
(
pRspWrapper
==
NULL
)
{
tscWarn
(
"msg discard from vg %d, epoch %d since out of memory"
,
pParam
->
vgId
,
pParam
->
epoch
);
tscWarn
(
"msg discard from vg %d, epoch %d since out of memory"
,
pParam
->
vgId
,
pParam
->
epoch
);
...
@@ -843,14 +829,14 @@ int32_t tmqPollCb(void* param, const SDataBuf* pMsg, int32_t code) {
...
@@ -843,14 +829,14 @@ int32_t tmqPollCb(void* param, const SDataBuf* pMsg, int32_t code) {
pRspWrapper
->
msg
.
reqOffset
,
pRspWrapper
->
msg
.
rspOffset
);
pRspWrapper
->
msg
.
reqOffset
,
pRspWrapper
->
msg
.
rspOffset
);
taosWriteQitem
(
tmq
->
mqueue
,
pRspWrapper
);
taosWriteQitem
(
tmq
->
mqueue
,
pRspWrapper
);
/*tsem_post(&tmq->rspSem);*/
tsem_post
(
&
tmq
->
rspSem
);
return
0
;
return
0
;
CREATE_MSG_FAIL:
CREATE_MSG_FAIL:
if
(
pParam
->
epoch
==
tmq
->
epoch
)
{
if
(
pParam
->
epoch
==
tmq
->
epoch
)
{
atomic_store_32
(
&
pVg
->
vgStatus
,
TMQ_VG_STATUS__IDLE
);
atomic_store_32
(
&
pVg
->
vgStatus
,
TMQ_VG_STATUS__IDLE
);
}
}
/*tsem_post(&tmq->rspSem);*/
tsem_post
(
&
tmq
->
rspSem
);
return
-
1
;
return
-
1
;
}
}
...
@@ -927,6 +913,12 @@ bool tmqUpdateEp(tmq_t* tmq, int32_t epoch, SMqAskEpRsp* pRsp) {
...
@@ -927,6 +913,12 @@ bool tmqUpdateEp(tmq_t* tmq, int32_t epoch, SMqAskEpRsp* pRsp) {
if
(
tmq
->
clientTopics
)
taosArrayDestroy
(
tmq
->
clientTopics
);
if
(
tmq
->
clientTopics
)
taosArrayDestroy
(
tmq
->
clientTopics
);
taosHashCleanup
(
pHash
);
taosHashCleanup
(
pHash
);
tmq
->
clientTopics
=
newTopics
;
tmq
->
clientTopics
=
newTopics
;
if
(
taosArrayGetSize
(
tmq
->
clientTopics
)
==
0
)
atomic_store_8
(
&
tmq
->
status
,
TMQ_CONSUMER_STATUS__NO_TOPIC
);
else
atomic_store_8
(
&
tmq
->
status
,
TMQ_CONSUMER_STATUS__READY
);
atomic_store_32
(
&
tmq
->
epoch
,
epoch
);
atomic_store_32
(
&
tmq
->
epoch
,
epoch
);
return
set
;
return
set
;
}
}
...
@@ -955,9 +947,7 @@ int32_t tmqAskEpCb(void* param, const SDataBuf* pMsg, int32_t code) {
...
@@ -955,9 +947,7 @@ int32_t tmqAskEpCb(void* param, const SDataBuf* pMsg, int32_t code) {
tDecodeSMqAskEpRsp
(
POINTER_SHIFT
(
pMsg
->
pData
,
sizeof
(
SMqRspHead
)),
&
rsp
);
tDecodeSMqAskEpRsp
(
POINTER_SHIFT
(
pMsg
->
pData
,
sizeof
(
SMqRspHead
)),
&
rsp
);
/*printf("rsp epoch %ld sz %ld\n", rsp.epoch, rsp.topics->size);*/
/*printf("rsp epoch %ld sz %ld\n", rsp.epoch, rsp.topics->size);*/
/*printf("tmq epoch %ld sz %ld\n", tmq->epoch, tmq->clientTopics->size);*/
/*printf("tmq epoch %ld sz %ld\n", tmq->epoch, tmq->clientTopics->size);*/
if
(
tmqUpdateEp
(
tmq
,
head
->
epoch
,
&
rsp
))
{
tmqUpdateEp
(
tmq
,
head
->
epoch
,
&
rsp
);
atomic_store_8
(
&
tmq
->
status
,
TMQ_CONSUMER_STATUS__READY
);
}
tDeleteSMqAskEpRsp
(
&
rsp
);
tDeleteSMqAskEpRsp
(
&
rsp
);
}
else
{
}
else
{
SMqAskEpRspWrapper
*
pWrapper
=
taosAllocateQitem
(
sizeof
(
SMqAskEpRspWrapper
));
SMqAskEpRspWrapper
*
pWrapper
=
taosAllocateQitem
(
sizeof
(
SMqAskEpRspWrapper
));
...
@@ -972,7 +962,7 @@ int32_t tmqAskEpCb(void* param, const SDataBuf* pMsg, int32_t code) {
...
@@ -972,7 +962,7 @@ int32_t tmqAskEpCb(void* param, const SDataBuf* pMsg, int32_t code) {
tDecodeSMqAskEpRsp
(
POINTER_SHIFT
(
pMsg
->
pData
,
sizeof
(
SMqRspHead
)),
&
pWrapper
->
msg
);
tDecodeSMqAskEpRsp
(
POINTER_SHIFT
(
pMsg
->
pData
,
sizeof
(
SMqRspHead
)),
&
pWrapper
->
msg
);
taosWriteQitem
(
tmq
->
mqueue
,
pWrapper
);
taosWriteQitem
(
tmq
->
mqueue
,
pWrapper
);
/*tsem_post(&tmq->rspSem);*/
tsem_post
(
&
tmq
->
rspSem
);
taosMemoryFree
(
pParam
);
taosMemoryFree
(
pParam
);
}
}
...
@@ -1076,7 +1066,7 @@ tmq_resp_err_t tmq_seek(tmq_t* tmq, const tmq_topic_vgroup_t* offset) {
...
@@ -1076,7 +1066,7 @@ tmq_resp_err_t tmq_seek(tmq_t* tmq, const tmq_topic_vgroup_t* offset) {
return
TMQ_RESP_ERR__FAIL
;
return
TMQ_RESP_ERR__FAIL
;
}
}
SMqPollReq
V2
*
tmqBuildConsumeReqImpl
(
tmq_t
*
tmq
,
int64_t
blocking
Time
,
SMqClientTopic
*
pTopic
,
SMqClientVg
*
pVg
)
{
SMqPollReq
*
tmqBuildConsumeReqImpl
(
tmq_t
*
tmq
,
int64_t
wait
Time
,
SMqClientTopic
*
pTopic
,
SMqClientVg
*
pVg
)
{
int64_t
reqOffset
;
int64_t
reqOffset
;
if
(
pVg
->
currentOffset
>=
0
)
{
if
(
pVg
->
currentOffset
>=
0
)
{
reqOffset
=
pVg
->
currentOffset
;
reqOffset
=
pVg
->
currentOffset
;
...
@@ -1088,7 +1078,7 @@ SMqPollReqV2* tmqBuildConsumeReqImpl(tmq_t* tmq, int64_t blockingTime, SMqClient
...
@@ -1088,7 +1078,7 @@ SMqPollReqV2* tmqBuildConsumeReqImpl(tmq_t* tmq, int64_t blockingTime, SMqClient
reqOffset
=
tmq
->
resetOffsetCfg
;
reqOffset
=
tmq
->
resetOffsetCfg
;
}
}
SMqPollReq
V2
*
pReq
=
taosMemoryMalloc
(
sizeof
(
SMqPollReqV2
));
SMqPollReq
*
pReq
=
taosMemoryMalloc
(
sizeof
(
SMqPollReq
));
if
(
pReq
==
NULL
)
{
if
(
pReq
==
NULL
)
{
return
NULL
;
return
NULL
;
}
}
...
@@ -1101,14 +1091,14 @@ SMqPollReqV2* tmqBuildConsumeReqImpl(tmq_t* tmq, int64_t blockingTime, SMqClient
...
@@ -1101,14 +1091,14 @@ SMqPollReqV2* tmqBuildConsumeReqImpl(tmq_t* tmq, int64_t blockingTime, SMqClient
pReq
->
subKey
[
tlen
]
=
TMQ_SEPARATOR
;
pReq
->
subKey
[
tlen
]
=
TMQ_SEPARATOR
;
strcpy
(
pReq
->
subKey
+
tlen
+
1
,
pTopic
->
topicName
);
strcpy
(
pReq
->
subKey
+
tlen
+
1
,
pTopic
->
topicName
);
pReq
->
blockingTime
=
blocking
Time
;
pReq
->
waitTime
=
wait
Time
;
pReq
->
consumerId
=
tmq
->
consumerId
;
pReq
->
consumerId
=
tmq
->
consumerId
;
pReq
->
epoch
=
tmq
->
epoch
;
pReq
->
epoch
=
tmq
->
epoch
;
pReq
->
currentOffset
=
reqOffset
;
pReq
->
currentOffset
=
reqOffset
;
pReq
->
reqId
=
generateRequestId
();
pReq
->
reqId
=
generateRequestId
();
pReq
->
head
.
vgId
=
htonl
(
pVg
->
vgId
);
pReq
->
head
.
vgId
=
htonl
(
pVg
->
vgId
);
pReq
->
head
.
contLen
=
htonl
(
sizeof
(
SMqPollReq
V2
));
pReq
->
head
.
contLen
=
htonl
(
sizeof
(
SMqPollReq
));
return
pReq
;
return
pReq
;
}
}
...
@@ -1130,7 +1120,7 @@ SMqRspObj* tmqBuildRspFromWrapper(SMqPollRspWrapper* pWrapper) {
...
@@ -1130,7 +1120,7 @@ SMqRspObj* tmqBuildRspFromWrapper(SMqPollRspWrapper* pWrapper) {
return
pRspObj
;
return
pRspObj
;
}
}
int32_t
tmqPollImpl
(
tmq_t
*
tmq
,
int64_t
blocking
Time
)
{
int32_t
tmqPollImpl
(
tmq_t
*
tmq
,
int64_t
wait
Time
)
{
/*printf("call poll\n");*/
/*printf("call poll\n");*/
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
tmq
->
clientTopics
);
i
++
)
{
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
tmq
->
clientTopics
);
i
++
)
{
SMqClientTopic
*
pTopic
=
taosArrayGet
(
tmq
->
clientTopics
,
i
);
SMqClientTopic
*
pTopic
=
taosArrayGet
(
tmq
->
clientTopics
,
i
);
...
@@ -1151,17 +1141,17 @@ int32_t tmqPollImpl(tmq_t* tmq, int64_t blockingTime) {
...
@@ -1151,17 +1141,17 @@ int32_t tmqPollImpl(tmq_t* tmq, int64_t blockingTime) {
#endif
#endif
}
}
atomic_store_32
(
&
pVg
->
vgSkipCnt
,
0
);
atomic_store_32
(
&
pVg
->
vgSkipCnt
,
0
);
SMqPollReq
V2
*
pReq
=
tmqBuildConsumeReqImpl
(
tmq
,
blocking
Time
,
pTopic
,
pVg
);
SMqPollReq
*
pReq
=
tmqBuildConsumeReqImpl
(
tmq
,
wait
Time
,
pTopic
,
pVg
);
if
(
pReq
==
NULL
)
{
if
(
pReq
==
NULL
)
{
atomic_store_32
(
&
pVg
->
vgStatus
,
TMQ_VG_STATUS__IDLE
);
atomic_store_32
(
&
pVg
->
vgStatus
,
TMQ_VG_STATUS__IDLE
);
/*tsem_post(&tmq->rspSem);*/
tsem_post
(
&
tmq
->
rspSem
);
return
-
1
;
return
-
1
;
}
}
SMqPollCbParam
*
pParam
=
taosMemoryMalloc
(
sizeof
(
SMqPollCbParam
));
SMqPollCbParam
*
pParam
=
taosMemoryMalloc
(
sizeof
(
SMqPollCbParam
));
if
(
pParam
==
NULL
)
{
if
(
pParam
==
NULL
)
{
taosMemoryFree
(
pReq
);
taosMemoryFree
(
pReq
);
atomic_store_32
(
&
pVg
->
vgStatus
,
TMQ_VG_STATUS__IDLE
);
atomic_store_32
(
&
pVg
->
vgStatus
,
TMQ_VG_STATUS__IDLE
);
/*tsem_post(&tmq->rspSem);*/
tsem_post
(
&
tmq
->
rspSem
);
return
-
1
;
return
-
1
;
}
}
pParam
->
tmq
=
tmq
;
pParam
->
tmq
=
tmq
;
...
@@ -1169,20 +1159,19 @@ int32_t tmqPollImpl(tmq_t* tmq, int64_t blockingTime) {
...
@@ -1169,20 +1159,19 @@ int32_t tmqPollImpl(tmq_t* tmq, int64_t blockingTime) {
pParam
->
pTopic
=
pTopic
;
pParam
->
pTopic
=
pTopic
;
pParam
->
vgId
=
pVg
->
vgId
;
pParam
->
vgId
=
pVg
->
vgId
;
pParam
->
epoch
=
tmq
->
epoch
;
pParam
->
epoch
=
tmq
->
epoch
;
pParam
->
sync
=
0
;
SMsgSendInfo
*
sendInfo
=
taosMemoryMalloc
(
sizeof
(
SMsgSendInfo
));
SMsgSendInfo
*
sendInfo
=
taosMemoryMalloc
(
sizeof
(
SMsgSendInfo
));
if
(
sendInfo
==
NULL
)
{
if
(
sendInfo
==
NULL
)
{
taosMemoryFree
(
pReq
);
taosMemoryFree
(
pReq
);
taosMemoryFree
(
pParam
);
taosMemoryFree
(
pParam
);
atomic_store_32
(
&
pVg
->
vgStatus
,
TMQ_VG_STATUS__IDLE
);
atomic_store_32
(
&
pVg
->
vgStatus
,
TMQ_VG_STATUS__IDLE
);
/*tsem_post(&tmq->rspSem);*/
tsem_post
(
&
tmq
->
rspSem
);
return
-
1
;
return
-
1
;
}
}
sendInfo
->
msgInfo
=
(
SDataBuf
){
sendInfo
->
msgInfo
=
(
SDataBuf
){
.
pData
=
pReq
,
.
pData
=
pReq
,
.
len
=
sizeof
(
SMqPollReq
V2
),
.
len
=
sizeof
(
SMqPollReq
),
.
handle
=
NULL
,
.
handle
=
NULL
,
};
};
sendInfo
->
requestId
=
pReq
->
reqId
;
sendInfo
->
requestId
=
pReq
->
reqId
;
...
@@ -1222,7 +1211,7 @@ int32_t tmqHandleNoPollRsp(tmq_t* tmq, SMqRspWrapper* rspWrapper, bool* pReset)
...
@@ -1222,7 +1211,7 @@ int32_t tmqHandleNoPollRsp(tmq_t* tmq, SMqRspWrapper* rspWrapper, bool* pReset)
return
0
;
return
0
;
}
}
SMqRspObj
*
tmqHandleAllRsp
(
tmq_t
*
tmq
,
int64_t
blocking
Time
,
bool
pollIfReset
)
{
SMqRspObj
*
tmqHandleAllRsp
(
tmq_t
*
tmq
,
int64_t
wait
Time
,
bool
pollIfReset
)
{
while
(
1
)
{
while
(
1
)
{
SMqRspWrapper
*
rspWrapper
=
NULL
;
SMqRspWrapper
*
rspWrapper
=
NULL
;
taosGetQitem
(
tmq
->
qall
,
(
void
**
)
&
rspWrapper
);
taosGetQitem
(
tmq
->
qall
,
(
void
**
)
&
rspWrapper
);
...
@@ -1261,37 +1250,41 @@ SMqRspObj* tmqHandleAllRsp(tmq_t* tmq, int64_t blockingTime, bool pollIfReset) {
...
@@ -1261,37 +1250,41 @@ SMqRspObj* tmqHandleAllRsp(tmq_t* tmq, int64_t blockingTime, bool pollIfReset) {
taosFreeQitem
(
rspWrapper
);
taosFreeQitem
(
rspWrapper
);
if
(
pollIfReset
&&
reset
)
{
if
(
pollIfReset
&&
reset
)
{
tscDebug
(
"consumer %ld reset and repoll"
,
tmq
->
consumerId
);
tscDebug
(
"consumer %ld reset and repoll"
,
tmq
->
consumerId
);
tmqPollImpl
(
tmq
,
blocking
Time
);
tmqPollImpl
(
tmq
,
wait
Time
);
}
}
}
}
}
}
}
}
TAOS_RES
*
tmq_consumer_poll
(
tmq_t
*
tmq
,
int64_t
blocking
_time
)
{
TAOS_RES
*
tmq_consumer_poll
(
tmq_t
*
tmq
,
int64_t
wait
_time
)
{
SMqRspObj
*
rspObj
;
SMqRspObj
*
rspObj
;
int64_t
startTime
=
taosGetTimestampMs
();
int64_t
startTime
=
taosGetTimestampMs
();
rspObj
=
tmqHandleAllRsp
(
tmq
,
blocking
_time
,
false
);
rspObj
=
tmqHandleAllRsp
(
tmq
,
wait
_time
,
false
);
if
(
rspObj
)
{
if
(
rspObj
)
{
return
(
TAOS_RES
*
)
rspObj
;
return
(
TAOS_RES
*
)
rspObj
;
}
}
if
(
atomic_load_8
(
&
tmq
->
status
)
==
TMQ_CONSUMER_STATUS__INIT
)
{
return
NULL
;
}
while
(
1
)
{
while
(
1
)
{
tmqHandleAllDelayedTask
(
tmq
);
tmqHandleAllDelayedTask
(
tmq
);
tmqPollImpl
(
tmq
,
blocking_time
);
tmqPollImpl
(
tmq
,
wait_time
);
/*tsem_wait(&tmq->rspSem);*/
rspObj
=
tmqHandleAllRsp
(
tmq
,
blocking
_time
,
false
);
rspObj
=
tmqHandleAllRsp
(
tmq
,
wait
_time
,
false
);
if
(
rspObj
)
{
if
(
rspObj
)
{
return
(
TAOS_RES
*
)
rspObj
;
return
(
TAOS_RES
*
)
rspObj
;
}
}
if
(
blocking
_time
!=
0
)
{
if
(
wait
_time
!=
0
)
{
int64_t
endTime
=
taosGetTimestampMs
();
int64_t
endTime
=
taosGetTimestampMs
();
if
(
endTime
-
startTime
>
blocking_time
)
{
int64_t
leftTime
=
endTime
-
startTime
;
if
(
leftTime
>
wait_time
)
{
tscDebug
(
"consumer %ld (epoch %d) timeout, no rsp"
,
tmq
->
consumerId
,
tmq
->
epoch
);
tscDebug
(
"consumer %ld (epoch %d) timeout, no rsp"
,
tmq
->
consumerId
,
tmq
->
epoch
);
return
NULL
;
return
NULL
;
}
}
tsem_timewait
(
&
tmq
->
rspSem
,
leftTime
*
1000
);
}
}
}
}
}
}
...
...
source/common/src/tmsg.c
浏览文件 @
a0fcc9a2
...
@@ -517,7 +517,6 @@ int32_t tSerializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pReq
...
@@ -517,7 +517,6 @@ int32_t tSerializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pReq
if
(
tEncodeI32
(
&
encoder
,
pReq
->
ttl
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
ttl
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
numOfColumns
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
numOfColumns
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
numOfTags
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
numOfTags
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
numOfSmas
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
commentLen
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
commentLen
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
ast1Len
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
ast1Len
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
ast2Len
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
ast2Len
)
<
0
)
return
-
1
;
...
@@ -527,6 +526,7 @@ int32_t tSerializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pReq
...
@@ -527,6 +526,7 @@ int32_t tSerializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pReq
if
(
tEncodeI8
(
&
encoder
,
pField
->
type
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pField
->
type
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pField
->
bytes
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pField
->
bytes
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pField
->
name
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pField
->
name
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pField
->
flags
)
<
0
)
return
-
1
;
}
}
for
(
int32_t
i
=
0
;
i
<
pReq
->
numOfTags
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pReq
->
numOfTags
;
++
i
)
{
...
@@ -534,13 +534,7 @@ int32_t tSerializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pReq
...
@@ -534,13 +534,7 @@ int32_t tSerializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pReq
if
(
tEncodeI8
(
&
encoder
,
pField
->
type
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pField
->
type
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pField
->
bytes
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pField
->
bytes
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pField
->
name
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pField
->
name
)
<
0
)
return
-
1
;
}
if
(
tEncodeI8
(
&
encoder
,
pField
->
flags
)
<
0
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
pReq
->
numOfSmas
;
++
i
)
{
SField
*
pField
=
taosArrayGet
(
pReq
->
pSmas
,
i
);
if
(
tEncodeI8
(
&
encoder
,
pField
->
type
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pField
->
bytes
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pField
->
name
)
<
0
)
return
-
1
;
}
}
if
(
pReq
->
commentLen
>
0
)
{
if
(
pReq
->
commentLen
>
0
)
{
...
@@ -571,15 +565,13 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR
...
@@ -571,15 +565,13 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
ttl
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
ttl
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
numOfColumns
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
numOfColumns
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
numOfTags
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
numOfTags
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
numOfSmas
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
commentLen
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
commentLen
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
ast1Len
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
ast1Len
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
ast2Len
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
ast2Len
)
<
0
)
return
-
1
;
pReq
->
pColumns
=
taosArrayInit
(
pReq
->
numOfColumns
,
sizeof
(
SField
));
pReq
->
pColumns
=
taosArrayInit
(
pReq
->
numOfColumns
,
sizeof
(
SField
));
pReq
->
pTags
=
taosArrayInit
(
pReq
->
numOfTags
,
sizeof
(
SField
));
pReq
->
pTags
=
taosArrayInit
(
pReq
->
numOfTags
,
sizeof
(
SField
));
pReq
->
pSmas
=
taosArrayInit
(
pReq
->
numOfSmas
,
sizeof
(
SField
));
if
(
pReq
->
pColumns
==
NULL
||
pReq
->
pTags
==
NULL
)
{
if
(
pReq
->
pColumns
==
NULL
||
pReq
->
pTags
==
NULL
||
pReq
->
pSmas
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
}
}
...
@@ -589,6 +581,7 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR
...
@@ -589,6 +581,7 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR
if
(
tDecodeI8
(
&
decoder
,
&
field
.
type
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
field
.
type
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
field
.
bytes
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
field
.
bytes
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
field
.
name
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
field
.
name
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
field
.
flags
)
<
0
)
return
-
1
;
if
(
taosArrayPush
(
pReq
->
pColumns
,
&
field
)
==
NULL
)
{
if
(
taosArrayPush
(
pReq
->
pColumns
,
&
field
)
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
...
@@ -600,23 +593,13 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR
...
@@ -600,23 +593,13 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR
if
(
tDecodeI8
(
&
decoder
,
&
field
.
type
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
field
.
type
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
field
.
bytes
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
field
.
bytes
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
field
.
name
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
field
.
name
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
field
.
flags
)
<
0
)
return
-
1
;
if
(
taosArrayPush
(
pReq
->
pTags
,
&
field
)
==
NULL
)
{
if
(
taosArrayPush
(
pReq
->
pTags
,
&
field
)
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
}
}
}
}
for
(
int32_t
i
=
0
;
i
<
pReq
->
numOfSmas
;
++
i
)
{
SField
field
=
{
0
};
if
(
tDecodeI8
(
&
decoder
,
&
field
.
type
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
field
.
bytes
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
field
.
name
)
<
0
)
return
-
1
;
if
(
taosArrayPush
(
pReq
->
pSmas
,
&
field
)
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
}
if
(
pReq
->
commentLen
>
0
)
{
if
(
pReq
->
commentLen
>
0
)
{
pReq
->
comment
=
taosMemoryMalloc
(
pReq
->
commentLen
);
pReq
->
comment
=
taosMemoryMalloc
(
pReq
->
commentLen
);
if
(
pReq
->
comment
==
NULL
)
return
-
1
;
if
(
pReq
->
comment
==
NULL
)
return
-
1
;
...
@@ -644,13 +627,11 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR
...
@@ -644,13 +627,11 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR
void
tFreeSMCreateStbReq
(
SMCreateStbReq
*
pReq
)
{
void
tFreeSMCreateStbReq
(
SMCreateStbReq
*
pReq
)
{
taosArrayDestroy
(
pReq
->
pColumns
);
taosArrayDestroy
(
pReq
->
pColumns
);
taosArrayDestroy
(
pReq
->
pTags
);
taosArrayDestroy
(
pReq
->
pTags
);
taosArrayDestroy
(
pReq
->
pSmas
);
taosMemoryFreeClear
(
pReq
->
comment
);
taosMemoryFreeClear
(
pReq
->
comment
);
taosMemoryFreeClear
(
pReq
->
pAst1
);
taosMemoryFreeClear
(
pReq
->
pAst1
);
taosMemoryFreeClear
(
pReq
->
pAst2
);
taosMemoryFreeClear
(
pReq
->
pAst2
);
pReq
->
pColumns
=
NULL
;
pReq
->
pColumns
=
NULL
;
pReq
->
pTags
=
NULL
;
pReq
->
pTags
=
NULL
;
pReq
->
pSmas
=
NULL
;
}
}
int32_t
tSerializeSMDropStbReq
(
void
*
buf
,
int32_t
bufLen
,
SMDropStbReq
*
pReq
)
{
int32_t
tSerializeSMDropStbReq
(
void
*
buf
,
int32_t
bufLen
,
SMDropStbReq
*
pReq
)
{
...
...
source/dnode/mnode/impl/inc/mndDef.h
浏览文件 @
a0fcc9a2
...
@@ -358,13 +358,11 @@ typedef struct {
...
@@ -358,13 +358,11 @@ typedef struct {
int32_t
ttl
;
int32_t
ttl
;
int32_t
numOfColumns
;
int32_t
numOfColumns
;
int32_t
numOfTags
;
int32_t
numOfTags
;
int32_t
numOfSmas
;
int32_t
commentLen
;
int32_t
commentLen
;
int32_t
ast1Len
;
int32_t
ast1Len
;
int32_t
ast2Len
;
int32_t
ast2Len
;
SSchema
*
pColumns
;
SSchema
*
pColumns
;
SSchema
*
pTags
;
SSchema
*
pTags
;
SSchema
*
pSmas
;
char
*
comment
;
char
*
comment
;
char
*
pAst1
;
char
*
pAst1
;
char
*
pAst2
;
char
*
pAst2
;
...
...
source/dnode/mnode/impl/inc/mndInt.h
浏览文件 @
a0fcc9a2
...
@@ -45,7 +45,7 @@ extern "C" {
...
@@ -45,7 +45,7 @@ extern "C" {
typedef
int32_t
(
*
MndMsgFp
)(
SNodeMsg
*
pMsg
);
typedef
int32_t
(
*
MndMsgFp
)(
SNodeMsg
*
pMsg
);
typedef
int32_t
(
*
MndInitFp
)(
SMnode
*
pMnode
);
typedef
int32_t
(
*
MndInitFp
)(
SMnode
*
pMnode
);
typedef
void
(
*
MndCleanupFp
)(
SMnode
*
pMnode
);
typedef
void
(
*
MndCleanupFp
)(
SMnode
*
pMnode
);
typedef
int32_t
(
*
ShowRetrieveFp
)(
SNodeMsg
*
pMsg
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rows
);
typedef
int32_t
(
*
ShowRetrieveFp
)(
SNodeMsg
*
pMsg
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rows
);
typedef
void
(
*
ShowFreeIterFp
)(
SMnode
*
pMnode
,
void
*
pIter
);
typedef
void
(
*
ShowFreeIterFp
)(
SMnode
*
pMnode
,
void
*
pIter
);
typedef
struct
SQWorkerMgmt
SQHandle
;
typedef
struct
SQWorkerMgmt
SQHandle
;
...
@@ -84,7 +84,7 @@ typedef struct {
...
@@ -84,7 +84,7 @@ typedef struct {
int64_t
timeseriesAllowed
;
int64_t
timeseriesAllowed
;
}
SGrantInfo
;
}
SGrantInfo
;
struct
SMnode
{
typedef
struct
SMnode
{
int32_t
selfId
;
int32_t
selfId
;
int64_t
clusterId
;
int64_t
clusterId
;
int8_t
replica
;
int8_t
replica
;
...
@@ -109,7 +109,7 @@ struct SMnode {
...
@@ -109,7 +109,7 @@ struct SMnode {
SGrantInfo
grant
;
SGrantInfo
grant
;
MndMsgFp
msgFp
[
TDMT_MAX
];
MndMsgFp
msgFp
[
TDMT_MAX
];
SMsgCb
msgCb
;
SMsgCb
msgCb
;
};
}
SMnode
;
void
mndSetMsgHandle
(
SMnode
*
pMnode
,
tmsg_t
msgType
,
MndMsgFp
fp
);
void
mndSetMsgHandle
(
SMnode
*
pMnode
,
tmsg_t
msgType
,
MndMsgFp
fp
);
int64_t
mndGenerateUid
(
char
*
name
,
int32_t
len
);
int64_t
mndGenerateUid
(
char
*
name
,
int32_t
len
);
...
...
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
a0fcc9a2
...
@@ -72,8 +72,8 @@ void mndCleanupStb(SMnode *pMnode) {}
...
@@ -72,8 +72,8 @@ void mndCleanupStb(SMnode *pMnode) {}
SSdbRaw
*
mndStbActionEncode
(
SStbObj
*
pStb
)
{
SSdbRaw
*
mndStbActionEncode
(
SStbObj
*
pStb
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
int32_t
size
=
sizeof
(
SStbObj
)
+
(
pStb
->
numOfColumns
+
pStb
->
numOfTags
+
pStb
->
numOfSmas
)
*
sizeof
(
SSchema
)
+
int32_t
size
=
sizeof
(
SStbObj
)
+
(
pStb
->
numOfColumns
+
pStb
->
numOfTags
)
*
sizeof
(
SSchema
)
+
+
pStb
->
commentLen
+
+
pStb
->
commentLen
+
pStb
->
ast1Len
+
pStb
->
ast2Len
+
TSDB_STB_RESERVE_SIZE
;
pStb
->
ast1Len
+
pStb
->
ast2Len
+
TSDB_STB_RESERVE_SIZE
;
SSdbRaw
*
pRaw
=
sdbAllocRaw
(
SDB_STB
,
TSDB_STB_VER_NUMBER
,
size
);
SSdbRaw
*
pRaw
=
sdbAllocRaw
(
SDB_STB
,
TSDB_STB_VER_NUMBER
,
size
);
if
(
pRaw
==
NULL
)
goto
_OVER
;
if
(
pRaw
==
NULL
)
goto
_OVER
;
...
@@ -91,7 +91,6 @@ SSdbRaw *mndStbActionEncode(SStbObj *pStb) {
...
@@ -91,7 +91,6 @@ SSdbRaw *mndStbActionEncode(SStbObj *pStb) {
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
ttl
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
ttl
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
numOfColumns
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
numOfColumns
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
numOfTags
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
numOfTags
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
numOfSmas
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
commentLen
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
commentLen
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
ast1Len
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
ast1Len
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
ast2Len
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
ast2Len
,
_OVER
)
...
@@ -112,14 +111,6 @@ SSdbRaw *mndStbActionEncode(SStbObj *pStb) {
...
@@ -112,14 +111,6 @@ SSdbRaw *mndStbActionEncode(SStbObj *pStb) {
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pSchema
->
name
,
TSDB_COL_NAME_LEN
,
_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pSchema
->
name
,
TSDB_COL_NAME_LEN
,
_OVER
)
}
}
for
(
int32_t
i
=
0
;
i
<
pStb
->
numOfSmas
;
++
i
)
{
SSchema
*
pSchema
=
&
pStb
->
pSmas
[
i
];
SDB_SET_INT8
(
pRaw
,
dataPos
,
pSchema
->
type
,
_OVER
)
SDB_SET_INT16
(
pRaw
,
dataPos
,
pSchema
->
colId
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pSchema
->
bytes
,
_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pSchema
->
name
,
TSDB_COL_NAME_LEN
,
_OVER
)
}
if
(
pStb
->
commentLen
>
0
)
{
if
(
pStb
->
commentLen
>
0
)
{
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pStb
->
comment
,
pStb
->
commentLen
,
_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pStb
->
comment
,
pStb
->
commentLen
,
_OVER
)
}
}
...
@@ -178,15 +169,13 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) {
...
@@ -178,15 +169,13 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) {
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
ttl
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
ttl
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
numOfColumns
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
numOfColumns
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
numOfTags
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
numOfTags
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
numOfSmas
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
commentLen
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
commentLen
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
ast1Len
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
ast1Len
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
ast2Len
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
ast2Len
,
_OVER
)
pStb
->
pColumns
=
taosMemoryCalloc
(
pStb
->
numOfColumns
,
sizeof
(
SSchema
));
pStb
->
pColumns
=
taosMemoryCalloc
(
pStb
->
numOfColumns
,
sizeof
(
SSchema
));
pStb
->
pTags
=
taosMemoryCalloc
(
pStb
->
numOfTags
,
sizeof
(
SSchema
));
pStb
->
pTags
=
taosMemoryCalloc
(
pStb
->
numOfTags
,
sizeof
(
SSchema
));
pStb
->
pSmas
=
taosMemoryCalloc
(
pStb
->
numOfSmas
,
sizeof
(
SSchema
));
if
(
pStb
->
pColumns
==
NULL
||
pStb
->
pTags
==
NULL
)
{
if
(
pStb
->
pColumns
==
NULL
||
pStb
->
pTags
==
NULL
||
pStb
->
pSmas
==
NULL
)
{
goto
_OVER
;
goto
_OVER
;
}
}
...
@@ -206,14 +195,6 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) {
...
@@ -206,14 +195,6 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) {
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pSchema
->
name
,
TSDB_COL_NAME_LEN
,
_OVER
)
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pSchema
->
name
,
TSDB_COL_NAME_LEN
,
_OVER
)
}
}
for
(
int32_t
i
=
0
;
i
<
pStb
->
numOfSmas
;
++
i
)
{
SSchema
*
pSchema
=
&
pStb
->
pSmas
[
i
];
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
pSchema
->
type
,
_OVER
)
SDB_GET_INT16
(
pRaw
,
dataPos
,
&
pSchema
->
colId
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pSchema
->
bytes
,
_OVER
)
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pSchema
->
name
,
TSDB_COL_NAME_LEN
,
_OVER
)
}
if
(
pStb
->
commentLen
>
0
)
{
if
(
pStb
->
commentLen
>
0
)
{
pStb
->
comment
=
taosMemoryCalloc
(
pStb
->
commentLen
,
1
);
pStb
->
comment
=
taosMemoryCalloc
(
pStb
->
commentLen
,
1
);
if
(
pStb
->
comment
==
NULL
)
goto
_OVER
;
if
(
pStb
->
comment
==
NULL
)
goto
_OVER
;
...
@@ -291,18 +272,6 @@ static int32_t mndStbActionUpdate(SSdb *pSdb, SStbObj *pOld, SStbObj *pNew) {
...
@@ -291,18 +272,6 @@ static int32_t mndStbActionUpdate(SSdb *pSdb, SStbObj *pOld, SStbObj *pNew) {
}
}
}
}
if
(
pOld
->
numOfSmas
<
pNew
->
numOfSmas
)
{
void
*
pSmas
=
taosMemoryMalloc
(
pNew
->
numOfSmas
*
sizeof
(
SSchema
));
if
(
pSmas
!=
NULL
)
{
taosMemoryFree
(
pOld
->
pSmas
);
pOld
->
pSmas
=
pSmas
;
}
else
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
mTrace
(
"stb:%s, failed to perform update action since %s"
,
pOld
->
name
,
terrstr
());
taosWUnLockLatch
(
&
pOld
->
lock
);
}
}
if
(
pOld
->
commentLen
<
pNew
->
commentLen
)
{
if
(
pOld
->
commentLen
<
pNew
->
commentLen
)
{
void
*
comment
=
taosMemoryMalloc
(
pNew
->
commentLen
);
void
*
comment
=
taosMemoryMalloc
(
pNew
->
commentLen
);
if
(
comment
!=
NULL
)
{
if
(
comment
!=
NULL
)
{
...
@@ -411,11 +380,6 @@ static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pSt
...
@@ -411,11 +380,6 @@ static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pSt
req
.
schemaTag
.
nCols
=
pStb
->
numOfTags
;
req
.
schemaTag
.
nCols
=
pStb
->
numOfTags
;
req
.
schemaTag
.
pSchema
=
pStb
->
pTags
;
req
.
schemaTag
.
pSchema
=
pStb
->
pTags
;
// TODO: remove here
for
(
int
iCol
=
0
;
iCol
<
req
.
schema
.
nCols
;
iCol
++
)
{
req
.
schema
.
pSchema
[
iCol
].
flags
=
SCHEMA_SMA_ON
;
}
if
(
req
.
rollup
)
{
if
(
req
.
rollup
)
{
req
.
pRSmaParam
.
xFilesFactor
=
pStb
->
xFilesFactor
;
req
.
pRSmaParam
.
xFilesFactor
=
pStb
->
xFilesFactor
;
req
.
pRSmaParam
.
delay
=
pStb
->
delay
;
req
.
pRSmaParam
.
delay
=
pStb
->
delay
;
...
@@ -674,7 +638,6 @@ static int32_t mndCreateStb(SMnode *pMnode, SNodeMsg *pReq, SMCreateStbReq *pCre
...
@@ -674,7 +638,6 @@ static int32_t mndCreateStb(SMnode *pMnode, SNodeMsg *pReq, SMCreateStbReq *pCre
stbObj
.
ttl
=
pCreate
->
ttl
;
stbObj
.
ttl
=
pCreate
->
ttl
;
stbObj
.
numOfColumns
=
pCreate
->
numOfColumns
;
stbObj
.
numOfColumns
=
pCreate
->
numOfColumns
;
stbObj
.
numOfTags
=
pCreate
->
numOfTags
;
stbObj
.
numOfTags
=
pCreate
->
numOfTags
;
stbObj
.
numOfSmas
=
pCreate
->
numOfSmas
;
stbObj
.
commentLen
=
pCreate
->
commentLen
;
stbObj
.
commentLen
=
pCreate
->
commentLen
;
if
(
stbObj
.
commentLen
>
0
)
{
if
(
stbObj
.
commentLen
>
0
)
{
stbObj
.
comment
=
taosMemoryCalloc
(
stbObj
.
commentLen
,
1
);
stbObj
.
comment
=
taosMemoryCalloc
(
stbObj
.
commentLen
,
1
);
...
@@ -707,8 +670,7 @@ static int32_t mndCreateStb(SMnode *pMnode, SNodeMsg *pReq, SMCreateStbReq *pCre
...
@@ -707,8 +670,7 @@ static int32_t mndCreateStb(SMnode *pMnode, SNodeMsg *pReq, SMCreateStbReq *pCre
stbObj
.
pColumns
=
taosMemoryMalloc
(
stbObj
.
numOfColumns
*
sizeof
(
SSchema
));
stbObj
.
pColumns
=
taosMemoryMalloc
(
stbObj
.
numOfColumns
*
sizeof
(
SSchema
));
stbObj
.
pTags
=
taosMemoryMalloc
(
stbObj
.
numOfTags
*
sizeof
(
SSchema
));
stbObj
.
pTags
=
taosMemoryMalloc
(
stbObj
.
numOfTags
*
sizeof
(
SSchema
));
stbObj
.
pSmas
=
taosMemoryMalloc
(
stbObj
.
numOfSmas
*
sizeof
(
SSchema
));
if
(
stbObj
.
pColumns
==
NULL
||
stbObj
.
pTags
==
NULL
)
{
if
(
stbObj
.
pColumns
==
NULL
||
stbObj
.
pTags
==
NULL
||
stbObj
.
pSmas
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
}
}
...
@@ -718,6 +680,7 @@ static int32_t mndCreateStb(SMnode *pMnode, SNodeMsg *pReq, SMCreateStbReq *pCre
...
@@ -718,6 +680,7 @@ static int32_t mndCreateStb(SMnode *pMnode, SNodeMsg *pReq, SMCreateStbReq *pCre
SSchema
*
pSchema
=
&
stbObj
.
pColumns
[
i
];
SSchema
*
pSchema
=
&
stbObj
.
pColumns
[
i
];
pSchema
->
type
=
pField
->
type
;
pSchema
->
type
=
pField
->
type
;
pSchema
->
bytes
=
pField
->
bytes
;
pSchema
->
bytes
=
pField
->
bytes
;
pSchema
->
flags
=
pField
->
flags
;
memcpy
(
pSchema
->
name
,
pField
->
name
,
TSDB_COL_NAME_LEN
);
memcpy
(
pSchema
->
name
,
pField
->
name
,
TSDB_COL_NAME_LEN
);
pSchema
->
colId
=
stbObj
.
nextColId
;
pSchema
->
colId
=
stbObj
.
nextColId
;
stbObj
.
nextColId
++
;
stbObj
.
nextColId
++
;
...
@@ -733,18 +696,6 @@ static int32_t mndCreateStb(SMnode *pMnode, SNodeMsg *pReq, SMCreateStbReq *pCre
...
@@ -733,18 +696,6 @@ static int32_t mndCreateStb(SMnode *pMnode, SNodeMsg *pReq, SMCreateStbReq *pCre
stbObj
.
nextColId
++
;
stbObj
.
nextColId
++
;
}
}
for
(
int32_t
i
=
0
;
i
<
stbObj
.
numOfSmas
;
++
i
)
{
SField
*
pField
=
taosArrayGet
(
pCreate
->
pSmas
,
i
);
SSchema
*
pSchema
=
&
stbObj
.
pSmas
[
i
];
SSchema
*
pColSchema
=
mndFindStbColumns
(
&
stbObj
,
pField
->
name
);
if
(
pColSchema
==
NULL
)
{
mError
(
"stb:%s, sma:%s not found in columns"
,
stbObj
.
name
,
pField
->
name
);
terrno
=
TSDB_CODE_MND_INVALID_STB_OPTION
;
return
-
1
;
}
memcpy
(
pSchema
,
pColSchema
,
sizeof
(
SSchema
));
}
int32_t
code
=
-
1
;
int32_t
code
=
-
1
;
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
TRN_TYPE_CREATE_STB
,
&
pReq
->
rpcMsg
);
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
TRN_TYPE_CREATE_STB
,
&
pReq
->
rpcMsg
);
if
(
pTrans
==
NULL
)
goto
_OVER
;
if
(
pTrans
==
NULL
)
goto
_OVER
;
...
...
source/dnode/mnode/impl/src/mndSync.c
浏览文件 @
a0fcc9a2
...
@@ -22,13 +22,15 @@ static int32_t mndInitWal(SMnode *pMnode) {
...
@@ -22,13 +22,15 @@ static int32_t mndInitWal(SMnode *pMnode) {
char
path
[
PATH_MAX
]
=
{
0
};
char
path
[
PATH_MAX
]
=
{
0
};
snprintf
(
path
,
sizeof
(
path
),
"%s%swal"
,
pMnode
->
path
,
TD_DIRSEP
);
snprintf
(
path
,
sizeof
(
path
),
"%s%swal"
,
pMnode
->
path
,
TD_DIRSEP
);
SWalCfg
cfg
=
{.
vgId
=
1
,
SWalCfg
cfg
=
{
.
vgId
=
1
,
.
fsyncPeriod
=
0
,
.
fsyncPeriod
=
0
,
.
rollPeriod
=
-
1
,
.
rollPeriod
=
-
1
,
.
segSize
=
-
1
,
.
segSize
=
-
1
,
.
retentionPeriod
=
-
1
,
.
retentionPeriod
=
-
1
,
.
retentionSize
=
-
1
,
.
retentionSize
=
-
1
,
.
level
=
TAOS_WAL_FSYNC
};
.
level
=
TAOS_WAL_FSYNC
,
};
pMgmt
->
pWal
=
walOpen
(
path
,
&
cfg
);
pMgmt
->
pWal
=
walOpen
(
path
,
&
cfg
);
if
(
pMgmt
->
pWal
==
NULL
)
return
-
1
;
if
(
pMgmt
->
pWal
==
NULL
)
return
-
1
;
...
@@ -54,62 +56,62 @@ static int32_t mndRestoreWal(SMnode *pMnode) {
...
@@ -54,62 +56,62 @@ static int32_t mndRestoreWal(SMnode *pMnode) {
int64_t
first
=
walGetFirstVer
(
pWal
);
int64_t
first
=
walGetFirstVer
(
pWal
);
int64_t
last
=
walGetLastVer
(
pWal
);
int64_t
last
=
walGetLastVer
(
pWal
);
mDebug
(
"start to restore
sdb wal, sdb ver:%"
PRId64
", wal
first:%"
PRId64
" last:%"
PRId64
,
lastSdbVer
,
first
,
last
);
mDebug
(
"start to restore
wal, sdbver:%"
PRId64
",
first:%"
PRId64
" last:%"
PRId64
,
lastSdbVer
,
first
,
last
);
first
=
TMAX
(
lastSdbVer
+
1
,
first
);
first
=
TMAX
(
lastSdbVer
+
1
,
first
);
for
(
int64_t
ver
=
first
;
ver
>=
0
&&
ver
<=
last
;
++
ver
)
{
for
(
int64_t
ver
=
first
;
ver
>=
0
&&
ver
<=
last
;
++
ver
)
{
if
(
walReadWithHandle
(
pHandle
,
ver
)
<
0
)
{
if
(
walReadWithHandle
(
pHandle
,
ver
)
<
0
)
{
mError
(
"
failed to read by wal handle since %s, ver:%"
PRId64
,
terrstr
(),
ver
);
mError
(
"
ver:%"
PRId64
", failed to read from wal since %s"
,
ver
,
terrstr
()
);
goto
WAL_RESTORE
_OVER
;
goto
_OVER
;
}
}
SWalHead
*
pHead
=
pHandle
->
pHead
;
SWalHead
*
pHead
=
pHandle
->
pHead
;
int64_t
sdbVer
=
sdbUpdateVer
(
pSdb
,
0
);
int64_t
sdbVer
=
sdbUpdateVer
(
pSdb
,
0
);
if
(
sdbVer
+
1
!=
ver
)
{
if
(
sdbVer
+
1
!=
ver
)
{
terrno
=
TSDB_CODE_SDB_INVALID_WAl_VER
;
terrno
=
TSDB_CODE_SDB_INVALID_WAl_VER
;
mError
(
"
failed to read wal from sdb, sdbVer:%"
PRId64
" inconsistent with ver:%"
PRId64
,
sdbVer
,
v
er
);
mError
(
"
ver:%"
PRId64
", failed to write to sdb, since inconsistent with sdbver:%"
PRId64
,
ver
,
sdbV
er
);
goto
WAL_RESTORE
_OVER
;
goto
_OVER
;
}
}
mTrace
(
"
wal
:%"
PRId64
", will be restored, content:%p"
,
ver
,
pHead
->
head
.
body
);
mTrace
(
"
ver
:%"
PRId64
", will be restored, content:%p"
,
ver
,
pHead
->
head
.
body
);
if
(
sdbWriteWithoutFree
(
pSdb
,
(
void
*
)
pHead
->
head
.
body
)
<
0
)
{
if
(
sdbWriteWithoutFree
(
pSdb
,
(
void
*
)
pHead
->
head
.
body
)
<
0
)
{
mError
(
"
failed to read wal from sdb since %s, ver:%"
PRId64
,
terrstr
(),
ver
);
mError
(
"
ver:%"
PRId64
", failed to write to sdb since %s"
,
ver
,
terrstr
()
);
goto
WAL_RESTORE
_OVER
;
goto
_OVER
;
}
}
sdbUpdateVer
(
pSdb
,
1
);
sdbUpdateVer
(
pSdb
,
1
);
mDebug
(
"
wal
:%"
PRId64
", is restored"
,
ver
);
mDebug
(
"
ver
:%"
PRId64
", is restored"
,
ver
);
}
}
int64_t
sdbVer
=
sdbUpdateVer
(
pSdb
,
0
);
int64_t
sdbVer
=
sdbUpdateVer
(
pSdb
,
0
);
mDebug
(
"restore
sdb wal finished, sdb
ver:%"
PRId64
,
sdbVer
);
mDebug
(
"restore
wal finished, sdb
ver:%"
PRId64
,
sdbVer
);
mndTransPullup
(
pMnode
);
mndTransPullup
(
pMnode
);
sdbVer
=
sdbUpdateVer
(
pSdb
,
0
);
sdbVer
=
sdbUpdateVer
(
pSdb
,
0
);
mDebug
(
"pullup trans finished, sdb
ver:%"
PRId64
,
sdbVer
);
mDebug
(
"pullup trans finished, sdbver:%"
PRId64
,
sdbVer
);
if
(
sdbVer
!=
lastSdbVer
)
{
if
(
sdbVer
!=
lastSdbVer
)
{
mInfo
(
"sdb restored from %"
PRId64
" to %"
PRId64
", write file"
,
lastSdbVer
,
sdbVer
);
mInfo
(
"sdb restored from %"
PRId64
" to %"
PRId64
", write file"
,
lastSdbVer
,
sdbVer
);
if
(
sdbWriteFile
(
pSdb
)
!=
0
)
{
if
(
sdbWriteFile
(
pSdb
)
!=
0
)
{
goto
WAL_RESTORE
_OVER
;
goto
_OVER
;
}
}
if
(
walCommit
(
pWal
,
sdbVer
)
!=
0
)
{
if
(
walCommit
(
pWal
,
sdbVer
)
!=
0
)
{
goto
WAL_RESTORE
_OVER
;
goto
_OVER
;
}
}
if
(
walBeginSnapshot
(
pWal
,
sdbVer
)
<
0
)
{
if
(
walBeginSnapshot
(
pWal
,
sdbVer
)
<
0
)
{
goto
WAL_RESTORE
_OVER
;
goto
_OVER
;
}
}
if
(
walEndSnapshot
(
pWal
)
<
0
)
{
if
(
walEndSnapshot
(
pWal
)
<
0
)
{
goto
WAL_RESTORE
_OVER
;
goto
_OVER
;
}
}
}
}
code
=
0
;
code
=
0
;
WAL_RESTORE
_OVER:
_OVER:
walCloseReadHandle
(
pHandle
);
walCloseReadHandle
(
pHandle
);
return
code
;
return
code
;
}
}
...
@@ -158,11 +160,11 @@ int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw) {
...
@@ -158,11 +160,11 @@ int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw) {
int64_t
ver
=
sdbUpdateVer
(
pSdb
,
1
);
int64_t
ver
=
sdbUpdateVer
(
pSdb
,
1
);
if
(
walWrite
(
pWal
,
ver
,
1
,
pRaw
,
sdbGetRawTotalSize
(
pRaw
))
<
0
)
{
if
(
walWrite
(
pWal
,
ver
,
1
,
pRaw
,
sdbGetRawTotalSize
(
pRaw
))
<
0
)
{
sdbUpdateVer
(
pSdb
,
-
1
);
sdbUpdateVer
(
pSdb
,
-
1
);
mError
(
"
failed to write raw:%p since %s, ver:%"
PRId64
,
pRaw
,
terrstr
(),
ver
);
mError
(
"
ver:%"
PRId64
", failed to write raw:%p to wal since %s"
,
ver
,
pRaw
,
terrstr
()
);
return
-
1
;
return
-
1
;
}
}
mTrace
(
"
raw:%p, write to wal, ver:%"
PRId64
,
pRaw
,
ver
);
mTrace
(
"
ver:%"
PRId64
", write to wal, raw:%p"
,
ver
,
pRaw
);
walCommit
(
pWal
,
ver
);
walCommit
(
pWal
,
ver
);
walFsync
(
pWal
,
true
);
walFsync
(
pWal
,
true
);
...
...
source/dnode/mnode/impl/src/mndTelem.c
浏览文件 @
a0fcc9a2
...
@@ -146,7 +146,6 @@ int32_t mndInitTelem(SMnode* pMnode) {
...
@@ -146,7 +146,6 @@ int32_t mndInitTelem(SMnode* pMnode) {
taosGetEmail
(
pMgmt
->
email
,
sizeof
(
pMgmt
->
email
));
taosGetEmail
(
pMgmt
->
email
,
sizeof
(
pMgmt
->
email
));
mndSetMsgHandle
(
pMnode
,
TDMT_MND_TELEM_TIMER
,
mndProcessTelemTimer
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_TELEM_TIMER
,
mndProcessTelemTimer
);
mDebug
(
"mnode telemetry is initialized"
);
return
0
;
return
0
;
}
}
...
...
source/dnode/mnode/impl/src/mndUser.c
浏览文件 @
a0fcc9a2
...
@@ -21,8 +21,8 @@
...
@@ -21,8 +21,8 @@
#include "mndTrans.h"
#include "mndTrans.h"
#include "tbase64.h"
#include "tbase64.h"
#define
TSDB_
USER_VER_NUMBER 1
#define USER_VER_NUMBER 1
#define
TSDB_
USER_RESERVE_SIZE 64
#define USER_RESERVE_SIZE 64
static
int32_t
mndCreateDefaultUsers
(
SMnode
*
pMnode
);
static
int32_t
mndCreateDefaultUsers
(
SMnode
*
pMnode
);
static
SSdbRaw
*
mndUserActionEncode
(
SUserObj
*
pUser
);
static
SSdbRaw
*
mndUserActionEncode
(
SUserObj
*
pUser
);
...
@@ -35,7 +35,7 @@ static int32_t mndProcessCreateUserReq(SNodeMsg *pReq);
...
@@ -35,7 +35,7 @@ static int32_t mndProcessCreateUserReq(SNodeMsg *pReq);
static
int32_t
mndProcessAlterUserReq
(
SNodeMsg
*
pReq
);
static
int32_t
mndProcessAlterUserReq
(
SNodeMsg
*
pReq
);
static
int32_t
mndProcessDropUserReq
(
SNodeMsg
*
pReq
);
static
int32_t
mndProcessDropUserReq
(
SNodeMsg
*
pReq
);
static
int32_t
mndProcessGetUserAuthReq
(
SNodeMsg
*
pReq
);
static
int32_t
mndProcessGetUserAuthReq
(
SNodeMsg
*
pReq
);
static
int32_t
mndRetrieveUsers
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rows
);
static
int32_t
mndRetrieveUsers
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rows
);
static
void
mndCancelGetNextUser
(
SMnode
*
pMnode
,
void
*
pIter
);
static
void
mndCancelGetNextUser
(
SMnode
*
pMnode
,
void
*
pIter
);
int32_t
mndInitUser
(
SMnode
*
pMnode
)
{
int32_t
mndInitUser
(
SMnode
*
pMnode
)
{
...
@@ -93,9 +93,9 @@ static SSdbRaw *mndUserActionEncode(SUserObj *pUser) {
...
@@ -93,9 +93,9 @@ static SSdbRaw *mndUserActionEncode(SUserObj *pUser) {
int32_t
numOfReadDbs
=
taosHashGetSize
(
pUser
->
readDbs
);
int32_t
numOfReadDbs
=
taosHashGetSize
(
pUser
->
readDbs
);
int32_t
numOfWriteDbs
=
taosHashGetSize
(
pUser
->
writeDbs
);
int32_t
numOfWriteDbs
=
taosHashGetSize
(
pUser
->
writeDbs
);
int32_t
size
=
sizeof
(
SUserObj
)
+
TSDB_
USER_RESERVE_SIZE
+
(
numOfReadDbs
+
numOfWriteDbs
)
*
TSDB_DB_FNAME_LEN
;
int32_t
size
=
sizeof
(
SUserObj
)
+
USER_RESERVE_SIZE
+
(
numOfReadDbs
+
numOfWriteDbs
)
*
TSDB_DB_FNAME_LEN
;
SSdbRaw
*
pRaw
=
sdbAllocRaw
(
SDB_USER
,
TSDB_
USER_VER_NUMBER
,
size
);
SSdbRaw
*
pRaw
=
sdbAllocRaw
(
SDB_USER
,
USER_VER_NUMBER
,
size
);
if
(
pRaw
==
NULL
)
goto
USER_ENCODE_OVER
;
if
(
pRaw
==
NULL
)
goto
USER_ENCODE_OVER
;
int32_t
dataPos
=
0
;
int32_t
dataPos
=
0
;
...
@@ -120,7 +120,7 @@ static SSdbRaw *mndUserActionEncode(SUserObj *pUser) {
...
@@ -120,7 +120,7 @@ static SSdbRaw *mndUserActionEncode(SUserObj *pUser) {
db
=
taosHashIterate
(
pUser
->
writeDbs
,
db
);
db
=
taosHashIterate
(
pUser
->
writeDbs
,
db
);
}
}
SDB_SET_RESERVE
(
pRaw
,
dataPos
,
TSDB_
USER_RESERVE_SIZE
,
USER_ENCODE_OVER
)
SDB_SET_RESERVE
(
pRaw
,
dataPos
,
USER_RESERVE_SIZE
,
USER_ENCODE_OVER
)
SDB_SET_DATALEN
(
pRaw
,
dataPos
,
USER_ENCODE_OVER
)
SDB_SET_DATALEN
(
pRaw
,
dataPos
,
USER_ENCODE_OVER
)
terrno
=
0
;
terrno
=
0
;
...
@@ -142,7 +142,7 @@ static SSdbRow *mndUserActionDecode(SSdbRaw *pRaw) {
...
@@ -142,7 +142,7 @@ static SSdbRow *mndUserActionDecode(SSdbRaw *pRaw) {
int8_t
sver
=
0
;
int8_t
sver
=
0
;
if
(
sdbGetRawSoftVer
(
pRaw
,
&
sver
)
!=
0
)
goto
USER_DECODE_OVER
;
if
(
sdbGetRawSoftVer
(
pRaw
,
&
sver
)
!=
0
)
goto
USER_DECODE_OVER
;
if
(
sver
!=
TSDB_
USER_VER_NUMBER
)
{
if
(
sver
!=
USER_VER_NUMBER
)
{
terrno
=
TSDB_CODE_SDB_INVALID_DATA_VER
;
terrno
=
TSDB_CODE_SDB_INVALID_DATA_VER
;
goto
USER_DECODE_OVER
;
goto
USER_DECODE_OVER
;
}
}
...
@@ -184,7 +184,7 @@ static SSdbRow *mndUserActionDecode(SSdbRaw *pRaw) {
...
@@ -184,7 +184,7 @@ static SSdbRow *mndUserActionDecode(SSdbRaw *pRaw) {
taosHashPut
(
pUser
->
writeDbs
,
db
,
len
,
db
,
TSDB_DB_FNAME_LEN
);
taosHashPut
(
pUser
->
writeDbs
,
db
,
len
,
db
,
TSDB_DB_FNAME_LEN
);
}
}
SDB_GET_RESERVE
(
pRaw
,
dataPos
,
TSDB_
USER_RESERVE_SIZE
,
USER_DECODE_OVER
)
SDB_GET_RESERVE
(
pRaw
,
dataPos
,
USER_RESERVE_SIZE
,
USER_DECODE_OVER
)
terrno
=
0
;
terrno
=
0
;
...
@@ -639,7 +639,7 @@ GET_AUTH_OVER:
...
@@ -639,7 +639,7 @@ GET_AUTH_OVER:
return
code
;
return
code
;
}
}
static
int32_t
mndRetrieveUsers
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rows
)
{
static
int32_t
mndRetrieveUsers
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rows
)
{
SMnode
*
pMnode
=
pReq
->
pNode
;
SMnode
*
pMnode
=
pReq
->
pNode
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int32_t
numOfRows
=
0
;
int32_t
numOfRows
=
0
;
...
@@ -652,29 +652,29 @@ static int32_t mndRetrieveUsers(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock* pB
...
@@ -652,29 +652,29 @@ static int32_t mndRetrieveUsers(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock* pB
if
(
pShow
->
pIter
==
NULL
)
break
;
if
(
pShow
->
pIter
==
NULL
)
break
;
cols
=
0
;
cols
=
0
;
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
);
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
);
char
name
[
TSDB_USER_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
char
name
[
TSDB_USER_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
STR_WITH_MAXSIZE_TO_VARSTR
(
name
,
pUser
->
user
,
pShow
->
bytes
[
cols
]);
STR_WITH_MAXSIZE_TO_VARSTR
(
name
,
pUser
->
user
,
pShow
->
bytes
[
cols
]);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
name
,
false
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
name
,
false
);
cols
++
;
cols
++
;
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
);
const
char
*
src
=
pUser
->
superUser
?
"super"
:
"normal"
;
const
char
*
src
=
pUser
->
superUser
?
"super"
:
"normal"
;
char
b
[
10
+
VARSTR_HEADER_SIZE
]
=
{
0
};
char
b
[
10
+
VARSTR_HEADER_SIZE
]
=
{
0
};
STR_WITH_SIZE_TO_VARSTR
(
b
,
src
,
strlen
(
src
));
STR_WITH_SIZE_TO_VARSTR
(
b
,
src
,
strlen
(
src
));
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
b
,
false
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
b
,
false
);
cols
++
;
cols
++
;
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pUser
->
createdTime
,
false
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pUser
->
createdTime
,
false
);
cols
++
;
cols
++
;
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
);
STR_WITH_MAXSIZE_TO_VARSTR
(
name
,
pUser
->
acct
,
pShow
->
bytes
[
cols
]);
STR_WITH_MAXSIZE_TO_VARSTR
(
name
,
pUser
->
acct
,
pShow
->
bytes
[
cols
]);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
name
,
false
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
name
,
false
);
numOfRows
++
;
numOfRows
++
;
sdbRelease
(
pSdb
,
pUser
);
sdbRelease
(
pSdb
,
pUser
);
...
...
source/dnode/mnode/impl/test/sma/sma.cpp
浏览文件 @
a0fcc9a2
...
@@ -114,18 +114,15 @@ void* MndTestSma::BuildCreateBSmaStbReq(const char* stbname, int32_t* pContLen)
...
@@ -114,18 +114,15 @@ void* MndTestSma::BuildCreateBSmaStbReq(const char* stbname, int32_t* pContLen)
SMCreateStbReq
createReq
=
{
0
};
SMCreateStbReq
createReq
=
{
0
};
createReq
.
numOfColumns
=
3
;
createReq
.
numOfColumns
=
3
;
createReq
.
numOfTags
=
1
;
createReq
.
numOfTags
=
1
;
createReq
.
numOfSmas
=
1
;
createReq
.
igExists
=
0
;
createReq
.
igExists
=
0
;
createReq
.
pColumns
=
taosArrayInit
(
createReq
.
numOfColumns
,
sizeof
(
SField
));
createReq
.
pColumns
=
taosArrayInit
(
createReq
.
numOfColumns
,
sizeof
(
SField
));
createReq
.
pTags
=
taosArrayInit
(
createReq
.
numOfTags
,
sizeof
(
SField
));
createReq
.
pTags
=
taosArrayInit
(
createReq
.
numOfTags
,
sizeof
(
SField
));
createReq
.
pSmas
=
taosArrayInit
(
createReq
.
numOfSmas
,
sizeof
(
SField
));
strcpy
(
createReq
.
name
,
stbname
);
strcpy
(
createReq
.
name
,
stbname
);
PushField
(
createReq
.
pColumns
,
8
,
TSDB_DATA_TYPE_TIMESTAMP
,
"ts"
);
PushField
(
createReq
.
pColumns
,
8
,
TSDB_DATA_TYPE_TIMESTAMP
,
"ts"
);
PushField
(
createReq
.
pColumns
,
2
,
TSDB_DATA_TYPE_TINYINT
,
"col1"
);
PushField
(
createReq
.
pColumns
,
2
,
TSDB_DATA_TYPE_TINYINT
,
"col1"
);
PushField
(
createReq
.
pColumns
,
8
,
TSDB_DATA_TYPE_BIGINT
,
"col2"
);
PushField
(
createReq
.
pColumns
,
8
,
TSDB_DATA_TYPE_BIGINT
,
"col2"
);
PushField
(
createReq
.
pTags
,
2
,
TSDB_DATA_TYPE_TINYINT
,
"tag1"
);
PushField
(
createReq
.
pTags
,
2
,
TSDB_DATA_TYPE_TINYINT
,
"tag1"
);
PushField
(
createReq
.
pSmas
,
2
,
TSDB_DATA_TYPE_TINYINT
,
"col1"
);
int32_t
tlen
=
tSerializeSMCreateStbReq
(
NULL
,
0
,
&
createReq
);
int32_t
tlen
=
tSerializeSMCreateStbReq
(
NULL
,
0
,
&
createReq
);
void
*
pHead
=
rpcMallocCont
(
tlen
);
void
*
pHead
=
rpcMallocCont
(
tlen
);
...
@@ -190,7 +187,7 @@ void* MndTestSma::BuildDropTSmaReq(const char* smaname, int8_t igNotExists, int3
...
@@ -190,7 +187,7 @@ void* MndTestSma::BuildDropTSmaReq(const char* smaname, int8_t igNotExists, int3
}
}
TEST_F
(
MndTestSma
,
01
_Create_Show_Meta_Drop_Restart_Stb
)
{
TEST_F
(
MndTestSma
,
01
_Create_Show_Meta_Drop_Restart_Stb
)
{
#if 0
#if 0
const char* dbname = "1.d1";
const char* dbname = "1.d1";
const char* stbname = "1.d1.stb";
const char* stbname = "1.d1.stb";
const char* smaname = "1.d1.sma";
const char* smaname = "1.d1.sma";
...
@@ -264,7 +261,7 @@ TEST_F(MndTestSma, 02_Create_Show_Meta_Drop_Restart_BSma) {
...
@@ -264,7 +261,7 @@ TEST_F(MndTestSma, 02_Create_Show_Meta_Drop_Restart_BSma) {
pReq
=
BuildCreateBSmaStbReq
(
stbname
,
&
contLen
);
pReq
=
BuildCreateBSmaStbReq
(
stbname
,
&
contLen
);
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_STB
,
pReq
,
contLen
);
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
test
.
SendShowReq
(
TSDB_MGMT_TABLE_STB
,
"user_stables"
,
dbname
);
test
.
SendShowReq
(
TSDB_MGMT_TABLE_STB
,
"user_stables"
,
dbname
);
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
}
}
...
@@ -280,7 +277,7 @@ TEST_F(MndTestSma, 02_Create_Show_Meta_Drop_Restart_BSma) {
...
@@ -280,7 +277,7 @@ TEST_F(MndTestSma, 02_Create_Show_Meta_Drop_Restart_BSma) {
pReq
=
BuildDropStbReq
(
stbname
,
&
contLen
);
pReq
=
BuildDropStbReq
(
stbname
,
&
contLen
);
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_STB
,
pReq
,
contLen
);
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
test
.
SendShowReq
(
TSDB_MGMT_TABLE_STB
,
"user_stables"
,
dbname
);
test
.
SendShowReq
(
TSDB_MGMT_TABLE_STB
,
"user_stables"
,
dbname
);
EXPECT_EQ
(
test
.
GetShowRows
(),
0
);
EXPECT_EQ
(
test
.
GetShowRows
(),
0
);
}
}
...
...
source/dnode/mnode/sdb/src/sdb.c
浏览文件 @
a0fcc9a2
...
@@ -162,7 +162,4 @@ static int32_t sdbCreateDir(SSdb *pSdb) {
...
@@ -162,7 +162,4 @@ static int32_t sdbCreateDir(SSdb *pSdb) {
return
0
;
return
0
;
}
}
int64_t
sdbUpdateVer
(
SSdb
*
pSdb
,
int32_t
val
)
{
int64_t
sdbUpdateVer
(
SSdb
*
pSdb
,
int32_t
val
)
{
return
atomic_add_fetch_64
(
&
pSdb
->
curVer
,
val
);
}
pSdb
->
curVer
+=
val
;
\ No newline at end of file
return
pSdb
->
curVer
;
}
\ No newline at end of file
source/dnode/mnode/sdb/src/sdbFile.c
浏览文件 @
a0fcc9a2
...
@@ -28,7 +28,7 @@ static int32_t sdbRunDeployFp(SSdb *pSdb) {
...
@@ -28,7 +28,7 @@ static int32_t sdbRunDeployFp(SSdb *pSdb) {
if
(
fp
==
NULL
)
continue
;
if
(
fp
==
NULL
)
continue
;
if
((
*
fp
)(
pSdb
->
pMnode
)
!=
0
)
{
if
((
*
fp
)(
pSdb
->
pMnode
)
!=
0
)
{
mError
(
"failed to deploy sdb:%
d since %s"
,
i
,
terrstr
());
mError
(
"failed to deploy sdb:%
s since %s"
,
sdbTableName
(
i
)
,
terrstr
());
return
-
1
;
return
-
1
;
}
}
}
}
...
...
source/dnode/vnode/CMakeLists.txt
浏览文件 @
a0fcc9a2
...
@@ -19,7 +19,6 @@ target_sources(
...
@@ -19,7 +19,6 @@ target_sources(
"src/meta/metaOpen.c"
"src/meta/metaOpen.c"
"src/meta/metaIdx.c"
"src/meta/metaIdx.c"
"src/meta/metaTable.c"
"src/meta/metaTable.c"
"src/meta/metaTDBImpl.c"
"src/meta/metaQuery.c"
"src/meta/metaQuery.c"
"src/meta/metaCommit.c"
"src/meta/metaCommit.c"
"src/meta/metaEntry.c"
"src/meta/metaEntry.c"
...
@@ -33,7 +32,6 @@ target_sources(
...
@@ -33,7 +32,6 @@ target_sources(
"src/tsdb/tsdbFS.c"
"src/tsdb/tsdbFS.c"
"src/tsdb/tsdbMain.c"
"src/tsdb/tsdbMain.c"
"src/tsdb/tsdbMemTable.c"
"src/tsdb/tsdbMemTable.c"
"src/tsdb/tsdbOptions.c"
"src/tsdb/tsdbRead.c"
"src/tsdb/tsdbRead.c"
"src/tsdb/tsdbReadImpl.c"
"src/tsdb/tsdbReadImpl.c"
"src/tsdb/tsdbScan.c"
"src/tsdb/tsdbScan.c"
...
...
source/dnode/vnode/inc/vnode.h
浏览文件 @
a0fcc9a2
...
@@ -74,7 +74,7 @@ typedef struct SMeta SMeta; // todo: remove
...
@@ -74,7 +74,7 @@ typedef struct SMeta SMeta; // todo: remove
typedef
struct
SMetaReader
SMetaReader
;
typedef
struct
SMetaReader
SMetaReader
;
typedef
struct
SMetaEntry
SMetaEntry
;
typedef
struct
SMetaEntry
SMetaEntry
;
void
metaReaderInit
(
SMetaReader
*
pReader
,
S
Vnode
*
pVnode
,
int32_t
flags
);
void
metaReaderInit
(
SMetaReader
*
pReader
,
S
Meta
*
pMeta
,
int32_t
flags
);
void
metaReaderClear
(
SMetaReader
*
pReader
);
void
metaReaderClear
(
SMetaReader
*
pReader
);
int
metaReadNext
(
SMetaReader
*
pReader
);
int
metaReadNext
(
SMetaReader
*
pReader
);
...
@@ -111,7 +111,7 @@ bool tsdbNextDataBlock(tsdbReaderT pTsdbReadHandle);
...
@@ -111,7 +111,7 @@ bool tsdbNextDataBlock(tsdbReaderT pTsdbReadHandle);
void
tsdbRetrieveDataBlockInfo
(
tsdbReaderT
*
pTsdbReadHandle
,
SDataBlockInfo
*
pBlockInfo
);
void
tsdbRetrieveDataBlockInfo
(
tsdbReaderT
*
pTsdbReadHandle
,
SDataBlockInfo
*
pBlockInfo
);
int32_t
tsdbRetrieveDataBlockStatisInfo
(
tsdbReaderT
*
pTsdbReadHandle
,
SColumnDataAgg
**
pBlockStatis
);
int32_t
tsdbRetrieveDataBlockStatisInfo
(
tsdbReaderT
*
pTsdbReadHandle
,
SColumnDataAgg
**
pBlockStatis
);
SArray
*
tsdbRetrieveDataBlock
(
tsdbReaderT
*
pTsdbReadHandle
,
SArray
*
pColumnIdList
);
SArray
*
tsdbRetrieveDataBlock
(
tsdbReaderT
*
pTsdbReadHandle
,
SArray
*
pColumnIdList
);
void
tsdbResetReadHandle
(
tsdbReaderT
queryHandle
,
SQueryTableDataCond
*
pCond
);
void
tsdbResetReadHandle
(
tsdbReaderT
queryHandle
,
SQueryTableDataCond
*
pCond
);
void
tsdbDestroyTableGroup
(
STableGroupInfo
*
pGroupList
);
void
tsdbDestroyTableGroup
(
STableGroupInfo
*
pGroupList
);
int32_t
tsdbGetOneTableGroup
(
void
*
pMeta
,
uint64_t
uid
,
TSKEY
startKey
,
STableGroupInfo
*
pGroupInfo
);
int32_t
tsdbGetOneTableGroup
(
void
*
pMeta
,
uint64_t
uid
,
TSKEY
startKey
,
STableGroupInfo
*
pGroupInfo
);
int32_t
tsdbGetTableGroupFromIdList
(
STsdb
*
tsdb
,
SArray
*
pTableIdList
,
STableGroupInfo
*
pGroupInfo
);
int32_t
tsdbGetTableGroupFromIdList
(
STsdb
*
tsdb
,
SArray
*
pTableIdList
,
STableGroupInfo
*
pGroupInfo
);
...
...
source/dnode/vnode/src/inc/meta.h
浏览文件 @
a0fcc9a2
...
@@ -16,13 +16,14 @@
...
@@ -16,13 +16,14 @@
#ifndef _TD_VNODE_META_H_
#ifndef _TD_VNODE_META_H_
#define _TD_VNODE_META_H_
#define _TD_VNODE_META_H_
#include "vnodeInt.h"
#ifdef __cplusplus
#ifdef __cplusplus
extern
"C"
{
extern
"C"
{
#endif
#endif
typedef
struct
SMetaIdx
SMetaIdx
;
typedef
struct
SMetaIdx
SMetaIdx
;
typedef
struct
SMetaDB
SMetaDB
;
typedef
struct
SMetaDB
SMetaDB
;
typedef
struct
SMCtbCursor
SMCtbCursor
;
typedef
struct
SMSmaCursor
SMSmaCursor
;
typedef
struct
SMSmaCursor
SMSmaCursor
;
// metaDebug ==================
// metaDebug ==================
...
@@ -36,22 +37,16 @@ typedef struct SMSmaCursor SMSmaCursor;
...
@@ -36,22 +37,16 @@ typedef struct SMSmaCursor SMSmaCursor;
// clang-format on
// clang-format on
// metaOpen ==================
// metaOpen ==================
int
metaOpen
(
SVnode
*
pVnode
,
SMeta
**
ppMeta
);
int
metaClose
(
SMeta
*
pMeta
);
// metaEntry ==================
// metaEntry ==================
int
metaEncodeEntry
(
SCoder
*
pCoder
,
const
SMetaEntry
*
pME
);
int
metaEncodeEntry
(
SCoder
*
pCoder
,
const
SMetaEntry
*
pME
);
int
metaDecodeEntry
(
SCoder
*
pCoder
,
SMetaEntry
*
pME
);
int
metaDecodeEntry
(
SCoder
*
pCoder
,
SMetaEntry
*
pME
);
// metaTable ==================
// metaTable ==================
int
metaCreateSTable
(
SMeta
*
pMeta
,
int64_t
version
,
SVCreateStbReq
*
pReq
);
int
metaDropSTable
(
SMeta
*
pMeta
,
int64_t
verison
,
SVDropStbReq
*
pReq
);
int
metaDropSTable
(
SMeta
*
pMeta
,
int64_t
verison
,
SVDropStbReq
*
pReq
);
int
metaCreateTable
(
SMeta
*
pMeta
,
int64_t
version
,
SVCreateTbReq
*
pReq
);
// metaQuery ==================
// metaQuery ==================
int
metaGetTableEntryByVersion
(
SMetaReader
*
pReader
,
int64_t
version
,
tb_uid_t
uid
);
int
metaGetTableEntryByVersion
(
SMetaReader
*
pReader
,
int64_t
version
,
tb_uid_t
uid
);
int
metaGetTableEntryByUid
(
SMetaReader
*
pReader
,
tb_uid_t
uid
);
int
metaGetTableEntryByName
(
SMetaReader
*
pReader
,
const
char
*
name
);
// metaIdx ==================
// metaIdx ==================
int
metaOpenIdx
(
SMeta
*
pMeta
);
int
metaOpenIdx
(
SMeta
*
pMeta
);
...
@@ -60,8 +55,6 @@ int metaSaveTableToIdx(SMeta* pMeta, const STbCfg* pTbOptions);
...
@@ -60,8 +55,6 @@ int metaSaveTableToIdx(SMeta* pMeta, const STbCfg* pTbOptions);
int
metaRemoveTableFromIdx
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
int
metaRemoveTableFromIdx
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
// metaCommit ==================
// metaCommit ==================
int
metaBegin
(
SMeta
*
pMeta
);
static
FORCE_INLINE
tb_uid_t
metaGenerateUid
(
SMeta
*
pMeta
)
{
return
tGenIdPI64
();
}
static
FORCE_INLINE
tb_uid_t
metaGenerateUid
(
SMeta
*
pMeta
)
{
return
tGenIdPI64
();
}
struct
SMeta
{
struct
SMeta
{
...
@@ -106,27 +99,12 @@ typedef struct {
...
@@ -106,27 +99,12 @@ typedef struct {
}
STtlIdxKey
;
}
STtlIdxKey
;
#if 1
#if 1
#define META_SUPER_TABLE TD_SUPER_TABLE
#define META_CHILD_TABLE TD_CHILD_TABLE
#define META_NORMAL_TABLE TD_NORMAL_TABLE
// int metaCreateTable(SMeta* pMeta, STbCfg* pTbCfg, STbDdlH* pHandle);
// int metaCreateTable(SMeta* pMeta, STbCfg* pTbCfg, STbDdlH* pHandle);
int
metaDropTable
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
int
metaDropTable
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
int
metaCommit
(
SMeta
*
pMeta
);
int32_t
metaCreateTSma
(
SMeta
*
pMeta
,
SSmaCfg
*
pCfg
);
int32_t
metaDropTSma
(
SMeta
*
pMeta
,
int64_t
indexUid
);
SSchemaWrapper
*
metaGetTableSchema
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int32_t
sver
,
bool
isinline
);
STSchema
*
metaGetTbTSchema
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int32_t
sver
);
void
*
metaGetSmaInfoByIndex
(
SMeta
*
pMeta
,
int64_t
indexUid
,
bool
isDecode
);
STSmaWrapper
*
metaGetSmaInfoByTable
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
SArray
*
metaGetSmaTbUids
(
SMeta
*
pMeta
,
bool
isDup
);
int
metaGetTbNum
(
SMeta
*
pMeta
);
SMSmaCursor
*
metaOpenSmaCursor
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
SMSmaCursor
*
metaOpenSmaCursor
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
void
metaCloseSmaCursor
(
SMSmaCursor
*
pSmaCur
);
void
metaCloseSmaCursor
(
SMSmaCursor
*
pSmaCur
);
int64_t
metaSmaCursorNext
(
SMSmaCursor
*
pSmaCur
);
int64_t
metaSmaCursorNext
(
SMSmaCursor
*
pSmaCur
);
SMCtbCursor
*
metaOpenCtbCursor
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
void
metaCloseCtbCurosr
(
SMCtbCursor
*
pCtbCur
);
tb_uid_t
metaCtbCursorNext
(
SMCtbCursor
*
pCtbCur
);
#ifndef META_REFACT
#ifndef META_REFACT
// SMetaDB
// SMetaDB
...
...
source/dnode/vnode/src/inc/tq.h
浏览文件 @
a0fcc9a2
...
@@ -16,6 +16,8 @@
...
@@ -16,6 +16,8 @@
#ifndef _TD_VNODE_TQ_H_
#ifndef _TD_VNODE_TQ_H_
#define _TD_VNODE_TQ_H_
#define _TD_VNODE_TQ_H_
#include "vnodeInt.h"
#include "executor.h"
#include "executor.h"
#include "os.h"
#include "os.h"
#include "tcache.h"
#include "tcache.h"
...
@@ -237,17 +239,7 @@ int tqInit();
...
@@ -237,17 +239,7 @@ int tqInit();
void
tqCleanUp
();
void
tqCleanUp
();
// open in each vnode
// open in each vnode
STQ
*
tqOpen
(
const
char
*
path
,
SVnode
*
pVnode
,
SWal
*
pWal
);
void
tqClose
(
STQ
*
);
// required by vnode
// required by vnode
int
tqPushMsg
(
STQ
*
,
void
*
msg
,
int32_t
msgLen
,
tmsg_t
msgType
,
int64_t
ver
);
int
tqCommit
(
STQ
*
);
int32_t
tqProcessPollReq
(
STQ
*
pTq
,
SRpcMsg
*
pMsg
,
int32_t
workerId
);
int32_t
tqProcessVgChangeReq
(
STQ
*
pTq
,
char
*
msg
,
int32_t
msgLen
);
int32_t
tqProcessTaskExec
(
STQ
*
pTq
,
char
*
msg
,
int32_t
msgLen
,
int32_t
workerId
);
int32_t
tqProcessTaskDeploy
(
STQ
*
pTq
,
char
*
msg
,
int32_t
msgLen
);
int32_t
tqProcessStreamTrigger
(
STQ
*
pTq
,
void
*
data
,
int32_t
dataLen
,
int32_t
workerId
);
int32_t
tqSerializeConsumer
(
const
STqConsumer
*
,
STqSerializedHead
**
);
int32_t
tqSerializeConsumer
(
const
STqConsumer
*
,
STqSerializedHead
**
);
int32_t
tqDeserializeConsumer
(
STQ
*
,
const
STqSerializedHead
*
,
STqConsumer
**
);
int32_t
tqDeserializeConsumer
(
STQ
*
,
const
STqSerializedHead
*
,
STqConsumer
**
);
...
...
source/dnode/vnode/src/inc/tsdb.h
浏览文件 @
a0fcc9a2
...
@@ -16,6 +16,8 @@
...
@@ -16,6 +16,8 @@
#ifndef _TD_VNODE_TSDB_H_
#ifndef _TD_VNODE_TSDB_H_
#define _TD_VNODE_TSDB_H_
#define _TD_VNODE_TSDB_H_
#include "vnodeInt.h"
#ifdef __cplusplus
#ifdef __cplusplus
extern
"C"
{
extern
"C"
{
#endif
#endif
...
@@ -43,7 +45,6 @@ int tsdbLoadDataFromCache(STable *pTable, SSkipListIterator *pIter, TSKEY maxKe
...
@@ -43,7 +45,6 @@ int tsdbLoadDataFromCache(STable *pTable, SSkipListIterator *pIter, TSKEY maxKe
TKEY
*
filterKeys
,
int
nFilterKeys
,
bool
keepDup
,
SMergeInfo
*
pMergeInfo
);
TKEY
*
filterKeys
,
int
nFilterKeys
,
bool
keepDup
,
SMergeInfo
*
pMergeInfo
);
// tsdbCommit ================
// tsdbCommit ================
int
tsdbBegin
(
STsdb
*
pTsdb
);
#if 1
#if 1
...
@@ -60,16 +61,9 @@ struct STable {
...
@@ -60,16 +61,9 @@ struct STable {
#define TABLE_TID(t) (t)->tid
#define TABLE_TID(t) (t)->tid
#define TABLE_UID(t) (t)->uid
#define TABLE_UID(t) (t)->uid
int
tsdbOpen
(
SVnode
*
pVnode
,
STsdb
**
ppTsdb
);
int
tsdbClose
(
STsdb
*
pTsdb
);
int
tsdbInsertData
(
STsdb
*
pTsdb
,
int64_t
version
,
SSubmitReq
*
pMsg
,
SSubmitRsp
*
pRsp
);
int
tsdbPrepareCommit
(
STsdb
*
pTsdb
);
int
tsdbPrepareCommit
(
STsdb
*
pTsdb
);
int
tsdbCommit
(
STsdb
*
pTsdb
);
int32_t
tsdbInitSma
(
STsdb
*
pTsdb
);
int32_t
tsdbInitSma
(
STsdb
*
pTsdb
);
int32_t
tsdbCreateTSma
(
STsdb
*
pTsdb
,
char
*
pMsg
);
int32_t
tsdbDropTSma
(
STsdb
*
pTsdb
,
char
*
pMsg
);
int32_t
tsdbDropTSma
(
STsdb
*
pTsdb
,
char
*
pMsg
);
int32_t
tsdbUpdateSmaWindow
(
STsdb
*
pTsdb
,
SSubmitReq
*
pMsg
,
int64_t
version
);
int32_t
tsdbInsertTSmaData
(
STsdb
*
pTsdb
,
int64_t
indexUid
,
const
char
*
msg
);
int32_t
tsdbDropTSmaData
(
STsdb
*
pTsdb
,
int64_t
indexUid
);
int32_t
tsdbDropTSmaData
(
STsdb
*
pTsdb
,
int64_t
indexUid
);
int32_t
tsdbInsertRSmaData
(
STsdb
*
pTsdb
,
char
*
msg
);
int32_t
tsdbInsertRSmaData
(
STsdb
*
pTsdb
,
char
*
msg
);
void
tsdbCleanupReadHandle
(
tsdbReaderT
queryHandle
);
void
tsdbCleanupReadHandle
(
tsdbReaderT
queryHandle
);
...
@@ -237,12 +231,6 @@ static FORCE_INLINE TSKEY tsdbNextIterKey(SSkipListIterator *pIter) {
...
@@ -237,12 +231,6 @@ static FORCE_INLINE TSKEY tsdbNextIterKey(SSkipListIterator *pIter) {
return
TD_ROW_KEY
(
row
);
return
TD_ROW_KEY
(
row
);
}
}
// tsdbOptions
extern
const
STsdbCfg
defautlTsdbOptions
;
int
tsdbValidateOptions
(
const
STsdbCfg
*
);
void
tsdbOptionsCopy
(
STsdbCfg
*
pDest
,
const
STsdbCfg
*
pSrc
);
// tsdbReadImpl
// tsdbReadImpl
typedef
struct
SReadH
SReadH
;
typedef
struct
SReadH
SReadH
;
...
...
source/dnode/vnode/src/inc/tsdbSma.h
浏览文件 @
a0fcc9a2
...
@@ -16,9 +16,7 @@
...
@@ -16,9 +16,7 @@
#ifndef _TD_VNODE_TSDB_SMA_H_
#ifndef _TD_VNODE_TSDB_SMA_H_
#define _TD_VNODE_TSDB_SMA_H_
#define _TD_VNODE_TSDB_SMA_H_
#include "os.h"
#include "tsdb.h"
#include "thash.h"
#include "tmsg.h"
#ifdef __cplusplus
#ifdef __cplusplus
extern
"C"
{
extern
"C"
{
...
@@ -32,12 +30,6 @@ struct STbDdlH {
...
@@ -32,12 +30,6 @@ struct STbDdlH {
__tb_ddl_fn_t
fp
;
__tb_ddl_fn_t
fp
;
};
};
typedef
struct
{
tb_uid_t
suid
;
SArray
*
tbUids
;
SHashObj
*
uidHash
;
}
STbUidStore
;
static
FORCE_INLINE
int32_t
tsdbUidStoreInit
(
STbUidStore
**
pStore
)
{
static
FORCE_INLINE
int32_t
tsdbUidStoreInit
(
STbUidStore
**
pStore
)
{
ASSERT
(
*
pStore
==
NULL
);
ASSERT
(
*
pStore
==
NULL
);
*
pStore
=
taosMemoryCalloc
(
1
,
sizeof
(
STbUidStore
));
*
pStore
=
taosMemoryCalloc
(
1
,
sizeof
(
STbUidStore
));
...
...
source/dnode/vnode/src/inc/vnd.h
浏览文件 @
a0fcc9a2
...
@@ -16,6 +16,10 @@
...
@@ -16,6 +16,10 @@
#ifndef _TD_VND_H_
#ifndef _TD_VND_H_
#define _TD_VND_H_
#define _TD_VND_H_
#include "sync.h"
#include "syncTools.h"
#include "vnodeInt.h"
#ifdef __cplusplus
#ifdef __cplusplus
extern
"C"
{
extern
"C"
{
#endif
#endif
...
@@ -61,8 +65,6 @@ struct SVBufPool {
...
@@ -61,8 +65,6 @@ struct SVBufPool {
int
vnodeOpenBufPool
(
SVnode
*
pVnode
,
int64_t
size
);
int
vnodeOpenBufPool
(
SVnode
*
pVnode
,
int64_t
size
);
int
vnodeCloseBufPool
(
SVnode
*
pVnode
);
int
vnodeCloseBufPool
(
SVnode
*
pVnode
);
void
vnodeBufPoolReset
(
SVBufPool
*
pPool
);
void
vnodeBufPoolReset
(
SVBufPool
*
pPool
);
void
*
vnodeBufPoolMalloc
(
SVBufPool
*
pPool
,
int
size
);
void
vnodeBufPoolFree
(
SVBufPool
*
pPool
,
void
*
p
);
// vnodeQuery ====================
// vnodeQuery ====================
int
vnodeQueryOpen
(
SVnode
*
pVnode
);
int
vnodeQueryOpen
(
SVnode
*
pVnode
);
...
@@ -79,6 +81,20 @@ int vnodeLoadInfo(const char* dir, SVnodeInfo* pInfo);
...
@@ -79,6 +81,20 @@ int vnodeLoadInfo(const char* dir, SVnodeInfo* pInfo);
int
vnodeSyncCommit
(
SVnode
*
pVnode
);
int
vnodeSyncCommit
(
SVnode
*
pVnode
);
int
vnodeAsyncCommit
(
SVnode
*
pVnode
);
int
vnodeAsyncCommit
(
SVnode
*
pVnode
);
// vnodeCommit ====================
int32_t
vnodeSyncOpen
(
SVnode
*
pVnode
,
char
*
path
);
int32_t
vnodeSyncStart
(
SVnode
*
pVnode
);
void
vnodeSyncClose
(
SVnode
*
pVnode
);
void
vnodeSyncSetQ
(
SVnode
*
pVnode
,
void
*
qHandle
);
void
vnodeSyncSetRpc
(
SVnode
*
pVnode
,
void
*
rpcHandle
);
int32_t
vnodeSyncEqMsg
(
void
*
qHandle
,
SRpcMsg
*
pMsg
);
int32_t
vnodeSendMsg
(
void
*
rpcHandle
,
const
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
);
void
vnodeSyncCommitCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
);
void
vnodeSyncPreCommitCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
);
void
vnodeSyncRollBackCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
);
int32_t
vnodeSyncGetSnapshotCb
(
struct
SSyncFSM
*
pFsm
,
SSnapshot
*
pSnapshot
);
SSyncFSM
*
syncVnodeMakeFsm
();
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
source/dnode/vnode/src/inc/vnodeInt.h
浏览文件 @
a0fcc9a2
...
@@ -59,6 +59,55 @@ typedef struct SQWorkerMgmt SQHandle;
...
@@ -59,6 +59,55 @@ typedef struct SQWorkerMgmt SQHandle;
#define VNODE_TQ_DIR "tq"
#define VNODE_TQ_DIR "tq"
#define VNODE_WAL_DIR "wal"
#define VNODE_WAL_DIR "wal"
// vnd.h
void
*
vnodeBufPoolMalloc
(
SVBufPool
*
pPool
,
int
size
);
void
vnodeBufPoolFree
(
SVBufPool
*
pPool
,
void
*
p
);
// meta
typedef
struct
SMCtbCursor
SMCtbCursor
;
typedef
struct
STbUidStore
STbUidStore
;
int
metaOpen
(
SVnode
*
pVnode
,
SMeta
**
ppMeta
);
int
metaClose
(
SMeta
*
pMeta
);
int
metaBegin
(
SMeta
*
pMeta
);
int
metaCommit
(
SMeta
*
pMeta
);
int
metaCreateSTable
(
SMeta
*
pMeta
,
int64_t
version
,
SVCreateStbReq
*
pReq
);
int
metaCreateTable
(
SMeta
*
pMeta
,
int64_t
version
,
SVCreateTbReq
*
pReq
);
SSchemaWrapper
*
metaGetTableSchema
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int32_t
sver
,
bool
isinline
);
STSchema
*
metaGetTbTSchema
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int32_t
sver
);
int
metaGetTableEntryByUid
(
SMetaReader
*
pReader
,
tb_uid_t
uid
);
int
metaGetTableEntryByName
(
SMetaReader
*
pReader
,
const
char
*
name
);
int
metaGetTbNum
(
SMeta
*
pMeta
);
SMCtbCursor
*
metaOpenCtbCursor
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
void
metaCloseCtbCurosr
(
SMCtbCursor
*
pCtbCur
);
tb_uid_t
metaCtbCursorNext
(
SMCtbCursor
*
pCtbCur
);
SArray
*
metaGetSmaTbUids
(
SMeta
*
pMeta
,
bool
isDup
);
void
*
metaGetSmaInfoByIndex
(
SMeta
*
pMeta
,
int64_t
indexUid
,
bool
isDecode
);
STSmaWrapper
*
metaGetSmaInfoByTable
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
int32_t
metaCreateTSma
(
SMeta
*
pMeta
,
SSmaCfg
*
pCfg
);
int32_t
metaDropTSma
(
SMeta
*
pMeta
,
int64_t
indexUid
);
// tsdb
int
tsdbOpen
(
SVnode
*
pVnode
,
STsdb
**
ppTsdb
);
int
tsdbClose
(
STsdb
*
pTsdb
);
int
tsdbBegin
(
STsdb
*
pTsdb
);
int
tsdbCommit
(
STsdb
*
pTsdb
);
int32_t
tsdbUpdateSmaWindow
(
STsdb
*
pTsdb
,
SSubmitReq
*
pMsg
,
int64_t
version
);
int32_t
tsdbCreateTSma
(
STsdb
*
pTsdb
,
char
*
pMsg
);
int32_t
tsdbInsertTSmaData
(
STsdb
*
pTsdb
,
int64_t
indexUid
,
const
char
*
msg
);
int
tsdbInsertData
(
STsdb
*
pTsdb
,
int64_t
version
,
SSubmitReq
*
pMsg
,
SSubmitRsp
*
pRsp
);
// tq
STQ
*
tqOpen
(
const
char
*
path
,
SVnode
*
pVnode
,
SWal
*
pWal
);
void
tqClose
(
STQ
*
);
int
tqPushMsg
(
STQ
*
,
void
*
msg
,
int32_t
msgLen
,
tmsg_t
msgType
,
int64_t
ver
);
int
tqCommit
(
STQ
*
);
int32_t
tqProcessVgChangeReq
(
STQ
*
pTq
,
char
*
msg
,
int32_t
msgLen
);
int32_t
tqProcessTaskExec
(
STQ
*
pTq
,
char
*
msg
,
int32_t
msgLen
,
int32_t
workerId
);
int32_t
tqProcessTaskDeploy
(
STQ
*
pTq
,
char
*
msg
,
int32_t
msgLen
);
int32_t
tqProcessStreamTrigger
(
STQ
*
pTq
,
void
*
data
,
int32_t
dataLen
,
int32_t
workerId
);
int32_t
tqProcessPollReq
(
STQ
*
pTq
,
SRpcMsg
*
pMsg
,
int32_t
workerId
);
typedef
struct
{
typedef
struct
{
int8_t
streamType
;
// sma or other
int8_t
streamType
;
// sma or other
int8_t
dstType
;
int8_t
dstType
;
...
@@ -106,6 +155,12 @@ struct SVnode {
...
@@ -106,6 +155,12 @@ struct SVnode {
SQHandle
*
pQuery
;
SQHandle
*
pQuery
;
};
};
struct
STbUidStore
{
tb_uid_t
suid
;
SArray
*
tbUids
;
SHashObj
*
uidHash
;
};
#define TD_VID(PVNODE) (PVNODE)->config.vgId
#define TD_VID(PVNODE) (PVNODE)->config.vgId
typedef
struct
STbDdlH
STbDdlH
;
typedef
struct
STbDdlH
STbDdlH
;
...
@@ -113,18 +168,6 @@ typedef struct STbDdlH STbDdlH;
...
@@ -113,18 +168,6 @@ typedef struct STbDdlH STbDdlH;
// sma
// sma
void
smaHandleRes
(
void
*
pVnode
,
int64_t
smaId
,
const
SArray
*
data
);
void
smaHandleRes
(
void
*
pVnode
,
int64_t
smaId
,
const
SArray
*
data
);
#include "vnd.h"
#include "meta.h"
#include "tsdb.h"
#include "tq.h"
#include "vnodeSync.h"
#include "tsdbSma.h"
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
source/dnode/vnode/src/inc/vnodeSync.h
已删除
100644 → 0
浏览文件 @
ccffe945
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _TD_VNODE_SYNC_H_
#define _TD_VNODE_SYNC_H_
#ifdef __cplusplus
extern
"C"
{
#endif
int32_t
vnodeSyncOpen
(
SVnode
*
pVnode
,
char
*
path
);
int32_t
vnodeSyncStart
(
SVnode
*
pVnode
);
void
vnodeSyncClose
(
SVnode
*
pVnode
);
void
vnodeSyncSetQ
(
SVnode
*
pVnode
,
void
*
qHandle
);
void
vnodeSyncSetRpc
(
SVnode
*
pVnode
,
void
*
rpcHandle
);
int32_t
vnodeSyncEqMsg
(
void
*
qHandle
,
SRpcMsg
*
pMsg
);
int32_t
vnodeSendMsg
(
void
*
rpcHandle
,
const
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
);
void
vnodeSyncCommitCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
);
void
vnodeSyncPreCommitCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
);
void
vnodeSyncRollBackCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
);
int32_t
vnodeSyncGetSnapshotCb
(
struct
SSyncFSM
*
pFsm
,
SSnapshot
*
pSnapshot
);
SSyncFSM
*
syncVnodeMakeFsm
();
#ifdef __cplusplus
}
#endif
#endif
/*_TD_VNODE_SYNC_H_*/
source/dnode/vnode/src/meta/metaCommit.c
浏览文件 @
a0fcc9a2
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include "
vnodeInt
.h"
#include "
meta
.h"
static
FORCE_INLINE
void
*
metaMalloc
(
void
*
pPool
,
size_t
size
)
{
return
vnodeBufPoolMalloc
((
SVBufPool
*
)
pPool
,
size
);
}
static
FORCE_INLINE
void
*
metaMalloc
(
void
*
pPool
,
size_t
size
)
{
return
vnodeBufPoolMalloc
((
SVBufPool
*
)
pPool
,
size
);
}
static
FORCE_INLINE
void
metaFree
(
void
*
pPool
,
void
*
p
)
{
vnodeBufPoolFree
((
SVBufPool
*
)
pPool
,
p
);
}
static
FORCE_INLINE
void
metaFree
(
void
*
pPool
,
void
*
p
)
{
vnodeBufPoolFree
((
SVBufPool
*
)
pPool
,
p
);
}
...
...
source/dnode/vnode/src/meta/metaEntry.c
浏览文件 @
a0fcc9a2
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include "
vnodeInt
.h"
#include "
meta
.h"
int
metaEncodeEntry
(
SCoder
*
pCoder
,
const
SMetaEntry
*
pME
)
{
int
metaEncodeEntry
(
SCoder
*
pCoder
,
const
SMetaEntry
*
pME
)
{
if
(
tStartEncode
(
pCoder
)
<
0
)
return
-
1
;
if
(
tStartEncode
(
pCoder
)
<
0
)
return
-
1
;
...
...
source/dnode/vnode/src/meta/metaIdx.c
浏览文件 @
a0fcc9a2
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
#ifdef USE_INVERTED_INDEX
#ifdef USE_INVERTED_INDEX
#include "index.h"
#include "index.h"
#endif
#endif
#include "
vnodeInt
.h"
#include "
meta
.h"
struct
SMetaIdx
{
struct
SMetaIdx
{
#ifdef USE_INVERTED_INDEX
#ifdef USE_INVERTED_INDEX
...
...
source/dnode/vnode/src/meta/metaOpen.c
浏览文件 @
a0fcc9a2
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include "
vnodeInt
.h"
#include "
meta
.h"
static
int
tbDbKeyCmpr
(
const
void
*
pKey1
,
int
kLen1
,
const
void
*
pKey2
,
int
kLen2
);
static
int
tbDbKeyCmpr
(
const
void
*
pKey1
,
int
kLen1
,
const
void
*
pKey2
,
int
kLen2
);
static
int
skmDbKeyCmpr
(
const
void
*
pKey1
,
int
kLen1
,
const
void
*
pKey2
,
int
kLen2
);
static
int
skmDbKeyCmpr
(
const
void
*
pKey1
,
int
kLen1
,
const
void
*
pKey2
,
int
kLen2
);
...
...
source/dnode/vnode/src/meta/metaQuery.c
浏览文件 @
a0fcc9a2
...
@@ -13,12 +13,12 @@
...
@@ -13,12 +13,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include "
vnodeInt
.h"
#include "
meta
.h"
void
metaReaderInit
(
SMetaReader
*
pReader
,
S
Vnode
*
pVnode
,
int32_t
flags
)
{
void
metaReaderInit
(
SMetaReader
*
pReader
,
S
Meta
*
pMeta
,
int32_t
flags
)
{
memset
(
pReader
,
0
,
sizeof
(
*
pReader
));
memset
(
pReader
,
0
,
sizeof
(
*
pReader
));
pReader
->
flags
=
flags
;
pReader
->
flags
=
flags
;
pReader
->
pMeta
=
p
Vnode
->
p
Meta
;
pReader
->
pMeta
=
pMeta
;
}
}
void
metaReaderClear
(
SMetaReader
*
pReader
)
{
void
metaReaderClear
(
SMetaReader
*
pReader
)
{
...
@@ -32,6 +32,7 @@ int metaGetTableEntryByVersion(SMetaReader *pReader, int64_t version, tb_uid_t u
...
@@ -32,6 +32,7 @@ int metaGetTableEntryByVersion(SMetaReader *pReader, int64_t version, tb_uid_t u
// query table.db
// query table.db
if
(
tdbDbGet
(
pMeta
->
pTbDb
,
&
tbDbKey
,
sizeof
(
tbDbKey
),
&
pReader
->
pBuf
,
&
pReader
->
szBuf
)
<
0
)
{
if
(
tdbDbGet
(
pMeta
->
pTbDb
,
&
tbDbKey
,
sizeof
(
tbDbKey
),
&
pReader
->
pBuf
,
&
pReader
->
szBuf
)
<
0
)
{
terrno
=
TSDB_CODE_PAR_TABLE_NOT_EXIST
;
goto
_err
;
goto
_err
;
}
}
...
@@ -54,6 +55,7 @@ int metaGetTableEntryByUid(SMetaReader *pReader, tb_uid_t uid) {
...
@@ -54,6 +55,7 @@ int metaGetTableEntryByUid(SMetaReader *pReader, tb_uid_t uid) {
// query uid.idx
// query uid.idx
if
(
tdbDbGet
(
pMeta
->
pUidIdx
,
&
uid
,
sizeof
(
uid
),
&
pReader
->
pBuf
,
&
pReader
->
szBuf
)
<
0
)
{
if
(
tdbDbGet
(
pMeta
->
pUidIdx
,
&
uid
,
sizeof
(
uid
),
&
pReader
->
pBuf
,
&
pReader
->
szBuf
)
<
0
)
{
terrno
=
TSDB_CODE_PAR_TABLE_NOT_EXIST
;
return
-
1
;
return
-
1
;
}
}
...
@@ -67,6 +69,7 @@ int metaGetTableEntryByName(SMetaReader *pReader, const char *name) {
...
@@ -67,6 +69,7 @@ int metaGetTableEntryByName(SMetaReader *pReader, const char *name) {
// query name.idx
// query name.idx
if
(
tdbDbGet
(
pMeta
->
pNameIdx
,
name
,
strlen
(
name
)
+
1
,
&
pReader
->
pBuf
,
&
pReader
->
szBuf
)
<
0
)
{
if
(
tdbDbGet
(
pMeta
->
pNameIdx
,
name
,
strlen
(
name
)
+
1
,
&
pReader
->
pBuf
,
&
pReader
->
szBuf
)
<
0
)
{
terrno
=
TSDB_CODE_PAR_TABLE_NOT_EXIST
;
return
-
1
;
return
-
1
;
}
}
...
@@ -91,7 +94,7 @@ SMTbCursor *metaOpenTbCursor(SMeta *pMeta) {
...
@@ -91,7 +94,7 @@ SMTbCursor *metaOpenTbCursor(SMeta *pMeta) {
return
NULL
;
return
NULL
;
}
}
metaReaderInit
(
&
pTbCur
->
mr
,
pMeta
->
pVnode
,
0
);
metaReaderInit
(
&
pTbCur
->
mr
,
pMeta
,
0
);
tdbDbcOpen
(
pMeta
->
pUidIdx
,
&
pTbCur
->
pDbc
);
tdbDbcOpen
(
pMeta
->
pUidIdx
,
&
pTbCur
->
pDbc
);
...
@@ -122,7 +125,7 @@ int metaTbCursorNext(SMTbCursor *pTbCur) {
...
@@ -122,7 +125,7 @@ int metaTbCursorNext(SMTbCursor *pTbCur) {
}
}
metaGetTableEntryByVersion
(
&
pTbCur
->
mr
,
*
(
int64_t
*
)
pTbCur
->
pVal
,
*
(
tb_uid_t
*
)
pTbCur
->
pKey
);
metaGetTableEntryByVersion
(
&
pTbCur
->
mr
,
*
(
int64_t
*
)
pTbCur
->
pVal
,
*
(
tb_uid_t
*
)
pTbCur
->
pKey
);
if
(
pTbCur
->
mr
.
me
.
type
==
META
_SUPER_TABLE
)
{
if
(
pTbCur
->
mr
.
me
.
type
==
TSDB
_SUPER_TABLE
)
{
continue
;
continue
;
}
}
...
@@ -234,7 +237,7 @@ STSchema *metaGetTbTSchema(SMeta *pMeta, tb_uid_t uid, int32_t sver) {
...
@@ -234,7 +237,7 @@ STSchema *metaGetTbTSchema(SMeta *pMeta, tb_uid_t uid, int32_t sver) {
STSchemaBuilder
sb
=
{
0
};
STSchemaBuilder
sb
=
{
0
};
SSchema
*
pSchema
;
SSchema
*
pSchema
;
metaReaderInit
(
&
mr
,
pMeta
->
pVnode
,
0
);
metaReaderInit
(
&
mr
,
pMeta
,
0
);
metaGetTableEntryByUid
(
&
mr
,
uid
);
metaGetTableEntryByUid
(
&
mr
,
uid
);
if
(
mr
.
me
.
type
==
TSDB_CHILD_TABLE
)
{
if
(
mr
.
me
.
type
==
TSDB_CHILD_TABLE
)
{
...
...
source/dnode/vnode/src/meta/metaTable.c
浏览文件 @
a0fcc9a2
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include "
vnodeInt
.h"
#include "
meta
.h"
static
int
metaHandleEntry
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
);
static
int
metaHandleEntry
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
);
static
int
metaSaveToTbDb
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
);
static
int
metaSaveToTbDb
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
);
...
@@ -37,7 +37,7 @@ int metaCreateSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
...
@@ -37,7 +37,7 @@ int metaCreateSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
SMetaReader
mr
=
{
0
};
SMetaReader
mr
=
{
0
};
// validate req
// validate req
metaReaderInit
(
&
mr
,
pMeta
->
pVnode
,
0
);
metaReaderInit
(
&
mr
,
pMeta
,
0
);
if
(
metaGetTableEntryByName
(
&
mr
,
pReq
->
name
)
==
0
)
{
if
(
metaGetTableEntryByName
(
&
mr
,
pReq
->
name
)
==
0
)
{
// TODO: just for pass case
// TODO: just for pass case
#if 0
#if 0
...
@@ -91,7 +91,7 @@ int metaCreateTable(SMeta *pMeta, int64_t version, SVCreateTbReq *pReq) {
...
@@ -91,7 +91,7 @@ int metaCreateTable(SMeta *pMeta, int64_t version, SVCreateTbReq *pReq) {
pReq
->
ctime
=
taosGetTimestampSec
();
pReq
->
ctime
=
taosGetTimestampSec
();
// validate req
// validate req
metaReaderInit
(
&
mr
,
pMeta
->
pVnode
,
0
);
metaReaderInit
(
&
mr
,
pMeta
,
0
);
if
(
metaGetTableEntryByName
(
&
mr
,
pReq
->
name
)
==
0
)
{
if
(
metaGetTableEntryByName
(
&
mr
,
pReq
->
name
)
==
0
)
{
terrno
=
TSDB_CODE_TDB_TABLE_ALREADY_EXIST
;
terrno
=
TSDB_CODE_TDB_TABLE_ALREADY_EXIST
;
metaReaderClear
(
&
mr
);
metaReaderClear
(
&
mr
);
...
...
source/dnode/vnode/src/tq/tq.c
浏览文件 @
a0fcc9a2
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include "
vnodeInt
.h"
#include "
tq
.h"
int32_t
tqInit
()
{
int32_t
tqInit
()
{
//
//
...
@@ -78,7 +78,7 @@ int32_t tqPushMsgNew(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_
...
@@ -78,7 +78,7 @@ int32_t tqPushMsgNew(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_
SMqDataBlkRsp
rsp
=
{
0
};
SMqDataBlkRsp
rsp
=
{
0
};
rsp
.
reqOffset
=
pExec
->
pushHandle
.
reqOffset
;
rsp
.
reqOffset
=
pExec
->
pushHandle
.
reqOffset
;
rsp
.
blockData
=
taosArrayInit
(
0
,
sizeof
(
int32_t
));
rsp
.
blockData
=
taosArrayInit
(
0
,
sizeof
(
void
*
));
rsp
.
blockDataLen
=
taosArrayInit
(
0
,
sizeof
(
int32_t
));
rsp
.
blockDataLen
=
taosArrayInit
(
0
,
sizeof
(
int32_t
));
if
(
pExec
->
subType
==
TOPIC_SUB_TYPE__TABLE
)
{
if
(
pExec
->
subType
==
TOPIC_SUB_TYPE__TABLE
)
{
...
@@ -176,7 +176,7 @@ int32_t tqPushMsgNew(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_
...
@@ -176,7 +176,7 @@ int32_t tqPushMsgNew(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_
atomic_store_ptr
(
&
pExec
->
pushHandle
.
handle
,
NULL
);
atomic_store_ptr
(
&
pExec
->
pushHandle
.
handle
,
NULL
);
taosWUnLockLatch
(
&
pExec
->
pushHandle
.
lock
);
taosWUnLockLatch
(
&
pExec
->
pushHandle
.
lock
);
v
Debug
(
"vg %d offset %ld from consumer %ld (epoch %d) send rsp, block num: %d, reqOffset: %ld, rspOffset: %ld"
,
tq
Debug
(
"vg %d offset %ld from consumer %ld (epoch %d) send rsp, block num: %d, reqOffset: %ld, rspOffset: %ld"
,
TD_VID
(
pTq
->
pVnode
),
fetchOffset
,
pExec
->
pushHandle
.
consumerId
,
pExec
->
pushHandle
.
epoch
,
rsp
.
blockNum
,
TD_VID
(
pTq
->
pVnode
),
fetchOffset
,
pExec
->
pushHandle
.
consumerId
,
pExec
->
pushHandle
.
epoch
,
rsp
.
blockNum
,
rsp
.
reqOffset
,
rsp
.
rspOffset
);
rsp
.
reqOffset
,
rsp
.
rspOffset
);
...
@@ -210,35 +210,6 @@ int tqPushMsg(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t ver)
...
@@ -210,35 +210,6 @@ int tqPushMsg(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t ver)
tmsgPutToQueue
(
&
pTq
->
pVnode
->
msgCb
,
FETCH_QUEUE
,
&
req
);
tmsgPutToQueue
(
&
pTq
->
pVnode
->
msgCb
,
FETCH_QUEUE
,
&
req
);
#if 0
void* pIter = taosHashIterate(pTq->tqPushMgr->pHash, NULL);
while (pIter != NULL) {
STqPusher* pusher = *(STqPusher**)pIter;
if (pusher->type == TQ_PUSHER_TYPE__STREAM) {
STqStreamPusher* streamPusher = (STqStreamPusher*)pusher;
// repack
STqStreamToken* token = taosMemoryMalloc(sizeof(STqStreamToken));
if (token == NULL) {
taosHashCancelIterate(pTq->tqPushMgr->pHash, pIter);
terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1;
}
token->type = TQ_STREAM_TOKEN__DATA;
token->data = msg;
// set input
// exec
}
// send msg to ep
}
// iterate hash
// process all msg
// if waiting
// memcpy and send msg to fetch thread
// TODO: add reference
// if handle waiting, launch query and response to consumer
//
// if no waiting handle, return
#endif
return
0
;
return
0
;
}
}
...
@@ -375,9 +346,9 @@ int32_t tqDeserializeConsumer(STQ* pTq, const STqSerializedHead* pHead, STqConsu
...
@@ -375,9 +346,9 @@ int32_t tqDeserializeConsumer(STQ* pTq, const STqSerializedHead* pHead, STqConsu
}
}
int32_t
tqProcessPollReq
(
STQ
*
pTq
,
SRpcMsg
*
pMsg
,
int32_t
workerId
)
{
int32_t
tqProcessPollReq
(
STQ
*
pTq
,
SRpcMsg
*
pMsg
,
int32_t
workerId
)
{
SMqPollReq
V2
*
pReq
=
pMsg
->
pCont
;
SMqPollReq
*
pReq
=
pMsg
->
pCont
;
int64_t
consumerId
=
pReq
->
consumerId
;
int64_t
consumerId
=
pReq
->
consumerId
;
int64_t
waitTime
=
pReq
->
blocking
Time
;
int64_t
waitTime
=
pReq
->
wait
Time
;
int32_t
reqEpoch
=
pReq
->
epoch
;
int32_t
reqEpoch
=
pReq
->
epoch
;
int64_t
fetchOffset
;
int64_t
fetchOffset
;
...
@@ -390,7 +361,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
...
@@ -390,7 +361,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
fetchOffset
=
pReq
->
currentOffset
+
1
;
fetchOffset
=
pReq
->
currentOffset
+
1
;
}
}
v
Debug
(
"tmq poll: consumer %ld (epoch %d) recv poll req in vg %d, req %ld %ld"
,
consumerId
,
pReq
->
epoch
,
tq
Debug
(
"tmq poll: consumer %ld (epoch %d) recv poll req in vg %d, req %ld %ld"
,
consumerId
,
pReq
->
epoch
,
TD_VID
(
pTq
->
pVnode
),
pReq
->
currentOffset
,
fetchOffset
);
TD_VID
(
pTq
->
pVnode
),
pReq
->
currentOffset
,
fetchOffset
);
STqExec
*
pExec
=
taosHashGet
(
pTq
->
execs
,
pReq
->
subKey
,
strlen
(
pReq
->
subKey
));
STqExec
*
pExec
=
taosHashGet
(
pTq
->
execs
,
pReq
->
subKey
,
strlen
(
pReq
->
subKey
));
...
@@ -418,7 +389,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
...
@@ -418,7 +389,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
while
(
1
)
{
while
(
1
)
{
consumerEpoch
=
atomic_load_32
(
&
pExec
->
epoch
);
consumerEpoch
=
atomic_load_32
(
&
pExec
->
epoch
);
if
(
consumerEpoch
>
reqEpoch
)
{
if
(
consumerEpoch
>
reqEpoch
)
{
v
Debug
(
"tmq poll: consumer %ld (epoch %d) vg %d offset %ld, found new consumer epoch %d discard req epoch %d"
,
tq
Debug
(
"tmq poll: consumer %ld (epoch %d) vg %d offset %ld, found new consumer epoch %d discard req epoch %d"
,
consumerId
,
pReq
->
epoch
,
TD_VID
(
pTq
->
pVnode
),
fetchOffset
,
consumerEpoch
,
reqEpoch
);
consumerId
,
pReq
->
epoch
,
TD_VID
(
pTq
->
pVnode
),
fetchOffset
,
consumerEpoch
,
reqEpoch
);
break
;
break
;
}
}
...
@@ -426,7 +397,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
...
@@ -426,7 +397,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
taosThreadMutexLock
(
&
pExec
->
pWalReader
->
mutex
);
taosThreadMutexLock
(
&
pExec
->
pWalReader
->
mutex
);
if
(
walFetchHead
(
pExec
->
pWalReader
,
fetchOffset
,
pHeadWithCkSum
)
<
0
)
{
if
(
walFetchHead
(
pExec
->
pWalReader
,
fetchOffset
,
pHeadWithCkSum
)
<
0
)
{
v
Debug
(
"tmq poll: consumer %ld (epoch %d) vg %d offset %ld, no more log to return"
,
consumerId
,
pReq
->
epoch
,
tq
Debug
(
"tmq poll: consumer %ld (epoch %d) vg %d offset %ld, no more log to return"
,
consumerId
,
pReq
->
epoch
,
TD_VID
(
pTq
->
pVnode
),
fetchOffset
);
TD_VID
(
pTq
->
pVnode
),
fetchOffset
);
taosThreadMutexUnlock
(
&
pExec
->
pWalReader
->
mutex
);
taosThreadMutexUnlock
(
&
pExec
->
pWalReader
->
mutex
);
break
;
break
;
...
@@ -448,7 +419,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
...
@@ -448,7 +419,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
// TODO: no more log, set timer to wait blocking time
// TODO: no more log, set timer to wait blocking time
// if data inserted during waiting, launch query and
// if data inserted during waiting, launch query and
// response to user
// response to user
v
Debug("tmq poll: consumer %ld (epoch %d) vg %d offset %ld, no more log to return", consumerId, pReq->epoch,
tq
Debug("tmq poll: consumer %ld (epoch %d) vg %d offset %ld, no more log to return", consumerId, pReq->epoch,
TD_VID(pTq->pVnode), fetchOffset);
TD_VID(pTq->pVnode), fetchOffset);
#if 0
#if 0
...
@@ -476,7 +447,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
...
@@ -476,7 +447,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
}
}
#endif
#endif
v
Debug
(
"tmq poll: consumer %ld (epoch %d) iter log, vg %d offset %ld msgType %d"
,
consumerId
,
pReq
->
epoch
,
tq
Debug
(
"tmq poll: consumer %ld (epoch %d) iter log, vg %d offset %ld msgType %d"
,
consumerId
,
pReq
->
epoch
,
TD_VID
(
pTq
->
pVnode
),
fetchOffset
,
pHead
->
msgType
);
TD_VID
(
pTq
->
pVnode
),
fetchOffset
,
pHead
->
msgType
);
if
(
pHead
->
msgType
==
TDMT_VND_SUBMIT
)
{
if
(
pHead
->
msgType
==
TDMT_VND_SUBMIT
)
{
...
@@ -591,7 +562,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
...
@@ -591,7 +562,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
pMsg
->
code
=
0
;
pMsg
->
code
=
0
;
tmsgSendRsp
(
pMsg
);
tmsgSendRsp
(
pMsg
);
v
Debug
(
"vg %d offset %ld from consumer %ld (epoch %d) send rsp, block num: %d, reqOffset: %ld, rspOffset: %ld"
,
tq
Debug
(
"vg %d offset %ld from consumer %ld (epoch %d) send rsp, block num: %d, reqOffset: %ld, rspOffset: %ld"
,
TD_VID
(
pTq
->
pVnode
),
fetchOffset
,
consumerId
,
pReq
->
epoch
,
rsp
.
blockNum
,
rsp
.
reqOffset
,
rsp
.
rspOffset
);
TD_VID
(
pTq
->
pVnode
),
fetchOffset
,
consumerId
,
pReq
->
epoch
,
rsp
.
blockNum
,
rsp
.
reqOffset
,
rsp
.
rspOffset
);
// TODO destroy
// TODO destroy
...
@@ -618,7 +589,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
...
@@ -618,7 +589,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
fetchOffset = pReq->currentOffset + 1;
fetchOffset = pReq->currentOffset + 1;
}
}
v
Debug("tmq poll: consumer %ld (epoch %d) recv poll req in vg %d, req %ld %ld", consumerId, pReq->epoch,
tq
Debug("tmq poll: consumer %ld (epoch %d) recv poll req in vg %d, req %ld %ld", consumerId, pReq->epoch,
TD_VID(pTq->pVnode), pReq->currentOffset, fetchOffset);
TD_VID(pTq->pVnode), pReq->currentOffset, fetchOffset);
SMqPollRspV2 rspV2 = {0};
SMqPollRspV2 rspV2 = {0};
...
@@ -660,7 +631,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
...
@@ -660,7 +631,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
return 0;
return 0;
}
}
v
Debug("poll topic %s from consumer %ld (epoch %d) vg %d", pTopic->topicName, consumerId, pReq->epoch,
tq
Debug("poll topic %s from consumer %ld (epoch %d) vg %d", pTopic->topicName, consumerId, pReq->epoch,
TD_VID(pTq->pVnode));
TD_VID(pTq->pVnode));
rspV2.reqOffset = pReq->currentOffset;
rspV2.reqOffset = pReq->currentOffset;
...
@@ -671,7 +642,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
...
@@ -671,7 +642,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
// TODO
// TODO
consumerEpoch = atomic_load_32(&pConsumer->epoch);
consumerEpoch = atomic_load_32(&pConsumer->epoch);
if (consumerEpoch > reqEpoch) {
if (consumerEpoch > reqEpoch) {
v
Debug("tmq poll: consumer %ld (epoch %d) vg %d offset %ld, found new consumer epoch %d discard req epoch %d",
tq
Debug("tmq poll: consumer %ld (epoch %d) vg %d offset %ld, found new consumer epoch %d discard req epoch %d",
consumerId, pReq->epoch, TD_VID(pTq->pVnode), fetchOffset, consumerEpoch, reqEpoch);
consumerId, pReq->epoch, TD_VID(pTq->pVnode), fetchOffset, consumerEpoch, reqEpoch);
break;
break;
}
}
...
@@ -680,11 +651,11 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
...
@@ -680,11 +651,11 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
// TODO: no more log, set timer to wait blocking time
// TODO: no more log, set timer to wait blocking time
// if data inserted during waiting, launch query and
// if data inserted during waiting, launch query and
// response to user
// response to user
v
Debug("tmq poll: consumer %ld (epoch %d) vg %d offset %ld, no more log to return", consumerId, pReq->epoch,
tq
Debug("tmq poll: consumer %ld (epoch %d) vg %d offset %ld, no more log to return", consumerId, pReq->epoch,
TD_VID(pTq->pVnode), fetchOffset);
TD_VID(pTq->pVnode), fetchOffset);
break;
break;
}
}
v
Debug("tmq poll: consumer %ld (epoch %d) iter log, vg %d offset %ld msgType %d", consumerId, pReq->epoch,
tq
Debug("tmq poll: consumer %ld (epoch %d) iter log, vg %d offset %ld msgType %d", consumerId, pReq->epoch,
TD_VID(pTq->pVnode), fetchOffset, pHead->msgType);
TD_VID(pTq->pVnode), fetchOffset, pHead->msgType);
/*int8_t pos = fetchOffset % TQ_BUFFER_SIZE;*/
/*int8_t pos = fetchOffset % TQ_BUFFER_SIZE;*/
/*pHead = pTopic->pReadhandle->pHead;*/
/*pHead = pTopic->pReadhandle->pHead;*/
...
@@ -709,7 +680,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
...
@@ -709,7 +680,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
}
}
if (taosArrayGetSize(pRes) == 0) {
if (taosArrayGetSize(pRes) == 0) {
v
Debug("tmq poll: consumer %ld (epoch %d) iter log, vg %d skip log %ld since not wanted", consumerId,
tq
Debug("tmq poll: consumer %ld (epoch %d) iter log, vg %d skip log %ld since not wanted", consumerId,
pReq->epoch, TD_VID(pTq->pVnode), fetchOffset);
pReq->epoch, TD_VID(pTq->pVnode), fetchOffset);
fetchOffset++;
fetchOffset++;
rspV2.skipLogNum++;
rspV2.skipLogNum++;
...
@@ -770,7 +741,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
...
@@ -770,7 +741,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
pMsg->pCont = buf;
pMsg->pCont = buf;
pMsg->contLen = msgLen;
pMsg->contLen = msgLen;
pMsg->code = 0;
pMsg->code = 0;
v
Debug("vg %d offset %ld msgType %d from consumer %ld (epoch %d) actual rsp", TD_VID(pTq->pVnode), fetchOffset,
tq
Debug("vg %d offset %ld msgType %d from consumer %ld (epoch %d) actual rsp", TD_VID(pTq->pVnode), fetchOffset,
pHead->msgType, consumerId, pReq->epoch);
pHead->msgType, consumerId, pReq->epoch);
tmsgSendRsp(pMsg);
tmsgSendRsp(pMsg);
taosMemoryFree(pHead);
taosMemoryFree(pHead);
...
@@ -804,7 +775,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
...
@@ -804,7 +775,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
pMsg->contLen = tlen;
pMsg->contLen = tlen;
pMsg->code = 0;
pMsg->code = 0;
tmsgSendRsp(pMsg);
tmsgSendRsp(pMsg);
v
Debug("vg %d offset %ld from consumer %ld (epoch %d) not rsp", TD_VID(pTq->pVnode), fetchOffset, consumerId,
tq
Debug("vg %d offset %ld from consumer %ld (epoch %d) not rsp", TD_VID(pTq->pVnode), fetchOffset, consumerId,
pReq->epoch);
pReq->epoch);
/*}*/
/*}*/
...
...
source/dnode/vnode/src/tq/tqCommit.c
浏览文件 @
a0fcc9a2
...
@@ -13,4 +13,4 @@
...
@@ -13,4 +13,4 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include "
vnodeInt
.h"
#include "
tq
.h"
source/dnode/vnode/src/tq/tqMetaStore.c
浏览文件 @
a0fcc9a2
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
* You should have received a copy of the GNU Affero General Public License
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include "
vnodeInt
.h"
#include "
tq
.h"
// #include <fcntl.h>
// #include <fcntl.h>
// #include <string.h>
// #include <string.h>
// #include <unistd.h>
// #include <unistd.h>
...
@@ -86,7 +86,7 @@ STqMetaStore* tqStoreOpen(STQ* pTq, const char* path, FTqSerialize serializer, F
...
@@ -86,7 +86,7 @@ STqMetaStore* tqStoreOpen(STQ* pTq, const char* path, FTqSerialize serializer, F
}
}
strcpy
(
pMeta
->
dirPath
,
path
);
strcpy
(
pMeta
->
dirPath
,
path
);
char
*
name
=
taosMemoryMalloc
(
pathLen
+
10
)
;
char
*
name
=
taosMemoryMalloc
(
pathLen
+
10
)
;
strcpy
(
name
,
path
);
strcpy
(
name
,
path
);
if
(
!
taosDirExist
(
name
)
&&
taosMkDir
(
name
)
!=
0
)
{
if
(
!
taosDirExist
(
name
)
&&
taosMkDir
(
name
)
!=
0
)
{
...
...
source/dnode/vnode/src/tq/tqOffset.c
浏览文件 @
a0fcc9a2
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
*/
*/
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include "
vnodeInt
.h"
#include "
tq
.h"
enum
ETqOffsetPersist
{
enum
ETqOffsetPersist
{
TQ_OFFSET_PERSIST__LAZY
=
1
,
TQ_OFFSET_PERSIST__LAZY
=
1
,
...
...
source/dnode/vnode/src/tq/tqRead.c
浏览文件 @
a0fcc9a2
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include "
vnodeInt
.h"
#include "
tq
.h"
STqReadHandle
*
tqInitSubmitMsgScanner
(
SMeta
*
pMeta
)
{
STqReadHandle
*
tqInitSubmitMsgScanner
(
SMeta
*
pMeta
)
{
STqReadHandle
*
pReadHandle
=
taosMemoryMalloc
(
sizeof
(
STqReadHandle
));
STqReadHandle
*
pReadHandle
=
taosMemoryMalloc
(
sizeof
(
STqReadHandle
));
...
...
source/dnode/vnode/src/tsdb/tsdbCommit.c
浏览文件 @
a0fcc9a2
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include "
vnodeInt
.h"
#include "
tsdb
.h"
#define TSDB_MAX_SUBBLOCKS 8
#define TSDB_MAX_SUBBLOCKS 8
...
...
source/dnode/vnode/src/tsdb/tsdbCommit2.c
浏览文件 @
a0fcc9a2
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include "
vnodeInt
.h"
#include "
tsdb
.h"
int
tsdbBegin
(
STsdb
*
pTsdb
)
{
int
tsdbBegin
(
STsdb
*
pTsdb
)
{
STsdbMemTable
*
pMem
;
STsdbMemTable
*
pMem
;
...
...
source/dnode/vnode/src/tsdb/tsdbCompact.c
浏览文件 @
a0fcc9a2
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#if 0
#if 0
#include "tsdb
int
.h"
#include "tsdb.h"
typedef struct {
typedef struct {
STable * pTable;
STable * pTable;
...
@@ -531,4 +531,3 @@ static int tsdbCompactMeta(STsdbRepo *pRepo) {
...
@@ -531,4 +531,3 @@ static int tsdbCompactMeta(STsdbRepo *pRepo) {
}
}
#endif
#endif
source/dnode/vnode/src/tsdb/tsdbFS.c
浏览文件 @
a0fcc9a2
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include "
vnodeInt
.h"
#include "
tsdb
.h"
typedef
enum
{
TSDB_TXN_TEMP_FILE
=
0
,
TSDB_TXN_CURR_FILE
}
TSDB_TXN_FILE_T
;
typedef
enum
{
TSDB_TXN_TEMP_FILE
=
0
,
TSDB_TXN_CURR_FILE
}
TSDB_TXN_FILE_T
;
static
const
char
*
tsdbTxnFname
[]
=
{
"current.t"
,
"current"
};
static
const
char
*
tsdbTxnFname
[]
=
{
"current.t"
,
"current"
};
...
...
source/dnode/vnode/src/tsdb/tsdbFile.c
浏览文件 @
a0fcc9a2
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include "
vnodeInt
.h"
#include "
tsdb
.h"
static
const
char
*
TSDB_FNAME_SUFFIX
[]
=
{
static
const
char
*
TSDB_FNAME_SUFFIX
[]
=
{
"head"
,
// TSDB_FILE_HEAD
"head"
,
// TSDB_FILE_HEAD
...
...
source/dnode/vnode/src/tsdb/tsdbMain.c
浏览文件 @
a0fcc9a2
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include "
vnodeInt
.h"
#include "
tsdb
.h"
int
tsdbOpen
(
SVnode
*
pVnode
,
STsdb
**
ppTsdb
)
{
int
tsdbOpen
(
SVnode
*
pVnode
,
STsdb
**
ppTsdb
)
{
STsdb
*
pTsdb
=
NULL
;
STsdb
*
pTsdb
=
NULL
;
...
...
source/dnode/vnode/src/tsdb/tsdbMemTable.c
浏览文件 @
a0fcc9a2
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include "
vnodeInt
.h"
#include "
tsdb
.h"
static
STbData
*
tsdbNewTbData
(
tb_uid_t
uid
);
static
STbData
*
tsdbNewTbData
(
tb_uid_t
uid
);
static
void
tsdbFreeTbData
(
STbData
*
pTbData
);
static
void
tsdbFreeTbData
(
STbData
*
pTbData
);
...
...
source/dnode/vnode/src/tsdb/tsdbOptions.c
已删除
100644 → 0
浏览文件 @
ccffe945
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "vnodeInt.h"
const
STsdbCfg
defautlTsdbOptions
=
{.
precision
=
0
,
.
lruCacheSize
=
0
,
.
days
=
10
,
.
minRows
=
100
,
.
maxRows
=
4096
,
.
keep2
=
3650
,
.
keep0
=
3650
,
.
keep1
=
3650
,
.
update
=
0
,
.
compression
=
TWO_STAGE_COMP
};
int
tsdbValidateOptions
(
const
STsdbCfg
*
pTsdbOptions
)
{
// TODO
return
0
;
}
void
tsdbOptionsCopy
(
STsdbCfg
*
pDest
,
const
STsdbCfg
*
pSrc
)
{
memcpy
(
pDest
,
pSrc
,
sizeof
(
STsdbCfg
));
}
\ No newline at end of file
source/dnode/vnode/src/tsdb/tsdbRead.c
浏览文件 @
a0fcc9a2
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include "
vnodeInt
.h"
#include "
tsdb
.h"
#define EXTRA_BYTES 2
#define EXTRA_BYTES 2
#define ASCENDING_TRAVERSE(o) (o == TSDB_ORDER_ASC)
#define ASCENDING_TRAVERSE(o) (o == TSDB_ORDER_ASC)
...
@@ -3618,7 +3618,7 @@ int32_t tsdbQuerySTableByTagCond(void* pMeta, uint64_t uid, TSKEY skey, const ch
...
@@ -3618,7 +3618,7 @@ int32_t tsdbQuerySTableByTagCond(void* pMeta, uint64_t uid, TSKEY skey, const ch
SColIndex
*
pColIndex
,
int32_t
numOfCols
,
uint64_t
reqId
,
uint64_t
taskId
)
{
SColIndex
*
pColIndex
,
int32_t
numOfCols
,
uint64_t
reqId
,
uint64_t
taskId
)
{
SMetaReader
mr
=
{
0
};
SMetaReader
mr
=
{
0
};
metaReaderInit
(
&
mr
,
(
(
SMeta
*
)
pMeta
)
->
pVnode
,
0
);
metaReaderInit
(
&
mr
,
(
SMeta
*
)
pMeta
,
0
);
if
(
metaGetTableEntryByUid
(
&
mr
,
uid
)
<
0
)
{
if
(
metaGetTableEntryByUid
(
&
mr
,
uid
)
<
0
)
{
tsdbError
(
"%p failed to get stable, uid:%"
PRIu64
", TID:0x%"
PRIx64
" QID:0x%"
PRIx64
,
pMeta
,
uid
,
taskId
,
reqId
);
tsdbError
(
"%p failed to get stable, uid:%"
PRIu64
", TID:0x%"
PRIx64
" QID:0x%"
PRIx64
,
pMeta
,
uid
,
taskId
,
reqId
);
...
@@ -3628,7 +3628,7 @@ int32_t tsdbQuerySTableByTagCond(void* pMeta, uint64_t uid, TSKEY skey, const ch
...
@@ -3628,7 +3628,7 @@ int32_t tsdbQuerySTableByTagCond(void* pMeta, uint64_t uid, TSKEY skey, const ch
tsdbDebug
(
"%p succeed to get stable, uid:%"
PRIu64
", TID:0x%"
PRIx64
" QID:0x%"
PRIx64
,
pMeta
,
uid
,
taskId
,
reqId
);
tsdbDebug
(
"%p succeed to get stable, uid:%"
PRIu64
", TID:0x%"
PRIx64
" QID:0x%"
PRIx64
,
pMeta
,
uid
,
taskId
,
reqId
);
}
}
if
(
mr
.
me
.
type
!=
META
_SUPER_TABLE
)
{
if
(
mr
.
me
.
type
!=
TSDB
_SUPER_TABLE
)
{
tsdbError
(
"%p query normal tag not allowed, uid:%"
PRIu64
", TID:0x%"
PRIx64
" QID:0x%"
PRIx64
,
pMeta
,
uid
,
taskId
,
tsdbError
(
"%p query normal tag not allowed, uid:%"
PRIu64
", TID:0x%"
PRIx64
" QID:0x%"
PRIx64
,
pMeta
,
uid
,
taskId
,
reqId
);
reqId
);
terrno
=
TSDB_CODE_OPS_NOT_SUPPORT
;
// basically, this error is caused by invalid sql issued by client
terrno
=
TSDB_CODE_OPS_NOT_SUPPORT
;
// basically, this error is caused by invalid sql issued by client
...
@@ -3687,10 +3687,9 @@ int32_t tsdbQueryTableList(void* pMeta, SArray* pRes, void* filterInfo) {
...
@@ -3687,10 +3687,9 @@ int32_t tsdbQueryTableList(void* pMeta, SArray* pRes, void* filterInfo) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
tsdbGetOneTableGroup
(
void
*
pMeta
,
uint64_t
uid
,
TSKEY
startKey
,
STableGroupInfo
*
pGroupInfo
)
{
int32_t
tsdbGetOneTableGroup
(
void
*
pMeta
,
uint64_t
uid
,
TSKEY
startKey
,
STableGroupInfo
*
pGroupInfo
)
{
SMeta
*
metaP
=
(
SMeta
*
)
pMeta
;
SMetaReader
mr
=
{
0
};
SMetaReader
mr
=
{
0
};
metaReaderInit
(
&
mr
,
metaP
->
pVnode
,
0
);
metaReaderInit
(
&
mr
,
(
SMeta
*
)
pMeta
,
0
);
if
(
metaGetTableEntryByUid
(
&
mr
,
uid
)
<
0
)
{
if
(
metaGetTableEntryByUid
(
&
mr
,
uid
)
<
0
)
{
terrno
=
TSDB_CODE_TDB_INVALID_TABLE_ID
;
terrno
=
TSDB_CODE_TDB_INVALID_TABLE_ID
;
...
...
source/dnode/vnode/src/tsdb/tsdbReadImpl.c
浏览文件 @
a0fcc9a2
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include "
vnodeInt
.h"
#include "
tsdb
.h"
#define TSDB_KEY_COL_OFFSET 0
#define TSDB_KEY_COL_OFFSET 0
...
...
source/dnode/vnode/src/tsdb/tsdbScan.c
浏览文件 @
a0fcc9a2
...
@@ -13,9 +13,8 @@
...
@@ -13,9 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#if 0
#if 0
#include "tsdb
int
.h"
#include "tsdb.h"
#ifndef _TSDB_PLUGINS
#ifndef _TSDB_PLUGINS
int tsdbScanFGroup(STsdbScanHandle* pScanHandle, char* rootDir, int fid) { return 0; }
int tsdbScanFGroup(STsdbScanHandle* pScanHandle, char* rootDir, int fid) { return 0; }
...
...
source/dnode/vnode/src/tsdb/tsdbSma.c
浏览文件 @
a0fcc9a2
...
@@ -13,7 +13,8 @@
...
@@ -13,7 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include "vnodeInt.h"
#include "tsdbSma.h"
#include "tsdb.h"
static
const
char
*
TSDB_SMA_DNAME
[]
=
{
static
const
char
*
TSDB_SMA_DNAME
[]
=
{
""
,
// TSDB_SMA_TYPE_BLOCK
""
,
// TSDB_SMA_TYPE_BLOCK
...
@@ -678,7 +679,6 @@ int32_t tsdbUpdateExpiredWindowImpl(STsdb *pTsdb, SSubmitReq *pMsg, int64_t vers
...
@@ -678,7 +679,6 @@ int32_t tsdbUpdateExpiredWindowImpl(STsdb *pTsdb, SSubmitReq *pMsg, int64_t vers
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
if
(
tsdbCheckAndInitSmaEnv
(
pTsdb
,
TSDB_SMA_TYPE_TIME_RANGE
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
tsdbCheckAndInitSmaEnv
(
pTsdb
,
TSDB_SMA_TYPE_TIME_RANGE
)
!=
TSDB_CODE_SUCCESS
)
{
terrno
=
TSDB_CODE_TDB_INIT_FAILED
;
terrno
=
TSDB_CODE_TDB_INIT_FAILED
;
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
...
...
source/dnode/vnode/src/tsdb/tsdbTDBImpl.c
浏览文件 @
a0fcc9a2
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
#define ALLOW_FORBID_FUNC
#define ALLOW_FORBID_FUNC
#include "
vnodeInt
.h"
#include "
tsdb
.h"
int32_t
tsdbOpenDBEnv
(
TENV
**
ppEnv
,
const
char
*
path
)
{
int32_t
tsdbOpenDBEnv
(
TENV
**
ppEnv
,
const
char
*
path
)
{
int
ret
=
0
;
int
ret
=
0
;
...
...
source/dnode/vnode/src/tsdb/tsdbWrite.c
浏览文件 @
a0fcc9a2
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include "
vnodeInt
.h"
#include "
tsdb
.h"
static
int
tsdbScanAndConvertSubmitMsg
(
STsdb
*
pTsdb
,
SSubmitReq
*
pMsg
);
static
int
tsdbScanAndConvertSubmitMsg
(
STsdb
*
pTsdb
,
SSubmitReq
*
pMsg
);
...
...
source/dnode/vnode/src/vnd/vnodeBufPool.c
浏览文件 @
a0fcc9a2
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include "vn
odeInt
.h"
#include "vn
d
.h"
/* ------------------------ STRUCTURES ------------------------ */
/* ------------------------ STRUCTURES ------------------------ */
...
...
source/dnode/vnode/src/vnd/vnodeCfg.c
浏览文件 @
a0fcc9a2
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include "vn
odeInt
.h"
#include "vn
d
.h"
const
SVnodeCfg
vnodeCfgDefault
=
{
const
SVnodeCfg
vnodeCfgDefault
=
{
.
vgId
=
-
1
,
.
vgId
=
-
1
,
...
...
source/dnode/vnode/src/vnd/vnodeCommit.c
浏览文件 @
a0fcc9a2
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include "vn
odeInt
.h"
#include "vn
d
.h"
#define VND_INFO_FNAME "vnode.json"
#define VND_INFO_FNAME "vnode.json"
#define VND_INFO_FNAME_TMP "vnode_tmp.json"
#define VND_INFO_FNAME_TMP "vnode_tmp.json"
...
@@ -175,7 +175,7 @@ int vnodeAsyncCommit(SVnode *pVnode) {
...
@@ -175,7 +175,7 @@ int vnodeAsyncCommit(SVnode *pVnode) {
vnodeWaitCommit
(
pVnode
);
vnodeWaitCommit
(
pVnode
);
// vnodeBufPoolSwitch(pVnode);
// vnodeBufPoolSwitch(pVnode);
tsdbPrepareCommit
(
pVnode
->
pTsdb
);
//
tsdbPrepareCommit(pVnode->pTsdb);
vnodeScheduleTask
(
vnodeCommitImpl
,
pVnode
);
vnodeScheduleTask
(
vnodeCommitImpl
,
pVnode
);
...
...
source/dnode/vnode/src/vnd/vnodeInt.c
浏览文件 @
a0fcc9a2
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
*/
*/
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include "vn
odeInt
.h"
#include "vn
d
.h"
// #include "vnodeInt.h"
// #include "vnodeInt.h"
int32_t
vnodeAlter
(
SVnode
*
pVnode
,
const
SVnodeCfg
*
pCfg
)
{
return
0
;
}
int32_t
vnodeAlter
(
SVnode
*
pVnode
,
const
SVnodeCfg
*
pCfg
)
{
return
0
;
}
...
...
source/dnode/vnode/src/vnd/vnodeModule.c
浏览文件 @
a0fcc9a2
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include "vn
odeInt
.h"
#include "vn
d
.h"
typedef
struct
SVnodeTask
SVnodeTask
;
typedef
struct
SVnodeTask
SVnodeTask
;
struct
SVnodeTask
{
struct
SVnodeTask
{
...
...
source/dnode/vnode/src/vnd/vnodeOpen.c
浏览文件 @
a0fcc9a2
...
@@ -13,8 +13,7 @@
...
@@ -13,8 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include "vnodeInt.h"
#include "vnd.h"
#include "vnodeSync.h"
int
vnodeCreate
(
const
char
*
path
,
SVnodeCfg
*
pCfg
,
STfs
*
pTfs
)
{
int
vnodeCreate
(
const
char
*
path
,
SVnodeCfg
*
pCfg
,
STfs
*
pTfs
)
{
SVnodeInfo
info
=
{
0
};
SVnodeInfo
info
=
{
0
};
...
...
source/dnode/vnode/src/vnd/vnodeQuery.c
浏览文件 @
a0fcc9a2
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include "vn
odeInt
.h"
#include "vn
d
.h"
int
vnodeQueryOpen
(
SVnode
*
pVnode
)
{
int
vnodeQueryOpen
(
SVnode
*
pVnode
)
{
return
qWorkerInit
(
NODE_TYPE_VNODE
,
TD_VID
(
pVnode
),
NULL
,
(
void
**
)
&
pVnode
->
pQuery
,
&
pVnode
->
msgCb
);
return
qWorkerInit
(
NODE_TYPE_VNODE
,
TD_VID
(
pVnode
),
NULL
,
(
void
**
)
&
pVnode
->
pQuery
,
&
pVnode
->
msgCb
);
...
@@ -51,9 +51,10 @@ int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg) {
...
@@ -51,9 +51,10 @@ int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg) {
}
}
// query meta
// query meta
metaReaderInit
(
&
mer1
,
pVnode
,
0
);
metaReaderInit
(
&
mer1
,
pVnode
->
pMeta
,
0
);
if
(
metaGetTableEntryByName
(
&
mer1
,
infoReq
.
tbName
)
<
0
)
{
if
(
metaGetTableEntryByName
(
&
mer1
,
infoReq
.
tbName
)
<
0
)
{
code
=
terrno
;
goto
_exit
;
goto
_exit
;
}
}
...
@@ -67,7 +68,7 @@ int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg) {
...
@@ -67,7 +68,7 @@ int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg) {
schemaTag
=
mer1
.
me
.
stbEntry
.
schemaTag
;
schemaTag
=
mer1
.
me
.
stbEntry
.
schemaTag
;
metaRsp
.
suid
=
mer1
.
me
.
uid
;
metaRsp
.
suid
=
mer1
.
me
.
uid
;
}
else
if
(
mer1
.
me
.
type
==
TSDB_CHILD_TABLE
)
{
}
else
if
(
mer1
.
me
.
type
==
TSDB_CHILD_TABLE
)
{
metaReaderInit
(
&
mer2
,
pVnode
,
0
);
metaReaderInit
(
&
mer2
,
pVnode
->
pMeta
,
0
);
if
(
metaGetTableEntryByUid
(
&
mer2
,
mer1
.
me
.
ctbEntry
.
suid
)
<
0
)
goto
_exit
;
if
(
metaGetTableEntryByUid
(
&
mer2
,
mer1
.
me
.
ctbEntry
.
suid
)
<
0
)
goto
_exit
;
strcpy
(
metaRsp
.
stbName
,
mer2
.
me
.
name
);
strcpy
(
metaRsp
.
stbName
,
mer2
.
me
.
name
);
...
@@ -105,6 +106,7 @@ int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg) {
...
@@ -105,6 +106,7 @@ int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg) {
}
}
tSerializeSTableMetaRsp
(
pRsp
,
rspLen
,
&
metaRsp
);
tSerializeSTableMetaRsp
(
pRsp
,
rspLen
,
&
metaRsp
);
_exit:
rpcMsg
.
handle
=
pMsg
->
handle
;
rpcMsg
.
handle
=
pMsg
->
handle
;
rpcMsg
.
ahandle
=
pMsg
->
ahandle
;
rpcMsg
.
ahandle
=
pMsg
->
ahandle
;
rpcMsg
.
refId
=
pMsg
->
refId
;
rpcMsg
.
refId
=
pMsg
->
refId
;
...
@@ -114,7 +116,6 @@ int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg) {
...
@@ -114,7 +116,6 @@ int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg) {
tmsgSendRsp
(
&
rpcMsg
);
tmsgSendRsp
(
&
rpcMsg
);
_exit:
taosMemoryFree
(
metaRsp
.
pSchemas
);
taosMemoryFree
(
metaRsp
.
pSchemas
);
metaReaderClear
(
&
mer2
);
metaReaderClear
(
&
mer2
);
metaReaderClear
(
&
mer1
);
metaReaderClear
(
&
mer1
);
...
@@ -123,7 +124,7 @@ _exit:
...
@@ -123,7 +124,7 @@ _exit:
int32_t
vnodeGetLoad
(
SVnode
*
pVnode
,
SVnodeLoad
*
pLoad
)
{
int32_t
vnodeGetLoad
(
SVnode
*
pVnode
,
SVnodeLoad
*
pLoad
)
{
pLoad
->
vgId
=
TD_VID
(
pVnode
);
pLoad
->
vgId
=
TD_VID
(
pVnode
);
//pLoad->syncState = TAOS_SYNC_STATE_LEADER;
//
pLoad->syncState = TAOS_SYNC_STATE_LEADER;
pLoad
->
syncState
=
syncGetMyRole
(
pVnode
->
sync
);
// sync integration
pLoad
->
syncState
=
syncGetMyRole
(
pVnode
->
sync
);
// sync integration
pLoad
->
numOfTables
=
metaGetTbNum
(
pVnode
->
pMeta
);
pLoad
->
numOfTables
=
metaGetTbNum
(
pVnode
->
pMeta
);
pLoad
->
numOfTimeSeries
=
400
;
pLoad
->
numOfTimeSeries
=
400
;
...
...
source/dnode/vnode/src/vnd/vnodeSvr.c
浏览文件 @
a0fcc9a2
...
@@ -13,9 +13,7 @@
...
@@ -13,9 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include "sync.h"
#include "vnd.h"
#include "syncTools.h"
#include "vnodeInt.h"
static
int
vnodeProcessCreateStbReq
(
SVnode
*
pVnode
,
int64_t
version
,
void
*
pReq
,
int
len
,
SRpcMsg
*
pRsp
);
static
int
vnodeProcessCreateStbReq
(
SVnode
*
pVnode
,
int64_t
version
,
void
*
pReq
,
int
len
,
SRpcMsg
*
pRsp
);
static
int
vnodeProcessAlterStbReq
(
SVnode
*
pVnode
,
void
*
pReq
,
int32_t
len
,
SRpcMsg
*
pRsp
);
static
int
vnodeProcessAlterStbReq
(
SVnode
*
pVnode
,
void
*
pReq
,
int32_t
len
,
SRpcMsg
*
pRsp
);
...
@@ -201,9 +199,7 @@ void smaHandleRes(void *pVnode, int64_t smaId, const SArray *data) {
...
@@ -201,9 +199,7 @@ void smaHandleRes(void *pVnode, int64_t smaId, const SArray *data) {
// sync integration
// sync integration
int
vnodeProcessSyncReq
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
SRpcMsg
**
pRsp
)
{
int
vnodeProcessSyncReq
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
SRpcMsg
**
pRsp
)
{
if
(
syncEnvIsStart
())
{
if
(
syncEnvIsStart
())
{
SSyncNode
*
pSyncNode
=
syncNodeAcquire
(
pVnode
->
sync
);
SSyncNode
*
pSyncNode
=
syncNodeAcquire
(
pVnode
->
sync
);
assert
(
pSyncNode
!=
NULL
);
assert
(
pSyncNode
!=
NULL
);
...
...
source/dnode/vnode/src/vnd/vnodeSync.c
浏览文件 @
a0fcc9a2
...
@@ -13,10 +13,11 @@
...
@@ -13,10 +13,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include "sync.h"
#include "vnd.h"
#include "syncTools.h"
// #include "sync.h"
#include "tmsgcb.h"
// #include "syncTools.h"
#include "vnodeInt.h"
// #include "tmsgcb.h"
// #include "vnodeInt.h"
// sync integration
// sync integration
...
@@ -113,7 +114,7 @@ void vnodeSyncCommitCb(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cb
...
@@ -113,7 +114,7 @@ void vnodeSyncCommitCb(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cb
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
syncUtilState2String
(
cbMeta
.
state
),
beginIndex
);
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
syncUtilState2String
(
cbMeta
.
state
),
beginIndex
);
syncRpcMsgLog2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
syncRpcMsgLog2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
SVnode
*
pVnode
=
(
SVnode
*
)(
pFsm
->
data
);
SVnode
*
pVnode
=
(
SVnode
*
)(
pFsm
->
data
);
SyncApplyMsg
*
pSyncApplyMsg
=
syncApplyMsgBuild2
(
pMsg
,
pVnode
->
config
.
vgId
,
&
cbMeta
);
SyncApplyMsg
*
pSyncApplyMsg
=
syncApplyMsgBuild2
(
pMsg
,
pVnode
->
config
.
vgId
,
&
cbMeta
);
SRpcMsg
applyMsg
;
SRpcMsg
applyMsg
;
syncApplyMsg2RpcMsg
(
pSyncApplyMsg
,
&
applyMsg
);
syncApplyMsg2RpcMsg
(
pSyncApplyMsg
,
&
applyMsg
);
...
...
source/libs/function/inc/functionMgtInt.h
浏览文件 @
a0fcc9a2
...
@@ -38,6 +38,7 @@ extern "C" {
...
@@ -38,6 +38,7 @@ extern "C" {
#define FUNC_MGT_SPECIAL_DATA_REQUIRED FUNC_MGT_FUNC_CLASSIFICATION_MASK(9)
#define FUNC_MGT_SPECIAL_DATA_REQUIRED FUNC_MGT_FUNC_CLASSIFICATION_MASK(9)
#define FUNC_MGT_DYNAMIC_SCAN_OPTIMIZED FUNC_MGT_FUNC_CLASSIFICATION_MASK(10)
#define FUNC_MGT_DYNAMIC_SCAN_OPTIMIZED FUNC_MGT_FUNC_CLASSIFICATION_MASK(10)
#define FUNC_MGT_MULTI_RES_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(11)
#define FUNC_MGT_MULTI_RES_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(11)
#define FUNC_MGT_SCAN_PC_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(12)
#define FUNC_MGT_TEST_MASK(val, mask) (((val) & (mask)) != 0)
#define FUNC_MGT_TEST_MASK(val, mask) (((val) & (mask)) != 0)
...
...
source/libs/function/src/builtins.c
浏览文件 @
a0fcc9a2
...
@@ -807,7 +807,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
...
@@ -807,7 +807,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.
finalizeFunc
=
NULL
},
.
finalizeFunc
=
NULL
},
{.
name
=
"tbname"
,
{.
name
=
"tbname"
,
.
type
=
FUNCTION_TYPE_TBNAME
,
.
type
=
FUNCTION_TYPE_TBNAME
,
.
classification
=
FUNC_MGT_PSEUDO_COLUMN_FUNC
,
.
classification
=
FUNC_MGT_PSEUDO_COLUMN_FUNC
|
FUNC_MGT_SCAN_PC_FUNC
,
.
translateFunc
=
translateTbnameColumn
,
.
translateFunc
=
translateTbnameColumn
,
.
getEnvFunc
=
NULL
,
.
getEnvFunc
=
NULL
,
.
initFunc
=
NULL
,
.
initFunc
=
NULL
,
...
...
source/libs/function/src/functionMgt.c
浏览文件 @
a0fcc9a2
...
@@ -15,12 +15,12 @@
...
@@ -15,12 +15,12 @@
#include "functionMgt.h"
#include "functionMgt.h"
#include "builtins.h"
#include "catalog.h"
#include "functionMgtInt.h"
#include "functionMgtInt.h"
#include "taos.h"
#include "taos.h"
#include "taoserror.h"
#include "taoserror.h"
#include "thash.h"
#include "thash.h"
#include "builtins.h"
#include "catalog.h"
typedef
struct
SFuncMgtService
{
typedef
struct
SFuncMgtService
{
SHashObj
*
pFuncNameHashTable
;
SHashObj
*
pFuncNameHashTable
;
...
@@ -36,14 +36,16 @@ static TdThreadOnce functionHashTableInit = PTHREAD_ONCE_INIT;
...
@@ -36,14 +36,16 @@ static TdThreadOnce functionHashTableInit = PTHREAD_ONCE_INIT;
static
int32_t
initFunctionCode
=
0
;
static
int32_t
initFunctionCode
=
0
;
static
void
doInitFunctionTable
()
{
static
void
doInitFunctionTable
()
{
gFunMgtService
.
pFuncNameHashTable
=
taosHashInit
(
funcMgtBuiltinsNum
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_NO_LOCK
);
gFunMgtService
.
pFuncNameHashTable
=
taosHashInit
(
funcMgtBuiltinsNum
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_NO_LOCK
);
if
(
NULL
==
gFunMgtService
.
pFuncNameHashTable
)
{
if
(
NULL
==
gFunMgtService
.
pFuncNameHashTable
)
{
initFunctionCode
=
TSDB_CODE_FAILED
;
initFunctionCode
=
TSDB_CODE_FAILED
;
return
;
return
;
}
}
for
(
int32_t
i
=
0
;
i
<
funcMgtBuiltinsNum
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
funcMgtBuiltinsNum
;
++
i
)
{
if
(
TSDB_CODE_SUCCESS
!=
taosHashPut
(
gFunMgtService
.
pFuncNameHashTable
,
funcMgtBuiltins
[
i
].
name
,
strlen
(
funcMgtBuiltins
[
i
].
name
),
&
i
,
sizeof
(
int32_t
)))
{
if
(
TSDB_CODE_SUCCESS
!=
taosHashPut
(
gFunMgtService
.
pFuncNameHashTable
,
funcMgtBuiltins
[
i
].
name
,
strlen
(
funcMgtBuiltins
[
i
].
name
),
&
i
,
sizeof
(
int32_t
)))
{
initFunctionCode
=
TSDB_CODE_FAILED
;
initFunctionCode
=
TSDB_CODE_FAILED
;
return
;
return
;
}
}
...
@@ -52,8 +54,9 @@ static void doInitFunctionTable() {
...
@@ -52,8 +54,9 @@ static void doInitFunctionTable() {
static
bool
isSpecificClassifyFunc
(
int32_t
funcId
,
uint64_t
classification
)
{
static
bool
isSpecificClassifyFunc
(
int32_t
funcId
,
uint64_t
classification
)
{
if
(
fmIsUserDefinedFunc
(
funcId
))
{
if
(
fmIsUserDefinedFunc
(
funcId
))
{
return
FUNC_MGT_AGG_FUNC
==
classification
?
FUNC_AGGREGATE_UDF_ID
==
funcId
:
return
FUNC_MGT_AGG_FUNC
==
classification
(
FUNC_MGT_SCALAR_FUNC
==
classification
?
FUNC_SCALAR_UDF_ID
==
funcId
:
false
);
?
FUNC_AGGREGATE_UDF_ID
==
funcId
:
(
FUNC_MGT_SCALAR_FUNC
==
classification
?
FUNC_SCALAR_UDF_ID
==
funcId
:
false
);
}
}
if
(
funcId
<
0
||
funcId
>=
funcMgtBuiltinsNum
)
{
if
(
funcId
<
0
||
funcId
>=
funcMgtBuiltinsNum
)
{
return
false
;
return
false
;
...
@@ -126,29 +129,19 @@ int32_t fmGetScalarFuncExecFuncs(int32_t funcId, SScalarFuncExecFuncs* pFpSet) {
...
@@ -126,29 +129,19 @@ int32_t fmGetScalarFuncExecFuncs(int32_t funcId, SScalarFuncExecFuncs* pFpSet) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
bool
fmIsAggFunc
(
int32_t
funcId
)
{
bool
fmIsAggFunc
(
int32_t
funcId
)
{
return
isSpecificClassifyFunc
(
funcId
,
FUNC_MGT_AGG_FUNC
);
}
return
isSpecificClassifyFunc
(
funcId
,
FUNC_MGT_AGG_FUNC
);
}
bool
fmIsScalarFunc
(
int32_t
funcId
)
{
bool
fmIsScalarFunc
(
int32_t
funcId
)
{
return
isSpecificClassifyFunc
(
funcId
,
FUNC_MGT_SCALAR_FUNC
);
}
return
isSpecificClassifyFunc
(
funcId
,
FUNC_MGT_SCALAR_FUNC
);
}
bool
fmIsPseudoColumnFunc
(
int32_t
funcId
)
{
bool
fmIsPseudoColumnFunc
(
int32_t
funcId
)
{
return
isSpecificClassifyFunc
(
funcId
,
FUNC_MGT_PSEUDO_COLUMN_FUNC
);
}
return
isSpecificClassifyFunc
(
funcId
,
FUNC_MGT_PSEUDO_COLUMN_FUNC
);
}
bool
fmIsWindowPseudoColumnFunc
(
int32_t
funcId
)
{
bool
fmIsScanPseudoColumnFunc
(
int32_t
funcId
)
{
return
isSpecificClassifyFunc
(
funcId
,
FUNC_MGT_SCAN_PC_FUNC
);
}
return
isSpecificClassifyFunc
(
funcId
,
FUNC_MGT_WINDOW_PC_FUNC
);
}
bool
fmIsWindowClauseFunc
(
int32_t
funcId
)
{
bool
fmIsWindowPseudoColumnFunc
(
int32_t
funcId
)
{
return
isSpecificClassifyFunc
(
funcId
,
FUNC_MGT_WINDOW_PC_FUNC
);
}
return
fmIsAggFunc
(
funcId
)
||
fmIsWindowPseudoColumnFunc
(
funcId
);
}
bool
fmIs
NonstandardSQLFunc
(
int32_t
funcId
)
{
bool
fmIs
WindowClauseFunc
(
int32_t
funcId
)
{
return
fmIsAggFunc
(
funcId
)
||
fmIsWindowPseudoColumnFunc
(
funcId
);
}
return
isSpecificClassifyFunc
(
funcId
,
FUNC_MGT_NONSTANDARD_SQL_FUNC
);
}
bool
fmIsNonstandardSQLFunc
(
int32_t
funcId
)
{
return
isSpecificClassifyFunc
(
funcId
,
FUNC_MGT_NONSTANDARD_SQL_FUNC
);
}
bool
fmIsSpecialDataRequiredFunc
(
int32_t
funcId
)
{
bool
fmIsSpecialDataRequiredFunc
(
int32_t
funcId
)
{
return
isSpecificClassifyFunc
(
funcId
,
FUNC_MGT_SPECIAL_DATA_REQUIRED
);
return
isSpecificClassifyFunc
(
funcId
,
FUNC_MGT_SPECIAL_DATA_REQUIRED
);
...
@@ -158,13 +151,9 @@ bool fmIsDynamicScanOptimizedFunc(int32_t funcId) {
...
@@ -158,13 +151,9 @@ bool fmIsDynamicScanOptimizedFunc(int32_t funcId) {
return
isSpecificClassifyFunc
(
funcId
,
FUNC_MGT_DYNAMIC_SCAN_OPTIMIZED
);
return
isSpecificClassifyFunc
(
funcId
,
FUNC_MGT_DYNAMIC_SCAN_OPTIMIZED
);
}
}
bool
fmIsMultiResFunc
(
int32_t
funcId
)
{
bool
fmIsMultiResFunc
(
int32_t
funcId
)
{
return
isSpecificClassifyFunc
(
funcId
,
FUNC_MGT_MULTI_RES_FUNC
);
}
return
isSpecificClassifyFunc
(
funcId
,
FUNC_MGT_MULTI_RES_FUNC
);
}
bool
fmIsUserDefinedFunc
(
int32_t
funcId
)
{
bool
fmIsUserDefinedFunc
(
int32_t
funcId
)
{
return
funcId
>
FUNC_UDF_ID_START
;
}
return
funcId
>
FUNC_UDF_ID_START
;
}
void
fmFuncMgtDestroy
()
{
void
fmFuncMgtDestroy
()
{
void
*
m
=
gFunMgtService
.
pFuncNameHashTable
;
void
*
m
=
gFunMgtService
.
pFuncNameHashTable
;
...
...
source/libs/nodes/src/nodesCloneFuncs.c
浏览文件 @
a0fcc9a2
...
@@ -224,6 +224,7 @@ static SNode* logicScanCopy(const SScanLogicNode* pSrc, SScanLogicNode* pDst) {
...
@@ -224,6 +224,7 @@ static SNode* logicScanCopy(const SScanLogicNode* pSrc, SScanLogicNode* pDst) {
COPY_ALL_SCALAR_FIELDS
;
COPY_ALL_SCALAR_FIELDS
;
COPY_BASE_OBJECT_FIELD
(
node
,
logicNodeCopy
);
COPY_BASE_OBJECT_FIELD
(
node
,
logicNodeCopy
);
CLONE_NODE_LIST_FIELD
(
pScanCols
);
CLONE_NODE_LIST_FIELD
(
pScanCols
);
CLONE_NODE_LIST_FIELD
(
pScanPseudoCols
);
CLONE_OBJECT_FIELD
(
pMeta
,
tableMetaClone
);
CLONE_OBJECT_FIELD
(
pMeta
,
tableMetaClone
);
CLONE_OBJECT_FIELD
(
pVgroupList
,
vgroupsInfoClone
);
CLONE_OBJECT_FIELD
(
pVgroupList
,
vgroupsInfoClone
);
CLONE_NODE_LIST_FIELD
(
pDynamicScanFuncs
);
CLONE_NODE_LIST_FIELD
(
pDynamicScanFuncs
);
...
...
source/libs/nodes/src/nodesCodeFuncs.c
浏览文件 @
a0fcc9a2
...
@@ -467,6 +467,7 @@ static int32_t jsonToLogicPlanNode(const SJson* pJson, void* pObj) {
...
@@ -467,6 +467,7 @@ static int32_t jsonToLogicPlanNode(const SJson* pJson, void* pObj) {
}
}
static
const
char
*
jkScanLogicPlanScanCols
=
"ScanCols"
;
static
const
char
*
jkScanLogicPlanScanCols
=
"ScanCols"
;
static
const
char
*
jkScanLogicPlanScanPseudoCols
=
"ScanPseudoCols"
;
static
const
char
*
jkScanLogicPlanTableMetaSize
=
"TableMetaSize"
;
static
const
char
*
jkScanLogicPlanTableMetaSize
=
"TableMetaSize"
;
static
const
char
*
jkScanLogicPlanTableMeta
=
"TableMeta"
;
static
const
char
*
jkScanLogicPlanTableMeta
=
"TableMeta"
;
...
@@ -477,6 +478,9 @@ static int32_t logicScanNodeToJson(const void* pObj, SJson* pJson) {
...
@@ -477,6 +478,9 @@ static int32_t logicScanNodeToJson(const void* pObj, SJson* pJson) {
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodeListToJson
(
pJson
,
jkScanLogicPlanScanCols
,
pNode
->
pScanCols
);
code
=
nodeListToJson
(
pJson
,
jkScanLogicPlanScanCols
,
pNode
->
pScanCols
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodeListToJson
(
pJson
,
jkScanLogicPlanScanPseudoCols
,
pNode
->
pScanPseudoCols
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddIntegerToObject
(
pJson
,
jkScanLogicPlanTableMetaSize
,
TABLE_META_SIZE
(
pNode
->
pMeta
));
code
=
tjsonAddIntegerToObject
(
pJson
,
jkScanLogicPlanTableMetaSize
,
TABLE_META_SIZE
(
pNode
->
pMeta
));
}
}
...
@@ -495,6 +499,9 @@ static int32_t jsonToLogicScanNode(const SJson* pJson, void* pObj) {
...
@@ -495,6 +499,9 @@ static int32_t jsonToLogicScanNode(const SJson* pJson, void* pObj) {
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeList
(
pJson
,
jkScanLogicPlanScanCols
,
&
pNode
->
pScanCols
);
code
=
jsonToNodeList
(
pJson
,
jkScanLogicPlanScanCols
,
&
pNode
->
pScanCols
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeList
(
pJson
,
jkScanLogicPlanScanPseudoCols
,
&
pNode
->
pScanPseudoCols
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonGetIntValue
(
pJson
,
jkScanLogicPlanTableMetaSize
,
&
objSize
);
code
=
tjsonGetIntValue
(
pJson
,
jkScanLogicPlanTableMetaSize
,
&
objSize
);
}
}
...
@@ -670,6 +677,7 @@ static int32_t jsonToName(const SJson* pJson, void* pObj) {
...
@@ -670,6 +677,7 @@ static int32_t jsonToName(const SJson* pJson, void* pObj) {
}
}
static
const
char
*
jkScanPhysiPlanScanCols
=
"ScanCols"
;
static
const
char
*
jkScanPhysiPlanScanCols
=
"ScanCols"
;
static
const
char
*
jkScanPhysiPlanScanPseudoCols
=
"ScanPseudoCols"
;
static
const
char
*
jkScanPhysiPlanTableId
=
"TableId"
;
static
const
char
*
jkScanPhysiPlanTableId
=
"TableId"
;
static
const
char
*
jkScanPhysiPlanTableType
=
"TableType"
;
static
const
char
*
jkScanPhysiPlanTableType
=
"TableType"
;
static
const
char
*
jkScanPhysiPlanTableName
=
"TableName"
;
static
const
char
*
jkScanPhysiPlanTableName
=
"TableName"
;
...
@@ -681,6 +689,9 @@ static int32_t physiScanNodeToJson(const void* pObj, SJson* pJson) {
...
@@ -681,6 +689,9 @@ static int32_t physiScanNodeToJson(const void* pObj, SJson* pJson) {
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodeListToJson
(
pJson
,
jkScanPhysiPlanScanCols
,
pNode
->
pScanCols
);
code
=
nodeListToJson
(
pJson
,
jkScanPhysiPlanScanCols
,
pNode
->
pScanCols
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodeListToJson
(
pJson
,
jkScanPhysiPlanScanPseudoCols
,
pNode
->
pScanPseudoCols
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddIntegerToObject
(
pJson
,
jkScanPhysiPlanTableId
,
pNode
->
uid
);
code
=
tjsonAddIntegerToObject
(
pJson
,
jkScanPhysiPlanTableId
,
pNode
->
uid
);
}
}
...
@@ -701,6 +712,9 @@ static int32_t jsonToPhysiScanNode(const SJson* pJson, void* pObj) {
...
@@ -701,6 +712,9 @@ static int32_t jsonToPhysiScanNode(const SJson* pJson, void* pObj) {
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeList
(
pJson
,
jkScanPhysiPlanScanCols
,
&
pNode
->
pScanCols
);
code
=
jsonToNodeList
(
pJson
,
jkScanPhysiPlanScanCols
,
&
pNode
->
pScanCols
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeList
(
pJson
,
jkScanPhysiPlanScanPseudoCols
,
&
pNode
->
pScanPseudoCols
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonGetUBigIntValue
(
pJson
,
jkScanPhysiPlanTableId
,
&
pNode
->
uid
);
code
=
tjsonGetUBigIntValue
(
pJson
,
jkScanPhysiPlanTableId
,
&
pNode
->
uid
);
}
}
...
...
source/libs/nodes/src/nodesUtilFuncs.c
浏览文件 @
a0fcc9a2
...
@@ -1043,6 +1043,7 @@ bool nodesIsTimelineQuery(const SNode* pQuery) { return false; }
...
@@ -1043,6 +1043,7 @@ bool nodesIsTimelineQuery(const SNode* pQuery) { return false; }
typedef
struct
SCollectColumnsCxt
{
typedef
struct
SCollectColumnsCxt
{
int32_t
errCode
;
int32_t
errCode
;
const
char
*
pTableAlias
;
const
char
*
pTableAlias
;
ECollectColType
collectType
;
SNodeList
*
pCols
;
SNodeList
*
pCols
;
SHashObj
*
pColHash
;
SHashObj
*
pColHash
;
}
SCollectColumnsCxt
;
}
SCollectColumnsCxt
;
...
@@ -1057,25 +1058,33 @@ static EDealRes doCollect(SCollectColumnsCxt* pCxt, SColumnNode* pCol, SNode* pN
...
@@ -1057,25 +1058,33 @@ static EDealRes doCollect(SCollectColumnsCxt* pCxt, SColumnNode* pCol, SNode* pN
if
(
NULL
==
taosHashGet
(
pCxt
->
pColHash
,
name
,
len
))
{
if
(
NULL
==
taosHashGet
(
pCxt
->
pColHash
,
name
,
len
))
{
pCxt
->
errCode
=
taosHashPut
(
pCxt
->
pColHash
,
name
,
len
,
NULL
,
0
);
pCxt
->
errCode
=
taosHashPut
(
pCxt
->
pColHash
,
name
,
len
,
NULL
,
0
);
if
(
TSDB_CODE_SUCCESS
==
pCxt
->
errCode
)
{
if
(
TSDB_CODE_SUCCESS
==
pCxt
->
errCode
)
{
pCxt
->
errCode
=
nodesList
Append
(
pCxt
->
pCols
,
pNode
);
pCxt
->
errCode
=
nodesList
StrictAppend
(
pCxt
->
pCols
,
nodesCloneNode
(
pNode
)
);
}
}
return
(
TSDB_CODE_SUCCESS
==
pCxt
->
errCode
?
DEAL_RES_IGNORE_CHILD
:
DEAL_RES_ERROR
);
return
(
TSDB_CODE_SUCCESS
==
pCxt
->
errCode
?
DEAL_RES_IGNORE_CHILD
:
DEAL_RES_ERROR
);
}
}
return
DEAL_RES_CONTINUE
;
return
DEAL_RES_CONTINUE
;
}
}
static
bool
isCollectType
(
ECollectColType
collectType
,
EColumnType
colType
)
{
return
COLLECT_COL_TYPE_ALL
==
collectType
?
true
:
(
COLLECT_COL_TYPE_TAG
==
collectType
?
COLUMN_TYPE_TAG
==
colType
:
COLUMN_TYPE_TAG
!=
colType
);
}
static
EDealRes
collectColumns
(
SNode
*
pNode
,
void
*
pContext
)
{
static
EDealRes
collectColumns
(
SNode
*
pNode
,
void
*
pContext
)
{
SCollectColumnsCxt
*
pCxt
=
(
SCollectColumnsCxt
*
)
pContext
;
SCollectColumnsCxt
*
pCxt
=
(
SCollectColumnsCxt
*
)
pContext
;
if
(
QUERY_NODE_COLUMN
==
nodeType
(
pNode
))
{
if
(
QUERY_NODE_COLUMN
==
nodeType
(
pNode
))
{
SColumnNode
*
pCol
=
(
SColumnNode
*
)
pNode
;
SColumnNode
*
pCol
=
(
SColumnNode
*
)
pNode
;
if
(
NULL
==
pCxt
->
pTableAlias
||
0
==
strcmp
(
pCxt
->
pTableAlias
,
pCol
->
tableAlias
))
{
if
(
isCollectType
(
pCxt
->
collectType
,
pCol
->
colType
)
&&
(
NULL
==
pCxt
->
pTableAlias
||
0
==
strcmp
(
pCxt
->
pTableAlias
,
pCol
->
tableAlias
)))
{
return
doCollect
(
pCxt
,
pCol
,
pNode
);
return
doCollect
(
pCxt
,
pCol
,
pNode
);
}
}
}
}
return
DEAL_RES_CONTINUE
;
return
DEAL_RES_CONTINUE
;
}
}
int32_t
nodesCollectColumns
(
SSelectStmt
*
pSelect
,
ESqlClause
clause
,
const
char
*
pTableAlias
,
SNodeList
**
pCols
)
{
int32_t
nodesCollectColumns
(
SSelectStmt
*
pSelect
,
ESqlClause
clause
,
const
char
*
pTableAlias
,
ECollectColType
type
,
SNodeList
**
pCols
)
{
if
(
NULL
==
pSelect
||
NULL
==
pCols
)
{
if
(
NULL
==
pSelect
||
NULL
==
pCols
)
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -1083,6 +1092,7 @@ int32_t nodesCollectColumns(SSelectStmt* pSelect, ESqlClause clause, const char*
...
@@ -1083,6 +1092,7 @@ int32_t nodesCollectColumns(SSelectStmt* pSelect, ESqlClause clause, const char*
SCollectColumnsCxt
cxt
=
{
SCollectColumnsCxt
cxt
=
{
.
errCode
=
TSDB_CODE_SUCCESS
,
.
errCode
=
TSDB_CODE_SUCCESS
,
.
pTableAlias
=
pTableAlias
,
.
pTableAlias
=
pTableAlias
,
.
collectType
=
type
,
.
pCols
=
nodesMakeList
(),
.
pCols
=
nodesMakeList
(),
.
pColHash
=
taosHashInit
(
128
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_NO_LOCK
)};
.
pColHash
=
taosHashInit
(
128
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_NO_LOCK
)};
if
(
NULL
==
cxt
.
pCols
||
NULL
==
cxt
.
pColHash
)
{
if
(
NULL
==
cxt
.
pCols
||
NULL
==
cxt
.
pColHash
)
{
...
@@ -1092,11 +1102,11 @@ int32_t nodesCollectColumns(SSelectStmt* pSelect, ESqlClause clause, const char*
...
@@ -1092,11 +1102,11 @@ int32_t nodesCollectColumns(SSelectStmt* pSelect, ESqlClause clause, const char*
nodesWalkSelectStmt
(
pSelect
,
clause
,
collectColumns
,
&
cxt
);
nodesWalkSelectStmt
(
pSelect
,
clause
,
collectColumns
,
&
cxt
);
taosHashCleanup
(
cxt
.
pColHash
);
taosHashCleanup
(
cxt
.
pColHash
);
if
(
TSDB_CODE_SUCCESS
!=
cxt
.
errCode
)
{
if
(
TSDB_CODE_SUCCESS
!=
cxt
.
errCode
)
{
nodes
Clear
List
(
cxt
.
pCols
);
nodes
Destroy
List
(
cxt
.
pCols
);
return
cxt
.
errCode
;
return
cxt
.
errCode
;
}
}
if
(
0
==
LIST_LENGTH
(
cxt
.
pCols
))
{
if
(
0
==
LIST_LENGTH
(
cxt
.
pCols
))
{
nodes
Clear
List
(
cxt
.
pCols
);
nodes
Destroy
List
(
cxt
.
pCols
);
cxt
.
pCols
=
NULL
;
cxt
.
pCols
=
NULL
;
}
}
*
pCols
=
cxt
.
pCols
;
*
pCols
=
cxt
.
pCols
;
...
@@ -1123,10 +1133,12 @@ int32_t nodesCollectFuncs(SSelectStmt* pSelect, FFuncClassifier classifier, SNod
...
@@ -1123,10 +1133,12 @@ int32_t nodesCollectFuncs(SSelectStmt* pSelect, FFuncClassifier classifier, SNod
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
SCollectFuncsCxt
cxt
=
{.
errCode
=
TSDB_CODE_SUCCESS
,
.
classifier
=
classifier
,
.
pFuncs
=
nodesMakeList
()};
SCollectFuncsCxt
cxt
=
{
.
errCode
=
TSDB_CODE_SUCCESS
,
.
classifier
=
classifier
,
.
pFuncs
=
(
NULL
==
*
pFuncs
?
nodesMakeList
()
:
*
pFuncs
)};
if
(
NULL
==
cxt
.
pFuncs
)
{
if
(
NULL
==
cxt
.
pFuncs
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
*
pFuncs
=
NULL
;
nodesWalkSelectStmt
(
pSelect
,
SQL_CLAUSE_GROUP_BY
,
collectFuncs
,
&
cxt
);
nodesWalkSelectStmt
(
pSelect
,
SQL_CLAUSE_GROUP_BY
,
collectFuncs
,
&
cxt
);
if
(
TSDB_CODE_SUCCESS
!=
cxt
.
errCode
)
{
if
(
TSDB_CODE_SUCCESS
!=
cxt
.
errCode
)
{
nodesDestroyList
(
cxt
.
pFuncs
);
nodesDestroyList
(
cxt
.
pFuncs
);
...
@@ -1136,7 +1148,6 @@ int32_t nodesCollectFuncs(SSelectStmt* pSelect, FFuncClassifier classifier, SNod
...
@@ -1136,7 +1148,6 @@ int32_t nodesCollectFuncs(SSelectStmt* pSelect, FFuncClassifier classifier, SNod
*
pFuncs
=
cxt
.
pFuncs
;
*
pFuncs
=
cxt
.
pFuncs
;
}
else
{
}
else
{
nodesDestroyList
(
cxt
.
pFuncs
);
nodesDestroyList
(
cxt
.
pFuncs
);
*
pFuncs
=
NULL
;
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
a0fcc9a2
...
@@ -1905,18 +1905,9 @@ static int32_t columnDefNodeToField(SNodeList* pList, SArray** pArray) {
...
@@ -1905,18 +1905,9 @@ static int32_t columnDefNodeToField(SNodeList* pList, SArray** pArray) {
SColumnDefNode
*
pCol
=
(
SColumnDefNode
*
)
pNode
;
SColumnDefNode
*
pCol
=
(
SColumnDefNode
*
)
pNode
;
SField
field
=
{.
type
=
pCol
->
dataType
.
type
,
.
bytes
=
calcTypeBytes
(
pCol
->
dataType
)};
SField
field
=
{.
type
=
pCol
->
dataType
.
type
,
.
bytes
=
calcTypeBytes
(
pCol
->
dataType
)};
strcpy
(
field
.
name
,
pCol
->
colName
);
strcpy
(
field
.
name
,
pCol
->
colName
);
taosArrayPush
(
*
pArray
,
&
field
);
if
(
pCol
->
sma
)
{
field
.
flags
|=
SCHEMA_SMA_ON
;
}
}
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
columnNodeToField
(
SNodeList
*
pList
,
SArray
**
pArray
)
{
*
pArray
=
taosArrayInit
(
LIST_LENGTH
(
pList
),
sizeof
(
SField
));
SNode
*
pNode
;
FOREACH
(
pNode
,
pList
)
{
SColumnNode
*
pCol
=
(
SColumnNode
*
)
pNode
;
SField
field
=
{.
type
=
pCol
->
node
.
resType
.
type
,
.
bytes
=
calcTypeBytes
(
pCol
->
node
.
resType
)};
strcpy
(
field
.
name
,
pCol
->
colName
);
taosArrayPush
(
*
pArray
,
&
field
);
taosArrayPush
(
*
pArray
,
&
field
);
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -2249,13 +2240,6 @@ static int32_t buildCreateStbReq(STranslateContext* pCxt, SCreateTableStmt* pStm
...
@@ -2249,13 +2240,6 @@ static int32_t buildCreateStbReq(STranslateContext* pCxt, SCreateTableStmt* pStm
columnDefNodeToField
(
pStmt
->
pTags
,
&
pReq
->
pTags
);
columnDefNodeToField
(
pStmt
->
pTags
,
&
pReq
->
pTags
);
pReq
->
numOfColumns
=
LIST_LENGTH
(
pStmt
->
pCols
);
pReq
->
numOfColumns
=
LIST_LENGTH
(
pStmt
->
pCols
);
pReq
->
numOfTags
=
LIST_LENGTH
(
pStmt
->
pTags
);
pReq
->
numOfTags
=
LIST_LENGTH
(
pStmt
->
pTags
);
if
(
NULL
==
pStmt
->
pOptions
->
pSma
)
{
columnDefNodeToField
(
pStmt
->
pCols
,
&
pReq
->
pSmas
);
pReq
->
numOfSmas
=
pReq
->
numOfColumns
;
}
else
{
columnNodeToField
(
pStmt
->
pOptions
->
pSma
,
&
pReq
->
pSmas
);
pReq
->
numOfSmas
=
LIST_LENGTH
(
pStmt
->
pOptions
->
pSma
);
}
SName
tableName
;
SName
tableName
;
tNameExtractFullName
(
toName
(
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
dbName
,
pStmt
->
tableName
,
&
tableName
),
pReq
->
name
);
tNameExtractFullName
(
toName
(
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
dbName
,
pStmt
->
tableName
,
&
tableName
),
pReq
->
name
);
...
...
source/libs/planner/src/planLogicCreater.c
浏览文件 @
a0fcc9a2
...
@@ -129,14 +129,66 @@ static int32_t createChildLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelec
...
@@ -129,14 +129,66 @@ static int32_t createChildLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelec
return
code
;
return
code
;
}
}
static
EScanType
getScanType
(
SLogicPlanContext
*
pCxt
,
SNodeList
*
pScanCols
,
STableMeta
*
pMeta
)
{
typedef
struct
SCreateColumnCxt
{
int32_t
errCode
;
SNodeList
*
pList
;
}
SCreateColumnCxt
;
static
EDealRes
doCreateColumn
(
SNode
*
pNode
,
void
*
pContext
)
{
SCreateColumnCxt
*
pCxt
=
(
SCreateColumnCxt
*
)
pContext
;
switch
(
nodeType
(
pNode
))
{
case
QUERY_NODE_COLUMN
:
{
SNode
*
pCol
=
nodesCloneNode
(
pNode
);
if
(
NULL
==
pCol
)
{
return
DEAL_RES_ERROR
;
}
return
(
TSDB_CODE_SUCCESS
==
nodesListAppend
(
pCxt
->
pList
,
pCol
)
?
DEAL_RES_IGNORE_CHILD
:
DEAL_RES_ERROR
);
}
case
QUERY_NODE_OPERATOR
:
case
QUERY_NODE_LOGIC_CONDITION
:
case
QUERY_NODE_FUNCTION
:
{
SExprNode
*
pExpr
=
(
SExprNode
*
)
pNode
;
SColumnNode
*
pCol
=
(
SColumnNode
*
)
nodesMakeNode
(
QUERY_NODE_COLUMN
);
if
(
NULL
==
pCol
)
{
return
DEAL_RES_ERROR
;
}
pCol
->
node
.
resType
=
pExpr
->
resType
;
strcpy
(
pCol
->
colName
,
pExpr
->
aliasName
);
return
(
TSDB_CODE_SUCCESS
==
nodesListAppend
(
pCxt
->
pList
,
pCol
)
?
DEAL_RES_IGNORE_CHILD
:
DEAL_RES_ERROR
);
}
default:
break
;
}
return
DEAL_RES_CONTINUE
;
}
static
int32_t
createColumnByRewriteExps
(
SLogicPlanContext
*
pCxt
,
SNodeList
*
pExprs
,
SNodeList
**
pList
)
{
SCreateColumnCxt
cxt
=
{.
errCode
=
TSDB_CODE_SUCCESS
,
.
pList
=
(
NULL
==
*
pList
?
nodesMakeList
()
:
*
pList
)};
if
(
NULL
==
cxt
.
pList
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
nodesWalkExprs
(
pExprs
,
doCreateColumn
,
&
cxt
);
if
(
TSDB_CODE_SUCCESS
!=
cxt
.
errCode
)
{
nodesDestroyList
(
cxt
.
pList
);
return
cxt
.
errCode
;
}
if
(
NULL
==
*
pList
)
{
*
pList
=
cxt
.
pList
;
}
return
cxt
.
errCode
;
}
static
EScanType
getScanType
(
SLogicPlanContext
*
pCxt
,
SNodeList
*
pScanPseudoCols
,
SNodeList
*
pScanCols
,
STableMeta
*
pMeta
)
{
if
(
pCxt
->
pPlanCxt
->
topicQuery
||
pCxt
->
pPlanCxt
->
streamQuery
)
{
if
(
pCxt
->
pPlanCxt
->
topicQuery
||
pCxt
->
pPlanCxt
->
streamQuery
)
{
return
SCAN_TYPE_STREAM
;
return
SCAN_TYPE_STREAM
;
}
}
if
(
NULL
==
pScanCols
)
{
if
(
NULL
==
pScanCols
)
{
// select count(*) from t
// select count(*) from t
return
SCAN_TYPE_TABLE
;
return
NULL
==
pScanPseudoCols
?
SCAN_TYPE_TABLE
:
SCAN_TYPE_TAG
;
}
}
if
(
TSDB_SYSTEM_TABLE
==
pMeta
->
tableType
)
{
if
(
TSDB_SYSTEM_TABLE
==
pMeta
->
tableType
)
{
...
@@ -186,7 +238,6 @@ static int32_t addPrimaryKeyCol(uint64_t tableId, SNodeList** pCols) {
...
@@ -186,7 +238,6 @@ static int32_t addPrimaryKeyCol(uint64_t tableId, SNodeList** pCols) {
if
(
!
found
)
{
if
(
!
found
)
{
if
(
TSDB_CODE_SUCCESS
!=
nodesListStrictAppend
(
*
pCols
,
createPrimaryKeyCol
(
tableId
)))
{
if
(
TSDB_CODE_SUCCESS
!=
nodesListStrictAppend
(
*
pCols
,
createPrimaryKeyCol
(
tableId
)))
{
nodesDestroyList
(
*
pCols
);
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
}
}
...
@@ -214,31 +265,32 @@ static int32_t createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
...
@@ -214,31 +265,32 @@ static int32_t createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
pScan
->
dataRequired
=
FUNC_DATA_REQUIRED_DATA_LOAD
;
pScan
->
dataRequired
=
FUNC_DATA_REQUIRED_DATA_LOAD
;
// set columns to scan
// set columns to scan
SNodeList
*
pCols
=
NULL
;
int32_t
code
=
nodesCollectColumns
(
pSelect
,
SQL_CLAUSE_FROM
,
pRealTable
->
table
.
tableAlias
,
COLLECT_COL_TYPE_COL
,
int32_t
code
=
nodesCollectColumns
(
pSelect
,
SQL_CLAUSE_FROM
,
pRealTable
->
table
.
tableAlias
,
&
pCols
);
&
pScan
->
pScanCols
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
addPrimaryKeyCol
(
pScan
->
pMeta
->
uid
,
&
pCols
);
code
=
nodesCollectColumns
(
pSelect
,
SQL_CLAUSE_FROM
,
pRealTable
->
table
.
tableAlias
,
COLLECT_COL_TYPE_TAG
,
&
pScan
->
pScanPseudoCols
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
pScan
->
pScanCols
=
nodesCloneList
(
pCols
);
code
=
nodesCollectFuncs
(
pSelect
,
fmIsScanPseudoColumnFunc
,
&
pScan
->
pScanPseudoCols
);
if
(
NULL
==
pScan
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
}
}
}
pScan
->
scanType
=
getScanType
(
pCxt
,
pCols
,
pScan
->
pMeta
);
pScan
->
scanType
=
getScanType
(
pCxt
,
pScan
->
pScanPseudoCols
,
pScan
->
pScanCols
,
pScan
->
pMeta
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
addPrimaryKeyCol
(
pScan
->
pMeta
->
uid
,
&
pScan
->
pScanCols
);
}
// set output
// set output
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
pScan
->
node
.
pTargets
=
nodesCloneList
(
pCols
);
code
=
createColumnByRewriteExps
(
pCxt
,
pScan
->
pScanCols
,
&
pScan
->
node
.
pTargets
);
if
(
NULL
==
pScan
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
createColumnByRewriteExps
(
pCxt
,
pScan
->
pScanPseudoCols
,
&
pScan
->
node
.
pTargets
);
}
}
nodesClearList
(
pCols
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
*
pLogicNode
=
(
SLogicNode
*
)
pScan
;
*
pLogicNode
=
(
SLogicNode
*
)
pScan
;
}
else
{
}
else
{
...
@@ -362,57 +414,6 @@ static SColumnNode* createColumnByExpr(const char* pStmtName, SExprNode* pExpr)
...
@@ -362,57 +414,6 @@ static SColumnNode* createColumnByExpr(const char* pStmtName, SExprNode* pExpr)
return
pCol
;
return
pCol
;
}
}
typedef
struct
SCreateColumnCxt
{
int32_t
errCode
;
SNodeList
*
pList
;
}
SCreateColumnCxt
;
static
EDealRes
doCreateColumn
(
SNode
*
pNode
,
void
*
pContext
)
{
SCreateColumnCxt
*
pCxt
=
(
SCreateColumnCxt
*
)
pContext
;
switch
(
nodeType
(
pNode
))
{
case
QUERY_NODE_COLUMN
:
{
SNode
*
pCol
=
nodesCloneNode
(
pNode
);
if
(
NULL
==
pCol
)
{
return
DEAL_RES_ERROR
;
}
return
(
TSDB_CODE_SUCCESS
==
nodesListAppend
(
pCxt
->
pList
,
pCol
)
?
DEAL_RES_IGNORE_CHILD
:
DEAL_RES_ERROR
);
}
case
QUERY_NODE_OPERATOR
:
case
QUERY_NODE_LOGIC_CONDITION
:
case
QUERY_NODE_FUNCTION
:
{
SExprNode
*
pExpr
=
(
SExprNode
*
)
pNode
;
SColumnNode
*
pCol
=
(
SColumnNode
*
)
nodesMakeNode
(
QUERY_NODE_COLUMN
);
if
(
NULL
==
pCol
)
{
return
DEAL_RES_ERROR
;
}
pCol
->
node
.
resType
=
pExpr
->
resType
;
strcpy
(
pCol
->
colName
,
pExpr
->
aliasName
);
return
(
TSDB_CODE_SUCCESS
==
nodesListAppend
(
pCxt
->
pList
,
pCol
)
?
DEAL_RES_IGNORE_CHILD
:
DEAL_RES_ERROR
);
}
default:
break
;
}
return
DEAL_RES_CONTINUE
;
}
static
int32_t
createColumnByRewriteExps
(
SLogicPlanContext
*
pCxt
,
SNodeList
*
pExprs
,
SNodeList
**
pList
)
{
SCreateColumnCxt
cxt
=
{.
errCode
=
TSDB_CODE_SUCCESS
,
.
pList
=
(
NULL
==
*
pList
?
nodesMakeList
()
:
*
pList
)};
if
(
NULL
==
cxt
.
pList
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
nodesWalkExprs
(
pExprs
,
doCreateColumn
,
&
cxt
);
if
(
TSDB_CODE_SUCCESS
!=
cxt
.
errCode
)
{
nodesDestroyList
(
cxt
.
pList
);
return
cxt
.
errCode
;
}
if
(
NULL
==
*
pList
)
{
*
pList
=
cxt
.
pList
;
}
return
cxt
.
errCode
;
}
static
int32_t
createAggLogicNode
(
SLogicPlanContext
*
pCxt
,
SSelectStmt
*
pSelect
,
SLogicNode
**
pLogicNode
)
{
static
int32_t
createAggLogicNode
(
SLogicPlanContext
*
pCxt
,
SSelectStmt
*
pSelect
,
SLogicNode
**
pLogicNode
)
{
if
(
!
pSelect
->
hasAggFuncs
&&
NULL
==
pSelect
->
pGroupByList
)
{
if
(
!
pSelect
->
hasAggFuncs
&&
NULL
==
pSelect
->
pGroupByList
)
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -598,14 +599,7 @@ static int32_t createSortLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
...
@@ -598,14 +599,7 @@ static int32_t createSortLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
SNodeList
*
pCols
=
NULL
;
int32_t
code
=
nodesCollectColumns
(
pSelect
,
SQL_CLAUSE_ORDER_BY
,
NULL
,
COLLECT_COL_TYPE_ALL
,
&
pSort
->
node
.
pTargets
);
int32_t
code
=
nodesCollectColumns
(
pSelect
,
SQL_CLAUSE_ORDER_BY
,
NULL
,
&
pCols
);
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pCols
)
{
pSort
->
node
.
pTargets
=
nodesCloneList
(
pCols
);
if
(
NULL
==
pSort
->
node
.
pTargets
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
pSort
->
pSortKeys
=
nodesCloneList
(
pSelect
->
pOrderByList
);
pSort
->
pSortKeys
=
nodesCloneList
(
pSelect
->
pOrderByList
);
...
@@ -695,14 +689,8 @@ static int32_t createPartitionLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pS
...
@@ -695,14 +689,8 @@ static int32_t createPartitionLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pS
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
SNodeList
*
pCols
=
NULL
;
int32_t
code
=
int32_t
code
=
nodesCollectColumns
(
pSelect
,
SQL_CLAUSE_PARTITION_BY
,
NULL
,
&
pCols
);
nodesCollectColumns
(
pSelect
,
SQL_CLAUSE_PARTITION_BY
,
NULL
,
COLLECT_COL_TYPE_ALL
,
&
pPartition
->
node
.
pTargets
);
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pCols
)
{
pPartition
->
node
.
pTargets
=
nodesCloneList
(
pCols
);
if
(
NULL
==
pPartition
->
node
.
pTargets
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
pPartition
->
pPartitionKeys
=
nodesCloneList
(
pSelect
->
pPartitionByList
);
pPartition
->
pPartitionKeys
=
nodesCloneList
(
pSelect
->
pPartitionByList
);
...
...
source/libs/planner/src/planPhysiCreater.c
浏览文件 @
a0fcc9a2
...
@@ -380,6 +380,10 @@ static int32_t sortScanCols(SNodeList* pScanCols) {
...
@@ -380,6 +380,10 @@ static int32_t sortScanCols(SNodeList* pScanCols) {
}
}
static
int32_t
createScanCols
(
SPhysiPlanContext
*
pCxt
,
SScanPhysiNode
*
pScanPhysiNode
,
SNodeList
*
pScanCols
)
{
static
int32_t
createScanCols
(
SPhysiPlanContext
*
pCxt
,
SScanPhysiNode
*
pScanPhysiNode
,
SNodeList
*
pScanCols
)
{
if
(
NULL
==
pScanCols
)
{
return
TSDB_CODE_SUCCESS
;
}
pScanPhysiNode
->
pScanCols
=
nodesCloneList
(
pScanCols
);
pScanPhysiNode
->
pScanCols
=
nodesCloneList
(
pScanCols
);
if
(
NULL
==
pScanPhysiNode
->
pScanCols
)
{
if
(
NULL
==
pScanPhysiNode
->
pScanCols
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
...
@@ -394,9 +398,22 @@ static int32_t createScanPhysiNodeFinalize(SPhysiPlanContext* pCxt, SScanLogicNo
...
@@ -394,9 +398,22 @@ static int32_t createScanPhysiNodeFinalize(SPhysiPlanContext* pCxt, SScanLogicNo
// Data block describe also needs to be set without scanning column, such as SELECT COUNT(*) FROM t
// Data block describe also needs to be set without scanning column, such as SELECT COUNT(*) FROM t
code
=
addDataBlockSlots
(
pCxt
,
pScanPhysiNode
->
pScanCols
,
pScanPhysiNode
->
node
.
pOutputDataBlockDesc
);
code
=
addDataBlockSlots
(
pCxt
,
pScanPhysiNode
->
pScanCols
,
pScanPhysiNode
->
node
.
pOutputDataBlockDesc
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pScanLogicNode
->
pScanPseudoCols
)
{
pScanPhysiNode
->
pScanPseudoCols
=
nodesCloneList
(
pScanLogicNode
->
pScanPseudoCols
);
if
(
NULL
==
pScanPhysiNode
->
pScanPseudoCols
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
addDataBlockSlots
(
pCxt
,
pScanPhysiNode
->
pScanPseudoCols
,
pScanPhysiNode
->
node
.
pOutputDataBlockDesc
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
setConditionsSlotId
(
pCxt
,
(
const
SLogicNode
*
)
pScanLogicNode
,
(
SPhysiNode
*
)
pScanPhysiNode
);
code
=
setConditionsSlotId
(
pCxt
,
(
const
SLogicNode
*
)
pScanLogicNode
,
(
SPhysiNode
*
)
pScanPhysiNode
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
pScanPhysiNode
->
uid
=
pScanLogicNode
->
pMeta
->
uid
;
pScanPhysiNode
->
uid
=
pScanLogicNode
->
pMeta
->
uid
;
pScanPhysiNode
->
tableType
=
pScanLogicNode
->
pMeta
->
tableType
;
pScanPhysiNode
->
tableType
=
pScanLogicNode
->
pMeta
->
tableType
;
...
@@ -1190,6 +1207,11 @@ static int32_t buildPhysiPlan(SPhysiPlanContext* pCxt, SLogicSubplan* pLogicSubp
...
@@ -1190,6 +1207,11 @@ static int32_t buildPhysiPlan(SPhysiPlanContext* pCxt, SLogicSubplan* pLogicSubp
++
(
pQueryPlan
->
numOfSubplans
);
++
(
pQueryPlan
->
numOfSubplans
);
}
}
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
nodesDestroyNode
(
pSubplan
);
return
code
;
}
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pParent
)
{
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pParent
)
{
code
=
nodesListMakeAppend
(
&
pParent
->
pChildren
,
pSubplan
);
code
=
nodesListMakeAppend
(
&
pParent
->
pChildren
,
pSubplan
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
...
@@ -1207,10 +1229,6 @@ static int32_t buildPhysiPlan(SPhysiPlanContext* pCxt, SLogicSubplan* pLogicSubp
...
@@ -1207,10 +1229,6 @@ static int32_t buildPhysiPlan(SPhysiPlanContext* pCxt, SLogicSubplan* pLogicSubp
}
}
}
}
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
nodesDestroyNode
(
pSubplan
);
}
return
code
;
return
code
;
}
}
...
...
source/libs/planner/test/planSTableTest.cpp
浏览文件 @
a0fcc9a2
...
@@ -19,7 +19,7 @@ using namespace std;
...
@@ -19,7 +19,7 @@ using namespace std;
class
PlanSuperTableTest
:
public
PlannerTestBase
{};
class
PlanSuperTableTest
:
public
PlannerTestBase
{};
TEST_F
(
PlanSuperTableTest
,
unionAll
)
{
TEST_F
(
PlanSuperTableTest
,
tbname
)
{
useDb
(
"root"
,
"test"
);
useDb
(
"root"
,
"test"
);
run
(
"select tbname from st1"
);
run
(
"select tbname from st1"
);
...
...
source/libs/transport/inc/transComm.h
浏览文件 @
a0fcc9a2
...
@@ -103,6 +103,9 @@ typedef void* queue[2];
...
@@ -103,6 +103,9 @@ typedef void* queue[2];
/* Return the structure holding the given element. */
/* Return the structure holding the given element. */
#define QUEUE_DATA(e, type, field) ((type*)((void*)((char*)(e)-offsetof(type, field))))
#define QUEUE_DATA(e, type, field) ((type*)((void*)((char*)(e)-offsetof(type, field))))
#define TRANS_RETRY_COUNT_LIMIT 10 // retry count limit
#define TRANS_RETRY_INTERVAL 5 // ms retry interval
typedef
struct
{
typedef
struct
{
SRpcInfo
*
pRpc
;
// associated SRpcInfo
SRpcInfo
*
pRpc
;
// associated SRpcInfo
SEpSet
epSet
;
// ip list provided by app
SEpSet
epSet
;
// ip list provided by app
...
@@ -137,14 +140,12 @@ typedef struct {
...
@@ -137,14 +140,12 @@ typedef struct {
int8_t
connType
;
// connection type cli/srv
int8_t
connType
;
// connection type cli/srv
int64_t
rid
;
// refId returned by taosAddRef
int64_t
rid
;
// refId returned by taosAddRef
int8_t
retryCount
;
STransCtx
appCtx
;
//
STransCtx
appCtx
;
//
STransMsg
*
pRsp
;
// for synchronous API
STransMsg
*
pRsp
;
// for synchronous API
tsem_t
*
pSem
;
// for synchronous API
tsem_t
*
pSem
;
// for synchronous API
int
hThrdIdx
;
int
hThrdIdx
;
char
*
ip
;
uint32_t
port
;
// SEpSet* pSet; // for synchronous API
}
STransConnCtx
;
}
STransConnCtx
;
#pragma pack(push, 1)
#pragma pack(push, 1)
...
@@ -215,8 +216,6 @@ void transBuildAuthHead(void* pMsg, int msgLen, void* pAuth, void* pKey);
...
@@ -215,8 +216,6 @@ void transBuildAuthHead(void* pMsg, int msgLen, void* pAuth, void* pKey);
bool
transCompressMsg
(
char
*
msg
,
int32_t
len
,
int32_t
*
flen
);
bool
transCompressMsg
(
char
*
msg
,
int32_t
len
,
int32_t
*
flen
);
bool
transDecompressMsg
(
char
*
msg
,
int32_t
len
,
int32_t
*
flen
);
bool
transDecompressMsg
(
char
*
msg
,
int32_t
len
,
int32_t
*
flen
);
void
transConnCtxDestroy
(
STransConnCtx
*
ctx
);
void
transFreeMsg
(
void
*
msg
);
void
transFreeMsg
(
void
*
msg
);
//
//
...
@@ -262,8 +261,8 @@ void transUnrefCliHandle(void* handle);
...
@@ -262,8 +261,8 @@ void transUnrefCliHandle(void* handle);
void
transReleaseCliHandle
(
void
*
handle
);
void
transReleaseCliHandle
(
void
*
handle
);
void
transReleaseSrvHandle
(
void
*
handle
);
void
transReleaseSrvHandle
(
void
*
handle
);
void
transSendRequest
(
void
*
shandle
,
const
char
*
ip
,
uint32_t
por
t
,
STransMsg
*
pMsg
,
STransCtx
*
pCtx
);
void
transSendRequest
(
void
*
shandle
,
const
SEpSet
*
pEpSe
t
,
STransMsg
*
pMsg
,
STransCtx
*
pCtx
);
void
transSendRecv
(
void
*
shandle
,
const
char
*
ip
,
uint32_t
por
t
,
STransMsg
*
pMsg
,
STransMsg
*
pRsp
);
void
transSendRecv
(
void
*
shandle
,
const
SEpSet
*
pEpSe
t
,
STransMsg
*
pMsg
,
STransMsg
*
pRsp
);
void
transSendResponse
(
const
STransMsg
*
msg
);
void
transSendResponse
(
const
STransMsg
*
msg
);
void
transRegisterMsg
(
const
STransMsg
*
msg
);
void
transRegisterMsg
(
const
STransMsg
*
msg
);
int
transGetConnInfo
(
void
*
thandle
,
STransHandleInfo
*
pInfo
);
int
transGetConnInfo
(
void
*
thandle
,
STransHandleInfo
*
pInfo
);
...
...
source/libs/transport/inc/transportInt.h
浏览文件 @
a0fcc9a2
...
@@ -62,8 +62,7 @@ typedef struct {
...
@@ -62,8 +62,7 @@ typedef struct {
char
ckey
[
TSDB_PASSWORD_LEN
];
// ciphering key
char
ckey
[
TSDB_PASSWORD_LEN
];
// ciphering key
void
(
*
cfp
)(
void
*
parent
,
SRpcMsg
*
,
SEpSet
*
);
void
(
*
cfp
)(
void
*
parent
,
SRpcMsg
*
,
SEpSet
*
);
int
(
*
afp
)(
void
*
parent
,
char
*
user
,
char
*
spi
,
char
*
encrypt
,
char
*
secret
,
char
*
ckey
);
bool
(
*
retry
)(
int32_t
code
);
int
(
*
retry
)(
void
*
parent
,
SRpcMsg
*
,
SEpSet
*
);
int32_t
refCount
;
int32_t
refCount
;
void
*
parent
;
void
*
parent
;
...
...
source/libs/transport/src/trans.c
浏览文件 @
a0fcc9a2
...
@@ -38,7 +38,6 @@ void* rpcOpen(const SRpcInit* pInit) {
...
@@ -38,7 +38,6 @@ void* rpcOpen(const SRpcInit* pInit) {
// register callback handle
// register callback handle
pRpc
->
cfp
=
pInit
->
cfp
;
pRpc
->
cfp
=
pInit
->
cfp
;
pRpc
->
afp
=
pInit
->
afp
;
pRpc
->
retry
=
pInit
->
rfp
;
pRpc
->
retry
=
pInit
->
rfp
;
if
(
pInit
->
connType
==
TAOS_CONN_SERVER
)
{
if
(
pInit
->
connType
==
TAOS_CONN_SERVER
)
{
...
@@ -116,19 +115,13 @@ int rpcReportProgress(void* pConn, char* pCont, int contLen) { return -1; }
...
@@ -116,19 +115,13 @@ int rpcReportProgress(void* pConn, char* pCont, int contLen) { return -1; }
void
rpcCancelRequest
(
int64_t
rid
)
{
return
;
}
void
rpcCancelRequest
(
int64_t
rid
)
{
return
;
}
void
rpcSendRequest
(
void
*
shandle
,
const
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
,
int64_t
*
pRid
)
{
void
rpcSendRequest
(
void
*
shandle
,
const
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
,
int64_t
*
pRid
)
{
char
*
ip
=
(
char
*
)(
pEpSet
->
eps
[
pEpSet
->
inUse
].
fqdn
);
transSendRequest
(
shandle
,
pEpSet
,
pMsg
,
NULL
);
uint32_t
port
=
pEpSet
->
eps
[
pEpSet
->
inUse
].
port
;
transSendRequest
(
shandle
,
ip
,
port
,
pMsg
,
NULL
);
}
}
void
rpcSendRequestWithCtx
(
void
*
shandle
,
const
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
,
int64_t
*
pRid
,
SRpcCtx
*
pCtx
)
{
void
rpcSendRequestWithCtx
(
void
*
shandle
,
const
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
,
int64_t
*
pRid
,
SRpcCtx
*
pCtx
)
{
char
*
ip
=
(
char
*
)(
pEpSet
->
eps
[
pEpSet
->
inUse
].
fqdn
);
transSendRequest
(
shandle
,
pEpSet
,
pMsg
,
pCtx
);
uint32_t
port
=
pEpSet
->
eps
[
pEpSet
->
inUse
].
port
;
transSendRequest
(
shandle
,
ip
,
port
,
pMsg
,
pCtx
);
}
}
void
rpcSendRecv
(
void
*
shandle
,
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
,
SRpcMsg
*
pRsp
)
{
void
rpcSendRecv
(
void
*
shandle
,
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
,
SRpcMsg
*
pRsp
)
{
char
*
ip
=
(
char
*
)(
pEpSet
->
eps
[
pEpSet
->
inUse
].
fqdn
);
transSendRecv
(
shandle
,
pEpSet
,
pMsg
,
pRsp
);
uint32_t
port
=
pEpSet
->
eps
[
pEpSet
->
inUse
].
port
;
transSendRecv
(
shandle
,
ip
,
port
,
pMsg
,
pRsp
);
}
}
void
rpcSendResponse
(
const
SRpcMsg
*
pMsg
)
{
transSendResponse
(
pMsg
);
}
void
rpcSendResponse
(
const
SRpcMsg
*
pMsg
)
{
transSendResponse
(
pMsg
);
}
...
...
source/libs/transport/src/transCli.c
浏览文件 @
a0fcc9a2
/*
/* * Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
*
* This program is free software: you can use, redistribute, and/or modify
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* it under the terms of the GNU Affero General Public License, version 3
...
@@ -97,7 +96,7 @@ static void cliSendCb(uv_write_t* req, int status);
...
@@ -97,7 +96,7 @@ static void cliSendCb(uv_write_t* req, int status);
static
void
cliConnCb
(
uv_connect_t
*
req
,
int
status
);
static
void
cliConnCb
(
uv_connect_t
*
req
,
int
status
);
static
void
cliAsyncCb
(
uv_async_t
*
handle
);
static
void
cliAsyncCb
(
uv_async_t
*
handle
);
static
void
cliAppCb
(
SCliConn
*
pConn
,
STrans
Msg
*
pMsg
);
static
int
cliAppCb
(
SCliConn
*
pConn
,
STransMsg
*
pResp
,
SCli
Msg
*
pMsg
);
static
SCliConn
*
cliCreateConn
(
SCliThrdObj
*
thrd
);
static
SCliConn
*
cliCreateConn
(
SCliThrdObj
*
thrd
);
static
void
cliDestroyConn
(
SCliConn
*
pConn
,
bool
clear
/*clear tcp handle or not*/
);
static
void
cliDestroyConn
(
SCliConn
*
pConn
,
bool
clear
/*clear tcp handle or not*/
);
...
@@ -227,6 +226,9 @@ static void cliWalkCb(uv_handle_t* handle, void* arg);
...
@@ -227,6 +226,9 @@ static void cliWalkCb(uv_handle_t* handle, void* arg);
#define REQUEST_PERSIS_HANDLE(msg) ((msg)->persistHandle == 1)
#define REQUEST_PERSIS_HANDLE(msg) ((msg)->persistHandle == 1)
#define REQUEST_RELEASE_HANDLE(cmsg) ((cmsg)->type == Release)
#define REQUEST_RELEASE_HANDLE(cmsg) ((cmsg)->type == Release)
#define EPSET_GET_INUSE_IP(epSet) ((epSet)->eps[(epSet)->inUse].fqdn)
#define EPSET_GET_INUSE_PORT(epSet) ((epSet)->eps[(epSet)->inUse].port)
static
void
*
cliWorkThread
(
void
*
arg
);
static
void
*
cliWorkThread
(
void
*
arg
);
bool
cliMaySendCachedMsg
(
SCliConn
*
conn
)
{
bool
cliMaySendCachedMsg
(
SCliConn
*
conn
)
{
...
@@ -311,14 +313,10 @@ void cliHandleResp(SCliConn* conn) {
...
@@ -311,14 +313,10 @@ void cliHandleResp(SCliConn* conn) {
return
;
return
;
}
}
if
(
pCtx
==
NULL
||
pCtx
->
pSem
==
NULL
)
{
int
ret
=
cliAppCb
(
conn
,
&
transMsg
,
pMsg
);
tTrace
(
"%s cli conn %p handle resp"
,
pTransInst
->
label
,
conn
);
if
(
ret
!=
0
)
{
cliAppCb
(
conn
,
&
transMsg
);
tTrace
(
"try to send req to next node"
);
//(pTransInst->cfp)(pTransInst->parent, &transMsg, NULL);
return
;
}
else
{
tTrace
(
"%s cli conn(sync) %p handle resp"
,
pTransInst
->
label
,
conn
);
memcpy
((
char
*
)
pCtx
->
pRsp
,
(
char
*
)
&
transMsg
,
sizeof
(
transMsg
));
tsem_post
(
pCtx
->
pSem
);
}
}
destroyCmsg
(
pMsg
);
destroyCmsg
(
pMsg
);
...
@@ -375,17 +373,15 @@ void cliHandleExcept(SCliConn* pConn) {
...
@@ -375,17 +373,15 @@ void cliHandleExcept(SCliConn* pConn) {
}
}
if
(
pCtx
==
NULL
||
pCtx
->
pSem
==
NULL
)
{
if
(
pCtx
==
NULL
||
pCtx
->
pSem
==
NULL
)
{
tTrace
(
"%s cli conn %p handle except"
,
pTransInst
->
label
,
pConn
);
if
(
transMsg
.
ahandle
==
NULL
)
{
if
(
transMsg
.
ahandle
==
NULL
)
{
once
=
true
;
once
=
true
;
continue
;
continue
;
}
}
cliAppCb
(
pConn
,
&
transMsg
);
}
//(pTransInst->cfp)(pTransInst->parent, &transMsg, NULL);
int
ret
=
cliAppCb
(
pConn
,
&
transMsg
,
pMsg
);
}
else
{
if
(
ret
!=
0
)
{
tTrace
(
"%s cli conn(sync) %p handle except"
,
pTransInst
->
label
,
pConn
);
tTrace
(
"try to send req to next node"
);
memcpy
((
char
*
)(
pCtx
->
pRsp
),
(
char
*
)(
&
transMsg
),
sizeof
(
transMsg
));
return
;
tsem_post
(
pCtx
->
pSem
);
}
}
destroyCmsg
(
pMsg
);
destroyCmsg
(
pMsg
);
tTrace
(
"%s cli conn %p start to destroy"
,
CONN_GET_INST_LABEL
(
pConn
),
pConn
);
tTrace
(
"%s cli conn %p start to destroy"
,
CONN_GET_INST_LABEL
(
pConn
),
pConn
);
...
@@ -695,7 +691,7 @@ SCliConn* cliGetConn(SCliMsg* pMsg, SCliThrdObj* pThrd) {
...
@@ -695,7 +691,7 @@ SCliConn* cliGetConn(SCliMsg* pMsg, SCliThrdObj* pThrd) {
}
}
}
else
{
}
else
{
STransConnCtx
*
pCtx
=
pMsg
->
ctx
;
STransConnCtx
*
pCtx
=
pMsg
->
ctx
;
conn
=
getConnFromPool
(
pThrd
->
pool
,
pCtx
->
ip
,
pCtx
->
port
);
conn
=
getConnFromPool
(
pThrd
->
pool
,
EPSET_GET_INUSE_IP
(
&
pCtx
->
epSet
),
EPSET_GET_INUSE_PORT
(
&
pCtx
->
epSet
)
);
if
(
conn
!=
NULL
)
{
if
(
conn
!=
NULL
)
{
tTrace
(
"%s cli conn %p get from conn pool"
,
CONN_GET_INST_LABEL
(
conn
),
conn
);
tTrace
(
"%s cli conn %p get from conn pool"
,
CONN_GET_INST_LABEL
(
conn
),
conn
);
}
else
{
}
else
{
...
@@ -719,10 +715,6 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrdObj* pThrd) {
...
@@ -719,10 +715,6 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrdObj* pThrd) {
transCtxMerge
(
&
conn
->
ctx
,
&
pCtx
->
appCtx
);
transCtxMerge
(
&
conn
->
ctx
,
&
pCtx
->
appCtx
);
transQueuePush
(
&
conn
->
cliMsgs
,
pMsg
);
transQueuePush
(
&
conn
->
cliMsgs
,
pMsg
);
// tTrace("%s cli conn %p queue msg size %d", ((STrans*)pThrd->pTransInst)->label, conn, 2);
// return;
//}
// transDestroyBuffer(&conn->readBuf);
cliSend
(
conn
);
cliSend
(
conn
);
}
else
{
}
else
{
conn
=
cliCreateConn
(
pThrd
);
conn
=
cliCreateConn
(
pThrd
);
...
@@ -730,8 +722,8 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrdObj* pThrd) {
...
@@ -730,8 +722,8 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrdObj* pThrd) {
transQueuePush
(
&
conn
->
cliMsgs
,
pMsg
);
transQueuePush
(
&
conn
->
cliMsgs
,
pMsg
);
conn
->
hThrdIdx
=
pCtx
->
hThrdIdx
;
conn
->
hThrdIdx
=
pCtx
->
hThrdIdx
;
conn
->
ip
=
strdup
(
pMsg
->
ctx
->
ip
);
conn
->
ip
=
strdup
(
EPSET_GET_INUSE_IP
(
&
pCtx
->
epSet
)
);
conn
->
port
=
pMsg
->
ctx
->
port
;
conn
->
port
=
EPSET_GET_INUSE_PORT
(
&
pCtx
->
epSet
)
;
int
ret
=
transSetConnOption
((
uv_tcp_t
*
)
conn
->
stream
);
int
ret
=
transSetConnOption
((
uv_tcp_t
*
)
conn
->
stream
);
if
(
ret
)
{
if
(
ret
)
{
...
@@ -743,10 +735,14 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrdObj* pThrd) {
...
@@ -743,10 +735,14 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrdObj* pThrd) {
addr
.
sin_family
=
AF_INET
;
addr
.
sin_family
=
AF_INET
;
addr
.
sin_addr
.
s_addr
=
taosGetIpv4FromFqdn
(
conn
->
ip
);
addr
.
sin_addr
.
s_addr
=
taosGetIpv4FromFqdn
(
conn
->
ip
);
addr
.
sin_port
=
(
uint16_t
)
htons
((
uint16_t
)
conn
->
port
);
addr
.
sin_port
=
(
uint16_t
)
htons
((
uint16_t
)
conn
->
port
);
// uv_ip4_addr(pMsg->ctx->ip, pMsg->ctx->port, &addr);
tTrace
(
"%s cli conn %p try to connect to %s:%d"
,
pTransInst
->
label
,
conn
,
conn
->
ip
,
conn
->
port
);
// handle error in callback if fail to connect
ret
=
uv_tcp_connect
(
&
conn
->
connReq
,
(
uv_tcp_t
*
)(
conn
->
stream
),
(
const
struct
sockaddr
*
)
&
addr
,
cliConnCb
);
tTrace
(
"%s cli conn %p try to connect to %s:%d"
,
pTransInst
->
label
,
conn
,
pMsg
->
ctx
->
ip
,
pMsg
->
ctx
->
port
);
if
(
ret
!=
0
)
{
uv_tcp_connect
(
&
conn
->
connReq
,
(
uv_tcp_t
*
)(
conn
->
stream
),
(
const
struct
sockaddr
*
)
&
addr
,
cliConnCb
);
tTrace
(
"%s cli conn %p failed to connect to %s:%d, reason: %s"
,
pTransInst
->
label
,
conn
,
conn
->
ip
,
conn
->
port
,
uv_err_name
(
ret
));
cliHandleExcept
(
conn
);
return
;
}
}
}
}
}
static
void
cliAsyncCb
(
uv_async_t
*
handle
)
{
static
void
cliAsyncCb
(
uv_async_t
*
handle
)
{
...
@@ -856,12 +852,10 @@ static void destroyThrdObj(SCliThrdObj* pThrd) {
...
@@ -856,12 +852,10 @@ static void destroyThrdObj(SCliThrdObj* pThrd) {
}
}
static
void
transDestroyConnCtx
(
STransConnCtx
*
ctx
)
{
static
void
transDestroyConnCtx
(
STransConnCtx
*
ctx
)
{
if
(
ctx
!=
NULL
)
{
//
taosMemoryFree
(
ctx
->
ip
);
}
taosMemoryFree
(
ctx
);
taosMemoryFree
(
ctx
);
}
}
//
void
cliSendQuit
(
SCliThrdObj
*
thrd
)
{
void
cliSendQuit
(
SCliThrdObj
*
thrd
)
{
// cli can stop gracefully
// cli can stop gracefully
SCliMsg
*
msg
=
taosMemoryCalloc
(
1
,
sizeof
(
SCliMsg
));
SCliMsg
*
msg
=
taosMemoryCalloc
(
1
,
sizeof
(
SCliMsg
));
...
@@ -881,17 +875,58 @@ int cliRBChoseIdx(STrans* pTransInst) {
...
@@ -881,17 +875,58 @@ int cliRBChoseIdx(STrans* pTransInst) {
}
}
return
index
%
pTransInst
->
numOfThreads
;
return
index
%
pTransInst
->
numOfThreads
;
}
}
void
cliAppCb
(
SCliConn
*
pConn
,
STransMsg
*
trans
Msg
)
{
int
cliAppCb
(
SCliConn
*
pConn
,
STransMsg
*
pResp
,
SCliMsg
*
p
Msg
)
{
SCliThrdObj
*
pThrd
=
pConn
->
hostThrd
;
SCliThrdObj
*
pThrd
=
pConn
->
hostThrd
;
STrans
*
pTransInst
=
pThrd
->
pTransInst
;
STrans
*
pTransInst
=
pThrd
->
pTransInst
;
if
(
transMsg
->
code
==
TSDB_CODE_RPC_REDIRECT
&&
pTransInst
->
retry
!=
NULL
)
{
if
(
pMsg
==
NULL
||
pMsg
->
ctx
==
NULL
)
{
tTrace
(
"%s cli conn %p handle resp"
,
pTransInst
->
label
,
pConn
);
pTransInst
->
cfp
(
pTransInst
->
parent
,
pResp
,
NULL
);
return
0
;
}
STransConnCtx
*
pCtx
=
pMsg
->
ctx
;
SEpSet
*
pEpSet
=
&
pCtx
->
epSet
;
/*
* upper layer handle retry if code equal TSDB_CODE_RPC_NETWORK_UNAVAIL
*/
tmsg_t
msgType
=
pCtx
->
msgType
;
if
((
pTransInst
->
retry
!=
NULL
&&
(
pTransInst
->
retry
(
pResp
->
code
)))
||
((
pResp
->
code
==
TSDB_CODE_RPC_NETWORK_UNAVAIL
)
&&
msgType
==
TDMT_MND_CONNECT
))
{
pCtx
->
retryCount
+=
1
;
pMsg
->
st
=
taosGetTimestampUs
();
if
(
msgType
==
TDMT_MND_CONNECT
&&
pResp
->
code
==
TSDB_CODE_RPC_NETWORK_UNAVAIL
)
{
if
(
pCtx
->
retryCount
<
pEpSet
->
numOfEps
)
{
pEpSet
->
inUse
=
(
++
pEpSet
->
inUse
)
%
pEpSet
->
numOfEps
;
cliHandleReq
(
pMsg
,
pThrd
);
cliDestroy
((
uv_handle_t
*
)
pConn
->
stream
);
return
-
1
;
}
}
else
if
(
pCtx
->
retryCount
<
TRANS_RETRY_COUNT_LIMIT
)
{
if
(
pResp
->
contLen
==
0
)
{
pEpSet
->
inUse
=
(
pEpSet
->
inUse
++
)
%
pEpSet
->
numOfEps
;
}
else
{
SMEpSet
emsg
=
{
0
};
SMEpSet
emsg
=
{
0
};
tDeserializeSMEpSet
(
transMsg
->
pCont
,
transMsg
->
contLen
,
&
emsg
);
tDeserializeSMEpSet
(
pResp
->
pCont
,
pResp
->
contLen
,
&
emsg
);
pTransInst
->
retry
(
pTransInst
,
transMsg
,
&
(
emsg
.
epSet
));
pCtx
->
epSet
=
emsg
.
epSet
;
}
cliHandleReq
(
pMsg
,
pThrd
);
// release pConn
addConnToPool
(
pThrd
,
pConn
);
return
-
1
;
}
}
if
(
pCtx
->
pSem
!=
NULL
)
{
tTrace
(
"%s cli conn %p handle resp"
,
pTransInst
->
label
,
pConn
);
memcpy
((
char
*
)
pCtx
->
pRsp
,
(
char
*
)
pResp
,
sizeof
(
*
pResp
));
tsem_post
(
pCtx
->
pSem
);
}
else
{
}
else
{
pTransInst
->
cfp
(
pTransInst
->
parent
,
transMsg
,
NULL
);
tTrace
(
"%s cli conn %p handle resp"
,
pTransInst
->
label
,
pConn
);
pTransInst
->
cfp
(
pTransInst
->
parent
,
pResp
,
pEpSet
);
}
}
return
0
;
}
}
void
transCloseClient
(
void
*
arg
)
{
void
transCloseClient
(
void
*
arg
)
{
...
@@ -934,18 +969,17 @@ void transReleaseCliHandle(void* handle) {
...
@@ -934,18 +969,17 @@ void transReleaseCliHandle(void* handle) {
transSendAsync
(
thrd
->
asyncPool
,
&
cmsg
->
q
);
transSendAsync
(
thrd
->
asyncPool
,
&
cmsg
->
q
);
}
}
void
transSendRequest
(
void
*
shandle
,
const
char
*
ip
,
uint32_t
port
,
STransMsg
*
pMsg
,
STransCtx
*
ctx
)
{
void
transSendRequest
(
void
*
shandle
,
const
SEpSet
*
pEpSet
,
STransMsg
*
pReq
,
STransCtx
*
ctx
)
{
STrans
*
pTransInst
=
(
STrans
*
)
shandle
;
STrans
*
pTransInst
=
(
STrans
*
)
shandle
;
int
index
=
CONN_HOST_THREAD_INDEX
((
SCliConn
*
)
p
Msg
->
handle
);
int
index
=
CONN_HOST_THREAD_INDEX
((
SCliConn
*
)
p
Req
->
handle
);
if
(
index
==
-
1
)
{
if
(
index
==
-
1
)
{
index
=
cliRBChoseIdx
(
pTransInst
);
index
=
cliRBChoseIdx
(
pTransInst
);
}
}
STransConnCtx
*
pCtx
=
taosMemoryCalloc
(
1
,
sizeof
(
STransConnCtx
));
STransConnCtx
*
pCtx
=
taosMemoryCalloc
(
1
,
sizeof
(
STransConnCtx
));
pCtx
->
ahandle
=
pMsg
->
ahandle
;
pCtx
->
epSet
=
*
pEpSet
;
pCtx
->
msgType
=
pMsg
->
msgType
;
pCtx
->
ahandle
=
pReq
->
ahandle
;
pCtx
->
ip
=
strdup
(
ip
);
pCtx
->
msgType
=
pReq
->
msgType
;
pCtx
->
port
=
port
;
pCtx
->
hThrdIdx
=
index
;
pCtx
->
hThrdIdx
=
index
;
if
(
ctx
!=
NULL
)
{
if
(
ctx
!=
NULL
)
{
...
@@ -955,17 +989,18 @@ void transSendRequest(void* shandle, const char* ip, uint32_t port, STransMsg* p
...
@@ -955,17 +989,18 @@ void transSendRequest(void* shandle, const char* ip, uint32_t port, STransMsg* p
SCliMsg
*
cliMsg
=
taosMemoryCalloc
(
1
,
sizeof
(
SCliMsg
));
SCliMsg
*
cliMsg
=
taosMemoryCalloc
(
1
,
sizeof
(
SCliMsg
));
cliMsg
->
ctx
=
pCtx
;
cliMsg
->
ctx
=
pCtx
;
cliMsg
->
msg
=
*
p
Msg
;
cliMsg
->
msg
=
*
p
Req
;
cliMsg
->
st
=
taosGetTimestampUs
();
cliMsg
->
st
=
taosGetTimestampUs
();
cliMsg
->
type
=
Normal
;
cliMsg
->
type
=
Normal
;
SCliThrdObj
*
thrd
=
((
SCliObj
*
)
pTransInst
->
tcphandle
)
->
pThreadObj
[
index
];
SCliThrdObj
*
thrd
=
((
SCliObj
*
)
pTransInst
->
tcphandle
)
->
pThreadObj
[
index
];
tDebug
(
"send request at thread:%d %p, dst: %s:%d, app:%p"
,
index
,
pMsg
,
ip
,
port
,
pMsg
->
ahandle
);
tDebug
(
"send request at thread:%d %p, dst: %s:%d, app:%p"
,
index
,
pReq
,
EPSET_GET_INUSE_IP
(
&
pCtx
->
epSet
),
EPSET_GET_INUSE_PORT
(
&
pCtx
->
epSet
),
pReq
->
ahandle
);
ASSERT
(
transSendAsync
(
thrd
->
asyncPool
,
&
(
cliMsg
->
q
))
==
0
);
ASSERT
(
transSendAsync
(
thrd
->
asyncPool
,
&
(
cliMsg
->
q
))
==
0
);
}
}
void
transSendRecv
(
void
*
shandle
,
const
char
*
ip
,
uint32_t
por
t
,
STransMsg
*
pReq
,
STransMsg
*
pRsp
)
{
void
transSendRecv
(
void
*
shandle
,
const
SEpSet
*
pEpSe
t
,
STransMsg
*
pReq
,
STransMsg
*
pRsp
)
{
STrans
*
pTransInst
=
(
STrans
*
)
shandle
;
STrans
*
pTransInst
=
(
STrans
*
)
shandle
;
int
index
=
CONN_HOST_THREAD_INDEX
(
pReq
->
handle
);
int
index
=
CONN_HOST_THREAD_INDEX
(
pReq
->
handle
);
if
(
index
==
-
1
)
{
if
(
index
==
-
1
)
{
...
@@ -973,10 +1008,9 @@ void transSendRecv(void* shandle, const char* ip, uint32_t port, STransMsg* pReq
...
@@ -973,10 +1008,9 @@ void transSendRecv(void* shandle, const char* ip, uint32_t port, STransMsg* pReq
}
}
STransConnCtx
*
pCtx
=
taosMemoryCalloc
(
1
,
sizeof
(
STransConnCtx
));
STransConnCtx
*
pCtx
=
taosMemoryCalloc
(
1
,
sizeof
(
STransConnCtx
));
pCtx
->
epSet
=
*
pEpSet
;
pCtx
->
ahandle
=
pReq
->
ahandle
;
pCtx
->
ahandle
=
pReq
->
ahandle
;
pCtx
->
msgType
=
pReq
->
msgType
;
pCtx
->
msgType
=
pReq
->
msgType
;
pCtx
->
ip
=
strdup
(
ip
);
pCtx
->
port
=
port
;
pCtx
->
hThrdIdx
=
index
;
pCtx
->
hThrdIdx
=
index
;
pCtx
->
pSem
=
taosMemoryCalloc
(
1
,
sizeof
(
tsem_t
));
pCtx
->
pSem
=
taosMemoryCalloc
(
1
,
sizeof
(
tsem_t
));
pCtx
->
pRsp
=
pRsp
;
pCtx
->
pRsp
=
pRsp
;
...
@@ -989,6 +1023,9 @@ void transSendRecv(void* shandle, const char* ip, uint32_t port, STransMsg* pReq
...
@@ -989,6 +1023,9 @@ void transSendRecv(void* shandle, const char* ip, uint32_t port, STransMsg* pReq
cliMsg
->
type
=
Normal
;
cliMsg
->
type
=
Normal
;
SCliThrdObj
*
thrd
=
((
SCliObj
*
)
pTransInst
->
tcphandle
)
->
pThreadObj
[
index
];
SCliThrdObj
*
thrd
=
((
SCliObj
*
)
pTransInst
->
tcphandle
)
->
pThreadObj
[
index
];
tDebug
(
"send request at thread:%d %p, dst: %s:%d, app:%p"
,
index
,
pReq
,
EPSET_GET_INUSE_IP
(
&
pCtx
->
epSet
),
EPSET_GET_INUSE_PORT
(
&
pCtx
->
epSet
),
pReq
->
ahandle
);
transSendAsync
(
thrd
->
asyncPool
,
&
(
cliMsg
->
q
));
transSendAsync
(
thrd
->
asyncPool
,
&
(
cliMsg
->
q
));
tsem_t
*
pSem
=
pCtx
->
pSem
;
tsem_t
*
pSem
=
pCtx
->
pSem
;
tsem_wait
(
pSem
);
tsem_wait
(
pSem
);
...
...
source/libs/transport/src/transComm.c
浏览文件 @
a0fcc9a2
...
@@ -93,11 +93,6 @@ bool transDecompressMsg(char* msg, int32_t len, int32_t* flen) {
...
@@ -93,11 +93,6 @@ bool transDecompressMsg(char* msg, int32_t len, int32_t* flen) {
return
false
;
return
false
;
}
}
void
transConnCtxDestroy
(
STransConnCtx
*
ctx
)
{
taosMemoryFree
(
ctx
->
ip
);
taosMemoryFree
(
ctx
);
}
void
transFreeMsg
(
void
*
msg
)
{
void
transFreeMsg
(
void
*
msg
)
{
if
(
msg
==
NULL
)
{
if
(
msg
==
NULL
)
{
return
;
return
;
...
@@ -363,10 +358,4 @@ void transQueueDestroy(STransQueue* queue) {
...
@@ -363,10 +358,4 @@ void transQueueDestroy(STransQueue* queue) {
transQueueClear
(
queue
);
transQueueClear
(
queue
);
taosArrayDestroy
(
queue
->
q
);
taosArrayDestroy
(
queue
->
q
);
}
}
// int32_t transGetExHandle() {
// static
//}
// void transThreadOnce() {
// taosThreadOnce(&transModuleInit, );
//}
#endif
#endif
source/libs/transport/src/transSrv.c
浏览文件 @
a0fcc9a2
...
@@ -802,7 +802,6 @@ void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads,
...
@@ -802,7 +802,6 @@ void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads,
taosThreadOnce
(
&
transModuleInit
,
uvInitExHandleMgt
);
taosThreadOnce
(
&
transModuleInit
,
uvInitExHandleMgt
);
transSrvInst
++
;
transSrvInst
++
;
// uvOpenExHandleMgt(10000);
for
(
int
i
=
0
;
i
<
srv
->
numOfThreads
;
i
++
)
{
for
(
int
i
=
0
;
i
<
srv
->
numOfThreads
;
i
++
)
{
SWorkThrdObj
*
thrd
=
(
SWorkThrdObj
*
)
taosMemoryCalloc
(
1
,
sizeof
(
SWorkThrdObj
));
SWorkThrdObj
*
thrd
=
(
SWorkThrdObj
*
)
taosMemoryCalloc
(
1
,
sizeof
(
SWorkThrdObj
));
...
@@ -831,6 +830,7 @@ void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads,
...
@@ -831,6 +830,7 @@ void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads,
}
else
{
}
else
{
// TODO: clear all other resource later
// TODO: clear all other resource later
tError
(
"failed to create worker-thread %d"
,
i
);
tError
(
"failed to create worker-thread %d"
,
i
);
goto
End
;
}
}
}
}
if
(
false
==
addHandleToAcceptloop
(
srv
))
{
if
(
false
==
addHandleToAcceptloop
(
srv
))
{
...
@@ -840,6 +840,8 @@ void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads,
...
@@ -840,6 +840,8 @@ void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads,
if
(
err
==
0
)
{
if
(
err
==
0
)
{
tDebug
(
"success to create accept-thread"
);
tDebug
(
"success to create accept-thread"
);
}
else
{
}
else
{
tError
(
"failed to create accept-thread"
);
goto
End
;
// clear all resource later
// clear all resource later
}
}
...
@@ -1078,6 +1080,7 @@ void transRegisterMsg(const STransMsg* msg) {
...
@@ -1078,6 +1080,7 @@ void transRegisterMsg(const STransMsg* msg) {
transSendAsync
(
pThrd
->
asyncPool
,
&
srvMsg
->
q
);
transSendAsync
(
pThrd
->
asyncPool
,
&
srvMsg
->
q
);
uvReleaseExHandle
(
refId
);
uvReleaseExHandle
(
refId
);
return
;
return
;
_return1:
_return1:
tTrace
(
"server handle %p failed to send to register brokenlink"
,
exh
);
tTrace
(
"server handle %p failed to send to register brokenlink"
,
exh
);
rpcFreeCont
(
msg
->
pCont
);
rpcFreeCont
(
msg
->
pCont
);
...
...
source/os/src/osMemory.c
浏览文件 @
a0fcc9a2
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
#ifdef USE_TD_MEMORY
#ifdef USE_TD_MEMORY
#define TD_MEMORY_SYMBOL ('T'
<<24|'A'<<16|'O'<<8|
'S')
#define TD_MEMORY_SYMBOL ('T'
<< 24 | 'A' << 16 | 'O' << 8 |
'S')
#define TD_MEMORY_STACK_TRACE_DEPTH 10
#define TD_MEMORY_STACK_TRACE_DEPTH 10
...
@@ -36,11 +36,11 @@ typedef struct TdMemoryInfo {
...
@@ -36,11 +36,11 @@ typedef struct TdMemoryInfo {
// static TdMemoryInfoPtr GlobalMemoryPtr = NULL;
// static TdMemoryInfoPtr GlobalMemoryPtr = NULL;
#ifdef WINDOWS
#ifdef WINDOWS
#define tstrdup(str) _strdup(str)
#define tstrdup(str) _strdup(str)
#else
#else
#define tstrdup(str) strdup(str)
#define tstrdup(str) strdup(str)
#include<execinfo.h>
#include
<execinfo.h>
#define STACKCALL __attribute__((regparm(1), noinline))
#define STACKCALL __attribute__((regparm(1), noinline))
void
**
STACKCALL
taosGetEbp
(
void
)
{
void
**
STACKCALL
taosGetEbp
(
void
)
{
...
@@ -89,9 +89,9 @@ void *taosMemoryMalloc(int32_t size) {
...
@@ -89,9 +89,9 @@ void *taosMemoryMalloc(int32_t size) {
TdMemoryInfoPtr
pTdMemoryInfo
=
(
TdMemoryInfoPtr
)
tmp
;
TdMemoryInfoPtr
pTdMemoryInfo
=
(
TdMemoryInfoPtr
)
tmp
;
pTdMemoryInfo
->
memorySize
=
size
;
pTdMemoryInfo
->
memorySize
=
size
;
pTdMemoryInfo
->
symbol
=
TD_MEMORY_SYMBOL
;
pTdMemoryInfo
->
symbol
=
TD_MEMORY_SYMBOL
;
taosBackTrace
(
pTdMemoryInfo
->
stackTrace
,
TD_MEMORY_STACK_TRACE_DEPTH
);
taosBackTrace
(
pTdMemoryInfo
->
stackTrace
,
TD_MEMORY_STACK_TRACE_DEPTH
);
return
(
char
*
)
tmp
+
sizeof
(
TdMemoryInfo
);
return
(
char
*
)
tmp
+
sizeof
(
TdMemoryInfo
);
#else
#else
return
malloc
(
size
);
return
malloc
(
size
);
#endif
#endif
...
@@ -106,9 +106,9 @@ void *taosMemoryCalloc(int32_t num, int32_t size) {
...
@@ -106,9 +106,9 @@ void *taosMemoryCalloc(int32_t num, int32_t size) {
TdMemoryInfoPtr
pTdMemoryInfo
=
(
TdMemoryInfoPtr
)
tmp
;
TdMemoryInfoPtr
pTdMemoryInfo
=
(
TdMemoryInfoPtr
)
tmp
;
pTdMemoryInfo
->
memorySize
=
memorySize
;
pTdMemoryInfo
->
memorySize
=
memorySize
;
pTdMemoryInfo
->
symbol
=
TD_MEMORY_SYMBOL
;
pTdMemoryInfo
->
symbol
=
TD_MEMORY_SYMBOL
;
taosBackTrace
(
pTdMemoryInfo
->
stackTrace
,
TD_MEMORY_STACK_TRACE_DEPTH
);
taosBackTrace
(
pTdMemoryInfo
->
stackTrace
,
TD_MEMORY_STACK_TRACE_DEPTH
);
return
(
char
*
)
tmp
+
sizeof
(
TdMemoryInfo
);
return
(
char
*
)
tmp
+
sizeof
(
TdMemoryInfo
);
#else
#else
return
calloc
(
num
,
size
);
return
calloc
(
num
,
size
);
#endif
#endif
...
@@ -118,7 +118,7 @@ void *taosMemoryRealloc(void *ptr, int32_t size) {
...
@@ -118,7 +118,7 @@ void *taosMemoryRealloc(void *ptr, int32_t size) {
#ifdef USE_TD_MEMORY
#ifdef USE_TD_MEMORY
if
(
ptr
==
NULL
)
return
taosMemoryMalloc
(
size
);
if
(
ptr
==
NULL
)
return
taosMemoryMalloc
(
size
);
TdMemoryInfoPtr
pTdMemoryInfo
=
(
TdMemoryInfoPtr
)((
char
*
)
ptr
-
sizeof
(
TdMemoryInfo
));
TdMemoryInfoPtr
pTdMemoryInfo
=
(
TdMemoryInfoPtr
)((
char
*
)
ptr
-
sizeof
(
TdMemoryInfo
));
assert
(
pTdMemoryInfo
->
symbol
==
TD_MEMORY_SYMBOL
);
assert
(
pTdMemoryInfo
->
symbol
==
TD_MEMORY_SYMBOL
);
TdMemoryInfo
tdMemoryInfo
;
TdMemoryInfo
tdMemoryInfo
;
...
@@ -130,7 +130,7 @@ void *taosMemoryRealloc(void *ptr, int32_t size) {
...
@@ -130,7 +130,7 @@ void *taosMemoryRealloc(void *ptr, int32_t size) {
memcpy
(
tmp
,
&
tdMemoryInfo
,
sizeof
(
TdMemoryInfo
));
memcpy
(
tmp
,
&
tdMemoryInfo
,
sizeof
(
TdMemoryInfo
));
((
TdMemoryInfoPtr
)
tmp
)
->
memorySize
=
size
;
((
TdMemoryInfoPtr
)
tmp
)
->
memorySize
=
size
;
return
(
char
*
)
tmp
+
sizeof
(
TdMemoryInfo
);
return
(
char
*
)
tmp
+
sizeof
(
TdMemoryInfo
);
#else
#else
return
realloc
(
ptr
,
size
);
return
realloc
(
ptr
,
size
);
#endif
#endif
...
@@ -140,28 +140,25 @@ void *taosMemoryStrDup(void *ptr) {
...
@@ -140,28 +140,25 @@ void *taosMemoryStrDup(void *ptr) {
#ifdef USE_TD_MEMORY
#ifdef USE_TD_MEMORY
if
(
ptr
==
NULL
)
return
NULL
;
if
(
ptr
==
NULL
)
return
NULL
;
TdMemoryInfoPtr
pTdMemoryInfo
=
(
TdMemoryInfoPtr
)((
char
*
)
ptr
-
sizeof
(
TdMemoryInfo
));
TdMemoryInfoPtr
pTdMemoryInfo
=
(
TdMemoryInfoPtr
)((
char
*
)
ptr
-
sizeof
(
TdMemoryInfo
));
assert
(
pTdMemoryInfo
->
symbol
==
TD_MEMORY_SYMBOL
);
assert
(
pTdMemoryInfo
->
symbol
==
TD_MEMORY_SYMBOL
);
void
*
tmp
=
tstrdup
((
const
char
*
)
pTdMemoryInfo
);
void
*
tmp
=
tstrdup
((
const
char
*
)
pTdMemoryInfo
);
if
(
tmp
==
NULL
)
return
NULL
;
if
(
tmp
==
NULL
)
return
NULL
;
memcpy
(
tmp
,
pTdMemoryInfo
,
sizeof
(
TdMemoryInfo
));
memcpy
(
tmp
,
pTdMemoryInfo
,
sizeof
(
TdMemoryInfo
));
taosBackTrace
(((
TdMemoryInfoPtr
)
tmp
)
->
stackTrace
,
TD_MEMORY_STACK_TRACE_DEPTH
);
taosBackTrace
(((
TdMemoryInfoPtr
)
tmp
)
->
stackTrace
,
TD_MEMORY_STACK_TRACE_DEPTH
);
return
(
char
*
)
tmp
+
sizeof
(
TdMemoryInfo
);
return
(
char
*
)
tmp
+
sizeof
(
TdMemoryInfo
);
#else
#else
return
tstrdup
((
const
char
*
)
ptr
);
return
tstrdup
((
const
char
*
)
ptr
);
#endif
#endif
}
}
void
taosMemoryFree
(
void
*
ptr
)
{
void
taosMemoryFree
(
void
*
ptr
)
{
if
(
ptr
==
NULL
)
return
;
#ifdef USE_TD_MEMORY
#ifdef USE_TD_MEMORY
TdMemoryInfoPtr
pTdMemoryInfo
=
(
TdMemoryInfoPtr
)((
char
*
)
ptr
-
sizeof
(
TdMemoryInfo
));
TdMemoryInfoPtr
pTdMemoryInfo
=
(
TdMemoryInfoPtr
)((
char
*
)
ptr
-
sizeof
(
TdMemoryInfo
));
if
(
pTdMemoryInfo
->
symbol
==
TD_MEMORY_SYMBOL
)
{
if
(
pTdMemoryInfo
->
symbol
==
TD_MEMORY_SYMBOL
)
{
pTdMemoryInfo
->
memorySize
=
0
;
pTdMemoryInfo
->
memorySize
=
0
;
// memset(pTdMemoryInfo, 0, sizeof(TdMemoryInfo));
// memset(pTdMemoryInfo, 0, sizeof(TdMemoryInfo));
free
(
pTdMemoryInfo
);
free
(
pTdMemoryInfo
);
...
@@ -177,7 +174,7 @@ int32_t taosMemorySize(void *ptr) {
...
@@ -177,7 +174,7 @@ int32_t taosMemorySize(void *ptr) {
if
(
ptr
==
NULL
)
return
0
;
if
(
ptr
==
NULL
)
return
0
;
#ifdef USE_TD_MEMORY
#ifdef USE_TD_MEMORY
TdMemoryInfoPtr
pTdMemoryInfo
=
(
TdMemoryInfoPtr
)((
char
*
)
ptr
-
sizeof
(
TdMemoryInfo
));
TdMemoryInfoPtr
pTdMemoryInfo
=
(
TdMemoryInfoPtr
)((
char
*
)
ptr
-
sizeof
(
TdMemoryInfo
));
assert
(
pTdMemoryInfo
->
symbol
==
TD_MEMORY_SYMBOL
);
assert
(
pTdMemoryInfo
->
symbol
==
TD_MEMORY_SYMBOL
);
return
pTdMemoryInfo
->
memorySize
;
return
pTdMemoryInfo
->
memorySize
;
...
...
tests/script/jenkins/basic.txt
浏览文件 @
a0fcc9a2
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
./test.sh -f tsim/db/basic6.sim
./test.sh -f tsim/db/basic6.sim
./test.sh -f tsim/db/basic7.sim
./test.sh -f tsim/db/basic7.sim
./test.sh -f tsim/db/error1.sim
./test.sh -f tsim/db/error1.sim
./test.sh -f tsim/db/taosdlog.sim
# ---- dnode
# ---- dnode
./test.sh -f tsim/dnode/basic1.sim
./test.sh -f tsim/dnode/basic1.sim
...
...
tests/script/sh/deploy.sh
浏览文件 @
a0fcc9a2
...
@@ -128,6 +128,7 @@ echo "debugFlag 0" >> $TAOS_CFG
...
@@ -128,6 +128,7 @@ echo "debugFlag 0" >> $TAOS_CFG
echo
"mDebugFlag 143"
>>
$TAOS_CFG
echo
"mDebugFlag 143"
>>
$TAOS_CFG
echo
"dDebugFlag 143"
>>
$TAOS_CFG
echo
"dDebugFlag 143"
>>
$TAOS_CFG
echo
"vDebugFlag 143"
>>
$TAOS_CFG
echo
"vDebugFlag 143"
>>
$TAOS_CFG
echo
"tqDebugFlag 143"
>>
$TAOS_CFG
echo
"tsdbDebugFlag 143"
>>
$TAOS_CFG
echo
"tsdbDebugFlag 143"
>>
$TAOS_CFG
echo
"cDebugFlag 143"
>>
$TAOS_CFG
echo
"cDebugFlag 143"
>>
$TAOS_CFG
echo
"jniDebugFlag 143"
>>
$TAOS_CFG
echo
"jniDebugFlag 143"
>>
$TAOS_CFG
...
...
tests/script/tsim/db/alter_option.sim
浏览文件 @
a0fcc9a2
...
@@ -126,6 +126,49 @@ if $data16_db != ns then # precision
...
@@ -126,6 +126,49 @@ if $data16_db != ns then # precision
return -1
return -1
endi
endi
sleep 3000
sql show db.vgroups
if $data[0][4] == LEADER then
if $data[0][6] != FOLLOWER then
return -1
endi
if $data[0][8] != FOLLOWER then
return -1
endi
endi
if $data[0][6] == LEADER then
if $data[0][4] != FOLLOWER then
return -1
endi
if $data[0][8] != FOLLOWER then
return -1
endi
endi
if $data[0][8] == LEADER then
if $data[0][4] != FOLLOWER then
return -1
endi
if $data[0][6] != FOLLOWER then
return -1
endi
endi
if $data[0][4] != LEADER then
if $data[0][4] != FOLLOWER then
return -1
endi
endi
if $data[0][6] != LEADER then
if $data[0][6] != FOLLOWER then
return -1
endi
endi
if $data[0][8] != LEADER then
if $data[0][8] != FOLLOWER then
return -1
endi
endi
print ============== not support modify options: name, create_time, vgroups, ntables
print ============== not support modify options: name, create_time, vgroups, ntables
sql_error alter database db name dba
sql_error alter database db name dba
sql_error alter database db create_time "2022-03-03 15:08:13.329"
sql_error alter database db create_time "2022-03-03 15:08:13.329"
...
...
tests/script/tsim/db/taosdlog.sim
0 → 100644
浏览文件 @
a0fcc9a2
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system rm -rf ../../sim/dnode1/log
system sh/exec.sh -n dnode1 -s start
sql connect
print =============== create database
sql create database d1 vgroups 2
sql show databases
if $rows != 3 then
return -1
endi
print =============== restart
system sh/exec.sh -n dnode1 -s stop -x SIGKILL
sleep 2000
system rm -rf ../../sim/dnode1/log
system sh/exec.sh -n dnode1 -s start
sleep 2000
print =============== show databases
sql create database d2 vgroups 6
sql show databases
if $rows != 4 then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
tests/system-test/0-others/taosdlog.py
0 → 100644
浏览文件 @
a0fcc9a2
import
taos
import
sys
import
time
import
os
from
util.log
import
*
from
util.sql
import
*
from
util.cases
import
*
from
util.dnodes
import
*
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
f
"start to excute
{
__file__
}
"
)
tdSql
.
init
(
conn
.
cursor
())
def
getBuildPath
(
self
):
selfPath
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
if
(
"community"
in
selfPath
):
projPath
=
selfPath
[:
selfPath
.
find
(
"community"
)]
else
:
projPath
=
selfPath
[:
selfPath
.
find
(
"tests"
)]
for
root
,
dirs
,
files
in
os
.
walk
(
projPath
):
if
(
"taosd"
in
files
):
rootRealPath
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
root
))
if
(
"packaging"
not
in
rootRealPath
):
buildPath
=
root
[:
len
(
root
)
-
len
(
"/build/bin"
)]
break
return
buildPath
def
run
(
self
):
# sourcery skip: extract-duplicate-method, remove-redundant-fstring
tdSql
.
prepare
()
# time.sleep(2)
tdSql
.
query
(
"create user testpy pass 'testpy'"
)
buildPath
=
self
.
getBuildPath
()
if
(
buildPath
==
""
):
tdLog
.
exit
(
"taosd not found!"
)
else
:
tdLog
.
info
(
"taosd found in %s"
%
buildPath
)
logPath
=
buildPath
+
"/../sim/dnode1/log"
tdLog
.
info
(
"log path: %s"
%
logPath
)
tdDnodes
.
stop
(
1
)
time
.
sleep
(
2
)
tdSql
.
error
(
"show databases"
)
os
.
system
(
"rm -rf %s"
%
logPath
)
if
os
.
path
.
exists
(
logPath
)
==
True
:
tdLog
.
exit
(
"log pat still exist!"
)
tdDnodes
.
start
(
1
)
time
.
sleep
(
2
)
if
os
.
path
.
exists
(
logPath
)
!=
True
:
tdLog
.
exit
(
"log pat is not generated!"
)
tdSql
.
query
(
"show databases"
)
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
f
"
{
__file__
}
successfully executed"
)
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tools/shell/inc/shellInt.h
浏览文件 @
a0fcc9a2
...
@@ -85,7 +85,6 @@ typedef struct {
...
@@ -85,7 +85,6 @@ typedef struct {
TAOS
*
conn
;
TAOS
*
conn
;
TdThread
pid
;
TdThread
pid
;
tsem_t
cancelSem
;
tsem_t
cancelSem
;
int64_t
result
;
}
SShellObj
;
}
SShellObj
;
// shellArguments.c
// shellArguments.c
...
...
tools/shell/src/shellEngine.c
浏览文件 @
a0fcc9a2
...
@@ -213,13 +213,10 @@ void shellRunSingleCommandImp(char *command) {
...
@@ -213,13 +213,10 @@ void shellRunSingleCommandImp(char *command) {
return
;
return
;
}
}
int64_t
oresult
=
atomic_load_64
(
&
shell
.
result
);
if
(
shellRegexMatch
(
command
,
"^
\\
s*use
\\
s+[a-zA-Z0-9_]+
\\
s*;
\\
s*$"
,
REG_EXTENDED
|
REG_ICASE
))
{
if
(
shellRegexMatch
(
command
,
"^
\\
s*use
\\
s+[a-zA-Z0-9_]+
\\
s*;
\\
s*$"
,
REG_EXTENDED
|
REG_ICASE
))
{
fprintf
(
stdout
,
"Database changed.
\n\n
"
);
fprintf
(
stdout
,
"Database changed.
\n\n
"
);
fflush
(
stdout
);
fflush
(
stdout
);
atomic_store_64
(
&
shell
.
result
,
0
);
taos_free_result
(
pSql
);
taos_free_result
(
pSql
);
return
;
return
;
...
@@ -230,10 +227,7 @@ void shellRunSingleCommandImp(char *command) {
...
@@ -230,10 +227,7 @@ void shellRunSingleCommandImp(char *command) {
int32_t
error_no
=
0
;
int32_t
error_no
=
0
;
int32_t
numOfRows
=
shellDumpResult
(
pSql
,
fname
,
&
error_no
,
printMode
);
int32_t
numOfRows
=
shellDumpResult
(
pSql
,
fname
,
&
error_no
,
printMode
);
if
(
numOfRows
<
0
)
{
if
(
numOfRows
<
0
)
return
;
atomic_store_64
(
&
shell
.
result
,
0
);
return
;
}
et
=
taosGetTimestampUs
();
et
=
taosGetTimestampUs
();
if
(
error_no
==
0
)
{
if
(
error_no
==
0
)
{
...
@@ -250,8 +244,6 @@ void shellRunSingleCommandImp(char *command) {
...
@@ -250,8 +244,6 @@ void shellRunSingleCommandImp(char *command) {
}
}
printf
(
"
\n
"
);
printf
(
"
\n
"
);
atomic_store_64
(
&
shell
.
result
,
0
);
}
}
char
*
shellFormatTimestamp
(
char
*
buf
,
int64_t
val
,
int32_t
precision
)
{
char
*
shellFormatTimestamp
(
char
*
buf
,
int64_t
val
,
int32_t
precision
)
{
...
@@ -398,7 +390,6 @@ int32_t shellDumpResultToFile(const char *fname, TAOS_RES *tres) {
...
@@ -398,7 +390,6 @@ int32_t shellDumpResultToFile(const char *fname, TAOS_RES *tres) {
row
=
taos_fetch_row
(
tres
);
row
=
taos_fetch_row
(
tres
);
}
while
(
row
!=
NULL
);
}
while
(
row
!=
NULL
);
atomic_store_64
(
&
shell
.
result
,
0
);
taosCloseFile
(
&
pFile
);
taosCloseFile
(
&
pFile
);
return
numOfRows
;
return
numOfRows
;
...
@@ -766,7 +757,6 @@ void shellWriteHistory() {
...
@@ -766,7 +757,6 @@ void shellWriteHistory() {
void
shellPrintError
(
TAOS_RES
*
tres
,
int64_t
st
)
{
void
shellPrintError
(
TAOS_RES
*
tres
,
int64_t
st
)
{
int64_t
et
=
taosGetTimestampUs
();
int64_t
et
=
taosGetTimestampUs
();
atomic_store_ptr
(
&
shell
.
result
,
0
);
fprintf
(
stderr
,
"
\n
DB error: %s (%.6fs)
\n
"
,
taos_errstr
(
tres
),
(
et
-
st
)
/
1E6
);
fprintf
(
stderr
,
"
\n
DB error: %s (%.6fs)
\n
"
,
taos_errstr
(
tres
),
(
et
-
st
)
/
1E6
);
taos_free_result
(
tres
);
taos_free_result
(
tres
);
}
}
...
@@ -872,7 +862,6 @@ void shellGetGrantInfo() {
...
@@ -872,7 +862,6 @@ void shellGetGrantInfo() {
fprintf
(
stdout
,
"Server is Enterprise %s Edition, %s and will expire at %s.
\n
"
,
serverVersion
,
sinfo
,
expiretime
);
fprintf
(
stdout
,
"Server is Enterprise %s Edition, %s and will expire at %s.
\n
"
,
serverVersion
,
sinfo
,
expiretime
);
}
}
atomic_store_64
(
&
shell
.
result
,
0
);
taos_free_result
(
tres
);
taos_free_result
(
tres
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录