Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
fb628f7f
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
fb628f7f
编写于
12月 28, 2022
作者:
S
Shengliang Guan
提交者:
GitHub
12月 28, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #19212 from taosdata/merge/mainto3.0_1228
merge from main to 3.0
上级
0721ac3d
78c14a2c
变更
58
展开全部
显示空白变更内容
内联
并排
Showing
58 changed file
with
731 addition
and
586 deletion
+731
-586
include/libs/qcom/query.h
include/libs/qcom/query.h
+1
-1
include/util/taoserror.h
include/util/taoserror.h
+4
-0
include/util/tdef.h
include/util/tdef.h
+1
-1
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+15
-0
source/common/src/tglobal.c
source/common/src/tglobal.c
+6
-2
source/dnode/mgmt/exe/dmMain.c
source/dnode/mgmt/exe/dmMain.c
+5
-0
source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
+14
-0
source/dnode/mgmt/node_mgmt/src/dmTransport.c
source/dnode/mgmt/node_mgmt/src/dmTransport.c
+1
-0
source/dnode/mnode/impl/src/mndTrans.c
source/dnode/mnode/impl/src/mndTrans.c
+1
-1
source/dnode/vnode/src/meta/metaCache.c
source/dnode/vnode/src/meta/metaCache.c
+10
-11
source/dnode/vnode/src/meta/metaSnapshot.c
source/dnode/vnode/src/meta/metaSnapshot.c
+2
-2
source/dnode/vnode/src/tq/tq.c
source/dnode/vnode/src/tq/tq.c
+1
-0
source/dnode/vnode/src/tsdb/tsdbMergeTree.c
source/dnode/vnode/src/tsdb/tsdbMergeTree.c
+0
-1
source/dnode/vnode/src/tsdb/tsdbRead.c
source/dnode/vnode/src/tsdb/tsdbRead.c
+57
-120
source/dnode/vnode/src/vnd/vnodeCommit.c
source/dnode/vnode/src/vnd/vnodeCommit.c
+49
-22
source/dnode/vnode/src/vnd/vnodeSnapshot.c
source/dnode/vnode/src/vnd/vnodeSnapshot.c
+4
-4
source/dnode/vnode/src/vnd/vnodeSvr.c
source/dnode/vnode/src/vnd/vnodeSvr.c
+1
-1
source/dnode/vnode/src/vnd/vnodeSync.c
source/dnode/vnode/src/vnd/vnodeSync.c
+4
-4
source/libs/catalog/src/ctgAsync.c
source/libs/catalog/src/ctgAsync.c
+6
-3
source/libs/catalog/src/ctgCache.c
source/libs/catalog/src/ctgCache.c
+1
-0
source/libs/executor/src/dataDeleter.c
source/libs/executor/src/dataDeleter.c
+2
-3
source/libs/executor/src/dataDispatcher.c
source/libs/executor/src/dataDispatcher.c
+6
-7
source/libs/executor/src/exchangeoperator.c
source/libs/executor/src/exchangeoperator.c
+0
-1
source/libs/executor/src/executor.c
source/libs/executor/src/executor.c
+0
-1
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+4
-38
source/libs/executor/src/joinoperator.c
source/libs/executor/src/joinoperator.c
+29
-29
source/libs/executor/src/scanoperator.c
source/libs/executor/src/scanoperator.c
+3
-25
source/libs/executor/src/sortoperator.c
source/libs/executor/src/sortoperator.c
+10
-9
source/libs/executor/src/timewindowoperator.c
source/libs/executor/src/timewindowoperator.c
+24
-29
source/libs/executor/src/tsimplehash.c
source/libs/executor/src/tsimplehash.c
+3
-2
source/libs/executor/src/tsort.c
source/libs/executor/src/tsort.c
+1
-0
source/libs/function/src/udfd.c
source/libs/function/src/udfd.c
+1
-0
source/libs/parser/inc/parAst.h
source/libs/parser/inc/parAst.h
+1
-1
source/libs/parser/src/parAstCreater.c
source/libs/parser/src/parAstCreater.c
+4
-1
source/libs/scheduler/inc/schInt.h
source/libs/scheduler/inc/schInt.h
+1
-1
source/libs/scheduler/src/schJob.c
source/libs/scheduler/src/schJob.c
+5
-1
source/libs/stream/src/streamExec.c
source/libs/stream/src/streamExec.c
+4
-0
source/libs/stream/src/streamState.c
source/libs/stream/src/streamState.c
+1
-2
source/libs/sync/inc/syncInt.h
source/libs/sync/inc/syncInt.h
+1
-1
source/libs/sync/inc/syncPipeline.h
source/libs/sync/inc/syncPipeline.h
+3
-1
source/libs/sync/inc/syncSnapshot.h
source/libs/sync/inc/syncSnapshot.h
+3
-3
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+70
-43
source/libs/sync/src/syncPipeline.c
source/libs/sync/src/syncPipeline.c
+19
-16
source/libs/sync/src/syncRaftLog.c
source/libs/sync/src/syncRaftLog.c
+12
-12
source/libs/sync/src/syncSnapshot.c
source/libs/sync/src/syncSnapshot.c
+147
-151
source/libs/tdb/src/db/tdbPager.c
source/libs/tdb/src/db/tdbPager.c
+23
-3
source/libs/tdb/src/db/tdbTable.c
source/libs/tdb/src/db/tdbTable.c
+2
-2
source/libs/transport/src/transCli.c
source/libs/transport/src/transCli.c
+10
-1
source/libs/transport/src/transSvr.c
source/libs/transport/src/transSvr.c
+8
-7
source/util/src/terror.c
source/util/src/terror.c
+6
-6
tests/parallel_test/cases.task
tests/parallel_test/cases.task
+2
-2
tests/script/sh/deploy.sh
tests/script/sh/deploy.sh
+1
-0
tests/script/test.sh
tests/script/test.sh
+9
-6
tests/script/tsim/stream/basic3.sim
tests/script/tsim/stream/basic3.sim
+2
-2
tests/script/tsim/stream/sliding.sim
tests/script/tsim/stream/sliding.sim
+117
-0
tests/system-test/7-tmq/subscribeDb.py
tests/system-test/7-tmq/subscribeDb.py
+8
-4
tests/system-test/7-tmq/subscribeDb0.py
tests/system-test/7-tmq/subscribeDb0.py
+5
-2
tests/system-test/7-tmq/tmqCommon.py
tests/system-test/7-tmq/tmqCommon.py
+1
-1
未找到文件。
include/libs/qcom/query.h
浏览文件 @
fb628f7f
...
@@ -286,7 +286,7 @@ extern int32_t (*queryProcessMsgRsp[TDMT_MAX])(void* output, char* msg, int32_t
...
@@ -286,7 +286,7 @@ extern int32_t (*queryProcessMsgRsp[TDMT_MAX])(void* output, char* msg, int32_t
((_code) == TSDB_CODE_SYN_NOT_LEADER || (_code) == TSDB_CODE_SYN_RESTORING || (_code) == TSDB_CODE_SYN_INTERNAL_ERROR)
((_code) == TSDB_CODE_SYN_NOT_LEADER || (_code) == TSDB_CODE_SYN_RESTORING || (_code) == TSDB_CODE_SYN_INTERNAL_ERROR)
#define SYNC_OTHER_LEADER_REDIRECT_ERROR(_code) ((_code) == TSDB_CODE_MNODE_NOT_FOUND)
#define SYNC_OTHER_LEADER_REDIRECT_ERROR(_code) ((_code) == TSDB_CODE_MNODE_NOT_FOUND)
#define NO_RET_REDIRECT_ERROR(_code) ((_code) == TSDB_CODE_RPC_BROKEN_LINK || (_code) == TSDB_CODE_RPC_NETWORK_UNAVAIL)
#define NO_RET_REDIRECT_ERROR(_code) ((_code) == TSDB_CODE_RPC_BROKEN_LINK || (_code) == TSDB_CODE_RPC_NETWORK_UNAVAIL
|| (_code) == TSDB_CODE_RPC_SOMENODE_NOT_CONNECTED
)
#define NEED_REDIRECT_ERROR(_code) \
#define NEED_REDIRECT_ERROR(_code) \
(NO_RET_REDIRECT_ERROR(_code) || SYNC_UNKNOWN_LEADER_REDIRECT_ERROR(_code) || \
(NO_RET_REDIRECT_ERROR(_code) || SYNC_UNKNOWN_LEADER_REDIRECT_ERROR(_code) || \
...
...
include/util/taoserror.h
浏览文件 @
fb628f7f
...
@@ -65,6 +65,8 @@ int32_t* taosGetErrno();
...
@@ -65,6 +65,8 @@ int32_t* taosGetErrno();
#define TSDB_CODE_RPC_PORT_EADDRINUSE TAOS_DEF_ERROR_CODE(0, 0x0017) //
#define TSDB_CODE_RPC_PORT_EADDRINUSE TAOS_DEF_ERROR_CODE(0, 0x0017) //
#define TSDB_CODE_RPC_BROKEN_LINK TAOS_DEF_ERROR_CODE(0, 0x0018) //
#define TSDB_CODE_RPC_BROKEN_LINK TAOS_DEF_ERROR_CODE(0, 0x0018) //
#define TSDB_CODE_RPC_TIMEOUT TAOS_DEF_ERROR_CODE(0, 0x0019) //
#define TSDB_CODE_RPC_TIMEOUT TAOS_DEF_ERROR_CODE(0, 0x0019) //
#define TSDB_CODE_RPC_SOMENODE_NOT_CONNECTED TAOS_DEF_ERROR_CODE(0, 0x0020) // "Vgroup could not be connected"
#define TSDB_CODE_RPC_SOMENODE_BROKEN_LINK TAOS_DEF_ERROR_CODE(0, 0x0021) //
//common & util
//common & util
#define TSDB_CODE_OPS_NOT_SUPPORT TAOS_DEF_ERROR_CODE(0, 0x0100) //
#define TSDB_CODE_OPS_NOT_SUPPORT TAOS_DEF_ERROR_CODE(0, 0x0100) //
...
@@ -518,6 +520,8 @@ int32_t* taosGetErrno();
...
@@ -518,6 +520,8 @@ int32_t* taosGetErrno();
#define TSDB_CODE_SYN_STANDBY_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x0912)
#define TSDB_CODE_SYN_STANDBY_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x0912)
#define TSDB_CODE_SYN_BATCH_ERROR TAOS_DEF_ERROR_CODE(0, 0x0913)
#define TSDB_CODE_SYN_BATCH_ERROR TAOS_DEF_ERROR_CODE(0, 0x0913)
#define TSDB_CODE_SYN_RESTORING TAOS_DEF_ERROR_CODE(0, 0x0914)
#define TSDB_CODE_SYN_RESTORING TAOS_DEF_ERROR_CODE(0, 0x0914)
#define TSDB_CODE_SYN_INVALID_SNAPSHOT_MSG TAOS_DEF_ERROR_CODE(0, 0x0915) // internal
#define TSDB_CODE_SYN_BUFFER_FULL TAOS_DEF_ERROR_CODE(0, 0x0916) //
#define TSDB_CODE_SYN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x09FF)
#define TSDB_CODE_SYN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x09FF)
// tq
// tq
...
...
include/util/tdef.h
浏览文件 @
fb628f7f
...
@@ -255,7 +255,7 @@ typedef enum ELogicConditionType {
...
@@ -255,7 +255,7 @@ typedef enum ELogicConditionType {
#define TSDB_EP_LEN (TSDB_FQDN_LEN + 6)
#define TSDB_EP_LEN (TSDB_FQDN_LEN + 6)
#define TSDB_IPv4ADDR_LEN 16
#define TSDB_IPv4ADDR_LEN 16
#define TSDB_FILENAME_LEN 128
#define TSDB_FILENAME_LEN 128
#define TSDB_SHOW_SQL_LEN
1024
#define TSDB_SHOW_SQL_LEN
2048
#define TSDB_SLOW_QUERY_SQL_LEN 512
#define TSDB_SLOW_QUERY_SQL_LEN 512
#define TSDB_SHOW_SUBQUERY_LEN 1000
#define TSDB_SHOW_SUBQUERY_LEN 1000
...
...
source/client/src/clientImpl.c
浏览文件 @
fb628f7f
...
@@ -1403,6 +1403,21 @@ void processMsgFromServer(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet) {
...
@@ -1403,6 +1403,21 @@ void processMsgFromServer(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet) {
memcpy
((
void
*
)
tEpSet
,
(
void
*
)
pEpSet
,
sizeof
(
SEpSet
));
memcpy
((
void
*
)
tEpSet
,
(
void
*
)
pEpSet
,
sizeof
(
SEpSet
));
}
}
// pMsg is response msg
if
(
pMsg
->
msgType
==
TDMT_MND_CONNECT
+
1
)
{
// restore origin code
if
(
pMsg
->
code
==
TSDB_CODE_RPC_SOMENODE_NOT_CONNECTED
)
{
pMsg
->
code
=
TSDB_CODE_RPC_NETWORK_UNAVAIL
;
}
else
if
(
pMsg
->
code
==
TSDB_CODE_RPC_SOMENODE_BROKEN_LINK
)
{
pMsg
->
code
=
TSDB_CODE_RPC_BROKEN_LINK
;
}
}
else
{
// uniform to one error code: TSDB_CODE_RPC_SOMENODE_NOT_CONNECTED
if
(
pMsg
->
code
==
TSDB_CODE_RPC_SOMENODE_BROKEN_LINK
)
{
pMsg
->
code
=
TSDB_CODE_RPC_SOMENODE_NOT_CONNECTED
;
}
}
AsyncArg
*
arg
=
taosMemoryCalloc
(
1
,
sizeof
(
AsyncArg
));
AsyncArg
*
arg
=
taosMemoryCalloc
(
1
,
sizeof
(
AsyncArg
));
arg
->
msg
=
*
pMsg
;
arg
->
msg
=
*
pMsg
;
arg
->
pEpset
=
tEpSet
;
arg
->
pEpset
=
tEpSet
;
...
...
source/common/src/tglobal.c
浏览文件 @
fb628f7f
...
@@ -1316,12 +1316,17 @@ void taosSetDebugFlag(int32_t *pFlagPtr, const char *flagName, int32_t flagVal,
...
@@ -1316,12 +1316,17 @@ void taosSetDebugFlag(int32_t *pFlagPtr, const char *flagName, int32_t flagVal,
if
(
pItem
!=
NULL
&&
(
rewrite
||
pItem
->
i32
==
0
))
{
if
(
pItem
!=
NULL
&&
(
rewrite
||
pItem
->
i32
==
0
))
{
pItem
->
i32
=
flagVal
;
pItem
->
i32
=
flagVal
;
}
}
if
(
pFlagPtr
!=
NULL
)
{
*
pFlagPtr
=
flagVal
;
*
pFlagPtr
=
flagVal
;
}
}
}
void
taosSetAllDebugFlag
(
int32_t
flag
,
bool
rewrite
)
{
void
taosSetAllDebugFlag
(
int32_t
flag
,
bool
rewrite
)
{
if
(
flag
<=
0
)
return
;
if
(
flag
<=
0
)
return
;
taosSetDebugFlag
(
NULL
,
"debugFlag"
,
flag
,
rewrite
);
taosSetDebugFlag
(
NULL
,
"simDebugFlag"
,
flag
,
rewrite
);
taosSetDebugFlag
(
NULL
,
"tmrDebugFlag"
,
flag
,
rewrite
);
taosSetDebugFlag
(
&
uDebugFlag
,
"uDebugFlag"
,
flag
,
rewrite
);
taosSetDebugFlag
(
&
uDebugFlag
,
"uDebugFlag"
,
flag
,
rewrite
);
taosSetDebugFlag
(
&
rpcDebugFlag
,
"rpcDebugFlag"
,
flag
,
rewrite
);
taosSetDebugFlag
(
&
rpcDebugFlag
,
"rpcDebugFlag"
,
flag
,
rewrite
);
taosSetDebugFlag
(
&
jniDebugFlag
,
"jniDebugFlag"
,
flag
,
rewrite
);
taosSetDebugFlag
(
&
jniDebugFlag
,
"jniDebugFlag"
,
flag
,
rewrite
);
...
@@ -1340,6 +1345,5 @@ void taosSetAllDebugFlag(int32_t flag, bool rewrite) {
...
@@ -1340,6 +1345,5 @@ void taosSetAllDebugFlag(int32_t flag, bool rewrite) {
taosSetDebugFlag
(
&
idxDebugFlag
,
"idxDebugFlag"
,
flag
,
rewrite
);
taosSetDebugFlag
(
&
idxDebugFlag
,
"idxDebugFlag"
,
flag
,
rewrite
);
taosSetDebugFlag
(
&
tdbDebugFlag
,
"tdbDebugFlag"
,
flag
,
rewrite
);
taosSetDebugFlag
(
&
tdbDebugFlag
,
"tdbDebugFlag"
,
flag
,
rewrite
);
taosSetDebugFlag
(
&
metaDebugFlag
,
"metaDebugFlag"
,
flag
,
rewrite
);
taosSetDebugFlag
(
&
metaDebugFlag
,
"metaDebugFlag"
,
flag
,
rewrite
);
taosSetDebugFlag
(
&
metaDebugFlag
,
"tmrDebugFlag"
,
flag
,
rewrite
);
uInfo
(
"all debug flag are set to %d"
,
flag
);
uInfo
(
"all debug flag are set to %d"
,
flag
);
}
}
source/dnode/mgmt/exe/dmMain.c
浏览文件 @
fb628f7f
...
@@ -268,6 +268,11 @@ int mainWindows(int argc, char **argv) {
...
@@ -268,6 +268,11 @@ int mainWindows(int argc, char **argv) {
if
(
dmInit
()
!=
0
)
{
if
(
dmInit
()
!=
0
)
{
dError
(
"failed to init dnode since %s"
,
terrstr
());
dError
(
"failed to init dnode since %s"
,
terrstr
());
taosCleanupCfg
();
taosCloseLog
();
taosCleanupArgs
();
taosConvDestroy
();
return
-
1
;
return
-
1
;
}
}
...
...
source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
浏览文件 @
fb628f7f
...
@@ -140,6 +140,12 @@ static void vmProcessSyncQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numOf
...
@@ -140,6 +140,12 @@ static void vmProcessSyncQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numOf
static
int32_t
vmPutMsgToQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
,
EQueueType
qtype
)
{
static
int32_t
vmPutMsgToQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
,
EQueueType
qtype
)
{
const
STraceId
*
trace
=
&
pMsg
->
info
.
traceId
;
const
STraceId
*
trace
=
&
pMsg
->
info
.
traceId
;
if
(
pMsg
->
contLen
<
sizeof
(
SMsgHead
))
{
dGError
(
"invalid rpc msg with no msg head at pCont. pMsg:%p, type:%s, contLen:%d"
,
pMsg
,
TMSG_INFO
(
pMsg
->
msgType
),
pMsg
->
contLen
);
return
-
1
;
}
SMsgHead
*
pHead
=
pMsg
->
pCont
;
SMsgHead
*
pHead
=
pMsg
->
pCont
;
int32_t
code
=
0
;
int32_t
code
=
0
;
...
@@ -233,6 +239,14 @@ int32_t vmPutMsgToMgmtQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
...
@@ -233,6 +239,14 @@ int32_t vmPutMsgToMgmtQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
}
}
int32_t
vmPutRpcMsgToQueue
(
SVnodeMgmt
*
pMgmt
,
EQueueType
qtype
,
SRpcMsg
*
pRpc
)
{
int32_t
vmPutRpcMsgToQueue
(
SVnodeMgmt
*
pMgmt
,
EQueueType
qtype
,
SRpcMsg
*
pRpc
)
{
if
(
pRpc
->
contLen
<
sizeof
(
SMsgHead
))
{
dError
(
"invalid rpc msg with no msg head at pCont. pRpc:%p, type:%s, len:%d"
,
pRpc
,
TMSG_INFO
(
pRpc
->
msgType
),
pRpc
->
contLen
);
rpcFreeCont
(
pRpc
->
pCont
);
pRpc
->
pCont
=
NULL
;
return
-
1
;
}
SRpcMsg
*
pMsg
=
taosAllocateQitem
(
sizeof
(
SRpcMsg
),
RPC_QITEM
,
pRpc
->
contLen
);
SRpcMsg
*
pMsg
=
taosAllocateQitem
(
sizeof
(
SRpcMsg
),
RPC_QITEM
,
pRpc
->
contLen
);
if
(
pMsg
==
NULL
)
{
if
(
pMsg
==
NULL
)
{
rpcFreeCont
(
pRpc
->
pCont
);
rpcFreeCont
(
pRpc
->
pCont
);
...
...
source/dnode/mgmt/node_mgmt/src/dmTransport.c
浏览文件 @
fb628f7f
...
@@ -248,6 +248,7 @@ static inline void dmReleaseHandle(SRpcHandleInfo *pHandle, int8_t type) { rpcRe
...
@@ -248,6 +248,7 @@ static inline void dmReleaseHandle(SRpcHandleInfo *pHandle, int8_t type) { rpcRe
static
bool
rpcRfp
(
int32_t
code
,
tmsg_t
msgType
)
{
static
bool
rpcRfp
(
int32_t
code
,
tmsg_t
msgType
)
{
if
(
code
==
TSDB_CODE_RPC_NETWORK_UNAVAIL
||
code
==
TSDB_CODE_RPC_BROKEN_LINK
||
code
==
TSDB_CODE_MNODE_NOT_FOUND
||
if
(
code
==
TSDB_CODE_RPC_NETWORK_UNAVAIL
||
code
==
TSDB_CODE_RPC_BROKEN_LINK
||
code
==
TSDB_CODE_MNODE_NOT_FOUND
||
code
==
TSDB_CODE_RPC_SOMENODE_NOT_CONNECTED
||
code
==
TSDB_CODE_SYN_NOT_LEADER
||
code
==
TSDB_CODE_SYN_RESTORING
||
code
==
TSDB_CODE_VND_STOPPED
||
code
==
TSDB_CODE_SYN_NOT_LEADER
||
code
==
TSDB_CODE_SYN_RESTORING
||
code
==
TSDB_CODE_VND_STOPPED
||
code
==
TSDB_CODE_APP_IS_STARTING
||
code
==
TSDB_CODE_APP_IS_STOPPING
)
{
code
==
TSDB_CODE_APP_IS_STARTING
||
code
==
TSDB_CODE_APP_IS_STOPPING
)
{
if
(
msgType
==
TDMT_SCH_QUERY
||
msgType
==
TDMT_SCH_MERGE_QUERY
||
msgType
==
TDMT_SCH_FETCH
||
if
(
msgType
==
TDMT_SCH_QUERY
||
msgType
==
TDMT_SCH_MERGE_QUERY
||
msgType
==
TDMT_SCH_FETCH
||
...
...
source/dnode/mnode/impl/src/mndTrans.c
浏览文件 @
fb628f7f
...
@@ -957,7 +957,7 @@ static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans) {
...
@@ -957,7 +957,7 @@ static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans) {
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
SRpcHandleInfo
*
pInfo
=
taosArrayGet
(
pTrans
->
pRpcArray
,
i
);
SRpcHandleInfo
*
pInfo
=
taosArrayGet
(
pTrans
->
pRpcArray
,
i
);
if
(
pInfo
->
handle
!=
NULL
)
{
if
(
pInfo
->
handle
!=
NULL
)
{
if
(
code
==
TSDB_CODE_RPC_NETWORK_UNAVAIL
)
{
if
(
code
==
TSDB_CODE_RPC_NETWORK_UNAVAIL
||
code
==
TSDB_CODE_RPC_SOMENODE_NOT_CONNECTED
)
{
code
=
TSDB_CODE_MND_TRANS_NETWORK_UNAVAILL
;
code
=
TSDB_CODE_MND_TRANS_NETWORK_UNAVAILL
;
}
}
if
(
code
==
TSDB_CODE_SYN_TIMEOUT
)
{
if
(
code
==
TSDB_CODE_SYN_TIMEOUT
)
{
...
...
source/dnode/vnode/src/meta/metaCache.c
浏览文件 @
fb628f7f
...
@@ -57,7 +57,6 @@ struct SMetaCache {
...
@@ -57,7 +57,6 @@ struct SMetaCache {
TdThreadMutex
lock
;
TdThreadMutex
lock
;
SHashObj
*
pTableEntry
;
SHashObj
*
pTableEntry
;
SLRUCache
*
pUidResCache
;
SLRUCache
*
pUidResCache
;
uint64_t
keyBuf
[
3
];
}
sTagFilterResCache
;
}
sTagFilterResCache
;
};
};
...
@@ -429,20 +428,20 @@ int32_t metaGetCachedTableUidList(SMeta* pMeta, tb_uid_t suid, const uint8_t* pK
...
@@ -429,20 +428,20 @@ int32_t metaGetCachedTableUidList(SMeta* pMeta, tb_uid_t suid, const uint8_t* pK
bool
*
acquireRes
)
{
bool
*
acquireRes
)
{
// generate the composed key for LRU cache
// generate the composed key for LRU cache
SLRUCache
*
pCache
=
pMeta
->
pCache
->
sTagFilterResCache
.
pUidResCache
;
SLRUCache
*
pCache
=
pMeta
->
pCache
->
sTagFilterResCache
.
pUidResCache
;
uint64_t
*
pBuf
=
pMeta
->
pCache
->
sTagFilterResCache
.
keyBuf
;
SHashObj
*
pTableMap
=
pMeta
->
pCache
->
sTagFilterResCache
.
pTableEntry
;
SHashObj
*
pTableMap
=
pMeta
->
pCache
->
sTagFilterResCache
.
pTableEntry
;
TdThreadMutex
*
pLock
=
&
pMeta
->
pCache
->
sTagFilterResCache
.
lock
;
TdThreadMutex
*
pLock
=
&
pMeta
->
pCache
->
sTagFilterResCache
.
lock
;
uint64_t
buf
[
3
]
=
{
0
};
uint32_t
times
=
0
;
uint32_t
times
=
0
;
*
acquireRes
=
0
;
*
acquireRes
=
0
;
pB
uf
[
0
]
=
suid
;
b
uf
[
0
]
=
suid
;
memcpy
(
&
pB
uf
[
1
],
pKey
,
keyLen
);
memcpy
(
&
b
uf
[
1
],
pKey
,
keyLen
);
taosThreadMutexLock
(
pLock
);
taosThreadMutexLock
(
pLock
);
int32_t
len
=
keyLen
+
sizeof
(
uint64_t
);
int32_t
len
=
keyLen
+
sizeof
(
uint64_t
);
LRUHandle
*
pHandle
=
taosLRUCacheLookup
(
pCache
,
pB
uf
,
len
);
LRUHandle
*
pHandle
=
taosLRUCacheLookup
(
pCache
,
b
uf
,
len
);
if
(
pHandle
==
NULL
)
{
if
(
pHandle
==
NULL
)
{
taosThreadMutexUnlock
(
pLock
);
taosThreadMutexUnlock
(
pLock
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -476,10 +475,10 @@ int32_t metaGetCachedTableUidList(SMeta* pMeta, tb_uid_t suid, const uint8_t* pK
...
@@ -476,10 +475,10 @@ int32_t metaGetCachedTableUidList(SMeta* pMeta, tb_uid_t suid, const uint8_t* pK
SListNode
*
pNode
=
NULL
;
SListNode
*
pNode
=
NULL
;
while
((
pNode
=
tdListNext
(
&
iter
))
!=
NULL
)
{
while
((
pNode
=
tdListNext
(
&
iter
))
!=
NULL
)
{
memcpy
(
&
pB
uf
[
1
],
pNode
->
data
,
keyLen
);
memcpy
(
&
b
uf
[
1
],
pNode
->
data
,
keyLen
);
// check whether it is existed in LRU cache, and remove it from linked list if not.
// check whether it is existed in LRU cache, and remove it from linked list if not.
LRUHandle
*
pRes
=
taosLRUCacheLookup
(
pCache
,
pB
uf
,
len
);
LRUHandle
*
pRes
=
taosLRUCacheLookup
(
pCache
,
b
uf
,
len
);
if
(
pRes
==
NULL
)
{
// remove the item in the linked list
if
(
pRes
==
NULL
)
{
// remove the item in the linked list
taosArrayPush
(
pInvalidRes
,
&
pNode
);
taosArrayPush
(
pInvalidRes
,
&
pNode
);
}
else
{
}
else
{
...
@@ -547,14 +546,14 @@ int32_t metaUidFilterCachePut(SMeta* pMeta, uint64_t suid, const void* pKey, int
...
@@ -547,14 +546,14 @@ int32_t metaUidFilterCachePut(SMeta* pMeta, uint64_t suid, const void* pKey, int
tdListAppend
(
&
(
*
pEntry
)
->
list
,
pKey
);
tdListAppend
(
&
(
*
pEntry
)
->
list
,
pKey
);
}
}
uint64_t
*
pBuf
=
pMeta
->
pCache
->
sTagFilterResCache
.
keyBuf
;
uint64_t
buf
[
3
]
=
{
0
}
;
pB
uf
[
0
]
=
suid
;
b
uf
[
0
]
=
suid
;
memcpy
(
&
pB
uf
[
1
],
pKey
,
keyLen
);
memcpy
(
&
b
uf
[
1
],
pKey
,
keyLen
);
ASSERT
(
sizeof
(
uint64_t
)
+
keyLen
==
24
);
ASSERT
(
sizeof
(
uint64_t
)
+
keyLen
==
24
);
// add to cache.
// add to cache.
taosLRUCacheInsert
(
pCache
,
pB
uf
,
sizeof
(
uint64_t
)
+
keyLen
,
pPayload
,
payloadLen
,
freePayload
,
NULL
,
taosLRUCacheInsert
(
pCache
,
b
uf
,
sizeof
(
uint64_t
)
+
keyLen
,
pPayload
,
payloadLen
,
freePayload
,
NULL
,
TAOS_LRU_PRIORITY_LOW
);
TAOS_LRU_PRIORITY_LOW
);
taosThreadMutexUnlock
(
pLock
);
taosThreadMutexUnlock
(
pLock
);
...
...
source/dnode/vnode/src/meta/metaSnapshot.c
浏览文件 @
fb628f7f
...
@@ -113,7 +113,7 @@ int32_t metaSnapRead(SMetaSnapReader* pReader, uint8_t** ppData) {
...
@@ -113,7 +113,7 @@ int32_t metaSnapRead(SMetaSnapReader* pReader, uint8_t** ppData) {
pHdr
->
size
=
nData
;
pHdr
->
size
=
nData
;
memcpy
(
pHdr
->
data
,
pData
,
nData
);
memcpy
(
pHdr
->
data
,
pData
,
nData
);
meta
Info
(
"vgId:%d, vnode snapshot meta read data, version:%"
PRId64
" uid:%"
PRId64
" nData
:%d"
,
meta
Debug
(
"vgId:%d, vnode snapshot meta read data, version:%"
PRId64
" uid:%"
PRId64
" blockLen
:%d"
,
TD_VID
(
pReader
->
pMeta
->
pVnode
),
key
.
version
,
key
.
uid
,
nData
);
TD_VID
(
pReader
->
pMeta
->
pVnode
),
key
.
version
,
key
.
uid
,
nData
);
_exit:
_exit:
...
...
source/dnode/vnode/src/tq/tq.c
浏览文件 @
fb628f7f
...
@@ -1014,6 +1014,7 @@ int32_t tqProcessStreamTaskCheckReq(STQ* pTq, SRpcMsg* pMsg) {
...
@@ -1014,6 +1014,7 @@ int32_t tqProcessStreamTaskCheckReq(STQ* pTq, SRpcMsg* pMsg) {
tqError
(
"unable to encode rsp %d"
,
__LINE__
);
tqError
(
"unable to encode rsp %d"
,
__LINE__
);
return
-
1
;
return
-
1
;
}
}
void
*
buf
=
rpcMallocCont
(
sizeof
(
SMsgHead
)
+
len
);
void
*
buf
=
rpcMallocCont
(
sizeof
(
SMsgHead
)
+
len
);
((
SMsgHead
*
)
buf
)
->
vgId
=
htonl
(
req
.
upstreamNodeId
);
((
SMsgHead
*
)
buf
)
->
vgId
=
htonl
(
req
.
upstreamNodeId
);
...
...
source/dnode/vnode/src/tsdb/tsdbMergeTree.c
浏览文件 @
fb628f7f
...
@@ -567,7 +567,6 @@ int32_t tMergeTreeOpen(SMergeTree *pMTree, int8_t backward, SDataFReader *pFRead
...
@@ -567,7 +567,6 @@ int32_t tMergeTreeOpen(SMergeTree *pMTree, int8_t backward, SDataFReader *pFRead
pMTree
->
pLoadInfo
=
pBlockLoadInfo
;
pMTree
->
pLoadInfo
=
pBlockLoadInfo
;
pMTree
->
destroyLoadInfo
=
destroyLoadInfo
;
pMTree
->
destroyLoadInfo
=
destroyLoadInfo
;
ASSERT
(
pMTree
->
pLoadInfo
!=
NULL
);
for
(
int32_t
i
=
0
;
i
<
pFReader
->
pSet
->
nSttF
;
++
i
)
{
// open all last file
for
(
int32_t
i
=
0
;
i
<
pFReader
->
pSet
->
nSttF
;
++
i
)
{
// open all last file
struct
SLDataIter
*
pIter
=
NULL
;
struct
SLDataIter
*
pIter
=
NULL
;
...
...
source/dnode/vnode/src/tsdb/tsdbRead.c
浏览文件 @
fb628f7f
...
@@ -244,7 +244,7 @@ static int32_t setColumnIdSlotList(SBlockLoadSuppInfo* pSupInfo, SColumnInfo* pC
...
@@ -244,7 +244,7 @@ static int32_t setColumnIdSlotList(SBlockLoadSuppInfo* pSupInfo, SColumnInfo* pC
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
void
updateBlockSMAInfo
(
STSchema
*
pSchema
,
SBlockLoadSuppInfo
*
pSupInfo
)
{
static
int32_t
updateBlockSMAInfo
(
STSchema
*
pSchema
,
SBlockLoadSuppInfo
*
pSupInfo
)
{
int32_t
i
=
0
,
j
=
0
;
int32_t
i
=
0
,
j
=
0
;
while
(
i
<
pSchema
->
numOfCols
&&
j
<
pSupInfo
->
numOfCols
)
{
while
(
i
<
pSchema
->
numOfCols
&&
j
<
pSupInfo
->
numOfCols
)
{
...
@@ -252,7 +252,7 @@ static void updateBlockSMAInfo(STSchema* pSchema, SBlockLoadSuppInfo* pSupInfo)
...
@@ -252,7 +252,7 @@ static void updateBlockSMAInfo(STSchema* pSchema, SBlockLoadSuppInfo* pSupInfo)
if
(
pTCol
->
colId
==
pSupInfo
->
colId
[
j
])
{
if
(
pTCol
->
colId
==
pSupInfo
->
colId
[
j
])
{
if
(
!
IS_BSMA_ON
(
pTCol
))
{
if
(
!
IS_BSMA_ON
(
pTCol
))
{
pSupInfo
->
smaValid
=
false
;
pSupInfo
->
smaValid
=
false
;
return
;
return
TSDB_CODE_SUCCESS
;
}
}
i
+=
1
;
i
+=
1
;
...
@@ -261,9 +261,11 @@ static void updateBlockSMAInfo(STSchema* pSchema, SBlockLoadSuppInfo* pSupInfo)
...
@@ -261,9 +261,11 @@ static void updateBlockSMAInfo(STSchema* pSchema, SBlockLoadSuppInfo* pSupInfo)
// do nothing
// do nothing
i
+=
1
;
i
+=
1
;
}
else
{
}
else
{
ASSERT
(
0
)
;
return
TSDB_CODE_INVALID_PARA
;
}
}
}
}
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
initBlockScanInfoBuf
(
SBlockInfoBuf
*
pBuf
,
int32_t
numOfTables
)
{
static
int32_t
initBlockScanInfoBuf
(
SBlockInfoBuf
*
pBuf
,
int32_t
numOfTables
)
{
...
@@ -581,7 +583,7 @@ static int32_t tsdbReaderCreate(SVnode* pVnode, SQueryTableDataCond* pCond, STsd
...
@@ -581,7 +583,7 @@ static int32_t tsdbReaderCreate(SVnode* pVnode, SQueryTableDataCond* pCond, STsd
}
}
if
(
VND_IS_TSMA
(
pVnode
))
{
if
(
VND_IS_TSMA
(
pVnode
))
{
tsdbDebug
(
"vgId:%d, tsma is selected to query
"
,
TD_VID
(
pVnode
)
);
tsdbDebug
(
"vgId:%d, tsma is selected to query
, %s"
,
TD_VID
(
pVnode
),
idstr
);
}
}
initReaderStatus
(
&
pReader
->
status
);
initReaderStatus
(
&
pReader
->
status
);
...
@@ -596,7 +598,6 @@ static int32_t tsdbReaderCreate(SVnode* pVnode, SQueryTableDataCond* pCond, STsd
...
@@ -596,7 +598,6 @@ static int32_t tsdbReaderCreate(SVnode* pVnode, SQueryTableDataCond* pCond, STsd
pReader
->
type
=
pCond
->
type
;
pReader
->
type
=
pCond
->
type
;
pReader
->
window
=
updateQueryTimeWindow
(
pReader
->
pTsdb
,
&
pCond
->
twindows
);
pReader
->
window
=
updateQueryTimeWindow
(
pReader
->
pTsdb
,
&
pCond
->
twindows
);
pReader
->
blockInfoBuf
.
numPerBucket
=
1000
;
// 1000 tables per bucket
pReader
->
blockInfoBuf
.
numPerBucket
=
1000
;
// 1000 tables per bucket
ASSERT
(
pCond
->
numOfCols
>
0
);
if
(
pReader
->
pResBlock
==
NULL
)
{
if
(
pReader
->
pResBlock
==
NULL
)
{
pReader
->
freeBlock
=
true
;
pReader
->
freeBlock
=
true
;
...
@@ -607,6 +608,12 @@ static int32_t tsdbReaderCreate(SVnode* pVnode, SQueryTableDataCond* pCond, STsd
...
@@ -607,6 +608,12 @@ static int32_t tsdbReaderCreate(SVnode* pVnode, SQueryTableDataCond* pCond, STsd
}
}
}
}
if
(
pCond
->
numOfCols
<=
0
)
{
tsdbError
(
"vgId:%d, invalid column number %d in query cond, %s"
,
TD_VID
(
pVnode
),
pCond
->
numOfCols
,
idstr
);
code
=
TSDB_CODE_INVALID_PARA
;
goto
_end
;
}
// todo refactor.
// todo refactor.
limitOutputBufferSize
(
pCond
,
&
pReader
->
capacity
);
limitOutputBufferSize
(
pCond
,
&
pReader
->
capacity
);
...
@@ -795,8 +802,9 @@ static void doCopyColVal(SColumnInfoData* pColInfoData, int32_t rowIndex, int32_
...
@@ -795,8 +802,9 @@ static void doCopyColVal(SColumnInfoData* pColInfoData, int32_t rowIndex, int32_
}
}
static
SFileDataBlockInfo
*
getCurrentBlockInfo
(
SDataBlockIter
*
pBlockIter
)
{
static
SFileDataBlockInfo
*
getCurrentBlockInfo
(
SDataBlockIter
*
pBlockIter
)
{
if
(
taosArrayGetSize
(
pBlockIter
->
blockList
)
==
0
)
{
size_t
num
=
taosArrayGetSize
(
pBlockIter
->
blockList
);
ASSERT
(
pBlockIter
->
numOfBlocks
==
taosArrayGetSize
(
pBlockIter
->
blockList
));
if
(
num
==
0
)
{
ASSERT
(
pBlockIter
->
numOfBlocks
==
num
);
return
NULL
;
return
NULL
;
}
}
...
@@ -806,73 +814,6 @@ static SFileDataBlockInfo* getCurrentBlockInfo(SDataBlockIter* pBlockIter) {
...
@@ -806,73 +814,6 @@ static SFileDataBlockInfo* getCurrentBlockInfo(SDataBlockIter* pBlockIter) {
static
SDataBlk
*
getCurrentBlock
(
SDataBlockIter
*
pBlockIter
)
{
return
&
pBlockIter
->
block
;
}
static
SDataBlk
*
getCurrentBlock
(
SDataBlockIter
*
pBlockIter
)
{
return
&
pBlockIter
->
block
;
}
int32_t
binarySearchForTs
(
char
*
pValue
,
int
num
,
TSKEY
key
,
int
order
)
{
int32_t
midPos
=
-
1
;
int32_t
numOfRows
;
ASSERT
(
order
==
TSDB_ORDER_ASC
||
order
==
TSDB_ORDER_DESC
);
TSKEY
*
keyList
=
(
TSKEY
*
)
pValue
;
int32_t
firstPos
=
0
;
int32_t
lastPos
=
num
-
1
;
if
(
order
==
TSDB_ORDER_DESC
)
{
// find the first position which is smaller than the key
while
(
1
)
{
if
(
key
>=
keyList
[
firstPos
])
return
firstPos
;
if
(
key
==
keyList
[
lastPos
])
return
lastPos
;
if
(
key
<
keyList
[
lastPos
])
{
lastPos
+=
1
;
if
(
lastPos
>=
num
)
{
return
-
1
;
}
else
{
return
lastPos
;
}
}
numOfRows
=
lastPos
-
firstPos
+
1
;
midPos
=
(
numOfRows
>>
1
)
+
firstPos
;
if
(
key
<
keyList
[
midPos
])
{
firstPos
=
midPos
+
1
;
}
else
if
(
key
>
keyList
[
midPos
])
{
lastPos
=
midPos
-
1
;
}
else
{
break
;
}
}
}
else
{
// find the first position which is bigger than the key
while
(
1
)
{
if
(
key
<=
keyList
[
firstPos
])
return
firstPos
;
if
(
key
==
keyList
[
lastPos
])
return
lastPos
;
if
(
key
>
keyList
[
lastPos
])
{
lastPos
=
lastPos
+
1
;
if
(
lastPos
>=
num
)
return
-
1
;
else
return
lastPos
;
}
numOfRows
=
lastPos
-
firstPos
+
1
;
midPos
=
(
numOfRows
>>
1u
)
+
firstPos
;
if
(
key
<
keyList
[
midPos
])
{
lastPos
=
midPos
-
1
;
}
else
if
(
key
>
keyList
[
midPos
])
{
firstPos
=
midPos
+
1
;
}
else
{
break
;
}
}
}
return
midPos
;
}
static
int
doBinarySearchKey
(
TSKEY
*
keyList
,
int
num
,
int
pos
,
TSKEY
key
,
int
order
)
{
static
int
doBinarySearchKey
(
TSKEY
*
keyList
,
int
num
,
int
pos
,
TSKEY
key
,
int
order
)
{
// start end position
// start end position
int
s
,
e
;
int
s
,
e
;
...
@@ -973,8 +914,8 @@ static void copyNumericCols(const SColData* pData, SFileBlockDumpInfo* pDumpInfo
...
@@ -973,8 +914,8 @@ static void copyNumericCols(const SColData* pData, SFileBlockDumpInfo* pDumpInfo
int32_t
step
=
asc
?
1
:
-
1
;
int32_t
step
=
asc
?
1
:
-
1
;
// make sure it is aligned to 8bit
// make sure it is aligned to 8bit
, the allocated memory address is aligned to 256bit
ASSERT
((((
uint64_t
)
pColData
->
pData
)
&
(
0x8
-
1
))
==
0
);
//
ASSERT((((uint64_t)pColData->pData) & (0x8 - 1)) == 0);
// 1. copy data in a batch model
// 1. copy data in a batch model
memcpy
(
pColData
->
pData
,
p
,
dumpedRows
*
tDataTypes
[
pData
->
type
].
bytes
);
memcpy
(
pColData
->
pData
,
p
,
dumpedRows
*
tDataTypes
[
pData
->
type
].
bytes
);
...
@@ -1072,11 +1013,20 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn
...
@@ -1072,11 +1013,20 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn
// pDumpInfo->rowIndex = 0;
// pDumpInfo->rowIndex = 0;
}
else
if
(
!
asc
&&
pReader
->
window
.
ekey
>=
pBlock
->
maxKey
.
ts
)
{
}
else
if
(
!
asc
&&
pReader
->
window
.
ekey
>=
pBlock
->
maxKey
.
ts
)
{
// pDumpInfo->rowIndex = pBlock->nRow - 1;
// pDumpInfo->rowIndex = pBlock->nRow - 1;
}
else
{
}
else
{
// find the appropriate the start position in current block, and set it to be the current rowIndex
int32_t
pos
=
asc
?
pBlock
->
nRow
-
1
:
0
;
int32_t
pos
=
asc
?
pBlock
->
nRow
-
1
:
0
;
int32_t
order
=
asc
?
TSDB_ORDER_DESC
:
TSDB_ORDER_ASC
;
int32_t
order
=
asc
?
TSDB_ORDER_DESC
:
TSDB_ORDER_ASC
;
int64_t
key
=
asc
?
pReader
->
window
.
skey
:
pReader
->
window
.
ekey
;
int64_t
key
=
asc
?
pReader
->
window
.
skey
:
pReader
->
window
.
ekey
;
pDumpInfo
->
rowIndex
=
doBinarySearchKey
(
pBlockData
->
aTSKEY
,
pBlock
->
nRow
,
pos
,
key
,
order
);
pDumpInfo
->
rowIndex
=
doBinarySearchKey
(
pBlockData
->
aTSKEY
,
pBlock
->
nRow
,
pos
,
key
,
order
);
if
(
pDumpInfo
->
rowIndex
<
0
)
{
tsdbError
(
"%p failed to locate the start position in current block, global index:%d, table index:%d, brange:%"
PRId64
"-%"
PRId64
", minVer:%"
PRId64
", maxVer:%"
PRId64
" %s"
,
pReader
,
pBlockIter
->
index
,
pBlockInfo
->
tbBlockIdx
,
pBlock
->
minKey
.
ts
,
pBlock
->
maxKey
.
ts
,
pBlock
->
minVer
,
pBlock
->
maxVer
,
pReader
->
idStr
);
return
TSDB_CODE_INVALID_PARA
;
}
}
}
}
}
...
@@ -1185,7 +1135,6 @@ static int32_t doLoadFileBlockData(STsdbReader* pReader, SDataBlockIter* pBlockI
...
@@ -1185,7 +1135,6 @@ static int32_t doLoadFileBlockData(STsdbReader* pReader, SDataBlockIter* pBlockI
SFileDataBlockInfo
*
pBlockInfo
=
getCurrentBlockInfo
(
pBlockIter
);
SFileDataBlockInfo
*
pBlockInfo
=
getCurrentBlockInfo
(
pBlockIter
);
SFileBlockDumpInfo
*
pDumpInfo
=
&
pReader
->
status
.
fBlockDumpInfo
;
SFileBlockDumpInfo
*
pDumpInfo
=
&
pReader
->
status
.
fBlockDumpInfo
;
ASSERT
(
pBlockInfo
!=
NULL
);
SDataBlk
*
pBlock
=
getCurrentBlock
(
pBlockIter
);
SDataBlk
*
pBlock
=
getCurrentBlock
(
pBlockIter
);
code
=
tsdbReadDataBlock
(
pReader
->
pFileReader
,
pBlock
,
pBlockData
);
code
=
tsdbReadDataBlock
(
pReader
->
pFileReader
,
pBlock
,
pBlockData
);
...
@@ -1223,8 +1172,6 @@ static void cleanupBlockOrderSupporter(SBlockOrderSupporter* pSup) {
...
@@ -1223,8 +1172,6 @@ static void cleanupBlockOrderSupporter(SBlockOrderSupporter* pSup) {
}
}
static
int32_t
initBlockOrderSupporter
(
SBlockOrderSupporter
*
pSup
,
int32_t
numOfTables
)
{
static
int32_t
initBlockOrderSupporter
(
SBlockOrderSupporter
*
pSup
,
int32_t
numOfTables
)
{
ASSERT
(
numOfTables
>=
1
);
pSup
->
numOfBlocksPerTable
=
taosMemoryCalloc
(
1
,
sizeof
(
int32_t
)
*
numOfTables
);
pSup
->
numOfBlocksPerTable
=
taosMemoryCalloc
(
1
,
sizeof
(
int32_t
)
*
numOfTables
);
pSup
->
indexPerTable
=
taosMemoryCalloc
(
1
,
sizeof
(
int32_t
)
*
numOfTables
);
pSup
->
indexPerTable
=
taosMemoryCalloc
(
1
,
sizeof
(
int32_t
)
*
numOfTables
);
pSup
->
pDataBlockInfo
=
taosMemoryCalloc
(
1
,
POINTER_BYTES
*
numOfTables
);
pSup
->
pDataBlockInfo
=
taosMemoryCalloc
(
1
,
POINTER_BYTES
*
numOfTables
);
...
@@ -1331,7 +1278,10 @@ static int32_t initBlockIterator(STsdbReader* pReader, SDataBlockIter* pBlockIte
...
@@ -1331,7 +1278,10 @@ static int32_t initBlockIterator(STsdbReader* pReader, SDataBlockIter* pBlockIte
sup
.
numOfTables
+=
1
;
sup
.
numOfTables
+=
1
;
}
}
ASSERT
(
numOfBlocks
==
cnt
);
if
(
numOfBlocks
!=
cnt
&&
sup
.
numOfTables
!=
numOfTables
)
{
cleanupBlockOrderSupporter
(
&
sup
);
return
TSDB_CODE_INVALID_PARA
;
}
// since there is only one table qualified, blocks are not sorted
// since there is only one table qualified, blocks are not sorted
if
(
sup
.
numOfTables
==
1
)
{
if
(
sup
.
numOfTables
==
1
)
{
...
@@ -1353,9 +1303,8 @@ static int32_t initBlockIterator(STsdbReader* pReader, SDataBlockIter* pBlockIte
...
@@ -1353,9 +1303,8 @@ static int32_t initBlockIterator(STsdbReader* pReader, SDataBlockIter* pBlockIte
tsdbDebug
(
"%p create data blocks info struct completed, %d blocks in %d tables %s"
,
pReader
,
cnt
,
sup
.
numOfTables
,
tsdbDebug
(
"%p create data blocks info struct completed, %d blocks in %d tables %s"
,
pReader
,
cnt
,
sup
.
numOfTables
,
pReader
->
idStr
);
pReader
->
idStr
);
ASSERT
(
cnt
<=
numOfBlocks
&&
sup
.
numOfTables
<=
numOfTables
);
SMultiwayMergeTreeInfo
*
pTree
=
NULL
;
SMultiwayMergeTreeInfo
*
pTree
=
NULL
;
uint8_t
ret
=
tMergeTreeCreate
(
&
pTree
,
sup
.
numOfTables
,
&
sup
,
fileDataBlockOrderCompar
);
uint8_t
ret
=
tMergeTreeCreate
(
&
pTree
,
sup
.
numOfTables
,
&
sup
,
fileDataBlockOrderCompar
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
cleanupBlockOrderSupporter
(
&
sup
);
cleanupBlockOrderSupporter
(
&
sup
);
...
@@ -1434,8 +1383,6 @@ static bool getNeighborBlockOfSameTable(SFileDataBlockInfo* pBlockInfo, STableBl
...
@@ -1434,8 +1383,6 @@ static bool getNeighborBlockOfSameTable(SFileDataBlockInfo* pBlockInfo, STableBl
}
}
static
int32_t
findFileBlockInfoIndex
(
SDataBlockIter
*
pBlockIter
,
SFileDataBlockInfo
*
pFBlockInfo
)
{
static
int32_t
findFileBlockInfoIndex
(
SDataBlockIter
*
pBlockIter
,
SFileDataBlockInfo
*
pFBlockInfo
)
{
ASSERT
(
pBlockIter
!=
NULL
&&
pFBlockInfo
!=
NULL
);
int32_t
step
=
ASCENDING_TRAVERSE
(
pBlockIter
->
order
)
?
1
:
-
1
;
int32_t
step
=
ASCENDING_TRAVERSE
(
pBlockIter
->
order
)
?
1
:
-
1
;
int32_t
index
=
pBlockIter
->
index
;
int32_t
index
=
pBlockIter
->
index
;
...
@@ -1926,7 +1873,6 @@ static int32_t doMergeFileBlockAndLastBlock(SLastBlockReader* pLastBlockReader,
...
@@ -1926,7 +1873,6 @@ static int32_t doMergeFileBlockAndLastBlock(SLastBlockReader* pLastBlockReader,
}
}
doMergeRowsInLastBlock
(
pLastBlockReader
,
pBlockScanInfo
,
tsLastBlock
,
&
merge
,
&
pReader
->
verRange
);
doMergeRowsInLastBlock
(
pLastBlockReader
,
pBlockScanInfo
,
tsLastBlock
,
&
merge
,
&
pReader
->
verRange
);
ASSERT
(
mergeBlockData
);
// merge with block data if ts == key
// merge with block data if ts == key
if
(
tsLastBlock
==
pBlockData
->
aTSKEY
[
pDumpInfo
->
rowIndex
])
{
if
(
tsLastBlock
==
pBlockData
->
aTSKEY
[
pDumpInfo
->
rowIndex
])
{
...
@@ -1992,7 +1938,6 @@ static int32_t mergeFileBlockAndLastBlock(STsdbReader* pReader, SLastBlockReader
...
@@ -1992,7 +1938,6 @@ static int32_t mergeFileBlockAndLastBlock(STsdbReader* pReader, SLastBlockReader
tsdbRowMergerClear
(
&
merge
);
tsdbRowMergerClear
(
&
merge
);
return
code
;
return
code
;
}
else
{
}
else
{
ASSERT
(
0
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
}
else
{
// desc order
}
else
{
// desc order
...
@@ -2013,7 +1958,6 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo*
...
@@ -2013,7 +1958,6 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo*
TSDBROW
*
pRow
=
getValidMemRow
(
&
pBlockScanInfo
->
iter
,
pDelList
,
pReader
);
TSDBROW
*
pRow
=
getValidMemRow
(
&
pBlockScanInfo
->
iter
,
pDelList
,
pReader
);
TSDBROW
*
piRow
=
getValidMemRow
(
&
pBlockScanInfo
->
iiter
,
pDelList
,
pReader
);
TSDBROW
*
piRow
=
getValidMemRow
(
&
pBlockScanInfo
->
iiter
,
pDelList
,
pReader
);
ASSERT
(
pRow
!=
NULL
&&
piRow
!=
NULL
);
int64_t
tsLast
=
INT64_MIN
;
int64_t
tsLast
=
INT64_MIN
;
if
(
hasDataInLastBlock
(
pLastBlockReader
))
{
if
(
hasDataInLastBlock
(
pLastBlockReader
))
{
...
@@ -2237,7 +2181,6 @@ static int32_t initMemDataIterator(STableBlockScanInfo* pBlockScanInfo, STsdbRea
...
@@ -2237,7 +2181,6 @@ static int32_t initMemDataIterator(STableBlockScanInfo* pBlockScanInfo, STsdbRea
if
(
pReader
->
pReadSnap
->
pMem
!=
NULL
)
{
if
(
pReader
->
pReadSnap
->
pMem
!=
NULL
)
{
d
=
tsdbGetTbDataFromMemTable
(
pReader
->
pReadSnap
->
pMem
,
pReader
->
suid
,
pBlockScanInfo
->
uid
);
d
=
tsdbGetTbDataFromMemTable
(
pReader
->
pReadSnap
->
pMem
,
pReader
->
suid
,
pBlockScanInfo
->
uid
);
if
(
d
!=
NULL
)
{
if
(
d
!=
NULL
)
{
ASSERT
(
pBlockScanInfo
->
iter
.
iter
==
NULL
);
code
=
tsdbTbDataIterCreate
(
d
,
&
startKey
,
backward
,
&
pBlockScanInfo
->
iter
.
iter
);
code
=
tsdbTbDataIterCreate
(
d
,
&
startKey
,
backward
,
&
pBlockScanInfo
->
iter
.
iter
);
if
(
code
==
TSDB_CODE_SUCCESS
)
{
if
(
code
==
TSDB_CODE_SUCCESS
)
{
pBlockScanInfo
->
iter
.
hasVal
=
(
tsdbTbDataIterGet
(
pBlockScanInfo
->
iter
.
iter
)
!=
NULL
);
pBlockScanInfo
->
iter
.
hasVal
=
(
tsdbTbDataIterGet
(
pBlockScanInfo
->
iter
.
iter
)
!=
NULL
);
...
@@ -2351,10 +2294,9 @@ static int64_t getCurrentKeyInLastBlock(SLastBlockReader* pLastBlockReader) {
...
@@ -2351,10 +2294,9 @@ static int64_t getCurrentKeyInLastBlock(SLastBlockReader* pLastBlockReader) {
static
bool
hasDataInLastBlock
(
SLastBlockReader
*
pLastBlockReader
)
{
return
pLastBlockReader
->
mergeTree
.
pIter
!=
NULL
;
}
static
bool
hasDataInLastBlock
(
SLastBlockReader
*
pLastBlockReader
)
{
return
pLastBlockReader
->
mergeTree
.
pIter
!=
NULL
;
}
bool
hasDataInFileBlock
(
const
SBlockData
*
pBlockData
,
const
SFileBlockDumpInfo
*
pDumpInfo
)
{
bool
hasDataInFileBlock
(
const
SBlockData
*
pBlockData
,
const
SFileBlockDumpInfo
*
pDumpInfo
)
{
if
(
pBlockData
->
nRow
>
0
)
{
if
(
(
pBlockData
->
nRow
>
0
)
&&
(
pBlockData
->
nRow
!=
pDumpInfo
->
totalRows
)
)
{
ASSERT
(
pBlockData
->
nRow
==
pDumpInfo
->
totalRows
);
return
false
;
// this is an invalid result.
}
}
return
pBlockData
->
nRow
>
0
&&
(
!
pDumpInfo
->
allDumped
);
return
pBlockData
->
nRow
>
0
&&
(
!
pDumpInfo
->
allDumped
);
}
}
...
@@ -2585,7 +2527,6 @@ int32_t initDelSkylineIterator(STableBlockScanInfo* pBlockScanInfo, STsdbReader*
...
@@ -2585,7 +2527,6 @@ int32_t initDelSkylineIterator(STableBlockScanInfo* pBlockScanInfo, STsdbReader*
int32_t
code
=
0
;
int32_t
code
=
0
;
SArray
*
pDelData
=
taosArrayInit
(
4
,
sizeof
(
SDelData
));
SArray
*
pDelData
=
taosArrayInit
(
4
,
sizeof
(
SDelData
));
ASSERT
(
pReader
->
pReadSnap
!=
NULL
);
SDelFile
*
pDelFile
=
pReader
->
pReadSnap
->
fs
.
pDelFile
;
SDelFile
*
pDelFile
=
pReader
->
pReadSnap
->
fs
.
pDelFile
;
if
(
pDelFile
&&
taosArrayGetSize
(
pReader
->
pDelIdx
)
>
0
)
{
if
(
pDelFile
&&
taosArrayGetSize
(
pReader
->
pDelIdx
)
>
0
)
{
...
@@ -2869,7 +2810,6 @@ static int32_t doBuildDataBlock(STsdbReader* pReader) {
...
@@ -2869,7 +2810,6 @@ static int32_t doBuildDataBlock(STsdbReader* pReader) {
TSDBKEY
keyInBuf
=
getCurrentKeyInBuf
(
pScanInfo
,
pReader
);
TSDBKEY
keyInBuf
=
getCurrentKeyInBuf
(
pScanInfo
,
pReader
);
if
(
pBlockInfo
==
NULL
)
{
// build data block from last data file
if
(
pBlockInfo
==
NULL
)
{
// build data block from last data file
ASSERT
(
pBlockIter
->
numOfBlocks
==
0
);
code
=
buildComposedDataBlock
(
pReader
);
code
=
buildComposedDataBlock
(
pReader
);
}
else
if
(
fileBlockShouldLoad
(
pReader
,
pBlockInfo
,
pBlock
,
pScanInfo
,
keyInBuf
,
pLastBlockReader
))
{
}
else
if
(
fileBlockShouldLoad
(
pReader
,
pBlockInfo
,
pBlock
,
pScanInfo
,
keyInBuf
,
pLastBlockReader
))
{
code
=
doLoadFileBlockData
(
pReader
,
pBlockIter
,
&
pStatus
->
fileBlockData
,
pScanInfo
->
uid
);
code
=
doLoadFileBlockData
(
pReader
,
pBlockIter
,
&
pStatus
->
fileBlockData
,
pScanInfo
->
uid
);
...
@@ -3872,15 +3812,16 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, void* pTableL
...
@@ -3872,15 +3812,16 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, void* pTableL
}
}
if
(
pReader
->
pSchema
!=
NULL
)
{
if
(
pReader
->
pSchema
!=
NULL
)
{
updateBlockSMAInfo
(
pReader
->
pSchema
,
&
pReader
->
suppInfo
);
code
=
updateBlockSMAInfo
(
pReader
->
pSchema
,
&
pReader
->
suppInfo
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_err
;
}
}
}
STsdbReader
*
p
=
(
pReader
->
innerReader
[
0
]
!=
NULL
)
?
pReader
->
innerReader
[
0
]
:
pReader
;
STsdbReader
*
p
=
(
pReader
->
innerReader
[
0
]
!=
NULL
)
?
pReader
->
innerReader
[
0
]
:
pReader
;
pReader
->
status
.
pTableMap
=
createDataBlockScanInfo
(
p
,
&
pReader
->
blockInfoBuf
,
pTableList
,
numOfTables
);
pReader
->
status
.
pTableMap
=
createDataBlockScanInfo
(
p
,
&
pReader
->
blockInfoBuf
,
pTableList
,
numOfTables
);
if
(
pReader
->
status
.
pTableMap
==
NULL
)
{
if
(
pReader
->
status
.
pTableMap
==
NULL
)
{
tsdbReaderClose
(
p
);
*
ppReader
=
NULL
;
*
ppReader
=
NULL
;
code
=
TSDB_CODE_OUT_OF_MEMORY
;
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_err
;
goto
_err
;
}
}
...
@@ -4146,25 +4087,27 @@ static void doFillNullColSMA(SBlockLoadSuppInfo* pSup, int32_t numOfRows, int32_
...
@@ -4146,25 +4087,27 @@ static void doFillNullColSMA(SBlockLoadSuppInfo* pSup, int32_t numOfRows, int32_
}
}
int32_t
tsdbRetrieveDatablockSMA
(
STsdbReader
*
pReader
,
SSDataBlock
*
pDataBlock
,
bool
*
allHave
)
{
int32_t
tsdbRetrieveDatablockSMA
(
STsdbReader
*
pReader
,
SSDataBlock
*
pDataBlock
,
bool
*
allHave
)
{
SColumnDataAgg
***
pBlockSMA
=
&
pDataBlock
->
pBlockAgg
;
int32_t
code
=
0
;
int32_t
code
=
0
;
SColumnDataAgg
***
pBlockSMA
=
&
pDataBlock
->
pBlockAgg
;
*
allHave
=
false
;
*
allHave
=
false
;
*
pBlockSMA
=
NULL
;
if
(
pReader
->
type
==
TIMEWINDOW_RANGE_EXTERNAL
)
{
if
(
pReader
->
type
==
TIMEWINDOW_RANGE_EXTERNAL
)
{
*
pBlockSMA
=
NULL
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
// there is no statistics data for composed block
// there is no statistics data for composed block
if
(
pReader
->
status
.
composedDataBlock
||
(
!
pReader
->
suppInfo
.
smaValid
))
{
if
(
pReader
->
status
.
composedDataBlock
||
(
!
pReader
->
suppInfo
.
smaValid
))
{
*
pBlockSMA
=
NULL
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
SFileDataBlockInfo
*
pFBlock
=
getCurrentBlockInfo
(
&
pReader
->
status
.
blockIter
);
SFileDataBlockInfo
*
pFBlock
=
getCurrentBlockInfo
(
&
pReader
->
status
.
blockIter
);
SBlockLoadSuppInfo
*
pSup
=
&
pReader
->
suppInfo
;
SBlockLoadSuppInfo
*
pSup
=
&
pReader
->
suppInfo
;
ASSERT
(
pReader
->
pResBlock
->
info
.
id
.
uid
==
pFBlock
->
uid
);
if
(
pReader
->
pResBlock
->
info
.
id
.
uid
!=
pFBlock
->
uid
)
{
return
TSDB_CODE_SUCCESS
;
}
SDataBlk
*
pBlock
=
getCurrentBlock
(
&
pReader
->
status
.
blockIter
);
SDataBlk
*
pBlock
=
getCurrentBlock
(
&
pReader
->
status
.
blockIter
);
if
(
tDataBlkHasSma
(
pBlock
))
{
if
(
tDataBlkHasSma
(
pBlock
))
{
...
@@ -4192,11 +4135,8 @@ int32_t tsdbRetrieveDatablockSMA(STsdbReader* pReader, SSDataBlock* pDataBlock,
...
@@ -4192,11 +4135,8 @@ int32_t tsdbRetrieveDatablockSMA(STsdbReader* pReader, SSDataBlock* pDataBlock,
// update the number of NULL data rows
// update the number of NULL data rows
size_t
numOfCols
=
pSup
->
numOfCols
;
size_t
numOfCols
=
pSup
->
numOfCols
;
int32_t
i
=
0
,
j
=
0
;
size_t
size
=
taosArrayGetSize
(
pSup
->
pColAgg
);
// ensure capacity
// ensure capacity
if
(
pDataBlock
->
pDataBlock
)
{
if
(
pDataBlock
->
pDataBlock
)
{
size_t
colsNum
=
taosArrayGetSize
(
pDataBlock
->
pDataBlock
);
size_t
colsNum
=
taosArrayGetSize
(
pDataBlock
->
pDataBlock
);
taosArrayEnsureCap
(
pSup
->
pColAgg
,
colsNum
);
taosArrayEnsureCap
(
pSup
->
pColAgg
,
colsNum
);
}
}
...
@@ -4209,8 +4149,9 @@ int32_t tsdbRetrieveDatablockSMA(STsdbReader* pReader, SSDataBlock* pDataBlock,
...
@@ -4209,8 +4149,9 @@ int32_t tsdbRetrieveDatablockSMA(STsdbReader* pReader, SSDataBlock* pDataBlock,
// do fill all null column value SMA info
// do fill all null column value SMA info
doFillNullColSMA
(
pSup
,
pBlock
->
nRow
,
numOfCols
,
pTsAgg
);
doFillNullColSMA
(
pSup
,
pBlock
->
nRow
,
numOfCols
,
pTsAgg
);
size_t
size
=
taosArrayGetSize
(
pSup
->
pColAgg
);
i
=
0
,
j
=
0
;
i
nt32_t
i
=
0
,
j
=
0
;
while
(
j
<
numOfCols
&&
i
<
size
)
{
while
(
j
<
numOfCols
&&
i
<
size
)
{
SColumnDataAgg
*
pAgg
=
taosArrayGet
(
pSup
->
pColAgg
,
i
);
SColumnDataAgg
*
pAgg
=
taosArrayGet
(
pSup
->
pColAgg
,
i
);
if
(
pAgg
->
colId
==
pSup
->
colId
[
j
])
{
if
(
pAgg
->
colId
==
pSup
->
colId
[
j
])
{
...
@@ -4220,15 +4161,8 @@ int32_t tsdbRetrieveDatablockSMA(STsdbReader* pReader, SSDataBlock* pDataBlock,
...
@@ -4220,15 +4161,8 @@ int32_t tsdbRetrieveDatablockSMA(STsdbReader* pReader, SSDataBlock* pDataBlock,
}
else
if
(
pAgg
->
colId
<
pSup
->
colId
[
j
])
{
}
else
if
(
pAgg
->
colId
<
pSup
->
colId
[
j
])
{
i
+=
1
;
i
+=
1
;
}
else
if
(
pSup
->
colId
[
j
]
<
pAgg
->
colId
)
{
}
else
if
(
pSup
->
colId
[
j
]
<
pAgg
->
colId
)
{
if
(
pSup
->
colId
[
j
]
==
PRIMARYKEY_TIMESTAMP_COL_ID
)
{
// ASSERT(pSup->colId[j] == PRIMARYKEY_TIMESTAMP_COL_ID);
pResBlock
->
pBlockAgg
[
pSup
->
slotId
[
j
]]
=
&
pSup
->
tsColAgg
;
pResBlock
->
pBlockAgg
[
pSup
->
slotId
[
j
]]
=
&
pSup
->
tsColAgg
;
}
else
{
// all date in this block are null
SColumnDataAgg
nullColAgg
=
{.
colId
=
pSup
->
colId
[
j
],
.
numOfNull
=
pBlock
->
nRow
};
taosArrayPush
(
pSup
->
pColAgg
,
&
nullColAgg
);
pResBlock
->
pBlockAgg
[
pSup
->
slotId
[
j
]]
=
taosArrayGetLast
(
pSup
->
pColAgg
);
}
j
+=
1
;
j
+=
1
;
}
}
}
}
...
@@ -4460,9 +4394,12 @@ int32_t tsdbGetTableSchema(SVnode* pVnode, int64_t uid, STSchema** pSchema, int6
...
@@ -4460,9 +4394,12 @@ int32_t tsdbGetTableSchema(SVnode* pVnode, int64_t uid, STSchema** pSchema, int6
return
terrno
;
return
terrno
;
}
}
sversion
=
mr
.
me
.
stbEntry
.
schemaRow
.
version
;
sversion
=
mr
.
me
.
stbEntry
.
schemaRow
.
version
;
}
else
{
}
else
if
(
mr
.
me
.
type
==
TSDB_NORMAL_TABLE
)
{
ASSERT
(
mr
.
me
.
type
==
TSDB_NORMAL_TABLE
);
sversion
=
mr
.
me
.
ntbEntry
.
schemaRow
.
version
;
sversion
=
mr
.
me
.
ntbEntry
.
schemaRow
.
version
;
}
else
{
terrno
=
TSDB_CODE_INVALID_PARA
;
metaReaderClear
(
&
mr
);
return
terrno
;
}
}
metaReaderClear
(
&
mr
);
metaReaderClear
(
&
mr
);
...
...
source/dnode/vnode/src/vnd/vnodeCommit.c
浏览文件 @
fb628f7f
...
@@ -184,18 +184,51 @@ _err:
...
@@ -184,18 +184,51 @@ _err:
return
-
1
;
return
-
1
;
}
}
static
int32_t
vnodePrepareCommit
(
SVnode
*
pVnode
)
{
static
int32_t
vnodePrepareCommit
(
SVnode
*
pVnode
,
SCommitInfo
*
pInfo
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
int32_t
lino
=
0
;
char
dir
[
TSDB_FILENAME_LEN
]
=
{
0
};
tsem_wait
(
&
pVnode
->
canCommit
);
tsem_wait
(
&
pVnode
->
canCommit
);
pVnode
->
state
.
commitTerm
=
pVnode
->
state
.
applyTerm
;
pInfo
->
info
.
config
=
pVnode
->
config
;
pInfo
->
info
.
state
.
committed
=
pVnode
->
state
.
applied
;
pInfo
->
info
.
state
.
commitTerm
=
pVnode
->
state
.
applyTerm
;
pInfo
->
info
.
state
.
commitID
=
pVnode
->
state
.
commitID
;
pInfo
->
pVnode
=
pVnode
;
pInfo
->
txn
=
metaGetTxn
(
pVnode
->
pMeta
);
// save info
if
(
pVnode
->
pTfs
)
{
snprintf
(
dir
,
TSDB_FILENAME_LEN
,
"%s%s%s"
,
tfsGetPrimaryPath
(
pVnode
->
pTfs
),
TD_DIRSEP
,
pVnode
->
path
);
}
else
{
snprintf
(
dir
,
TSDB_FILENAME_LEN
,
"%s"
,
pVnode
->
path
);
}
if
(
vnodeSaveInfo
(
dir
,
&
pInfo
->
info
)
<
0
)
{
code
=
terrno
;
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
tsdbPrepareCommit
(
pVnode
->
pTsdb
);
tsdbPrepareCommit
(
pVnode
->
pTsdb
);
metaPrepareAsyncCommit
(
pVnode
->
pMeta
);
metaPrepareAsyncCommit
(
pVnode
->
pMeta
);
code
=
smaPrepareAsyncCommit
(
pVnode
->
pSma
);
code
=
smaPrepareAsyncCommit
(
pVnode
->
pSma
);
if
(
code
)
goto
_exit
;
if
(
code
)
goto
_exit
;
_exit:
vnodeBufPoolUnRef
(
pVnode
->
inUse
);
vnodeBufPoolUnRef
(
pVnode
->
inUse
);
pVnode
->
inUse
=
NULL
;
pVnode
->
inUse
=
NULL
;
_exit:
if
(
code
)
{
vError
(
"vgId:%d, %s failed at line %d since %s, commit id:%"
PRId64
,
TD_VID
(
pVnode
),
__func__
,
lino
,
tstrerror
(
code
),
pVnode
->
state
.
commitID
);
}
else
{
vDebug
(
"vgId:%d, %s done"
,
TD_VID
(
pVnode
),
__func__
);
}
return
code
;
return
code
;
}
}
...
@@ -217,33 +250,32 @@ _exit:
...
@@ -217,33 +250,32 @@ _exit:
int
vnodeAsyncCommit
(
SVnode
*
pVnode
)
{
int
vnodeAsyncCommit
(
SVnode
*
pVnode
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
// prepare to commit
code
=
vnodePrepareCommit
(
pVnode
);
if
(
code
)
goto
_exit
;
// schedule the task
pVnode
->
state
.
commitTerm
=
pVnode
->
state
.
applyTerm
;
SCommitInfo
*
pInfo
=
(
SCommitInfo
*
)
taosMemoryCalloc
(
1
,
sizeof
(
*
pInfo
));
SCommitInfo
*
pInfo
=
(
SCommitInfo
*
)
taosMemoryCalloc
(
1
,
sizeof
(
*
pInfo
));
if
(
NULL
==
pInfo
)
{
if
(
NULL
==
pInfo
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_exit
;
goto
_exit
;
}
}
pInfo
->
info
.
config
=
pVnode
->
config
;
pInfo
->
info
.
state
.
committed
=
pVnode
->
state
.
applied
;
// prepare to commit
pInfo
->
info
.
state
.
commitTerm
=
pVnode
->
state
.
applyTerm
;
code
=
vnodePrepareCommit
(
pVnode
,
pInfo
);
pInfo
->
info
.
state
.
commitID
=
pVnode
->
state
.
commitID
;
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
pInfo
->
pVnode
=
pVnode
;
goto
_exit
;
pInfo
->
txn
=
metaGetTxn
(
pVnode
->
pMeta
);
}
// schedule the task
code
=
vnodeScheduleTask
(
vnodeCommitTask
,
pInfo
);
code
=
vnodeScheduleTask
(
vnodeCommitTask
,
pInfo
);
_exit:
_exit:
if
(
code
)
{
if
(
code
)
{
if
(
NULL
!=
pInfo
)
{
taosMemoryFree
(
pInfo
);
}
tsem_post
(
&
pVnode
->
canCommit
);
tsem_post
(
&
pVnode
->
canCommit
);
vError
(
"vgId:%d, %s failed since %s, commit id:%"
PRId64
,
TD_VID
(
pVnode
),
__func__
,
tstrerror
(
code
),
vError
(
"vgId:%d, %s failed since %s, commit id:%"
PRId64
,
TD_VID
(
pVnode
),
__func__
,
tstrerror
(
code
),
pVnode
->
state
.
commitID
);
pVnode
->
state
.
commitID
);
}
else
{
}
else
{
vDebug
(
"vgId:%d, %s done"
,
TD_VID
(
pVnode
),
__func__
);
vInfo
(
"vgId:%d, vnode async commit done, commitId:%"
PRId64
" term:%"
PRId64
" applied:%"
PRId64
,
TD_VID
(
pVnode
),
pVnode
->
state
.
commitID
,
pVnode
->
state
.
applyTerm
,
pVnode
->
state
.
applied
);
}
}
return
code
;
return
code
;
}
}
...
@@ -262,7 +294,7 @@ static int vnodeCommitImpl(SCommitInfo *pInfo) {
...
@@ -262,7 +294,7 @@ static int vnodeCommitImpl(SCommitInfo *pInfo) {
char
dir
[
TSDB_FILENAME_LEN
]
=
{
0
};
char
dir
[
TSDB_FILENAME_LEN
]
=
{
0
};
SVnode
*
pVnode
=
pInfo
->
pVnode
;
SVnode
*
pVnode
=
pInfo
->
pVnode
;
vInfo
(
"vgId:%d, start to commit, commit
ID
:%"
PRId64
" version:%"
PRId64
" term: %"
PRId64
,
TD_VID
(
pVnode
),
vInfo
(
"vgId:%d, start to commit, commit
Id
:%"
PRId64
" version:%"
PRId64
" term: %"
PRId64
,
TD_VID
(
pVnode
),
pVnode
->
state
.
commitID
,
pVnode
->
state
.
applied
,
pVnode
->
state
.
applyTerm
);
pVnode
->
state
.
commitID
,
pVnode
->
state
.
applied
,
pVnode
->
state
.
applyTerm
);
// persist wal before starting
// persist wal before starting
...
@@ -271,16 +303,11 @@ static int vnodeCommitImpl(SCommitInfo *pInfo) {
...
@@ -271,16 +303,11 @@ static int vnodeCommitImpl(SCommitInfo *pInfo) {
return
-
1
;
return
-
1
;
}
}
// save info
if
(
pVnode
->
pTfs
)
{
if
(
pVnode
->
pTfs
)
{
snprintf
(
dir
,
TSDB_FILENAME_LEN
,
"%s%s%s"
,
tfsGetPrimaryPath
(
pVnode
->
pTfs
),
TD_DIRSEP
,
pVnode
->
path
);
snprintf
(
dir
,
TSDB_FILENAME_LEN
,
"%s%s%s"
,
tfsGetPrimaryPath
(
pVnode
->
pTfs
),
TD_DIRSEP
,
pVnode
->
path
);
}
else
{
}
else
{
snprintf
(
dir
,
TSDB_FILENAME_LEN
,
"%s"
,
pVnode
->
path
);
snprintf
(
dir
,
TSDB_FILENAME_LEN
,
"%s"
,
pVnode
->
path
);
}
}
if
(
vnodeSaveInfo
(
dir
,
&
pInfo
->
info
)
<
0
)
{
code
=
terrno
;
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
// walBeginSnapshot(pVnode->pWal, pVnode->state.applied);
// walBeginSnapshot(pVnode->pWal, pVnode->state.applied);
syncBeginSnapshot
(
pVnode
->
sync
,
pVnode
->
state
.
applied
);
syncBeginSnapshot
(
pVnode
->
sync
,
pVnode
->
state
.
applied
);
...
...
source/dnode/vnode/src/vnd/vnodeSnapshot.c
浏览文件 @
fb628f7f
...
@@ -257,7 +257,7 @@ _exit:
...
@@ -257,7 +257,7 @@ _exit:
pReader
->
index
++
;
pReader
->
index
++
;
*
nData
=
sizeof
(
SSnapDataHdr
)
+
pHdr
->
size
;
*
nData
=
sizeof
(
SSnapDataHdr
)
+
pHdr
->
size
;
pHdr
->
index
=
pReader
->
index
;
pHdr
->
index
=
pReader
->
index
;
v
Info
(
"vgId:%d, vnode snapshot read data,index:%"
PRId64
" type:%d nData
:%d "
,
TD_VID
(
pReader
->
pVnode
),
v
Debug
(
"vgId:%d, vnode snapshot read data, index:%"
PRId64
" type:%d blockLen
:%d "
,
TD_VID
(
pReader
->
pVnode
),
pReader
->
index
,
pHdr
->
type
,
*
nData
);
pReader
->
index
,
pHdr
->
type
,
*
nData
);
}
else
{
}
else
{
vInfo
(
"vgId:%d, vnode snapshot read data end, index:%"
PRId64
,
TD_VID
(
pReader
->
pVnode
),
pReader
->
index
);
vInfo
(
"vgId:%d, vnode snapshot read data end, index:%"
PRId64
,
TD_VID
(
pReader
->
pVnode
),
pReader
->
index
);
...
@@ -423,7 +423,7 @@ int32_t vnodeSnapWrite(SVSnapWriter *pWriter, uint8_t *pData, uint32_t nData) {
...
@@ -423,7 +423,7 @@ int32_t vnodeSnapWrite(SVSnapWriter *pWriter, uint8_t *pData, uint32_t nData) {
ASSERT
(
pHdr
->
index
==
pWriter
->
index
+
1
);
ASSERT
(
pHdr
->
index
==
pWriter
->
index
+
1
);
pWriter
->
index
=
pHdr
->
index
;
pWriter
->
index
=
pHdr
->
index
;
v
Info
(
"vgId:%d, vnode snapshot write data, index:%"
PRId64
" type:%d nData
:%d"
,
TD_VID
(
pVnode
),
pHdr
->
index
,
v
Debug
(
"vgId:%d, vnode snapshot write data, index:%"
PRId64
" type:%d blockLen
:%d"
,
TD_VID
(
pVnode
),
pHdr
->
index
,
pHdr
->
type
,
nData
);
pHdr
->
type
,
nData
);
switch
(
pHdr
->
type
)
{
switch
(
pHdr
->
type
)
{
...
...
source/dnode/vnode/src/vnd/vnodeSvr.c
浏览文件 @
fb628f7f
...
@@ -217,7 +217,7 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRp
...
@@ -217,7 +217,7 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRp
if
(
!
syncUtilUserCommit
(
pMsg
->
msgType
))
goto
_exit
;
if
(
!
syncUtilUserCommit
(
pMsg
->
msgType
))
goto
_exit
;
if
(
pMsg
->
msgType
==
TDMT_VND_STREAM_RECOVER_BLOCKING_STAGE
)
{
if
(
pMsg
->
msgType
==
TDMT_VND_STREAM_RECOVER_BLOCKING_STAGE
||
pMsg
->
msgType
==
TDMT_STREAM_TASK_CHECK_RSP
)
{
if
(
tqCheckLogInWal
(
pVnode
->
pTq
,
version
))
return
0
;
if
(
tqCheckLogInWal
(
pVnode
->
pTq
,
version
))
return
0
;
}
}
...
...
source/dnode/vnode/src/vnd/vnodeSync.c
浏览文件 @
fb628f7f
...
@@ -391,9 +391,9 @@ static int32_t vnodeSyncApplyMsg(const SSyncFSM *pFsm, SRpcMsg *pMsg, const SFsm
...
@@ -391,9 +391,9 @@ static int32_t vnodeSyncApplyMsg(const SSyncFSM *pFsm, SRpcMsg *pMsg, const SFsm
const
STraceId
*
trace
=
&
pMsg
->
info
.
traceId
;
const
STraceId
*
trace
=
&
pMsg
->
info
.
traceId
;
vGTrace
(
"vgId:%d, commit-cb is excuted, fsm:%p, index:%"
PRId64
", term:%"
PRIu64
", msg-index:%"
PRId64
vGTrace
(
"vgId:%d, commit-cb is excuted, fsm:%p, index:%"
PRId64
", term:%"
PRIu64
", msg-index:%"
PRId64
", weak:%d, code:%d, state:%d %s, type:%s"
,
", weak:%d, code:%d, state:%d %s, type:%s
code:0x%x
"
,
pVnode
->
config
.
vgId
,
pFsm
,
pMeta
->
index
,
pMeta
->
term
,
pMsg
->
info
.
conn
.
applyIndex
,
pMeta
->
isWeak
,
pMeta
->
code
,
pVnode
->
config
.
vgId
,
pFsm
,
pMeta
->
index
,
pMeta
->
term
,
pMsg
->
info
.
conn
.
applyIndex
,
pMeta
->
isWeak
,
pMeta
->
code
,
pMeta
->
state
,
syncStr
(
pMeta
->
state
),
TMSG_INFO
(
pMsg
->
msgType
));
pMeta
->
state
,
syncStr
(
pMeta
->
state
),
TMSG_INFO
(
pMsg
->
msgType
)
,
pMsg
->
code
);
return
tmsgPutToQueue
(
&
pVnode
->
msgCb
,
APPLY_QUEUE
,
pMsg
);
return
tmsgPutToQueue
(
&
pVnode
->
msgCb
,
APPLY_QUEUE
,
pMsg
);
}
}
...
@@ -465,9 +465,9 @@ static int32_t vnodeSnapshotStopWrite(const SSyncFSM *pFsm, void *pWriter, bool
...
@@ -465,9 +465,9 @@ static int32_t vnodeSnapshotStopWrite(const SSyncFSM *pFsm, void *pWriter, bool
static
int32_t
vnodeSnapshotDoWrite
(
const
SSyncFSM
*
pFsm
,
void
*
pWriter
,
void
*
pBuf
,
int32_t
len
)
{
static
int32_t
vnodeSnapshotDoWrite
(
const
SSyncFSM
*
pFsm
,
void
*
pWriter
,
void
*
pBuf
,
int32_t
len
)
{
SVnode
*
pVnode
=
pFsm
->
data
;
SVnode
*
pVnode
=
pFsm
->
data
;
vDebug
(
"vgId:%d, continue write vnode snapshot,
l
en:%d"
,
pVnode
->
config
.
vgId
,
len
);
vDebug
(
"vgId:%d, continue write vnode snapshot,
blockL
en:%d"
,
pVnode
->
config
.
vgId
,
len
);
int32_t
code
=
vnodeSnapWrite
(
pWriter
,
pBuf
,
len
);
int32_t
code
=
vnodeSnapWrite
(
pWriter
,
pBuf
,
len
);
vDebug
(
"vgId:%d, continue write vnode snapshot finished,
l
en:%d"
,
pVnode
->
config
.
vgId
,
len
);
vDebug
(
"vgId:%d, continue write vnode snapshot finished,
blockL
en:%d"
,
pVnode
->
config
.
vgId
,
len
);
return
code
;
return
code
;
}
}
...
...
source/libs/catalog/src/ctgAsync.c
浏览文件 @
fb628f7f
...
@@ -471,17 +471,20 @@ int32_t ctgHandleForceUpdate(SCatalog* pCtg, int32_t taskNum, SCtgJob* pJob, con
...
@@ -471,17 +471,20 @@ int32_t ctgHandleForceUpdate(SCatalog* pCtg, int32_t taskNum, SCtgJob* pJob, con
}
}
int32_t
ctgInitTask
(
SCtgJob
*
pJob
,
CTG_TASK_TYPE
type
,
void
*
param
,
int32_t
*
taskId
)
{
int32_t
ctgInitTask
(
SCtgJob
*
pJob
,
CTG_TASK_TYPE
type
,
void
*
param
,
int32_t
*
taskId
)
{
int32_t
code
=
0
;
int32_t
tid
=
atomic_fetch_add_32
(
&
pJob
->
taskIdx
,
1
);
int32_t
tid
=
atomic_fetch_add_32
(
&
pJob
->
taskIdx
,
1
);
CTG_LOCK
(
CTG_WRITE
,
&
pJob
->
taskLock
);
CTG_LOCK
(
CTG_WRITE
,
&
pJob
->
taskLock
);
CTG_ERR_RET
((
*
gCtgAsyncFps
[
type
].
initFp
)(
pJob
,
tid
,
param
));
CTG_ERR_JRET
((
*
gCtgAsyncFps
[
type
].
initFp
)(
pJob
,
tid
,
param
));
CTG_UNLOCK
(
CTG_WRITE
,
&
pJob
->
taskLock
);
if
(
taskId
)
{
if
(
taskId
)
{
*
taskId
=
tid
;
*
taskId
=
tid
;
}
}
return
TSDB_CODE_SUCCESS
;
_return:
CTG_UNLOCK
(
CTG_WRITE
,
&
pJob
->
taskLock
);
return
code
;
}
}
int32_t
ctgInitJob
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SCtgJob
**
job
,
const
SCatalogReq
*
pReq
,
catalogCallback
fp
,
int32_t
ctgInitJob
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SCtgJob
**
job
,
const
SCatalogReq
*
pReq
,
catalogCallback
fp
,
...
...
source/libs/catalog/src/ctgCache.c
浏览文件 @
fb628f7f
...
@@ -2500,6 +2500,7 @@ int32_t ctgGetTbMetasFromCache(SCatalog *pCtg, SRequestConnInfo *pConn, SCtgTbMe
...
@@ -2500,6 +2500,7 @@ int32_t ctgGetTbMetasFromCache(SCatalog *pCtg, SRequestConnInfo *pConn, SCtgTbMe
CTG_LOCK
(
CTG_READ
,
&
pCache
->
metaLock
);
CTG_LOCK
(
CTG_READ
,
&
pCache
->
metaLock
);
if
(
NULL
==
pCache
->
pMeta
)
{
if
(
NULL
==
pCache
->
pMeta
)
{
CTG_UNLOCK
(
CTG_READ
,
&
pCache
->
metaLock
);
ctgDebug
(
"tb %s meta not in cache, dbFName:%s"
,
pName
->
tname
,
dbFName
);
ctgDebug
(
"tb %s meta not in cache, dbFName:%s"
,
pName
->
tname
,
dbFName
);
ctgAddFetch
(
&
ctx
->
pFetchs
,
dbIdx
,
i
,
fetchIdx
,
baseResIdx
+
i
,
flag
);
ctgAddFetch
(
&
ctx
->
pFetchs
,
dbIdx
,
i
,
fetchIdx
,
baseResIdx
+
i
,
flag
);
taosArraySetSize
(
ctx
->
pResList
,
taosArrayGetSize
(
ctx
->
pResList
)
+
1
);
taosArraySetSize
(
ctx
->
pResList
,
taosArrayGetSize
(
ctx
->
pResList
)
+
1
);
...
...
source/libs/executor/src/dataDeleter.c
浏览文件 @
fb628f7f
...
@@ -62,8 +62,8 @@ static void toDataCacheEntry(SDataDeleterHandle* pHandle, const SInputData* pInp
...
@@ -62,8 +62,8 @@ static void toDataCacheEntry(SDataDeleterHandle* pHandle, const SInputData* pInp
pEntry
->
numOfCols
=
taosArrayGetSize
(
pInput
->
pData
->
pDataBlock
);
pEntry
->
numOfCols
=
taosArrayGetSize
(
pInput
->
pData
->
pDataBlock
);
pEntry
->
dataLen
=
sizeof
(
SDeleterRes
);
pEntry
->
dataLen
=
sizeof
(
SDeleterRes
);
ASSERT
(
1
==
pEntry
->
numOfRows
);
//
ASSERT(1 == pEntry->numOfRows);
ASSERT
(
3
==
pEntry
->
numOfCols
);
//
ASSERT(3 == pEntry->numOfCols);
pBuf
->
useSize
=
sizeof
(
SDataCacheEntry
);
pBuf
->
useSize
=
sizeof
(
SDataCacheEntry
);
...
@@ -167,7 +167,6 @@ static void getDataLength(SDataSinkHandle* pHandle, int64_t* pLen, bool* pQueryE
...
@@ -167,7 +167,6 @@ static void getDataLength(SDataSinkHandle* pHandle, int64_t* pLen, bool* pQueryE
SDataDeleterBuf
*
pBuf
=
NULL
;
SDataDeleterBuf
*
pBuf
=
NULL
;
taosReadQitem
(
pDeleter
->
pDataBlocks
,
(
void
**
)
&
pBuf
);
taosReadQitem
(
pDeleter
->
pDataBlocks
,
(
void
**
)
&
pBuf
);
ASSERT
(
NULL
!=
pBuf
);
memcpy
(
&
pDeleter
->
nextOutput
,
pBuf
,
sizeof
(
SDataDeleterBuf
));
memcpy
(
&
pDeleter
->
nextOutput
,
pBuf
,
sizeof
(
SDataDeleterBuf
));
taosFreeQitem
(
pBuf
);
taosFreeQitem
(
pBuf
);
...
...
source/libs/executor/src/dataDispatcher.c
浏览文件 @
fb628f7f
...
@@ -77,8 +77,8 @@ static void toDataCacheEntry(SDataDispatchHandle* pHandle, const SInputData* pIn
...
@@ -77,8 +77,8 @@ static void toDataCacheEntry(SDataDispatchHandle* pHandle, const SInputData* pIn
pBuf
->
useSize
=
sizeof
(
SDataCacheEntry
);
pBuf
->
useSize
=
sizeof
(
SDataCacheEntry
);
pEntry
->
dataLen
=
blockEncode
(
pInput
->
pData
,
pEntry
->
data
,
numOfCols
);
pEntry
->
dataLen
=
blockEncode
(
pInput
->
pData
,
pEntry
->
data
,
numOfCols
);
ASSERT
(
pEntry
->
numOfRows
==
*
(
int32_t
*
)(
pEntry
->
data
+
8
));
//
ASSERT(pEntry->numOfRows == *(int32_t*)(pEntry->data + 8));
ASSERT
(
pEntry
->
numOfCols
==
*
(
int32_t
*
)(
pEntry
->
data
+
8
+
4
));
//
ASSERT(pEntry->numOfCols == *(int32_t*)(pEntry->data + 8 + 4));
pBuf
->
useSize
+=
pEntry
->
dataLen
;
pBuf
->
useSize
+=
pEntry
->
dataLen
;
...
@@ -162,15 +162,14 @@ static void getDataLength(SDataSinkHandle* pHandle, int64_t* pLen, bool* pQueryE
...
@@ -162,15 +162,14 @@ static void getDataLength(SDataSinkHandle* pHandle, int64_t* pLen, bool* pQueryE
SDataDispatchBuf
*
pBuf
=
NULL
;
SDataDispatchBuf
*
pBuf
=
NULL
;
taosReadQitem
(
pDispatcher
->
pDataBlocks
,
(
void
**
)
&
pBuf
);
taosReadQitem
(
pDispatcher
->
pDataBlocks
,
(
void
**
)
&
pBuf
);
ASSERT
(
NULL
!=
pBuf
);
memcpy
(
&
pDispatcher
->
nextOutput
,
pBuf
,
sizeof
(
SDataDispatchBuf
));
memcpy
(
&
pDispatcher
->
nextOutput
,
pBuf
,
sizeof
(
SDataDispatchBuf
));
taosFreeQitem
(
pBuf
);
taosFreeQitem
(
pBuf
);
SDataCacheEntry
*
pEntry
=
(
SDataCacheEntry
*
)
pDispatcher
->
nextOutput
.
pData
;
SDataCacheEntry
*
pEntry
=
(
SDataCacheEntry
*
)
pDispatcher
->
nextOutput
.
pData
;
*
pLen
=
pEntry
->
dataLen
;
*
pLen
=
pEntry
->
dataLen
;
ASSERT
(
pEntry
->
numOfRows
==
*
(
int32_t
*
)(
pEntry
->
data
+
8
));
//
ASSERT(pEntry->numOfRows == *(int32_t*)(pEntry->data + 8));
ASSERT
(
pEntry
->
numOfCols
==
*
(
int32_t
*
)(
pEntry
->
data
+
8
+
4
));
//
ASSERT(pEntry->numOfCols == *(int32_t*)(pEntry->data + 8 + 4));
*
pQueryEnd
=
pDispatcher
->
queryEnd
;
*
pQueryEnd
=
pDispatcher
->
queryEnd
;
qDebug
(
"got data len %"
PRId64
", row num %d in sink"
,
*
pLen
,
qDebug
(
"got data len %"
PRId64
", row num %d in sink"
,
*
pLen
,
...
@@ -193,8 +192,8 @@ static int32_t getDataBlock(SDataSinkHandle* pHandle, SOutputData* pOutput) {
...
@@ -193,8 +192,8 @@ static int32_t getDataBlock(SDataSinkHandle* pHandle, SOutputData* pOutput) {
pOutput
->
numOfCols
=
pEntry
->
numOfCols
;
pOutput
->
numOfCols
=
pEntry
->
numOfCols
;
pOutput
->
compressed
=
pEntry
->
compressed
;
pOutput
->
compressed
=
pEntry
->
compressed
;
ASSERT
(
pEntry
->
numOfRows
==
*
(
int32_t
*
)(
pEntry
->
data
+
8
));
//
ASSERT(pEntry->numOfRows == *(int32_t*)(pEntry->data + 8));
ASSERT
(
pEntry
->
numOfCols
==
*
(
int32_t
*
)(
pEntry
->
data
+
8
+
4
));
//
ASSERT(pEntry->numOfCols == *(int32_t*)(pEntry->data + 8 + 4));
atomic_sub_fetch_64
(
&
pDispatcher
->
cachedSize
,
pEntry
->
dataLen
);
atomic_sub_fetch_64
(
&
pDispatcher
->
cachedSize
,
pEntry
->
dataLen
);
atomic_sub_fetch_64
(
&
gDataSinkStat
.
cachedSize
,
pEntry
->
dataLen
);
atomic_sub_fetch_64
(
&
gDataSinkStat
.
cachedSize
,
pEntry
->
dataLen
);
...
...
source/libs/executor/src/exchangeoperator.c
浏览文件 @
fb628f7f
...
@@ -373,7 +373,6 @@ int32_t loadRemoteDataCallback(void* param, SDataBuf* pMsg, int32_t code) {
...
@@ -373,7 +373,6 @@ int32_t loadRemoteDataCallback(void* param, SDataBuf* pMsg, int32_t code) {
pRsp
->
useconds
=
htobe64
(
pRsp
->
useconds
);
pRsp
->
useconds
=
htobe64
(
pRsp
->
useconds
);
pRsp
->
numOfBlocks
=
htonl
(
pRsp
->
numOfBlocks
);
pRsp
->
numOfBlocks
=
htonl
(
pRsp
->
numOfBlocks
);
ASSERT
(
pRsp
!=
NULL
);
qDebug
(
"%s fetch rsp received, index:%d, blocks:%d, rows:%"
PRId64
", %p"
,
pSourceDataInfo
->
taskId
,
index
,
pRsp
->
numOfBlocks
,
qDebug
(
"%s fetch rsp received, index:%d, blocks:%d, rows:%"
PRId64
", %p"
,
pSourceDataInfo
->
taskId
,
index
,
pRsp
->
numOfBlocks
,
pRsp
->
numOfRows
,
pExchangeInfo
);
pRsp
->
numOfRows
,
pExchangeInfo
);
}
else
{
}
else
{
...
...
source/libs/executor/src/executor.c
浏览文件 @
fb628f7f
...
@@ -942,7 +942,6 @@ int32_t qStreamRestoreParam(qTaskInfo_t tinfo) {
...
@@ -942,7 +942,6 @@ int32_t qStreamRestoreParam(qTaskInfo_t tinfo) {
}
}
return
0
;
return
0
;
}
}
bool
qStreamRecoverScanFinished
(
qTaskInfo_t
tinfo
)
{
bool
qStreamRecoverScanFinished
(
qTaskInfo_t
tinfo
)
{
SExecTaskInfo
*
pTaskInfo
=
(
SExecTaskInfo
*
)
tinfo
;
SExecTaskInfo
*
pTaskInfo
=
(
SExecTaskInfo
*
)
tinfo
;
return
pTaskInfo
->
streamInfo
.
recoverScanFinished
;
return
pTaskInfo
->
streamInfo
.
recoverScanFinished
;
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
fb628f7f
...
@@ -104,8 +104,6 @@ static int32_t doCopyToSDataBlock(SExecTaskInfo* pTaskInfo, SSDataBlock* pBlock,
...
@@ -104,8 +104,6 @@ static int32_t doCopyToSDataBlock(SExecTaskInfo* pTaskInfo, SSDataBlock* pBlock,
void
setOperatorCompleted
(
SOperatorInfo
*
pOperator
)
{
void
setOperatorCompleted
(
SOperatorInfo
*
pOperator
)
{
pOperator
->
status
=
OP_EXEC_DONE
;
pOperator
->
status
=
OP_EXEC_DONE
;
ASSERT
(
pOperator
->
pTaskInfo
!=
NULL
);
pOperator
->
cost
.
totalCost
=
(
taosGetTimestampUs
()
-
pOperator
->
pTaskInfo
->
cost
.
start
)
/
1000
.
0
;
pOperator
->
cost
.
totalCost
=
(
taosGetTimestampUs
()
-
pOperator
->
pTaskInfo
->
cost
.
start
)
/
1000
.
0
;
setTaskStatus
(
pOperator
->
pTaskInfo
,
TASK_COMPLETED
);
setTaskStatus
(
pOperator
->
pTaskInfo
,
TASK_COMPLETED
);
}
}
...
@@ -524,7 +522,7 @@ bool functionNeedToExecute(SqlFunctionCtx* pCtx) {
...
@@ -524,7 +522,7 @@ bool functionNeedToExecute(SqlFunctionCtx* pCtx) {
return
true
;
return
true
;
}
}
static
int32_t
doCreateConstantValColumn
Agg
Info
(
SInputColumnInfoData
*
pInput
,
SFunctParam
*
pFuncParam
,
int32_t
type
,
static
int32_t
doCreateConstantValColumn
SMA
Info
(
SInputColumnInfoData
*
pInput
,
SFunctParam
*
pFuncParam
,
int32_t
type
,
int32_t
paramIndex
,
int32_t
numOfRows
)
{
int32_t
paramIndex
,
int32_t
numOfRows
)
{
if
(
pInput
->
pData
[
paramIndex
]
==
NULL
)
{
if
(
pInput
->
pData
[
paramIndex
]
==
NULL
)
{
pInput
->
pData
[
paramIndex
]
=
taosMemoryCalloc
(
1
,
sizeof
(
SColumnInfoData
));
pInput
->
pData
[
paramIndex
]
=
taosMemoryCalloc
(
1
,
sizeof
(
SColumnInfoData
));
...
@@ -548,8 +546,6 @@ static int32_t doCreateConstantValColumnAggInfo(SInputColumnInfoData* pInput, SF
...
@@ -548,8 +546,6 @@ static int32_t doCreateConstantValColumnAggInfo(SInputColumnInfoData* pInput, SF
da
=
pInput
->
pColumnDataAgg
[
paramIndex
];
da
=
pInput
->
pColumnDataAgg
[
paramIndex
];
}
}
ASSERT
(
!
IS_VAR_DATA_TYPE
(
type
));
if
(
type
==
TSDB_DATA_TYPE_BIGINT
)
{
if
(
type
==
TSDB_DATA_TYPE_BIGINT
)
{
int64_t
v
=
pFuncParam
->
param
.
i
;
int64_t
v
=
pFuncParam
->
param
.
i
;
*
da
=
(
SColumnDataAgg
){.
numOfNull
=
0
,
.
min
=
v
,
.
max
=
v
,
.
sum
=
v
*
numOfRows
};
*
da
=
(
SColumnDataAgg
){.
numOfNull
=
0
,
.
min
=
v
,
.
max
=
v
,
.
sum
=
v
*
numOfRows
};
...
@@ -570,7 +566,7 @@ static int32_t doCreateConstantValColumnAggInfo(SInputColumnInfoData* pInput, SF
...
@@ -570,7 +566,7 @@ static int32_t doCreateConstantValColumnAggInfo(SInputColumnInfoData* pInput, SF
}
else
if
(
type
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
}
else
if
(
type
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
// do nothing
// do nothing
}
else
{
}
else
{
ASSERT
(
0
);
qError
(
"invalid constant type for sma info"
);
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -600,7 +596,7 @@ void setBlockSMAInfo(SqlFunctionCtx* pCtx, SExprInfo* pExprInfo, SSDataBlock* pB
...
@@ -600,7 +596,7 @@ void setBlockSMAInfo(SqlFunctionCtx* pCtx, SExprInfo* pExprInfo, SSDataBlock* pB
// the data in the corresponding SColumnInfoData will not be used.
// the data in the corresponding SColumnInfoData will not be used.
pInput
->
pData
[
j
]
=
taosArrayGet
(
pBlock
->
pDataBlock
,
slotId
);
pInput
->
pData
[
j
]
=
taosArrayGet
(
pBlock
->
pDataBlock
,
slotId
);
}
else
if
(
pFuncParam
->
type
==
FUNC_PARAM_TYPE_VALUE
)
{
}
else
if
(
pFuncParam
->
type
==
FUNC_PARAM_TYPE_VALUE
)
{
doCreateConstantValColumn
Agg
Info
(
pInput
,
pFuncParam
,
pFuncParam
->
param
.
nType
,
j
,
pBlock
->
info
.
rows
);
doCreateConstantValColumn
SMA
Info
(
pInput
,
pFuncParam
,
pFuncParam
->
param
.
nType
,
j
,
pBlock
->
info
.
rows
);
}
}
}
}
}
else
{
}
else
{
...
@@ -1577,8 +1573,7 @@ void destroyOperatorInfo(SOperatorInfo* pOperator) {
...
@@ -1577,8 +1573,7 @@ void destroyOperatorInfo(SOperatorInfo* pOperator) {
// each operator should be set their own function to return total cost buffer
// each operator should be set their own function to return total cost buffer
int32_t
optrDefaultBufFn
(
SOperatorInfo
*
pOperator
)
{
int32_t
optrDefaultBufFn
(
SOperatorInfo
*
pOperator
)
{
if
(
pOperator
->
blocking
)
{
if
(
pOperator
->
blocking
)
{
ASSERT
(
0
);
return
-
1
;
return
0
;
}
else
{
}
else
{
return
0
;
return
0
;
}
}
...
@@ -2205,7 +2200,6 @@ static int32_t extractTbscanInStreamOpTree(SOperatorInfo* pOperator, STableScanI
...
@@ -2205,7 +2200,6 @@ static int32_t extractTbscanInStreamOpTree(SOperatorInfo* pOperator, STableScanI
return
extractTbscanInStreamOpTree
(
pOperator
->
pDownstream
[
0
],
ppInfo
);
return
extractTbscanInStreamOpTree
(
pOperator
->
pDownstream
[
0
],
ppInfo
);
}
else
{
}
else
{
SStreamScanInfo
*
pInfo
=
pOperator
->
info
;
SStreamScanInfo
*
pInfo
=
pOperator
->
info
;
ASSERT
(
pInfo
->
pTableScanOp
->
operatorType
==
QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN
);
*
ppInfo
=
pInfo
->
pTableScanOp
->
info
;
*
ppInfo
=
pInfo
->
pTableScanOp
->
info
;
return
0
;
return
0
;
}
}
...
@@ -2217,13 +2211,11 @@ int32_t extractTableScanNode(SPhysiNode* pNode, STableScanPhysiNode** ppNode) {
...
@@ -2217,13 +2211,11 @@ int32_t extractTableScanNode(SPhysiNode* pNode, STableScanPhysiNode** ppNode) {
*
ppNode
=
(
STableScanPhysiNode
*
)
pNode
;
*
ppNode
=
(
STableScanPhysiNode
*
)
pNode
;
return
0
;
return
0
;
}
else
{
}
else
{
ASSERT
(
0
);
terrno
=
TSDB_CODE_APP_ERROR
;
terrno
=
TSDB_CODE_APP_ERROR
;
return
-
1
;
return
-
1
;
}
}
}
else
{
}
else
{
if
(
LIST_LENGTH
(
pNode
->
pChildren
)
!=
1
)
{
if
(
LIST_LENGTH
(
pNode
->
pChildren
)
!=
1
)
{
ASSERT
(
0
);
terrno
=
TSDB_CODE_APP_ERROR
;
terrno
=
TSDB_CODE_APP_ERROR
;
return
-
1
;
return
-
1
;
}
}
...
@@ -2233,32 +2225,6 @@ int32_t extractTableScanNode(SPhysiNode* pNode, STableScanPhysiNode** ppNode) {
...
@@ -2233,32 +2225,6 @@ int32_t extractTableScanNode(SPhysiNode* pNode, STableScanPhysiNode** ppNode) {
return
-
1
;
return
-
1
;
}
}
#if 0
int32_t rebuildReader(SOperatorInfo* pOperator, SSubplan* plan, SReadHandle* pHandle, int64_t uid, int64_t ts) {
STableScanInfo* pTableScanInfo = NULL;
if (extractTbscanInStreamOpTree(pOperator, &pTableScanInfo) < 0) {
return -1;
}
STableScanPhysiNode* pNode = NULL;
if (extractTableScanNode(plan->pNode, &pNode) < 0) {
ASSERT(0);
}
tsdbReaderClose(pTableScanInfo->dataReader);
STableListInfo info = {0};
pTableScanInfo->dataReader = doCreateDataReader(pNode, pHandle, &info, NULL);
if (pTableScanInfo->dataReader == NULL) {
ASSERT(0);
qError("failed to create data reader");
return TSDB_CODE_APP_ERROR;
}
// TODO: set uid and ts to data reader
return 0;
}
#endif
int32_t
createDataSinkParam
(
SDataSinkNode
*
pNode
,
void
**
pParam
,
qTaskInfo_t
*
pTaskInfo
,
SReadHandle
*
readHandle
)
{
int32_t
createDataSinkParam
(
SDataSinkNode
*
pNode
,
void
**
pParam
,
qTaskInfo_t
*
pTaskInfo
,
SReadHandle
*
readHandle
)
{
SExecTaskInfo
*
pTask
=
*
(
SExecTaskInfo
**
)
pTaskInfo
;
SExecTaskInfo
*
pTask
=
*
(
SExecTaskInfo
**
)
pTaskInfo
;
...
...
source/libs/executor/src/joinoperator.c
浏览文件 @
fb628f7f
...
@@ -42,19 +42,23 @@ typedef struct SJoinOperatorInfo {
...
@@ -42,19 +42,23 @@ typedef struct SJoinOperatorInfo {
static
void
setJoinColumnInfo
(
SColumnInfo
*
pColumn
,
const
SColumnNode
*
pColumnNode
);
static
void
setJoinColumnInfo
(
SColumnInfo
*
pColumn
,
const
SColumnNode
*
pColumnNode
);
static
SSDataBlock
*
doMergeJoin
(
struct
SOperatorInfo
*
pOperator
);
static
SSDataBlock
*
doMergeJoin
(
struct
SOperatorInfo
*
pOperator
);
static
void
destroyMergeJoinOperator
(
void
*
param
);
static
void
destroyMergeJoinOperator
(
void
*
param
);
static
void
extractTimeCondition
(
SJoinOperatorInfo
*
pInfo
,
SOperatorInfo
**
pDownstream
,
int32_t
num
OfDownstream
,
static
void
extractTimeCondition
(
SJoinOperatorInfo
*
pInfo
,
SOperatorInfo
**
pDownstream
,
int32_t
num
,
SSortMergeJoinPhysiNode
*
pJoinNode
);
SSortMergeJoinPhysiNode
*
pJoinNode
,
const
char
*
idStr
);
static
void
extractTimeCondition
(
SJoinOperatorInfo
*
pInfo
,
SOperatorInfo
**
pDownstream
,
int32_t
numOfDownstrea
m
,
static
void
extractTimeCondition
(
SJoinOperatorInfo
*
pInfo
,
SOperatorInfo
**
pDownstream
,
int32_t
nu
m
,
SSortMergeJoinPhysiNode
*
pJoinNode
)
{
SSortMergeJoinPhysiNode
*
pJoinNode
,
const
char
*
idStr
)
{
SNode
*
pMergeCondition
=
pJoinNode
->
pMergeCondition
;
SNode
*
pMergeCondition
=
pJoinNode
->
pMergeCondition
;
if
(
nodeType
(
pMergeCondition
)
==
QUERY_NODE_OPERATOR
)
{
if
(
nodeType
(
pMergeCondition
)
!=
QUERY_NODE_OPERATOR
)
{
qError
(
"not support this in join operator, %s"
,
idStr
);
return
;
// do not handle this
}
SOperatorNode
*
pNode
=
(
SOperatorNode
*
)
pMergeCondition
;
SOperatorNode
*
pNode
=
(
SOperatorNode
*
)
pMergeCondition
;
SColumnNode
*
col1
=
(
SColumnNode
*
)
pNode
->
pLeft
;
SColumnNode
*
col1
=
(
SColumnNode
*
)
pNode
->
pLeft
;
SColumnNode
*
col2
=
(
SColumnNode
*
)
pNode
->
pRight
;
SColumnNode
*
col2
=
(
SColumnNode
*
)
pNode
->
pRight
;
SColumnNode
*
leftTsCol
=
NULL
;
SColumnNode
*
leftTsCol
=
NULL
;
SColumnNode
*
rightTsCol
=
NULL
;
SColumnNode
*
rightTsCol
=
NULL
;
if
(
col1
->
dataBlockId
==
col2
->
dataBlockId
)
{
if
(
col1
->
dataBlockId
==
col2
->
dataBlockId
)
{
leftTsCol
=
col1
;
leftTsCol
=
col1
;
rightTsCol
=
col2
;
rightTsCol
=
col2
;
}
else
{
}
else
{
...
@@ -71,9 +75,7 @@ static void extractTimeCondition(SJoinOperatorInfo* pInfo, SOperatorInfo** pDown
...
@@ -71,9 +75,7 @@ static void extractTimeCondition(SJoinOperatorInfo* pInfo, SOperatorInfo** pDown
}
}
setJoinColumnInfo
(
&
pInfo
->
leftCol
,
leftTsCol
);
setJoinColumnInfo
(
&
pInfo
->
leftCol
,
leftTsCol
);
setJoinColumnInfo
(
&
pInfo
->
rightCol
,
rightTsCol
);
setJoinColumnInfo
(
&
pInfo
->
rightCol
,
rightTsCol
);
}
else
{
}
ASSERT
(
false
);
}}
SOperatorInfo
*
createMergeJoinOperatorInfo
(
SOperatorInfo
**
pDownstream
,
int32_t
numOfDownstream
,
SOperatorInfo
*
createMergeJoinOperatorInfo
(
SOperatorInfo
**
pDownstream
,
int32_t
numOfDownstream
,
SSortMergeJoinPhysiNode
*
pJoinNode
,
SExecTaskInfo
*
pTaskInfo
)
{
SSortMergeJoinPhysiNode
*
pJoinNode
,
SExecTaskInfo
*
pTaskInfo
)
{
...
@@ -97,7 +99,7 @@ SOperatorInfo* createMergeJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t
...
@@ -97,7 +99,7 @@ SOperatorInfo* createMergeJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t
pOperator
->
exprSupp
.
pExprInfo
=
pExprInfo
;
pOperator
->
exprSupp
.
pExprInfo
=
pExprInfo
;
pOperator
->
exprSupp
.
numOfExprs
=
numOfCols
;
pOperator
->
exprSupp
.
numOfExprs
=
numOfCols
;
extractTimeCondition
(
pInfo
,
pDownstream
,
numOfDownstream
,
pJoinNode
);
extractTimeCondition
(
pInfo
,
pDownstream
,
numOfDownstream
,
pJoinNode
,
GET_TASKID
(
pTaskInfo
)
);
if
(
pJoinNode
->
pOnConditions
!=
NULL
&&
pJoinNode
->
node
.
pConditions
!=
NULL
)
{
if
(
pJoinNode
->
pOnConditions
!=
NULL
&&
pJoinNode
->
node
.
pConditions
!=
NULL
)
{
pInfo
->
pCondAfterMerge
=
nodesMakeNode
(
QUERY_NODE_LOGIC_CONDITION
);
pInfo
->
pCondAfterMerge
=
nodesMakeNode
(
QUERY_NODE_LOGIC_CONDITION
);
...
@@ -364,8 +366,6 @@ static bool mergeJoinGetNextTimestamp(SOperatorInfo* pOperator, int64_t* pLeftTs
...
@@ -364,8 +366,6 @@ static bool mergeJoinGetNextTimestamp(SOperatorInfo* pOperator, int64_t* pLeftTs
char
*
pRightVal
=
colDataGetData
(
pRightCol
,
pJoinInfo
->
rightPos
);
char
*
pRightVal
=
colDataGetData
(
pRightCol
,
pJoinInfo
->
rightPos
);
*
pRightTs
=
*
(
int64_t
*
)
pRightVal
;
*
pRightTs
=
*
(
int64_t
*
)
pRightVal
;
ASSERT
(
pLeftCol
->
info
.
type
==
TSDB_DATA_TYPE_TIMESTAMP
);
ASSERT
(
pRightCol
->
info
.
type
==
TSDB_DATA_TYPE_TIMESTAMP
);
return
true
;
return
true
;
}
}
...
...
source/libs/executor/src/scanoperator.c
浏览文件 @
fb628f7f
...
@@ -232,30 +232,6 @@ static bool doLoadBlockSMA(STableScanBase* pTableScanInfo, SSDataBlock* pBlock,
...
@@ -232,30 +232,6 @@ static bool doLoadBlockSMA(STableScanBase* pTableScanInfo, SSDataBlock* pBlock,
if
(
!
allColumnsHaveAgg
)
{
if
(
!
allColumnsHaveAgg
)
{
return
false
;
return
false
;
}
}
#if 0
// if (allColumnsHaveAgg == true) {
int32_t numOfCols = taosArrayGetSize(pBlock->pDataBlock);
// todo create this buffer during creating operator
if (pBlock->pBlockAgg == NULL) {
pBlock->pBlockAgg = taosMemoryCalloc(numOfCols, POINTER_BYTES);
if (pBlock->pBlockAgg == NULL) {
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY);
}
}
size_t num = taosArrayGetSize(pTableScanInfo->matchInfo.pList);
for (int32_t i = 0; i < num; ++i) {
SColMatchItem* pColMatchInfo = taosArrayGet(pTableScanInfo->matchInfo.pList, i);
if (!pColMatchInfo->needOutput) {
continue;
}
pBlock->pBlockAgg[pColMatchInfo->dstSlotId] = pColAgg[i];
}
#endif
return
true
;
return
true
;
}
}
...
@@ -2251,6 +2227,7 @@ static void destroyStreamScanOperatorInfo(void* param) {
...
@@ -2251,6 +2227,7 @@ static void destroyStreamScanOperatorInfo(void* param) {
SOperatorInfo
*
createStreamScanOperatorInfo
(
SReadHandle
*
pHandle
,
STableScanPhysiNode
*
pTableScanNode
,
SNode
*
pTagCond
,
SOperatorInfo
*
createStreamScanOperatorInfo
(
SReadHandle
*
pHandle
,
STableScanPhysiNode
*
pTableScanNode
,
SNode
*
pTagCond
,
SExecTaskInfo
*
pTaskInfo
)
{
SExecTaskInfo
*
pTaskInfo
)
{
SArray
*
pColIds
=
NULL
;
SStreamScanInfo
*
pInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
SStreamScanInfo
));
SStreamScanInfo
*
pInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
SStreamScanInfo
));
SOperatorInfo
*
pOperator
=
taosMemoryCalloc
(
1
,
sizeof
(
SOperatorInfo
));
SOperatorInfo
*
pOperator
=
taosMemoryCalloc
(
1
,
sizeof
(
SOperatorInfo
));
...
@@ -2273,7 +2250,7 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys
...
@@ -2273,7 +2250,7 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys
}
}
int32_t
numOfOutput
=
taosArrayGetSize
(
pInfo
->
matchInfo
.
pList
);
int32_t
numOfOutput
=
taosArrayGetSize
(
pInfo
->
matchInfo
.
pList
);
SArray
*
pColIds
=
taosArrayInit
(
numOfOutput
,
sizeof
(
int16_t
));
pColIds
=
taosArrayInit
(
numOfOutput
,
sizeof
(
int16_t
));
for
(
int32_t
i
=
0
;
i
<
numOfOutput
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfOutput
;
++
i
)
{
SColMatchItem
*
id
=
taosArrayGet
(
pInfo
->
matchInfo
.
pList
,
i
);
SColMatchItem
*
id
=
taosArrayGet
(
pInfo
->
matchInfo
.
pList
,
i
);
...
@@ -2370,6 +2347,7 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys
...
@@ -2370,6 +2347,7 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys
memcpy
(
&
pTaskInfo
->
streamInfo
.
tableCond
,
&
pTSInfo
->
base
.
cond
,
sizeof
(
SQueryTableDataCond
));
memcpy
(
&
pTaskInfo
->
streamInfo
.
tableCond
,
&
pTSInfo
->
base
.
cond
,
sizeof
(
SQueryTableDataCond
));
}
else
{
}
else
{
taosArrayDestroy
(
pColIds
);
taosArrayDestroy
(
pColIds
);
pColIds
=
NULL
;
}
}
// create the pseduo columns info
// create the pseduo columns info
...
...
source/libs/executor/src/sortoperator.c
浏览文件 @
fb628f7f
...
@@ -47,12 +47,14 @@ SOperatorInfo* createSortOperatorInfo(SOperatorInfo* downstream, SSortPhysiNode*
...
@@ -47,12 +47,14 @@ SOperatorInfo* createSortOperatorInfo(SOperatorInfo* downstream, SSortPhysiNode*
SDataBlockDescNode
*
pDescNode
=
pSortNode
->
node
.
pOutputDataBlockDesc
;
SDataBlockDescNode
*
pDescNode
=
pSortNode
->
node
.
pOutputDataBlockDesc
;
int32_t
numOfCols
=
0
;
int32_t
numOfCols
=
0
;
SSDataBlock
*
pResBlock
=
createDataBlockFromDescNode
(
pDescNode
);
SExprInfo
*
pExprInfo
=
createExprInfo
(
pSortNode
->
pExprs
,
NULL
,
&
numOfCols
);
SExprInfo
*
pExprInfo
=
createExprInfo
(
pSortNode
->
pExprs
,
NULL
,
&
numOfCols
);
int32_t
numOfOutputCols
=
0
;
int32_t
numOfOutputCols
=
0
;
int32_t
code
=
int32_t
code
=
extractColMatchInfo
(
pSortNode
->
pTargets
,
pDescNode
,
&
numOfOutputCols
,
COL_MATCH_FROM_SLOT_ID
,
&
pInfo
->
matchInfo
);
extractColMatchInfo
(
pSortNode
->
pTargets
,
pDescNode
,
&
numOfOutputCols
,
COL_MATCH_FROM_SLOT_ID
,
&
pInfo
->
matchInfo
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
}
pOperator
->
exprSupp
.
pCtx
=
createSqlFunctionCtx
(
pExprInfo
,
numOfCols
,
&
pOperator
->
exprSupp
.
rowEntryInfoOffset
);
pOperator
->
exprSupp
.
pCtx
=
createSqlFunctionCtx
(
pExprInfo
,
numOfCols
,
&
pOperator
->
exprSupp
.
rowEntryInfoOffset
);
initResultSizeInfo
(
&
pOperator
->
resultInfo
,
1024
);
initResultSizeInfo
(
&
pOperator
->
resultInfo
,
1024
);
...
@@ -61,7 +63,7 @@ SOperatorInfo* createSortOperatorInfo(SOperatorInfo* downstream, SSortPhysiNode*
...
@@ -61,7 +63,7 @@ SOperatorInfo* createSortOperatorInfo(SOperatorInfo* downstream, SSortPhysiNode*
goto
_error
;
goto
_error
;
}
}
pInfo
->
binfo
.
pRes
=
pResBlock
;
pInfo
->
binfo
.
pRes
=
createDataBlockFromDescNode
(
pDescNode
)
;
pInfo
->
pSortInfo
=
createSortInfo
(
pSortNode
->
pSortKeys
);
pInfo
->
pSortInfo
=
createSortInfo
(
pSortNode
->
pSortKeys
);
initLimitInfo
(
pSortNode
->
node
.
pLimit
,
pSortNode
->
node
.
pSlimit
,
&
pInfo
->
limitInfo
);
initLimitInfo
(
pSortNode
->
node
.
pLimit
,
pSortNode
->
node
.
pSlimit
,
&
pInfo
->
limitInfo
);
...
@@ -86,7 +88,10 @@ SOperatorInfo* createSortOperatorInfo(SOperatorInfo* downstream, SSortPhysiNode*
...
@@ -86,7 +88,10 @@ SOperatorInfo* createSortOperatorInfo(SOperatorInfo* downstream, SSortPhysiNode*
_error:
_error:
pTaskInfo
->
code
=
TSDB_CODE_OUT_OF_MEMORY
;
pTaskInfo
->
code
=
TSDB_CODE_OUT_OF_MEMORY
;
taosMemoryFree
(
pInfo
);
if
(
pInfo
!=
NULL
)
{
destroySortOperatorInfo
(
pInfo
);
}
taosMemoryFree
(
pOperator
);
taosMemoryFree
(
pOperator
);
return
NULL
;
return
NULL
;
}
}
...
@@ -139,7 +144,6 @@ SSDataBlock* getSortedBlockData(SSortHandle* pHandle, SSDataBlock* pDataBlock, i
...
@@ -139,7 +144,6 @@ SSDataBlock* getSortedBlockData(SSortHandle* pHandle, SSDataBlock* pDataBlock, i
int32_t
numOfCols
=
taosArrayGetSize
(
pColMatchInfo
);
int32_t
numOfCols
=
taosArrayGetSize
(
pColMatchInfo
);
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SColMatchItem
*
pmInfo
=
taosArrayGet
(
pColMatchInfo
,
i
);
SColMatchItem
*
pmInfo
=
taosArrayGet
(
pColMatchInfo
,
i
);
// ASSERT(pmInfo->matchType == COL_MATCH_FROM_SLOT_ID);
SColumnInfoData
*
pSrc
=
taosArrayGet
(
p
->
pDataBlock
,
pmInfo
->
srcSlotId
);
SColumnInfoData
*
pSrc
=
taosArrayGet
(
p
->
pDataBlock
,
pmInfo
->
srcSlotId
);
SColumnInfoData
*
pDst
=
taosArrayGet
(
pDataBlock
->
pDataBlock
,
pmInfo
->
dstSlotId
);
SColumnInfoData
*
pDst
=
taosArrayGet
(
pDataBlock
->
pDataBlock
,
pmInfo
->
dstSlotId
);
...
@@ -272,7 +276,6 @@ void destroySortOperatorInfo(void* param) {
...
@@ -272,7 +276,6 @@ void destroySortOperatorInfo(void* param) {
}
}
int32_t
getExplainExecInfo
(
SOperatorInfo
*
pOptr
,
void
**
pOptrExplain
,
uint32_t
*
len
)
{
int32_t
getExplainExecInfo
(
SOperatorInfo
*
pOptr
,
void
**
pOptrExplain
,
uint32_t
*
len
)
{
ASSERT
(
pOptr
!=
NULL
);
SSortExecInfo
*
pInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
SSortExecInfo
));
SSortExecInfo
*
pInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
SSortExecInfo
));
SSortOperatorInfo
*
pOperatorInfo
=
(
SSortOperatorInfo
*
)
pOptr
->
info
;
SSortOperatorInfo
*
pOperatorInfo
=
(
SSortOperatorInfo
*
)
pOptr
->
info
;
...
@@ -329,7 +332,6 @@ SSDataBlock* getGroupSortedBlockData(SSortHandle* pHandle, SSDataBlock* pDataBlo
...
@@ -329,7 +332,6 @@ SSDataBlock* getGroupSortedBlockData(SSortHandle* pHandle, SSDataBlock* pDataBlo
int32_t
numOfCols
=
taosArrayGetSize
(
pColMatchInfo
);
int32_t
numOfCols
=
taosArrayGetSize
(
pColMatchInfo
);
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SColMatchItem
*
pmInfo
=
taosArrayGet
(
pColMatchInfo
,
i
);
SColMatchItem
*
pmInfo
=
taosArrayGet
(
pColMatchInfo
,
i
);
// ASSERT(pmInfo->matchType == COL_MATCH_FROM_SLOT_ID);
SColumnInfoData
*
pSrc
=
taosArrayGet
(
p
->
pDataBlock
,
pmInfo
->
srcSlotId
);
SColumnInfoData
*
pSrc
=
taosArrayGet
(
p
->
pDataBlock
,
pmInfo
->
srcSlotId
);
SColumnInfoData
*
pDst
=
taosArrayGet
(
pDataBlock
->
pDataBlock
,
pmInfo
->
dstSlotId
);
SColumnInfoData
*
pDst
=
taosArrayGet
(
pDataBlock
->
pDataBlock
,
pmInfo
->
dstSlotId
);
...
@@ -746,7 +748,6 @@ void destroyMultiwayMergeOperatorInfo(void* param) {
...
@@ -746,7 +748,6 @@ void destroyMultiwayMergeOperatorInfo(void* param) {
}
}
int32_t
getMultiwayMergeExplainExecInfo
(
SOperatorInfo
*
pOptr
,
void
**
pOptrExplain
,
uint32_t
*
len
)
{
int32_t
getMultiwayMergeExplainExecInfo
(
SOperatorInfo
*
pOptr
,
void
**
pOptrExplain
,
uint32_t
*
len
)
{
ASSERT
(
pOptr
!=
NULL
);
SSortExecInfo
*
pSortExecInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
SSortExecInfo
));
SSortExecInfo
*
pSortExecInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
SSortExecInfo
));
SMultiwayMergeOperatorInfo
*
pInfo
=
(
SMultiwayMergeOperatorInfo
*
)
pOptr
->
info
;
SMultiwayMergeOperatorInfo
*
pInfo
=
(
SMultiwayMergeOperatorInfo
*
)
pOptr
->
info
;
...
...
source/libs/executor/src/timewindowoperator.c
浏览文件 @
fb628f7f
...
@@ -907,7 +907,7 @@ static void removeDeleteResults(SHashObj* pUpdatedMap, SArray* pDelWins) {
...
@@ -907,7 +907,7 @@ static void removeDeleteResults(SHashObj* pUpdatedMap, SArray* pDelWins) {
}
}
bool
isOverdue
(
TSKEY
ekey
,
STimeWindowAggSupp
*
pTwSup
)
{
bool
isOverdue
(
TSKEY
ekey
,
STimeWindowAggSupp
*
pTwSup
)
{
ASSERT
(
pTwSup
->
maxTs
==
INT64_MIN
||
pTwSup
->
maxTs
>
0
);
ASSERT
S
(
pTwSup
->
maxTs
==
INT64_MIN
||
pTwSup
->
maxTs
>
0
,
"maxts should greater than 0"
);
return
pTwSup
->
maxTs
!=
INT64_MIN
&&
ekey
<
pTwSup
->
maxTs
-
pTwSup
->
waterMark
;
return
pTwSup
->
maxTs
!=
INT64_MIN
&&
ekey
<
pTwSup
->
maxTs
-
pTwSup
->
waterMark
;
}
}
...
@@ -1396,7 +1396,6 @@ static int32_t getAllIntervalWindow(SSHashObj* pHashMap, SHashObj* resWins) {
...
@@ -1396,7 +1396,6 @@ static int32_t getAllIntervalWindow(SSHashObj* pHashMap, SHashObj* resWins) {
while
((
pIte
=
tSimpleHashIterate
(
pHashMap
,
pIte
,
&
iter
))
!=
NULL
)
{
while
((
pIte
=
tSimpleHashIterate
(
pHashMap
,
pIte
,
&
iter
))
!=
NULL
)
{
void
*
key
=
tSimpleHashGetKey
(
pIte
,
&
keyLen
);
void
*
key
=
tSimpleHashGetKey
(
pIte
,
&
keyLen
);
uint64_t
groupId
=
*
(
uint64_t
*
)
key
;
uint64_t
groupId
=
*
(
uint64_t
*
)
key
;
ASSERT
(
keyLen
==
GET_RES_WINDOW_KEY_LEN
(
sizeof
(
TSKEY
)));
TSKEY
ts
=
*
(
int64_t
*
)((
char
*
)
key
+
sizeof
(
uint64_t
));
TSKEY
ts
=
*
(
int64_t
*
)((
char
*
)
key
+
sizeof
(
uint64_t
));
SResultRowPosition
*
pPos
=
(
SResultRowPosition
*
)
pIte
;
SResultRowPosition
*
pPos
=
(
SResultRowPosition
*
)
pIte
;
int32_t
code
=
saveWinResult
(
ts
,
pPos
->
pageId
,
pPos
->
offset
,
groupId
,
resWins
);
int32_t
code
=
saveWinResult
(
ts
,
pPos
->
pageId
,
pPos
->
offset
,
groupId
,
resWins
);
...
@@ -1547,7 +1546,7 @@ static void closeChildIntervalWindow(SOperatorInfo* pOperator, SArray* pChildren
...
@@ -1547,7 +1546,7 @@ static void closeChildIntervalWindow(SOperatorInfo* pOperator, SArray* pChildren
for
(
int32_t
i
=
0
;
i
<
size
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
size
;
i
++
)
{
SOperatorInfo
*
pChildOp
=
taosArrayGetP
(
pChildren
,
i
);
SOperatorInfo
*
pChildOp
=
taosArrayGetP
(
pChildren
,
i
);
SStreamIntervalOperatorInfo
*
pChInfo
=
pChildOp
->
info
;
SStreamIntervalOperatorInfo
*
pChInfo
=
pChildOp
->
info
;
ASSERT
(
pChInfo
->
twAggSup
.
calTrigger
==
STREAM_TRIGGER_AT_ONCE
);
ASSERT
S
(
pChInfo
->
twAggSup
.
calTrigger
==
STREAM_TRIGGER_AT_ONCE
,
"children trigger type should be at once"
);
pChInfo
->
twAggSup
.
maxTs
=
TMAX
(
pChInfo
->
twAggSup
.
maxTs
,
maxTs
);
pChInfo
->
twAggSup
.
maxTs
=
TMAX
(
pChInfo
->
twAggSup
.
maxTs
,
maxTs
);
closeStreamIntervalWindow
(
pChInfo
->
aggSup
.
pResultRowHashTable
,
&
pChInfo
->
twAggSup
,
&
pChInfo
->
interval
,
NULL
,
NULL
,
closeStreamIntervalWindow
(
pChInfo
->
aggSup
.
pResultRowHashTable
,
&
pChInfo
->
twAggSup
,
&
pChInfo
->
interval
,
NULL
,
NULL
,
NULL
,
pOperator
);
NULL
,
pOperator
);
...
@@ -1767,8 +1766,6 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SIntervalPh
...
@@ -1767,8 +1766,6 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SIntervalPh
.
maxTs
=
INT64_MIN
,
.
maxTs
=
INT64_MIN
,
};
};
ASSERT
(
as
.
calTrigger
!=
STREAM_TRIGGER_MAX_DELAY
);
pInfo
->
win
=
pTaskInfo
->
window
;
pInfo
->
win
=
pTaskInfo
->
window
;
pInfo
->
inputOrder
=
(
pPhyNode
->
window
.
inputTsOrder
==
ORDER_ASC
)
?
TSDB_ORDER_ASC
:
TSDB_ORDER_DESC
;
pInfo
->
inputOrder
=
(
pPhyNode
->
window
.
inputTsOrder
==
ORDER_ASC
)
?
TSDB_ORDER_ASC
:
TSDB_ORDER_DESC
;
pInfo
->
resultTsOrder
=
(
pPhyNode
->
window
.
outputTsOrder
==
ORDER_ASC
)
?
TSDB_ORDER_ASC
:
TSDB_ORDER_DESC
;
pInfo
->
resultTsOrder
=
(
pPhyNode
->
window
.
outputTsOrder
==
ORDER_ASC
)
?
TSDB_ORDER_ASC
:
TSDB_ORDER_DESC
;
...
@@ -2252,7 +2249,6 @@ static void doBuildPullDataBlock(SArray* array, int32_t* pIndex, SSDataBlock* pB
...
@@ -2252,7 +2249,6 @@ static void doBuildPullDataBlock(SArray* array, int32_t* pIndex, SSDataBlock* pB
return
;
return
;
}
}
blockDataEnsureCapacity
(
pBlock
,
size
-
(
*
pIndex
));
blockDataEnsureCapacity
(
pBlock
,
size
-
(
*
pIndex
));
ASSERT
(
3
<=
taosArrayGetSize
(
pBlock
->
pDataBlock
));
SColumnInfoData
*
pStartTs
=
(
SColumnInfoData
*
)
taosArrayGet
(
pBlock
->
pDataBlock
,
START_TS_COLUMN_INDEX
);
SColumnInfoData
*
pStartTs
=
(
SColumnInfoData
*
)
taosArrayGet
(
pBlock
->
pDataBlock
,
START_TS_COLUMN_INDEX
);
SColumnInfoData
*
pEndTs
=
(
SColumnInfoData
*
)
taosArrayGet
(
pBlock
->
pDataBlock
,
END_TS_COLUMN_INDEX
);
SColumnInfoData
*
pEndTs
=
(
SColumnInfoData
*
)
taosArrayGet
(
pBlock
->
pDataBlock
,
END_TS_COLUMN_INDEX
);
SColumnInfoData
*
pGroupId
=
(
SColumnInfoData
*
)
taosArrayGet
(
pBlock
->
pDataBlock
,
GROUPID_COLUMN_INDEX
);
SColumnInfoData
*
pGroupId
=
(
SColumnInfoData
*
)
taosArrayGet
(
pBlock
->
pDataBlock
,
GROUPID_COLUMN_INDEX
);
...
@@ -2346,6 +2342,17 @@ void doBuildResult(SOperatorInfo* pOperator, SStreamState* pState, SSDataBlock*
...
@@ -2346,6 +2342,17 @@ void doBuildResult(SOperatorInfo* pOperator, SStreamState* pState, SSDataBlock*
buildDataBlockFromGroupRes
(
pOperator
,
pState
,
pBlock
,
&
pOperator
->
exprSupp
,
pGroupResInfo
);
buildDataBlockFromGroupRes
(
pOperator
,
pState
,
pBlock
,
&
pOperator
->
exprSupp
,
pGroupResInfo
);
}
}
static
int32_t
getNextQualifiedFinalWindow
(
SInterval
*
pInterval
,
STimeWindow
*
pNext
,
SDataBlockInfo
*
pDataBlockInfo
,
TSKEY
*
primaryKeys
,
int32_t
prevPosition
)
{
int32_t
startPos
=
prevPosition
+
1
;
if
(
startPos
==
pDataBlockInfo
->
rows
)
{
startPos
=
-
1
;
}
else
{
*
pNext
=
getFinalTimeWindow
(
primaryKeys
[
startPos
],
pInterval
);
}
return
startPos
;
}
static
void
doStreamIntervalAggImpl
(
SOperatorInfo
*
pOperatorInfo
,
SSDataBlock
*
pSDataBlock
,
uint64_t
groupId
,
static
void
doStreamIntervalAggImpl
(
SOperatorInfo
*
pOperatorInfo
,
SSDataBlock
*
pSDataBlock
,
uint64_t
groupId
,
SHashObj
*
pUpdatedMap
)
{
SHashObj
*
pUpdatedMap
)
{
SStreamIntervalOperatorInfo
*
pInfo
=
(
SStreamIntervalOperatorInfo
*
)
pOperatorInfo
->
info
;
SStreamIntervalOperatorInfo
*
pInfo
=
(
SStreamIntervalOperatorInfo
*
)
pOperatorInfo
->
info
;
...
@@ -2359,7 +2366,6 @@ static void doStreamIntervalAggImpl(SOperatorInfo* pOperatorInfo, SSDataBlock* p
...
@@ -2359,7 +2366,6 @@ static void doStreamIntervalAggImpl(SOperatorInfo* pOperatorInfo, SSDataBlock* p
SResultRow
*
pResult
=
NULL
;
SResultRow
*
pResult
=
NULL
;
int32_t
forwardRows
=
0
;
int32_t
forwardRows
=
0
;
ASSERT
(
pSDataBlock
->
pDataBlock
!=
NULL
);
SColumnInfoData
*
pColDataInfo
=
taosArrayGet
(
pSDataBlock
->
pDataBlock
,
pInfo
->
primaryTsIndex
);
SColumnInfoData
*
pColDataInfo
=
taosArrayGet
(
pSDataBlock
->
pDataBlock
,
pInfo
->
primaryTsIndex
);
tsCols
=
(
int64_t
*
)
pColDataInfo
->
pData
;
tsCols
=
(
int64_t
*
)
pColDataInfo
->
pData
;
...
@@ -2456,8 +2462,12 @@ static void doStreamIntervalAggImpl(SOperatorInfo* pOperatorInfo, SSDataBlock* p
...
@@ -2456,8 +2462,12 @@ static void doStreamIntervalAggImpl(SOperatorInfo* pOperatorInfo, SSDataBlock* p
}
}
int32_t
prevEndPos
=
(
forwardRows
-
1
)
*
step
+
startPos
;
int32_t
prevEndPos
=
(
forwardRows
-
1
)
*
step
+
startPos
;
ASSERT
(
pSDataBlock
->
info
.
window
.
skey
>
0
&&
pSDataBlock
->
info
.
window
.
ekey
>
0
);
ASSERT
(
pSDataBlock
->
info
.
window
.
skey
>
0
&&
pSDataBlock
->
info
.
window
.
ekey
>
0
);
if
(
IS_FINAL_OP
(
pInfo
))
{
startPos
=
getNextQualifiedFinalWindow
(
&
pInfo
->
interval
,
&
nextWin
,
&
pSDataBlock
->
info
,
tsCols
,
prevEndPos
);
}
else
{
startPos
=
startPos
=
getNextQualifiedWindow
(
&
pInfo
->
interval
,
&
nextWin
,
&
pSDataBlock
->
info
,
tsCols
,
prevEndPos
,
TSDB_ORDER_ASC
);
getNextQualifiedWindow
(
&
pInfo
->
interval
,
&
nextWin
,
&
pSDataBlock
->
info
,
tsCols
,
prevEndPos
,
TSDB_ORDER_ASC
);
}
if
(
startPos
<
0
)
{
if
(
startPos
<
0
)
{
break
;
break
;
}
}
...
@@ -2482,7 +2492,6 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) {
...
@@ -2482,7 +2492,6 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) {
doBuildPullDataBlock
(
pInfo
->
pPullWins
,
&
pInfo
->
pullIndex
,
pInfo
->
pPullDataRes
);
doBuildPullDataBlock
(
pInfo
->
pPullWins
,
&
pInfo
->
pullIndex
,
pInfo
->
pPullDataRes
);
if
(
pInfo
->
pPullDataRes
->
info
.
rows
!=
0
)
{
if
(
pInfo
->
pPullDataRes
->
info
.
rows
!=
0
)
{
// process the rest of the data
// process the rest of the data
ASSERT
(
IS_FINAL_OP
(
pInfo
));
printDataBlock
(
pInfo
->
pPullDataRes
,
IS_FINAL_OP
(
pInfo
)
?
"interval final"
:
"interval semi"
);
printDataBlock
(
pInfo
->
pPullDataRes
,
IS_FINAL_OP
(
pInfo
)
?
"interval final"
:
"interval semi"
);
return
pInfo
->
pPullDataRes
;
return
pInfo
->
pPullDataRes
;
}
}
...
@@ -2543,7 +2552,6 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) {
...
@@ -2543,7 +2552,6 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) {
pInfo
->
numOfDatapack
++
;
pInfo
->
numOfDatapack
++
;
printDataBlock
(
pBlock
,
IS_FINAL_OP
(
pInfo
)
?
"interval final recv"
:
"interval semi recv"
);
printDataBlock
(
pBlock
,
IS_FINAL_OP
(
pInfo
)
?
"interval final recv"
:
"interval semi recv"
);
ASSERT
(
pBlock
->
info
.
type
!=
STREAM_INVERT
);
if
(
pBlock
->
info
.
type
==
STREAM_NORMAL
||
pBlock
->
info
.
type
==
STREAM_PULL_DATA
)
{
if
(
pBlock
->
info
.
type
==
STREAM_NORMAL
||
pBlock
->
info
.
type
==
STREAM_PULL_DATA
)
{
pInfo
->
binfo
.
pRes
->
info
.
type
=
pBlock
->
info
.
type
;
pInfo
->
binfo
.
pRes
->
info
.
type
=
pBlock
->
info
.
type
;
}
else
if
(
pBlock
->
info
.
type
==
STREAM_DELETE_DATA
||
pBlock
->
info
.
type
==
STREAM_DELETE_RESULT
||
}
else
if
(
pBlock
->
info
.
type
==
STREAM_DELETE_DATA
||
pBlock
->
info
.
type
==
STREAM_DELETE_RESULT
||
...
@@ -2633,7 +2641,6 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) {
...
@@ -2633,7 +2641,6 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) {
doBuildPullDataBlock
(
pInfo
->
pPullWins
,
&
pInfo
->
pullIndex
,
pInfo
->
pPullDataRes
);
doBuildPullDataBlock
(
pInfo
->
pPullWins
,
&
pInfo
->
pullIndex
,
pInfo
->
pPullDataRes
);
if
(
pInfo
->
pPullDataRes
->
info
.
rows
!=
0
)
{
if
(
pInfo
->
pPullDataRes
->
info
.
rows
!=
0
)
{
// process the rest of the data
// process the rest of the data
ASSERT
(
IS_FINAL_OP
(
pInfo
));
printDataBlock
(
pInfo
->
pPullDataRes
,
IS_FINAL_OP
(
pInfo
)
?
"interval final"
:
"interval semi"
);
printDataBlock
(
pInfo
->
pPullDataRes
,
IS_FINAL_OP
(
pInfo
)
?
"interval final"
:
"interval semi"
);
return
pInfo
->
pPullDataRes
;
return
pInfo
->
pPullDataRes
;
}
}
...
@@ -2688,7 +2695,7 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream,
...
@@ -2688,7 +2695,7 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream,
.
deleteMarkSaved
=
0
,
.
deleteMarkSaved
=
0
,
.
calTriggerSaved
=
0
,
.
calTriggerSaved
=
0
,
};
};
ASSERT
(
pInfo
->
twAggSup
.
calTrigger
!=
STREAM_TRIGGER_MAX_DELAY
);
ASSERT
S
(
pInfo
->
twAggSup
.
calTrigger
!=
STREAM_TRIGGER_MAX_DELAY
,
"trigger type should not be max delay"
);
pInfo
->
primaryTsIndex
=
((
SColumnNode
*
)
pIntervalPhyNode
->
window
.
pTspk
)
->
slotId
;
pInfo
->
primaryTsIndex
=
((
SColumnNode
*
)
pIntervalPhyNode
->
window
.
pTspk
)
->
slotId
;
size_t
keyBufSize
=
sizeof
(
int64_t
)
+
sizeof
(
int64_t
)
+
POINTER_BYTES
;
size_t
keyBufSize
=
sizeof
(
int64_t
)
+
sizeof
(
int64_t
)
+
POINTER_BYTES
;
initResultSizeInfo
(
&
pOperator
->
resultInfo
,
4096
);
initResultSizeInfo
(
&
pOperator
->
resultInfo
,
4096
);
...
@@ -2713,7 +2720,6 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream,
...
@@ -2713,7 +2720,6 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream,
initStreamFunciton
(
pOperator
->
exprSupp
.
pCtx
,
pOperator
->
exprSupp
.
numOfExprs
);
initStreamFunciton
(
pOperator
->
exprSupp
.
pCtx
,
pOperator
->
exprSupp
.
numOfExprs
);
ASSERT
(
numOfCols
>
0
);
initExecTimeWindowInfo
(
&
pInfo
->
twAggSup
.
timeWindowData
,
&
pTaskInfo
->
window
);
initExecTimeWindowInfo
(
&
pInfo
->
twAggSup
.
timeWindowData
,
&
pTaskInfo
->
window
);
pInfo
->
pState
=
taosMemoryCalloc
(
1
,
sizeof
(
SStreamState
));
pInfo
->
pState
=
taosMemoryCalloc
(
1
,
sizeof
(
SStreamState
));
...
@@ -2724,6 +2730,9 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream,
...
@@ -2724,6 +2730,9 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream,
pInfo
->
pChildren
=
NULL
;
pInfo
->
pChildren
=
NULL
;
if
(
numOfChild
>
0
)
{
if
(
numOfChild
>
0
)
{
pInfo
->
pChildren
=
taosArrayInit
(
numOfChild
,
sizeof
(
void
*
));
pInfo
->
pChildren
=
taosArrayInit
(
numOfChild
,
sizeof
(
void
*
));
if
(
!
pInfo
->
pChildren
)
{
goto
_error
;
}
for
(
int32_t
i
=
0
;
i
<
numOfChild
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
numOfChild
;
i
++
)
{
SOperatorInfo
*
pChildOp
=
createStreamFinalIntervalOperatorInfo
(
NULL
,
pPhyNode
,
pTaskInfo
,
0
);
SOperatorInfo
*
pChildOp
=
createStreamFinalIntervalOperatorInfo
(
NULL
,
pPhyNode
,
pTaskInfo
,
0
);
if
(
pChildOp
)
{
if
(
pChildOp
)
{
...
@@ -2746,7 +2755,6 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream,
...
@@ -2746,7 +2755,6 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream,
// semi interval operator does not catch result
// semi interval operator does not catch result
pInfo
->
isFinal
=
false
;
pInfo
->
isFinal
=
false
;
pOperator
->
name
=
"StreamSemiIntervalOperator"
;
pOperator
->
name
=
"StreamSemiIntervalOperator"
;
ASSERT
(
pInfo
->
aggSup
.
currentPageId
==
-
1
);
}
}
if
(
!
IS_FINAL_OP
(
pInfo
)
||
numOfChild
==
0
)
{
if
(
!
IS_FINAL_OP
(
pInfo
)
||
numOfChild
==
0
)
{
...
@@ -3162,15 +3170,6 @@ static void doStreamSessionAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSData
...
@@ -3162,15 +3170,6 @@ static void doStreamSessionAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSData
}
}
}
}
void
deleteWindow
(
SArray
*
pWinInfos
,
int32_t
index
,
FDelete
fp
)
{
ASSERT
(
index
>=
0
&&
index
<
taosArrayGetSize
(
pWinInfos
));
if
(
fp
)
{
void
*
ptr
=
taosArrayGet
(
pWinInfos
,
index
);
fp
(
ptr
);
}
taosArrayRemove
(
pWinInfos
,
index
);
}
static
void
doDeleteTimeWindows
(
SStreamAggSupporter
*
pAggSup
,
SSDataBlock
*
pBlock
,
SArray
*
result
)
{
static
void
doDeleteTimeWindows
(
SStreamAggSupporter
*
pAggSup
,
SSDataBlock
*
pBlock
,
SArray
*
result
)
{
SColumnInfoData
*
pStartTsCol
=
taosArrayGet
(
pBlock
->
pDataBlock
,
START_TS_COLUMN_INDEX
);
SColumnInfoData
*
pStartTsCol
=
taosArrayGet
(
pBlock
->
pDataBlock
,
START_TS_COLUMN_INDEX
);
TSKEY
*
startDatas
=
(
TSKEY
*
)
pStartTsCol
->
pData
;
TSKEY
*
startDatas
=
(
TSKEY
*
)
pStartTsCol
->
pData
;
...
@@ -3218,7 +3217,6 @@ static int32_t copyUpdateResult(SSHashObj* pStUpdated, SArray* pUpdated) {
...
@@ -3218,7 +3217,6 @@ static int32_t copyUpdateResult(SSHashObj* pStUpdated, SArray* pUpdated) {
int32_t
iter
=
0
;
int32_t
iter
=
0
;
while
((
pIte
=
tSimpleHashIterate
(
pStUpdated
,
pIte
,
&
iter
))
!=
NULL
)
{
while
((
pIte
=
tSimpleHashIterate
(
pStUpdated
,
pIte
,
&
iter
))
!=
NULL
)
{
void
*
key
=
tSimpleHashGetKey
(
pIte
,
&
keyLen
);
void
*
key
=
tSimpleHashGetKey
(
pIte
,
&
keyLen
);
ASSERT
(
keyLen
==
sizeof
(
SSessionKey
));
taosArrayPush
(
pUpdated
,
key
);
taosArrayPush
(
pUpdated
,
key
);
}
}
taosArraySort
(
pUpdated
,
sessionKeyCompareAsc
);
taosArraySort
(
pUpdated
,
sessionKeyCompareAsc
);
...
@@ -3279,7 +3277,6 @@ static void rebuildSessionWindow(SOperatorInfo* pOperator, SArray* pWinArray, SS
...
@@ -3279,7 +3277,6 @@ static void rebuildSessionWindow(SOperatorInfo* pOperator, SArray* pWinArray, SS
SStreamAggSupporter
*
pAggSup
=
&
pInfo
->
streamAggSup
;
SStreamAggSupporter
*
pAggSup
=
&
pInfo
->
streamAggSup
;
int32_t
numOfOutput
=
pSup
->
numOfExprs
;
int32_t
numOfOutput
=
pSup
->
numOfExprs
;
int32_t
numOfChildren
=
taosArrayGetSize
(
pInfo
->
pChildren
);
int32_t
numOfChildren
=
taosArrayGetSize
(
pInfo
->
pChildren
);
ASSERT
(
pInfo
->
pChildren
);
for
(
int32_t
i
=
0
;
i
<
size
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
size
;
i
++
)
{
SSessionKey
*
pWinKey
=
taosArrayGet
(
pWinArray
,
i
);
SSessionKey
*
pWinKey
=
taosArrayGet
(
pWinArray
,
i
);
...
@@ -3380,7 +3377,6 @@ static void copyDeleteWindowInfo(SArray* pResWins, SSHashObj* pStDeleted) {
...
@@ -3380,7 +3377,6 @@ static void copyDeleteWindowInfo(SArray* pResWins, SSHashObj* pStDeleted) {
void
initGroupResInfoFromArrayList
(
SGroupResInfo
*
pGroupResInfo
,
SArray
*
pArrayList
)
{
void
initGroupResInfoFromArrayList
(
SGroupResInfo
*
pGroupResInfo
,
SArray
*
pArrayList
)
{
pGroupResInfo
->
pRows
=
pArrayList
;
pGroupResInfo
->
pRows
=
pArrayList
;
pGroupResInfo
->
index
=
0
;
pGroupResInfo
->
index
=
0
;
ASSERT
(
pGroupResInfo
->
index
<=
getNumOfTotalRes
(
pGroupResInfo
));
}
}
void
doBuildSessionResult
(
SOperatorInfo
*
pOperator
,
SStreamState
*
pState
,
SGroupResInfo
*
pGroupResInfo
,
void
doBuildSessionResult
(
SOperatorInfo
*
pOperator
,
SStreamState
*
pState
,
SGroupResInfo
*
pGroupResInfo
,
...
@@ -4811,7 +4807,6 @@ SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SPhys
...
@@ -4811,7 +4807,6 @@ SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SPhys
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
numOfCols
=
0
;
int32_t
numOfCols
=
0
;
SExprInfo
*
pExprInfo
=
createExprInfo
(
pIntervalPhyNode
->
window
.
pFuncs
,
NULL
,
&
numOfCols
);
SExprInfo
*
pExprInfo
=
createExprInfo
(
pIntervalPhyNode
->
window
.
pFuncs
,
NULL
,
&
numOfCols
);
ASSERT
(
numOfCols
>
0
);
SSDataBlock
*
pResBlock
=
createDataBlockFromDescNode
(
pPhyNode
->
pOutputDataBlockDesc
);
SSDataBlock
*
pResBlock
=
createDataBlockFromDescNode
(
pPhyNode
->
pOutputDataBlockDesc
);
SInterval
interval
=
{
SInterval
interval
=
{
...
@@ -4831,7 +4826,7 @@ SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SPhys
...
@@ -4831,7 +4826,7 @@ SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SPhys
.
deleteMark
=
getDeleteMark
(
pIntervalPhyNode
),
.
deleteMark
=
getDeleteMark
(
pIntervalPhyNode
),
};
};
ASSERT
(
twAggSupp
.
calTrigger
!=
STREAM_TRIGGER_MAX_DELAY
);
ASSERT
S
(
twAggSupp
.
calTrigger
!=
STREAM_TRIGGER_MAX_DELAY
,
"trigger type should not be max delay"
);
pOperator
->
pTaskInfo
=
pTaskInfo
;
pOperator
->
pTaskInfo
=
pTaskInfo
;
pInfo
->
interval
=
interval
;
pInfo
->
interval
=
interval
;
...
...
source/libs/executor/src/tsimplehash.c
浏览文件 @
fb628f7f
...
@@ -49,7 +49,9 @@ static FORCE_INLINE int32_t taosHashCapacity(int32_t length) {
...
@@ -49,7 +49,9 @@ static FORCE_INLINE int32_t taosHashCapacity(int32_t length) {
}
}
SSHashObj
*
tSimpleHashInit
(
size_t
capacity
,
_hash_fn_t
fn
)
{
SSHashObj
*
tSimpleHashInit
(
size_t
capacity
,
_hash_fn_t
fn
)
{
ASSERT
(
fn
!=
NULL
);
if
(
fn
==
NULL
)
{
return
NULL
;
}
if
(
capacity
==
0
)
{
if
(
capacity
==
0
)
{
capacity
=
4
;
capacity
=
4
;
...
@@ -66,7 +68,6 @@ SSHashObj *tSimpleHashInit(size_t capacity, _hash_fn_t fn) {
...
@@ -66,7 +68,6 @@ SSHashObj *tSimpleHashInit(size_t capacity, _hash_fn_t fn) {
pHashObj
->
equalFp
=
memcmp
;
pHashObj
->
equalFp
=
memcmp
;
pHashObj
->
hashFp
=
fn
;
pHashObj
->
hashFp
=
fn
;
ASSERT
((
pHashObj
->
capacity
&
(
pHashObj
->
capacity
-
1
))
==
0
);
pHashObj
->
hashList
=
(
SHNode
**
)
taosMemoryCalloc
(
pHashObj
->
capacity
,
sizeof
(
void
*
));
pHashObj
->
hashList
=
(
SHNode
**
)
taosMemoryCalloc
(
pHashObj
->
capacity
,
sizeof
(
void
*
));
if
(
!
pHashObj
->
hashList
)
{
if
(
!
pHashObj
->
hashList
)
{
...
...
source/libs/executor/src/tsort.c
浏览文件 @
fb628f7f
...
@@ -800,6 +800,7 @@ STupleHandle* tsortNextTuple(SSortHandle* pHandle) {
...
@@ -800,6 +800,7 @@ STupleHandle* tsortNextTuple(SSortHandle* pHandle) {
}
}
}
}
// all sources are completed.
if
(
pHandle
->
cmpParam
.
numOfSources
==
pHandle
->
numOfCompletedSources
)
{
if
(
pHandle
->
cmpParam
.
numOfSources
==
pHandle
->
numOfCompletedSources
)
{
return
NULL
;
return
NULL
;
}
}
...
...
source/libs/function/src/udfd.c
浏览文件 @
fb628f7f
...
@@ -606,6 +606,7 @@ int32_t udfdLoadUdf(char *udfName, SUdf *udf) {
...
@@ -606,6 +606,7 @@ int32_t udfdLoadUdf(char *udfName, SUdf *udf) {
}
}
static
bool
udfdRpcRfp
(
int32_t
code
,
tmsg_t
msgType
)
{
static
bool
udfdRpcRfp
(
int32_t
code
,
tmsg_t
msgType
)
{
if
(
code
==
TSDB_CODE_RPC_NETWORK_UNAVAIL
||
code
==
TSDB_CODE_RPC_BROKEN_LINK
||
code
==
TSDB_CODE_SYN_NOT_LEADER
||
if
(
code
==
TSDB_CODE_RPC_NETWORK_UNAVAIL
||
code
==
TSDB_CODE_RPC_BROKEN_LINK
||
code
==
TSDB_CODE_SYN_NOT_LEADER
||
code
==
TSDB_CODE_RPC_SOMENODE_NOT_CONNECTED
||
code
==
TSDB_CODE_SYN_RESTORING
||
code
==
TSDB_CODE_MNODE_NOT_FOUND
||
code
==
TSDB_CODE_APP_IS_STARTING
||
code
==
TSDB_CODE_SYN_RESTORING
||
code
==
TSDB_CODE_MNODE_NOT_FOUND
||
code
==
TSDB_CODE_APP_IS_STARTING
||
code
==
TSDB_CODE_APP_IS_STOPPING
)
{
code
==
TSDB_CODE_APP_IS_STOPPING
)
{
if
(
msgType
==
TDMT_SCH_QUERY
||
msgType
==
TDMT_SCH_MERGE_QUERY
||
msgType
==
TDMT_SCH_FETCH
||
if
(
msgType
==
TDMT_SCH_QUERY
||
msgType
==
TDMT_SCH_MERGE_QUERY
||
msgType
==
TDMT_SCH_FETCH
||
...
...
source/libs/parser/inc/parAst.h
浏览文件 @
fb628f7f
...
@@ -197,7 +197,7 @@ SNode* createDropComponentNodeStmt(SAstCreateContext* pCxt, ENodeType type, cons
...
@@ -197,7 +197,7 @@ SNode* createDropComponentNodeStmt(SAstCreateContext* pCxt, ENodeType type, cons
SNode
*
createCreateTopicStmtUseQuery
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
const
SToken
*
pTopicName
,
SNode
*
createCreateTopicStmtUseQuery
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
const
SToken
*
pTopicName
,
SNode
*
pQuery
);
SNode
*
pQuery
);
SNode
*
createCreateTopicStmtUseDb
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
const
SToken
*
pTopicName
,
SNode
*
createCreateTopicStmtUseDb
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
const
SToken
*
pTopicName
,
const
SToken
*
pSubDbName
,
bool
withMeta
);
SToken
*
pSubDbName
,
bool
withMeta
);
SNode
*
createCreateTopicStmtUseTable
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
const
SToken
*
pTopicName
,
SNode
*
createCreateTopicStmtUseTable
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
const
SToken
*
pTopicName
,
SNode
*
pRealTable
,
bool
withMeta
);
SNode
*
pRealTable
,
bool
withMeta
);
SNode
*
createDropTopicStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreNotExists
,
const
SToken
*
pTopicName
);
SNode
*
createDropTopicStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreNotExists
,
const
SToken
*
pTopicName
);
...
...
source/libs/parser/src/parAstCreater.c
浏览文件 @
fb628f7f
...
@@ -1593,8 +1593,11 @@ SNode* createCreateTopicStmtUseQuery(SAstCreateContext* pCxt, bool ignoreExists,
...
@@ -1593,8 +1593,11 @@ SNode* createCreateTopicStmtUseQuery(SAstCreateContext* pCxt, bool ignoreExists,
}
}
SNode
*
createCreateTopicStmtUseDb
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
const
SToken
*
pTopicName
,
SNode
*
createCreateTopicStmtUseDb
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
const
SToken
*
pTopicName
,
const
SToken
*
pSubDbName
,
bool
withMeta
)
{
SToken
*
pSubDbName
,
bool
withMeta
)
{
CHECK_PARSER_STATUS
(
pCxt
);
CHECK_PARSER_STATUS
(
pCxt
);
if
(
!
checkDbName
(
pCxt
,
pSubDbName
,
true
))
{
return
NULL
;
}
SCreateTopicStmt
*
pStmt
=
(
SCreateTopicStmt
*
)
nodesMakeNode
(
QUERY_NODE_CREATE_TOPIC_STMT
);
SCreateTopicStmt
*
pStmt
=
(
SCreateTopicStmt
*
)
nodesMakeNode
(
QUERY_NODE_CREATE_TOPIC_STMT
);
CHECK_OUT_OF_MEM
(
pStmt
);
CHECK_OUT_OF_MEM
(
pStmt
);
COPY_STRING_FORM_ID_TOKEN
(
pStmt
->
topicName
,
pTopicName
);
COPY_STRING_FORM_ID_TOKEN
(
pStmt
->
topicName
,
pTopicName
);
...
...
source/libs/scheduler/inc/schInt.h
浏览文件 @
fb628f7f
...
@@ -375,7 +375,7 @@ extern SSchedulerMgmt schMgmt;
...
@@ -375,7 +375,7 @@ extern SSchedulerMgmt schMgmt;
#define SCH_JOB_NEED_WAIT(_job) (!SCH_IS_QUERY_JOB(_job))
#define SCH_JOB_NEED_WAIT(_job) (!SCH_IS_QUERY_JOB(_job))
#define SCH_JOB_NEED_DROP(_job) (SCH_IS_QUERY_JOB(_job))
#define SCH_JOB_NEED_DROP(_job) (SCH_IS_QUERY_JOB(_job))
#define SCH_IS_EXPLAIN_JOB(_job) (EXPLAIN_MODE_ANALYZE == (_job)->attr.explainMode)
#define SCH_IS_EXPLAIN_JOB(_job) (EXPLAIN_MODE_ANALYZE == (_job)->attr.explainMode)
#define SCH_NETWORK_ERR(_code) ((_code) == TSDB_CODE_RPC_BROKEN_LINK || (_code) == TSDB_CODE_RPC_NETWORK_UNAVAIL)
#define SCH_NETWORK_ERR(_code) ((_code) == TSDB_CODE_RPC_BROKEN_LINK || (_code) == TSDB_CODE_RPC_NETWORK_UNAVAIL
|| (_code) == TSDB_CODE_RPC_SOMENODE_NOT_CONNECTED
)
#define SCH_MERGE_TASK_NETWORK_ERR(_task, _code, _len) \
#define SCH_MERGE_TASK_NETWORK_ERR(_task, _code, _len) \
(SCH_NETWORK_ERR(_code) && (((_len) > 0) || (!SCH_IS_DATA_BIND_TASK(_task)) || (_task)->redirectCtx.inRedirect))
(SCH_NETWORK_ERR(_code) && (((_len) > 0) || (!SCH_IS_DATA_BIND_TASK(_task)) || (_task)->redirectCtx.inRedirect))
#define SCH_REDIRECT_MSGTYPE(_msgType) \
#define SCH_REDIRECT_MSGTYPE(_msgType) \
...
...
source/libs/scheduler/src/schJob.c
浏览文件 @
fb628f7f
...
@@ -668,6 +668,7 @@ void schFreeJobImpl(void *job) {
...
@@ -668,6 +668,7 @@ void schFreeJobImpl(void *job) {
taosMemoryFreeClear
(
pJob
->
userRes
.
execRes
);
taosMemoryFreeClear
(
pJob
->
userRes
.
execRes
);
taosMemoryFreeClear
(
pJob
->
fetchRes
);
taosMemoryFreeClear
(
pJob
->
fetchRes
);
taosMemoryFreeClear
(
pJob
->
sql
);
taosMemoryFreeClear
(
pJob
->
sql
);
tsem_destroy
(
&
pJob
->
rspSem
);
taosMemoryFree
(
pJob
);
taosMemoryFree
(
pJob
);
int32_t
jobNum
=
atomic_sub_fetch_32
(
&
schMgmt
.
jobNum
,
1
);
int32_t
jobNum
=
atomic_sub_fetch_32
(
&
schMgmt
.
jobNum
,
1
);
...
@@ -748,7 +749,10 @@ int32_t schInitJob(int64_t *pJobId, SSchedulerReq *pReq) {
...
@@ -748,7 +749,10 @@ int32_t schInitJob(int64_t *pJobId, SSchedulerReq *pReq) {
SCH_ERR_JRET
(
TSDB_CODE_OUT_OF_MEMORY
);
SCH_ERR_JRET
(
TSDB_CODE_OUT_OF_MEMORY
);
}
}
tsem_init
(
&
pJob
->
rspSem
,
0
,
0
);
if
(
tsem_init
(
&
pJob
->
rspSem
,
0
,
0
))
{
SCH_JOB_ELOG
(
"tsem_init failed, errno:%d"
,
errno
);
SCH_ERR_JRET
(
TSDB_CODE_OUT_OF_MEMORY
);
}
pJob
->
refId
=
taosAddRef
(
schMgmt
.
jobRef
,
pJob
);
pJob
->
refId
=
taosAddRef
(
schMgmt
.
jobRef
,
pJob
);
if
(
pJob
->
refId
<
0
)
{
if
(
pJob
->
refId
<
0
)
{
...
...
source/libs/stream/src/streamExec.c
浏览文件 @
fb628f7f
...
@@ -49,6 +49,10 @@ static int32_t streamTaskExecImpl(SStreamTask* pTask, const void* data, SArray*
...
@@ -49,6 +49,10 @@ static int32_t streamTaskExecImpl(SStreamTask* pTask, const void* data, SArray*
// exec
// exec
while
(
1
)
{
while
(
1
)
{
if
(
pTask
->
taskStatus
==
TASK_STATUS__DROPPING
)
{
return
0
;
}
SSDataBlock
*
output
=
NULL
;
SSDataBlock
*
output
=
NULL
;
uint64_t
ts
=
0
;
uint64_t
ts
=
0
;
if
((
code
=
qExecTask
(
exec
,
&
output
,
&
ts
))
<
0
)
{
if
((
code
=
qExecTask
(
exec
,
&
output
,
&
ts
))
<
0
)
{
...
...
source/libs/stream/src/streamState.c
浏览文件 @
fb628f7f
...
@@ -663,8 +663,7 @@ int32_t streamStateSessionClear(SStreamState* pState) {
...
@@ -663,8 +663,7 @@ int32_t streamStateSessionClear(SStreamState* pState) {
void
*
buf
=
NULL
;
void
*
buf
=
NULL
;
int32_t
size
=
0
;
int32_t
size
=
0
;
int32_t
code
=
streamStateSessionGetKVByCur
(
pCur
,
&
delKey
,
&
buf
,
&
size
);
int32_t
code
=
streamStateSessionGetKVByCur
(
pCur
,
&
delKey
,
&
buf
,
&
size
);
if
(
code
==
0
)
{
if
(
code
==
0
&&
size
>
0
)
{
ASSERT
(
size
>
0
);
memset
(
buf
,
0
,
size
);
memset
(
buf
,
0
,
size
);
streamStateSessionPut
(
pState
,
&
delKey
,
buf
,
size
);
streamStateSessionPut
(
pState
,
&
delKey
,
buf
,
size
);
}
else
{
}
else
{
...
...
source/libs/sync/inc/syncInt.h
浏览文件 @
fb628f7f
...
@@ -238,7 +238,7 @@ int32_t syncNodeStopPingTimer(SSyncNode* pSyncNode);
...
@@ -238,7 +238,7 @@ int32_t syncNodeStopPingTimer(SSyncNode* pSyncNode);
int32_t
syncNodeStartElectTimer
(
SSyncNode
*
pSyncNode
,
int32_t
ms
);
int32_t
syncNodeStartElectTimer
(
SSyncNode
*
pSyncNode
,
int32_t
ms
);
int32_t
syncNodeStopElectTimer
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeStopElectTimer
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeRestartElectTimer
(
SSyncNode
*
pSyncNode
,
int32_t
ms
);
int32_t
syncNodeRestartElectTimer
(
SSyncNode
*
pSyncNode
,
int32_t
ms
);
int32_t
syncNodeResetElectTimer
(
SSyncNode
*
pSyncNode
);
void
syncNodeResetElectTimer
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeStartHeartbeatTimer
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeStartHeartbeatTimer
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeStopHeartbeatTimer
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeStopHeartbeatTimer
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeRestartHeartbeatTimer
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeRestartHeartbeatTimer
(
SSyncNode
*
pSyncNode
);
...
...
source/libs/sync/inc/syncPipeline.h
浏览文件 @
fb628f7f
...
@@ -61,7 +61,7 @@ typedef struct SSyncLogBuffer {
...
@@ -61,7 +61,7 @@ typedef struct SSyncLogBuffer {
// SSyncLogRepMgr
// SSyncLogRepMgr
SSyncLogReplMgr
*
syncLogReplMgrCreate
();
SSyncLogReplMgr
*
syncLogReplMgrCreate
();
void
syncLogReplMgrDestroy
(
SSyncLogReplMgr
*
pMgr
);
void
syncLogReplMgrDestroy
(
SSyncLogReplMgr
*
pMgr
);
int32_t
syncLogReplMgrReset
(
SSyncLogReplMgr
*
pMgr
);
void
syncLogReplMgrReset
(
SSyncLogReplMgr
*
pMgr
);
int32_t
syncNodeLogReplMgrInit
(
SSyncNode
*
pNode
);
int32_t
syncNodeLogReplMgrInit
(
SSyncNode
*
pNode
);
void
syncNodeLogReplMgrDestroy
(
SSyncNode
*
pNode
);
void
syncNodeLogReplMgrDestroy
(
SSyncNode
*
pNode
);
...
@@ -109,6 +109,8 @@ SSyncRaftEntry* syncLogBufferGetOneEntry(SSyncLogBuffer* pBuf, SSyncNode* pNode,
...
@@ -109,6 +109,8 @@ SSyncRaftEntry* syncLogBufferGetOneEntry(SSyncLogBuffer* pBuf, SSyncNode* pNode,
int32_t
syncLogBufferValidate
(
SSyncLogBuffer
*
pBuf
);
int32_t
syncLogBufferValidate
(
SSyncLogBuffer
*
pBuf
);
int32_t
syncLogBufferRollback
(
SSyncLogBuffer
*
pBuf
,
SSyncNode
*
pNode
,
SyncIndex
toIndex
);
int32_t
syncLogBufferRollback
(
SSyncLogBuffer
*
pBuf
,
SSyncNode
*
pNode
,
SyncIndex
toIndex
);
int32_t
syncLogFsmExecute
(
SSyncNode
*
pNode
,
SSyncFSM
*
pFsm
,
ESyncState
role
,
SyncTerm
term
,
SSyncRaftEntry
*
pEntry
,
int32_t
applyCode
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
source/libs/sync/inc/syncSnapshot.h
浏览文件 @
fb628f7f
...
@@ -56,7 +56,7 @@ SSyncSnapshotSender *snapshotSenderCreate(SSyncNode *pSyncNode, int32_t replicaI
...
@@ -56,7 +56,7 @@ SSyncSnapshotSender *snapshotSenderCreate(SSyncNode *pSyncNode, int32_t replicaI
void
snapshotSenderDestroy
(
SSyncSnapshotSender
*
pSender
);
void
snapshotSenderDestroy
(
SSyncSnapshotSender
*
pSender
);
bool
snapshotSenderIsStart
(
SSyncSnapshotSender
*
pSender
);
bool
snapshotSenderIsStart
(
SSyncSnapshotSender
*
pSender
);
int32_t
snapshotSenderStart
(
SSyncSnapshotSender
*
pSender
);
int32_t
snapshotSenderStart
(
SSyncSnapshotSender
*
pSender
);
int32_t
snapshotSenderStop
(
SSyncSnapshotSender
*
pSender
,
bool
finish
);
void
snapshotSenderStop
(
SSyncSnapshotSender
*
pSender
,
bool
finish
);
int32_t
snapshotSend
(
SSyncSnapshotSender
*
pSender
);
int32_t
snapshotSend
(
SSyncSnapshotSender
*
pSender
);
int32_t
snapshotReSend
(
SSyncSnapshotSender
*
pSender
);
int32_t
snapshotReSend
(
SSyncSnapshotSender
*
pSender
);
...
@@ -79,8 +79,8 @@ typedef struct SSyncSnapshotReceiver {
...
@@ -79,8 +79,8 @@ typedef struct SSyncSnapshotReceiver {
SSyncSnapshotReceiver
*
snapshotReceiverCreate
(
SSyncNode
*
pSyncNode
,
SRaftId
fromId
);
SSyncSnapshotReceiver
*
snapshotReceiverCreate
(
SSyncNode
*
pSyncNode
,
SRaftId
fromId
);
void
snapshotReceiverDestroy
(
SSyncSnapshotReceiver
*
pReceiver
);
void
snapshotReceiverDestroy
(
SSyncSnapshotReceiver
*
pReceiver
);
int32_t
snapshotReceiverStart
(
SSyncSnapshotReceiver
*
pReceiver
,
SyncSnapshotSend
*
pBeginMsg
);
void
snapshotReceiverStart
(
SSyncSnapshotReceiver
*
pReceiver
,
SyncSnapshotSend
*
pBeginMsg
);
int32_t
snapshotReceiverStop
(
SSyncSnapshotReceiver
*
pReceiver
);
void
snapshotReceiverStop
(
SSyncSnapshotReceiver
*
pReceiver
);
bool
snapshotReceiverIsStart
(
SSyncSnapshotReceiver
*
pReceiver
);
bool
snapshotReceiverIsStart
(
SSyncSnapshotReceiver
*
pReceiver
);
void
snapshotReceiverForceStop
(
SSyncSnapshotReceiver
*
pReceiver
);
void
snapshotReceiverForceStop
(
SSyncSnapshotReceiver
*
pReceiver
);
...
...
source/libs/sync/src/syncMain.c
浏览文件 @
fb628f7f
...
@@ -200,12 +200,15 @@ int32_t syncProcessMsg(int64_t rid, SRpcMsg* pMsg) {
...
@@ -200,12 +200,15 @@ int32_t syncProcessMsg(int64_t rid, SRpcMsg* pMsg) {
code
=
syncNodeOnLocalCmd
(
pSyncNode
,
pMsg
);
code
=
syncNodeOnLocalCmd
(
pSyncNode
,
pMsg
);
break
;
break
;
default:
default:
sError
(
"vgId:%d, failed to process msg:%p since invalid type:%s"
,
pSyncNode
->
vgId
,
pMsg
,
terrno
=
TSDB_CODE_MSG_NOT_PROCESSED
;
TMSG_INFO
(
pMsg
->
msgType
));
code
=
-
1
;
code
=
-
1
;
}
}
syncNodeRelease
(
pSyncNode
);
syncNodeRelease
(
pSyncNode
);
if
(
code
!=
0
)
{
sDebug
(
"vgId:%d, failed to process sync msg:%p type:%s since 0x%x"
,
pSyncNode
->
vgId
,
pMsg
,
TMSG_INFO
(
pMsg
->
msgType
),
terrno
);
}
return
code
;
return
code
;
}
}
...
@@ -228,8 +231,7 @@ int32_t syncSendTimeoutRsp(int64_t rid, int64_t seq) {
...
@@ -228,8 +231,7 @@ int32_t syncSendTimeoutRsp(int64_t rid, int64_t seq) {
syncNodeRelease
(
pNode
);
syncNodeRelease
(
pNode
);
if
(
ret
==
1
)
{
if
(
ret
==
1
)
{
sInfo
(
"send timeout response, seq:%"
PRId64
" handle:%p ahandle:%p"
,
seq
,
rpcMsg
.
info
.
handle
,
sInfo
(
"send timeout response, seq:%"
PRId64
" handle:%p ahandle:%p"
,
seq
,
rpcMsg
.
info
.
handle
,
rpcMsg
.
info
.
ahandle
);
rpcMsg
.
info
.
ahandle
);
rpcSendResponse
(
&
rpcMsg
);
rpcSendResponse
(
&
rpcMsg
);
return
0
;
return
0
;
}
else
{
}
else
{
...
@@ -1084,13 +1086,17 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo) {
...
@@ -1084,13 +1086,17 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo) {
// snapshot senders
// snapshot senders
for
(
int32_t
i
=
0
;
i
<
TSDB_MAX_REPLICA
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
TSDB_MAX_REPLICA
;
++
i
)
{
SSyncSnapshotSender
*
pSender
=
snapshotSenderCreate
(
pSyncNode
,
i
);
SSyncSnapshotSender
*
pSender
=
snapshotSenderCreate
(
pSyncNode
,
i
);
// ASSERT(pSender != NULL);
if
(
pSender
==
NULL
)
return
NULL
;
(
pSyncNode
->
senders
)[
i
]
=
pSender
;
sSDebug
(
pSender
,
"snapshot sender create new while open, data:%p"
,
pSender
);
pSyncNode
->
senders
[
i
]
=
pSender
;
sSDebug
(
pSender
,
"snapshot sender create while open sync node, data:%p"
,
pSender
);
}
}
// snapshot receivers
// snapshot receivers
pSyncNode
->
pNewNodeReceiver
=
snapshotReceiverCreate
(
pSyncNode
,
EMPTY_RAFT_ID
);
pSyncNode
->
pNewNodeReceiver
=
snapshotReceiverCreate
(
pSyncNode
,
EMPTY_RAFT_ID
);
if
(
pSyncNode
->
pNewNodeReceiver
==
NULL
)
return
NULL
;
sRDebug
(
pSyncNode
->
pNewNodeReceiver
,
"snapshot receiver create while open sync node, data:%p"
,
pSyncNode
->
pNewNodeReceiver
);
// is config changing
// is config changing
pSyncNode
->
changing
=
false
;
pSyncNode
->
changing
=
false
;
...
@@ -1131,10 +1137,8 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo) {
...
@@ -1131,10 +1137,8 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo) {
pSyncNode
->
hbrSlowNum
=
0
;
pSyncNode
->
hbrSlowNum
=
0
;
pSyncNode
->
tmrRoutineNum
=
0
;
pSyncNode
->
tmrRoutineNum
=
0
;
sNInfo
(
pSyncNode
,
"sync open, node:%p"
,
pSyncNode
);
sNInfo
(
pSyncNode
,
"sync open, node:%p electInterval:%d heartbeatInterval:%d heartbeatTimeout:%d"
,
pSyncNode
,
sTrace
(
"vgId:%d, tsElectInterval:%d, tsHeartbeatInterval:%d, tsHeartbeatTimeout:%d"
,
pSyncNode
->
vgId
,
tsElectInterval
,
tsElectInterval
,
tsHeartbeatInterval
,
tsHeartbeatTimeout
);
tsHeartbeatInterval
,
tsHeartbeatTimeout
);
return
pSyncNode
;
return
pSyncNode
;
_error:
_error:
...
@@ -1251,6 +1255,8 @@ void syncNodePreClose(SSyncNode* pSyncNode) {
...
@@ -1251,6 +1255,8 @@ void syncNodePreClose(SSyncNode* pSyncNode) {
snapshotReceiverForceStop
(
pSyncNode
->
pNewNodeReceiver
);
snapshotReceiverForceStop
(
pSyncNode
->
pNewNodeReceiver
);
}
}
sDebug
(
"vgId:%d, snapshot receiver destroy while preclose sync node, data:%p"
,
pSyncNode
->
vgId
,
pSyncNode
->
pNewNodeReceiver
);
snapshotReceiverDestroy
(
pSyncNode
->
pNewNodeReceiver
);
snapshotReceiverDestroy
(
pSyncNode
->
pNewNodeReceiver
);
pSyncNode
->
pNewNodeReceiver
=
NULL
;
pSyncNode
->
pNewNodeReceiver
=
NULL
;
}
}
...
@@ -1295,15 +1301,15 @@ void syncNodeClose(SSyncNode* pSyncNode) {
...
@@ -1295,15 +1301,15 @@ void syncNodeClose(SSyncNode* pSyncNode) {
syncNodeStopHeartbeatTimer
(
pSyncNode
);
syncNodeStopHeartbeatTimer
(
pSyncNode
);
for
(
int32_t
i
=
0
;
i
<
TSDB_MAX_REPLICA
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
TSDB_MAX_REPLICA
;
++
i
)
{
if
(
(
pSyncNode
->
senders
)
[
i
]
!=
NULL
)
{
if
(
pSyncNode
->
senders
[
i
]
!=
NULL
)
{
s
STrace
((
pSyncNode
->
senders
)[
i
],
"snapshot sender destroy while close, data:%p"
,
(
pSyncNode
->
senders
)
[
i
]);
s
Debug
(
"vgId:%d, snapshot sender destroy while close, data:%p"
,
pSyncNode
->
vgId
,
pSyncNode
->
senders
[
i
]);
if
(
snapshotSenderIsStart
(
(
pSyncNode
->
senders
)
[
i
]))
{
if
(
snapshotSenderIsStart
(
pSyncNode
->
senders
[
i
]))
{
snapshotSenderStop
(
(
pSyncNode
->
senders
)
[
i
],
false
);
snapshotSenderStop
(
pSyncNode
->
senders
[
i
],
false
);
}
}
snapshotSenderDestroy
(
(
pSyncNode
->
senders
)
[
i
]);
snapshotSenderDestroy
(
pSyncNode
->
senders
[
i
]);
(
pSyncNode
->
senders
)
[
i
]
=
NULL
;
pSyncNode
->
senders
[
i
]
=
NULL
;
}
}
}
}
...
@@ -1312,6 +1318,7 @@ void syncNodeClose(SSyncNode* pSyncNode) {
...
@@ -1312,6 +1318,7 @@ void syncNodeClose(SSyncNode* pSyncNode) {
snapshotReceiverForceStop
(
pSyncNode
->
pNewNodeReceiver
);
snapshotReceiverForceStop
(
pSyncNode
->
pNewNodeReceiver
);
}
}
sDebug
(
"vgId:%d, snapshot receiver destroy while close, data:%p"
,
pSyncNode
->
vgId
,
pSyncNode
->
pNewNodeReceiver
);
snapshotReceiverDestroy
(
pSyncNode
->
pNewNodeReceiver
);
snapshotReceiverDestroy
(
pSyncNode
->
pNewNodeReceiver
);
pSyncNode
->
pNewNodeReceiver
=
NULL
;
pSyncNode
->
pNewNodeReceiver
=
NULL
;
}
}
...
@@ -1382,8 +1389,7 @@ int32_t syncNodeRestartElectTimer(SSyncNode* pSyncNode, int32_t ms) {
...
@@ -1382,8 +1389,7 @@ int32_t syncNodeRestartElectTimer(SSyncNode* pSyncNode, int32_t ms) {
return
ret
;
return
ret
;
}
}
int32_t
syncNodeResetElectTimer
(
SSyncNode
*
pSyncNode
)
{
void
syncNodeResetElectTimer
(
SSyncNode
*
pSyncNode
)
{
int32_t
ret
=
0
;
int32_t
electMS
;
int32_t
electMS
;
if
(
pSyncNode
->
pRaftCfg
->
isStandBy
)
{
if
(
pSyncNode
->
pRaftCfg
->
isStandBy
)
{
...
@@ -1391,11 +1397,11 @@ int32_t syncNodeResetElectTimer(SSyncNode* pSyncNode) {
...
@@ -1391,11 +1397,11 @@ int32_t syncNodeResetElectTimer(SSyncNode* pSyncNode) {
}
else
{
}
else
{
electMS
=
syncUtilElectRandomMS
(
pSyncNode
->
electBaseLine
,
2
*
pSyncNode
->
electBaseLine
);
electMS
=
syncUtilElectRandomMS
(
pSyncNode
->
electBaseLine
,
2
*
pSyncNode
->
electBaseLine
);
}
}
ret
=
syncNodeRestartElectTimer
(
pSyncNode
,
electMS
);
(
void
)
syncNodeRestartElectTimer
(
pSyncNode
,
electMS
);
sNTrace
(
pSyncNode
,
"reset elect timer, min:%d, max:%d, ms:%d"
,
pSyncNode
->
electBaseLine
,
2
*
pSyncNode
->
electBaseLine
,
sNTrace
(
pSyncNode
,
"reset elect timer, min:%d, max:%d, ms:%d"
,
pSyncNode
->
electBaseLine
,
2
*
pSyncNode
->
electBaseLine
,
electMS
);
electMS
);
return
ret
;
}
}
static
int32_t
syncNodeDoStartHeartbeatTimer
(
SSyncNode
*
pSyncNode
)
{
static
int32_t
syncNodeDoStartHeartbeatTimer
(
SSyncNode
*
pSyncNode
)
{
...
@@ -1455,23 +1461,20 @@ int32_t syncNodeRestartHeartbeatTimer(SSyncNode* pSyncNode) {
...
@@ -1455,23 +1461,20 @@ int32_t syncNodeRestartHeartbeatTimer(SSyncNode* pSyncNode) {
return
0
;
return
0
;
}
}
// utils --------------
int32_t
syncNodeSendMsgById
(
const
SRaftId
*
destRaftId
,
SSyncNode
*
pSyncNode
,
SRpcMsg
*
pMsg
)
{
int32_t
syncNodeSendMsgById
(
const
SRaftId
*
destRaftId
,
SSyncNode
*
pSyncNode
,
SRpcMsg
*
pMsg
)
{
SEpSet
epSet
;
SEpSet
epSet
;
syncUtilRaftId2EpSet
(
destRaftId
,
&
epSet
);
syncUtilRaftId2EpSet
(
destRaftId
,
&
epSet
);
if
(
pSyncNode
->
syncSendMSg
!=
NULL
)
{
if
(
pSyncNode
->
syncSendMSg
!=
NULL
)
{
// htonl
syncUtilMsgHtoN
(
pMsg
->
pCont
);
syncUtilMsgHtoN
(
pMsg
->
pCont
);
pMsg
->
info
.
noResp
=
1
;
pMsg
->
info
.
noResp
=
1
;
pSyncNode
->
syncSendMSg
(
&
epSet
,
pMsg
);
return
pSyncNode
->
syncSendMSg
(
&
epSet
,
pMsg
);
}
else
{
}
else
{
sError
(
"vgId:%d, sync send msg by id error, fp-send-msg is null"
,
pSyncNode
->
vgId
);
sError
(
"vgId:%d, sync send msg by id error, fp-send-msg is null"
,
pSyncNode
->
vgId
);
rpcFreeCont
(
pMsg
->
pCont
);
rpcFreeCont
(
pMsg
->
pCont
);
terrno
=
TSDB_CODE_SYN_INTERNAL_ERROR
;
return
-
1
;
return
-
1
;
}
}
return
0
;
}
}
int32_t
syncNodeSendMsgByInfo
(
const
SNodeInfo
*
nodeInfo
,
SSyncNode
*
pSyncNode
,
SRpcMsg
*
pMsg
)
{
int32_t
syncNodeSendMsgByInfo
(
const
SNodeInfo
*
nodeInfo
,
SSyncNode
*
pSyncNode
,
SRpcMsg
*
pMsg
)
{
...
@@ -1586,7 +1589,7 @@ void syncNodeDoConfigChange(SSyncNode* pSyncNode, SSyncCfg* pNewConfig, SyncInde
...
@@ -1586,7 +1589,7 @@ void syncNodeDoConfigChange(SSyncNode* pSyncNode, SSyncCfg* pNewConfig, SyncInde
memcpy
(
oldReplicasId
,
pSyncNode
->
replicasId
,
sizeof
(
oldReplicasId
));
memcpy
(
oldReplicasId
,
pSyncNode
->
replicasId
,
sizeof
(
oldReplicasId
));
SSyncSnapshotSender
*
oldSenders
[
TSDB_MAX_REPLICA
];
SSyncSnapshotSender
*
oldSenders
[
TSDB_MAX_REPLICA
];
for
(
int32_t
i
=
0
;
i
<
TSDB_MAX_REPLICA
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
TSDB_MAX_REPLICA
;
++
i
)
{
oldSenders
[
i
]
=
(
pSyncNode
->
senders
)
[
i
];
oldSenders
[
i
]
=
pSyncNode
->
senders
[
i
];
sSTrace
(
oldSenders
[
i
],
"snapshot sender save old"
);
sSTrace
(
oldSenders
[
i
],
"snapshot sender save old"
);
}
}
...
@@ -1625,7 +1628,7 @@ void syncNodeDoConfigChange(SSyncNode* pSyncNode, SSyncCfg* pNewConfig, SyncInde
...
@@ -1625,7 +1628,7 @@ void syncNodeDoConfigChange(SSyncNode* pSyncNode, SSyncCfg* pNewConfig, SyncInde
// clear new
// clear new
for
(
int32_t
i
=
0
;
i
<
TSDB_MAX_REPLICA
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
TSDB_MAX_REPLICA
;
++
i
)
{
(
pSyncNode
->
senders
)
[
i
]
=
NULL
;
pSyncNode
->
senders
[
i
]
=
NULL
;
}
}
// reset new
// reset new
...
@@ -1640,16 +1643,16 @@ void syncNodeDoConfigChange(SSyncNode* pSyncNode, SSyncCfg* pNewConfig, SyncInde
...
@@ -1640,16 +1643,16 @@ void syncNodeDoConfigChange(SSyncNode* pSyncNode, SSyncCfg* pNewConfig, SyncInde
sNTrace
(
pSyncNode
,
"snapshot sender reset for: %"
PRId64
", newIndex:%d, %s:%d, %p"
,
sNTrace
(
pSyncNode
,
"snapshot sender reset for: %"
PRId64
", newIndex:%d, %s:%d, %p"
,
(
pSyncNode
->
replicasId
)[
i
].
addr
,
i
,
host
,
port
,
oldSenders
[
j
]);
(
pSyncNode
->
replicasId
)[
i
].
addr
,
i
,
host
,
port
,
oldSenders
[
j
]);
(
pSyncNode
->
senders
)
[
i
]
=
oldSenders
[
j
];
pSyncNode
->
senders
[
i
]
=
oldSenders
[
j
];
oldSenders
[
j
]
=
NULL
;
oldSenders
[
j
]
=
NULL
;
reset
=
true
;
reset
=
true
;
// reset replicaIndex
// reset replicaIndex
int32_t
oldreplicaIndex
=
(
pSyncNode
->
senders
)
[
i
]
->
replicaIndex
;
int32_t
oldreplicaIndex
=
pSyncNode
->
senders
[
i
]
->
replicaIndex
;
(
pSyncNode
->
senders
)
[
i
]
->
replicaIndex
=
i
;
pSyncNode
->
senders
[
i
]
->
replicaIndex
=
i
;
sNTrace
(
pSyncNode
,
"snapshot sender udpate replicaIndex from %d to %d, %s:%d, %p, reset:%d"
,
oldreplicaIndex
,
sNTrace
(
pSyncNode
,
"snapshot sender udpate replicaIndex from %d to %d, %s:%d, %p, reset:%d"
,
oldreplicaIndex
,
i
,
host
,
port
,
(
pSyncNode
->
senders
)
[
i
],
reset
);
i
,
host
,
port
,
pSyncNode
->
senders
[
i
],
reset
);
break
;
break
;
}
}
...
@@ -1658,18 +1661,23 @@ void syncNodeDoConfigChange(SSyncNode* pSyncNode, SSyncCfg* pNewConfig, SyncInde
...
@@ -1658,18 +1661,23 @@ void syncNodeDoConfigChange(SSyncNode* pSyncNode, SSyncCfg* pNewConfig, SyncInde
// create new
// create new
for
(
int32_t
i
=
0
;
i
<
TSDB_MAX_REPLICA
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
TSDB_MAX_REPLICA
;
++
i
)
{
if
((
pSyncNode
->
senders
)[
i
]
==
NULL
)
{
if
(
pSyncNode
->
senders
[
i
]
==
NULL
)
{
(
pSyncNode
->
senders
)[
i
]
=
snapshotSenderCreate
(
pSyncNode
,
i
);
pSyncNode
->
senders
[
i
]
=
snapshotSenderCreate
(
pSyncNode
,
i
);
sSTrace
((
pSyncNode
->
senders
)[
i
],
"snapshot sender create new while reconfig, data:%p"
,
(
pSyncNode
->
senders
)[
i
]);
if
(
pSyncNode
->
senders
[
i
]
==
NULL
)
{
// will be created later while send snapshot
sSError
(
pSyncNode
->
senders
[
i
],
"snapshot sender create failed while reconfig"
);
}
else
{
sSDebug
(
pSyncNode
->
senders
[
i
],
"snapshot sender create while reconfig, data:%p"
,
pSyncNode
->
senders
[
i
]);
}
}
else
{
}
else
{
sS
Trace
((
pSyncNode
->
senders
)[
i
],
"snapshot sender already exist, data:%p"
,
(
pSyncNode
->
senders
)
[
i
]);
sS
Debug
(
pSyncNode
->
senders
[
i
],
"snapshot sender already exist, data:%p"
,
pSyncNode
->
senders
[
i
]);
}
}
}
}
// free old
// free old
for
(
int32_t
i
=
0
;
i
<
TSDB_MAX_REPLICA
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
TSDB_MAX_REPLICA
;
++
i
)
{
if
(
oldSenders
[
i
]
!=
NULL
)
{
if
(
oldSenders
[
i
]
!=
NULL
)
{
s
NTrace
(
pSyncNode
,
"snapshot sender destroy old, data:%p replica-index:%d"
,
oldSenders
[
i
],
i
);
s
SDebug
(
oldSenders
[
i
]
,
"snapshot sender destroy old, data:%p replica-index:%d"
,
oldSenders
[
i
],
i
);
snapshotSenderDestroy
(
oldSenders
[
i
]);
snapshotSenderDestroy
(
oldSenders
[
i
]);
oldSenders
[
i
]
=
NULL
;
oldSenders
[
i
]
=
NULL
;
}
}
...
@@ -1844,8 +1852,8 @@ void syncNodeBecomeLeader(SSyncNode* pSyncNode, const char* debugStr) {
...
@@ -1844,8 +1852,8 @@ void syncNodeBecomeLeader(SSyncNode* pSyncNode, const char* debugStr) {
SSyncSnapshotSender* pMySender = syncNodeGetSnapshotSender(pSyncNode, &(pSyncNode->myRaftId));
SSyncSnapshotSender* pMySender = syncNodeGetSnapshotSender(pSyncNode, &(pSyncNode->myRaftId));
if (pMySender != NULL) {
if (pMySender != NULL) {
for (int32_t i = 0; i < pSyncNode->pMatchIndex->replicaNum; ++i) {
for (int32_t i = 0; i < pSyncNode->pMatchIndex->replicaNum; ++i) {
if (
(pSyncNode->senders)
[i]->privateTerm > pMySender->privateTerm) {
if (
pSyncNode->senders
[i]->privateTerm > pMySender->privateTerm) {
pMySender->privateTerm =
(pSyncNode->senders)
[i]->privateTerm;
pMySender->privateTerm =
pSyncNode->senders
[i]->privateTerm;
}
}
}
}
(pMySender->privateTerm) += 100;
(pMySender->privateTerm) += 100;
...
@@ -2376,9 +2384,20 @@ int32_t syncCacheEntry(SSyncLogStore* pLogStore, SSyncRaftEntry* pEntry, LRUHand
...
@@ -2376,9 +2384,20 @@ int32_t syncCacheEntry(SSyncLogStore* pLogStore, SSyncRaftEntry* pEntry, LRUHand
}
}
int32_t
syncNodeAppend
(
SSyncNode
*
ths
,
SSyncRaftEntry
*
pEntry
)
{
int32_t
syncNodeAppend
(
SSyncNode
*
ths
,
SSyncRaftEntry
*
pEntry
)
{
if
(
pEntry
->
dataLen
<
sizeof
(
SMsgHead
))
{
sError
(
"vgId:%d, cannot append an invalid client request with no msg head. type:%s, dataLen:%d"
,
ths
->
vgId
,
TMSG_INFO
(
pEntry
->
originalRpcType
),
pEntry
->
dataLen
);
syncEntryDestroy
(
pEntry
);
return
-
1
;
}
// append to log buffer
// append to log buffer
if
(
syncLogBufferAppend
(
ths
->
pLogBuf
,
ths
,
pEntry
)
<
0
)
{
if
(
syncLogBufferAppend
(
ths
->
pLogBuf
,
ths
,
pEntry
)
<
0
)
{
sError
(
"vgId:%d, failed to enqueue sync log buffer. index:%"
PRId64
""
,
ths
->
vgId
,
pEntry
->
index
);
sError
(
"vgId:%d, failed to enqueue sync log buffer, index:%"
PRId64
,
ths
->
vgId
,
pEntry
->
index
);
terrno
=
TSDB_CODE_SYN_BUFFER_FULL
;
(
void
)
syncLogFsmExecute
(
ths
,
ths
->
pFsm
,
ths
->
state
,
ths
->
pRaftStore
->
currentTerm
,
pEntry
,
TSDB_CODE_SYN_BUFFER_FULL
);
syncEntryDestroy
(
pEntry
);
return
-
1
;
return
-
1
;
}
}
...
@@ -2671,16 +2690,24 @@ int32_t syncNodeOnClientRequest(SSyncNode* ths, SRpcMsg* pMsg, SyncIndex* pRetIn
...
@@ -2671,16 +2690,24 @@ int32_t syncNodeOnClientRequest(SSyncNode* ths, SRpcMsg* pMsg, SyncIndex* pRetIn
pEntry
=
syncEntryBuildFromRpcMsg
(
pMsg
,
term
,
index
);
pEntry
=
syncEntryBuildFromRpcMsg
(
pMsg
,
term
,
index
);
}
}
if
(
pEntry
==
NULL
)
{
sError
(
"vgId:%d, failed to process client request since %s."
,
ths
->
vgId
,
terrstr
());
return
-
1
;
}
if
(
ths
->
state
==
TAOS_SYNC_STATE_LEADER
)
{
if
(
ths
->
state
==
TAOS_SYNC_STATE_LEADER
)
{
if
(
pRetIndex
)
{
if
(
pRetIndex
)
{
(
*
pRetIndex
)
=
index
;
(
*
pRetIndex
)
=
index
;
}
}
int32_t
code
=
syncNodeAppend
(
ths
,
pEntry
);
int32_t
code
=
syncNodeAppend
(
ths
,
pEntry
);
if
(
code
<
0
&&
ths
->
vgId
!=
1
&&
vnodeIsMsgBlock
(
pEntry
->
originalRpcType
)
)
{
if
(
code
<
0
)
{
ASSERTS
(
false
,
"failed to append blocking msg"
);
sNError
(
ths
,
"failed to append blocking msg"
);
}
}
return
code
;
return
code
;
}
else
{
syncEntryDestroy
(
pEntry
);
pEntry
=
NULL
;
}
}
return
-
1
;
return
-
1
;
...
...
source/libs/sync/src/syncPipeline.c
浏览文件 @
fb628f7f
...
@@ -26,6 +26,11 @@
...
@@ -26,6 +26,11 @@
#include "syncSnapshot.h"
#include "syncSnapshot.h"
#include "syncUtil.h"
#include "syncUtil.h"
static
bool
syncIsMsgBlock
(
tmsg_t
type
)
{
return
(
type
==
TDMT_VND_CREATE_TABLE
)
||
(
type
==
TDMT_VND_ALTER_TABLE
)
||
(
type
==
TDMT_VND_DROP_TABLE
)
||
(
type
==
TDMT_VND_UPDATE_TAG_VAL
)
||
(
type
==
TDMT_VND_ALTER_CONFIRM
);
}
int64_t
syncLogBufferGetEndIndex
(
SSyncLogBuffer
*
pBuf
)
{
int64_t
syncLogBufferGetEndIndex
(
SSyncLogBuffer
*
pBuf
)
{
taosThreadMutexLock
(
&
pBuf
->
mutex
);
taosThreadMutexLock
(
&
pBuf
->
mutex
);
int64_t
index
=
pBuf
->
endIndex
;
int64_t
index
=
pBuf
->
endIndex
;
...
@@ -40,7 +45,7 @@ int32_t syncLogBufferAppend(SSyncLogBuffer* pBuf, SSyncNode* pNode, SSyncRaftEnt
...
@@ -40,7 +45,7 @@ int32_t syncLogBufferAppend(SSyncLogBuffer* pBuf, SSyncNode* pNode, SSyncRaftEnt
if
(
index
-
pBuf
->
startIndex
>=
pBuf
->
size
)
{
if
(
index
-
pBuf
->
startIndex
>=
pBuf
->
size
)
{
sError
(
"vgId:%d, failed to append due to sync log buffer full. index:%"
PRId64
""
,
pNode
->
vgId
,
index
);
sError
(
"vgId:%d, failed to append due to sync log buffer full. index:%"
PRId64
""
,
pNode
->
vgId
,
index
);
goto
_
out
;
goto
_
err
;
}
}
ASSERT
(
index
==
pBuf
->
endIndex
);
ASSERT
(
index
==
pBuf
->
endIndex
);
...
@@ -61,9 +66,8 @@ int32_t syncLogBufferAppend(SSyncLogBuffer* pBuf, SSyncNode* pNode, SSyncRaftEnt
...
@@ -61,9 +66,8 @@ int32_t syncLogBufferAppend(SSyncLogBuffer* pBuf, SSyncNode* pNode, SSyncRaftEnt
taosThreadMutexUnlock
(
&
pBuf
->
mutex
);
taosThreadMutexUnlock
(
&
pBuf
->
mutex
);
return
0
;
return
0
;
_
out
:
_
err
:
syncLogBufferValidate
(
pBuf
);
syncLogBufferValidate
(
pBuf
);
syncEntryDestroy
(
pEntry
);
taosThreadMutexUnlock
(
&
pBuf
->
mutex
);
taosThreadMutexUnlock
(
&
pBuf
->
mutex
);
return
-
1
;
return
-
1
;
}
}
...
@@ -112,7 +116,7 @@ SyncTerm syncLogReplMgrGetPrevLogTerm(SSyncLogReplMgr* pMgr, SSyncNode* pNode, S
...
@@ -112,7 +116,7 @@ SyncTerm syncLogReplMgrGetPrevLogTerm(SSyncLogReplMgr* pMgr, SSyncNode* pNode, S
return
prevLogTerm
;
return
prevLogTerm
;
}
}
s
Error
(
"vgId:%d, failed to get log term since %s. index: %"
PRId64
""
,
pNode
->
vgId
,
terrstr
(),
prevIndex
);
s
Info
(
"vgId:%d, failed to get log term since %s. index:%"
PRId64
,
pNode
->
vgId
,
terrstr
(),
prevIndex
);
terrno
=
TSDB_CODE_WAL_LOG_NOT_EXIST
;
terrno
=
TSDB_CODE_WAL_LOG_NOT_EXIST
;
return
-
1
;
return
-
1
;
}
}
...
@@ -441,26 +445,25 @@ _out:
...
@@ -441,26 +445,25 @@ _out:
return
matchIndex
;
return
matchIndex
;
}
}
int32_t
syncLogFsmExecute
(
SSyncNode
*
pNode
,
SSyncFSM
*
pFsm
,
ESyncState
role
,
SyncTerm
term
,
SSyncRaftEntry
*
pEntry
)
{
int32_t
syncLogFsmExecute
(
SSyncNode
*
pNode
,
SSyncFSM
*
pFsm
,
ESyncState
role
,
SyncTerm
term
,
SSyncRaftEntry
*
pEntry
,
ASSERTS
(
pFsm
->
FpCommitCb
!=
NULL
,
"No commit cb registered for the FSM"
);
int32_t
applyCode
)
{
if
((
pNode
->
replicaNum
==
1
)
&&
pNode
->
restoreFinish
&&
pNode
->
vgId
!=
1
)
{
if
((
pNode
->
replicaNum
==
1
)
&&
pNode
->
restoreFinish
&&
pNode
->
vgId
!=
1
)
{
return
0
;
return
0
;
}
}
if
(
pNode
->
vgId
!=
1
&&
vnode
IsMsgBlock
(
pEntry
->
originalRpcType
))
{
if
(
pNode
->
vgId
!=
1
&&
sync
IsMsgBlock
(
pEntry
->
originalRpcType
))
{
sTrace
(
"vgId:%d, blocking msg ready to execute
. index:%"
PRId64
", term: %"
PRId64
", type: %s"
,
pNode
->
vgId
,
sTrace
(
"vgId:%d, blocking msg ready to execute
, index:%"
PRId64
", term:%"
PRId64
", type:%s code:0x%x"
,
p
Entry
->
index
,
pEntry
->
term
,
TMSG_INFO
(
pEntry
->
originalRpcType
)
);
p
Node
->
vgId
,
pEntry
->
index
,
pEntry
->
term
,
TMSG_INFO
(
pEntry
->
originalRpcType
),
applyCode
);
}
}
SRpcMsg
rpcMsg
=
{
0
};
SRpcMsg
rpcMsg
=
{
.
code
=
applyCode
};
syncEntry2OriginalRpc
(
pEntry
,
&
rpcMsg
);
syncEntry2OriginalRpc
(
pEntry
,
&
rpcMsg
);
SFsmCbMeta
cbMeta
=
{
0
};
SFsmCbMeta
cbMeta
=
{
0
};
cbMeta
.
index
=
pEntry
->
index
;
cbMeta
.
index
=
pEntry
->
index
;
cbMeta
.
lastConfigIndex
=
syncNodeGetSnapshotConfigIndex
(
pNode
,
pEntry
->
index
);
cbMeta
.
lastConfigIndex
=
syncNodeGetSnapshotConfigIndex
(
pNode
,
pEntry
->
index
);
cbMeta
.
isWeak
=
pEntry
->
isWeak
;
cbMeta
.
isWeak
=
pEntry
->
isWeak
;
cbMeta
.
code
=
0
;
cbMeta
.
code
=
applyCode
;
cbMeta
.
state
=
role
;
cbMeta
.
state
=
role
;
cbMeta
.
seqNum
=
pEntry
->
seqNum
;
cbMeta
.
seqNum
=
pEntry
->
seqNum
;
cbMeta
.
term
=
pEntry
->
term
;
cbMeta
.
term
=
pEntry
->
term
;
...
@@ -469,7 +472,6 @@ int32_t syncLogFsmExecute(SSyncNode* pNode, SSyncFSM* pFsm, ESyncState role, Syn
...
@@ -469,7 +472,6 @@ int32_t syncLogFsmExecute(SSyncNode* pNode, SSyncFSM* pFsm, ESyncState role, Syn
(
void
)
syncRespMgrGetAndDel
(
pNode
->
pSyncRespMgr
,
cbMeta
.
seqNum
,
&
rpcMsg
.
info
);
(
void
)
syncRespMgrGetAndDel
(
pNode
->
pSyncRespMgr
,
cbMeta
.
seqNum
,
&
rpcMsg
.
info
);
int32_t
code
=
pFsm
->
FpCommitCb
(
pFsm
,
&
rpcMsg
,
&
cbMeta
);
int32_t
code
=
pFsm
->
FpCommitCb
(
pFsm
,
&
rpcMsg
,
&
cbMeta
);
ASSERT
(
rpcMsg
.
pCont
==
NULL
);
return
code
;
return
code
;
}
}
...
@@ -520,7 +522,7 @@ int32_t syncLogBufferCommit(SSyncLogBuffer* pBuf, SSyncNode* pNode, int64_t comm
...
@@ -520,7 +522,7 @@ int32_t syncLogBufferCommit(SSyncLogBuffer* pBuf, SSyncNode* pNode, int64_t comm
pEntry
->
term
,
TMSG_INFO
(
pEntry
->
originalRpcType
));
pEntry
->
term
,
TMSG_INFO
(
pEntry
->
originalRpcType
));
}
}
if
(
syncLogFsmExecute
(
pNode
,
pFsm
,
role
,
term
,
pEntry
)
!=
0
)
{
if
(
syncLogFsmExecute
(
pNode
,
pFsm
,
role
,
term
,
pEntry
,
0
)
!=
0
)
{
sError
(
"vgId:%d, failed to execute sync log entry. index:%"
PRId64
", term:%"
PRId64
sError
(
"vgId:%d, failed to execute sync log entry. index:%"
PRId64
", term:%"
PRId64
", role: %d, current term: %"
PRId64
,
", role: %d, current term: %"
PRId64
,
vgId
,
pEntry
->
index
,
pEntry
->
term
,
role
,
term
);
vgId
,
pEntry
->
index
,
pEntry
->
term
,
role
,
term
);
...
@@ -566,7 +568,9 @@ _out:
...
@@ -566,7 +568,9 @@ _out:
return
ret
;
return
ret
;
}
}
int32_t
syncLogReplMgrReset
(
SSyncLogReplMgr
*
pMgr
)
{
void
syncLogReplMgrReset
(
SSyncLogReplMgr
*
pMgr
)
{
if
(
pMgr
==
NULL
)
return
;
ASSERT
(
pMgr
->
startIndex
>=
0
);
ASSERT
(
pMgr
->
startIndex
>=
0
);
for
(
SyncIndex
index
=
pMgr
->
startIndex
;
index
<
pMgr
->
endIndex
;
index
++
)
{
for
(
SyncIndex
index
=
pMgr
->
startIndex
;
index
<
pMgr
->
endIndex
;
index
++
)
{
memset
(
&
pMgr
->
states
[
index
%
pMgr
->
size
],
0
,
sizeof
(
pMgr
->
states
[
0
]));
memset
(
&
pMgr
->
states
[
index
%
pMgr
->
size
],
0
,
sizeof
(
pMgr
->
states
[
0
]));
...
@@ -576,7 +580,6 @@ int32_t syncLogReplMgrReset(SSyncLogReplMgr* pMgr) {
...
@@ -576,7 +580,6 @@ int32_t syncLogReplMgrReset(SSyncLogReplMgr* pMgr) {
pMgr
->
endIndex
=
0
;
pMgr
->
endIndex
=
0
;
pMgr
->
restored
=
false
;
pMgr
->
restored
=
false
;
pMgr
->
retryBackoff
=
0
;
pMgr
->
retryBackoff
=
0
;
return
0
;
}
}
int32_t
syncLogReplMgrRetryOnNeed
(
SSyncLogReplMgr
*
pMgr
,
SSyncNode
*
pNode
)
{
int32_t
syncLogReplMgrRetryOnNeed
(
SSyncLogReplMgr
*
pMgr
,
SSyncNode
*
pNode
)
{
...
...
source/libs/sync/src/syncRaftLog.c
浏览文件 @
fb628f7f
...
@@ -115,8 +115,8 @@ static int32_t raftLogRestoreFromSnapshot(struct SSyncLogStore* pLogStore, SyncI
...
@@ -115,8 +115,8 @@ static int32_t raftLogRestoreFromSnapshot(struct SSyncLogStore* pLogStore, SyncI
const
char
*
sysErrStr
=
strerror
(
errno
);
const
char
*
sysErrStr
=
strerror
(
errno
);
sNError
(
pData
->
pSyncNode
,
sNError
(
pData
->
pSyncNode
,
"wal restore from snapshot error, index:%"
PRId64
", err:
%d %X, msg:%s, syserr:%d, sysmsg:%s"
,
"wal restore from snapshot error, index:%"
PRId64
", err:
0x%x, msg:%s, syserr:%d, sysmsg:%s"
,
snapshotIndex
,
snapshotIndex
,
err
,
err
,
errStr
,
sysErr
,
sysErrStr
);
err
,
errStr
,
sysErr
,
sysErrStr
);
return
-
1
;
return
-
1
;
}
}
...
@@ -212,8 +212,8 @@ static int32_t raftLogAppendEntry(struct SSyncLogStore* pLogStore, SSyncRaftEntr
...
@@ -212,8 +212,8 @@ static int32_t raftLogAppendEntry(struct SSyncLogStore* pLogStore, SSyncRaftEntr
int32_t
sysErr
=
errno
;
int32_t
sysErr
=
errno
;
const
char
*
sysErrStr
=
strerror
(
errno
);
const
char
*
sysErrStr
=
strerror
(
errno
);
sNError
(
pData
->
pSyncNode
,
"wal write error, index:%"
PRId64
", err:
%d %X
, msg:%s, syserr:%d, sysmsg:%s"
,
sNError
(
pData
->
pSyncNode
,
"wal write error, index:%"
PRId64
", err:
0x%x
, msg:%s, syserr:%d, sysmsg:%s"
,
pEntry
->
index
,
err
,
err
,
err
Str
,
sysErr
,
sysErrStr
);
pEntry
->
index
,
err
,
errStr
,
sysErr
,
sysErrStr
);
return
-
1
;
return
-
1
;
}
}
...
@@ -257,11 +257,11 @@ int32_t raftLogGetEntry(struct SSyncLogStore* pLogStore, SyncIndex index, SSyncR
...
@@ -257,11 +257,11 @@ int32_t raftLogGetEntry(struct SSyncLogStore* pLogStore, SyncIndex index, SSyncR
const
char
*
sysErrStr
=
strerror
(
errno
);
const
char
*
sysErrStr
=
strerror
(
errno
);
if
(
terrno
==
TSDB_CODE_WAL_LOG_NOT_EXIST
)
{
if
(
terrno
==
TSDB_CODE_WAL_LOG_NOT_EXIST
)
{
sNTrace
(
pData
->
pSyncNode
,
"wal read not exist, index:%"
PRId64
", err:
%d %X
, msg:%s, syserr:%d, sysmsg:%s"
,
index
,
sNTrace
(
pData
->
pSyncNode
,
"wal read not exist, index:%"
PRId64
", err:
0x%x
, msg:%s, syserr:%d, sysmsg:%s"
,
index
,
err
,
err
,
err
Str
,
sysErr
,
sysErrStr
);
err
,
errStr
,
sysErr
,
sysErrStr
);
}
else
{
}
else
{
sNTrace
(
pData
->
pSyncNode
,
"wal read error, index:%"
PRId64
", err:
%d %X, msg:%s, syserr:%d, sysmsg:%s"
,
index
,
sNTrace
(
pData
->
pSyncNode
,
"wal read error, index:%"
PRId64
", err:
0x%x, msg:%s, syserr:%d, sysmsg:%s"
,
index
,
err
,
err
,
err
,
err
Str
,
sysErr
,
sysErrStr
);
errStr
,
sysErr
,
sysErrStr
);
}
}
/*
/*
...
@@ -341,8 +341,8 @@ static int32_t raftLogTruncate(struct SSyncLogStore* pLogStore, SyncIndex fromIn
...
@@ -341,8 +341,8 @@ static int32_t raftLogTruncate(struct SSyncLogStore* pLogStore, SyncIndex fromIn
const
char
*
errStr
=
tstrerror
(
err
);
const
char
*
errStr
=
tstrerror
(
err
);
int32_t
sysErr
=
errno
;
int32_t
sysErr
=
errno
;
const
char
*
sysErrStr
=
strerror
(
errno
);
const
char
*
sysErrStr
=
strerror
(
errno
);
sError
(
"vgId:%d, wal truncate error, from-index:%"
PRId64
", err:
%d %X
, msg:%s, syserr:%d, sysmsg:%s"
,
sError
(
"vgId:%d, wal truncate error, from-index:%"
PRId64
", err:
0x%x
, msg:%s, syserr:%d, sysmsg:%s"
,
pData
->
pSyncNode
->
vgId
,
fromIndex
,
err
,
err
,
err
Str
,
sysErr
,
sysErrStr
);
pData
->
pSyncNode
->
vgId
,
fromIndex
,
err
,
errStr
,
sysErr
,
sysErrStr
);
}
}
// event log
// event log
...
@@ -392,8 +392,8 @@ int32_t raftLogUpdateCommitIndex(SSyncLogStore* pLogStore, SyncIndex index) {
...
@@ -392,8 +392,8 @@ int32_t raftLogUpdateCommitIndex(SSyncLogStore* pLogStore, SyncIndex index) {
const
char
*
errStr
=
tstrerror
(
err
);
const
char
*
errStr
=
tstrerror
(
err
);
int32_t
sysErr
=
errno
;
int32_t
sysErr
=
errno
;
const
char
*
sysErrStr
=
strerror
(
errno
);
const
char
*
sysErrStr
=
strerror
(
errno
);
sError
(
"vgId:%d, wal update commit index error, index:%"
PRId64
", err:
%d %X
, msg:%s, syserr:%d, sysmsg:%s"
,
sError
(
"vgId:%d, wal update commit index error, index:%"
PRId64
", err:
0x%x
, msg:%s, syserr:%d, sysmsg:%s"
,
pData
->
pSyncNode
->
vgId
,
index
,
err
,
err
,
err
Str
,
sysErr
,
sysErrStr
);
pData
->
pSyncNode
->
vgId
,
index
,
err
,
errStr
,
sysErr
,
sysErrStr
);
return
-
1
;
return
-
1
;
}
}
return
0
;
return
0
;
...
...
source/libs/sync/src/syncSnapshot.c
浏览文件 @
fb628f7f
此差异已折叠。
点击以展开。
source/libs/tdb/src/db/tdbPager.c
浏览文件 @
fb628f7f
...
@@ -869,11 +869,19 @@ static int tdbPagerRestore(SPager *pPager, const char *jFileName) {
...
@@ -869,11 +869,19 @@ static int tdbPagerRestore(SPager *pPager, const char *jFileName) {
return
-
1
;
return
-
1
;
}
}
if
(
tdbOsLSeek
(
jfd
,
0L
,
SEEK_SET
)
<
0
)
{
tdbError
(
"failed to lseek jfd due to %s. file:%s, offset:0"
,
strerror
(
errno
),
pPager
->
dbFileName
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
}
pageBuf
=
tdbOsCalloc
(
1
,
pPager
->
pageSize
);
pageBuf
=
tdbOsCalloc
(
1
,
pPager
->
pageSize
);
if
(
pageBuf
==
NULL
)
{
if
(
pageBuf
==
NULL
)
{
return
-
1
;
return
-
1
;
}
}
tdbDebug
(
"pager/restore: %p, %d/%d, txnId:%s"
,
pPager
,
pPager
->
dbOrigSize
,
pPager
->
dbFileSize
,
jFileName
);
for
(
int
pgIndex
=
0
;
pgIndex
<
journalSize
;
++
pgIndex
)
{
for
(
int
pgIndex
=
0
;
pgIndex
<
journalSize
;
++
pgIndex
)
{
// read pgno & the page from journal
// read pgno & the page from journal
SPgno
pgno
;
SPgno
pgno
;
...
@@ -884,6 +892,8 @@ static int tdbPagerRestore(SPager *pPager, const char *jFileName) {
...
@@ -884,6 +892,8 @@ static int tdbPagerRestore(SPager *pPager, const char *jFileName) {
return
-
1
;
return
-
1
;
}
}
tdbTrace
(
"pager/restore: restore pgno:%d,"
,
pgno
);
ret
=
tdbOsRead
(
jfd
,
pageBuf
,
pPager
->
pageSize
);
ret
=
tdbOsRead
(
jfd
,
pageBuf
,
pPager
->
pageSize
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
tdbOsFree
(
pageBuf
);
tdbOsFree
(
pageBuf
);
...
@@ -923,7 +933,7 @@ static int tdbPagerRestore(SPager *pPager, const char *jFileName) {
...
@@ -923,7 +933,7 @@ static int tdbPagerRestore(SPager *pPager, const char *jFileName) {
return
-
1
;
return
-
1
;
}
}
if
(
tdbOsRemove
(
pPager
->
jFileName
)
<
0
&&
errno
!=
ENOENT
)
{
if
(
tdbOsRemove
(
jFileName
)
<
0
&&
errno
!=
ENOENT
)
{
tdbError
(
"failed to remove file due to %s. jFileName:%s"
,
strerror
(
errno
),
pPager
->
jFileName
);
tdbError
(
"failed to remove file due to %s. jFileName:%s"
,
strerror
(
errno
),
pPager
->
jFileName
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
return
-
1
;
...
@@ -943,7 +953,12 @@ int tdbPagerRestoreJournals(SPager *pPager) {
...
@@ -943,7 +953,12 @@ int tdbPagerRestoreJournals(SPager *pPager) {
while
((
pDirEntry
=
tdbReadDir
(
pDir
))
!=
NULL
)
{
while
((
pDirEntry
=
tdbReadDir
(
pDir
))
!=
NULL
)
{
char
*
name
=
tdbDirEntryBaseName
(
tdbGetDirEntryName
(
pDirEntry
));
char
*
name
=
tdbDirEntryBaseName
(
tdbGetDirEntryName
(
pDirEntry
));
if
(
strncmp
(
TDB_MAINDB_NAME
"-journal"
,
name
,
16
)
==
0
)
{
if
(
strncmp
(
TDB_MAINDB_NAME
"-journal"
,
name
,
16
)
==
0
)
{
if
(
tdbPagerRestore
(
pPager
,
name
)
<
0
)
{
char
jname
[
TD_PATH_MAX
]
=
{
0
};
int
dirLen
=
strlen
(
pPager
->
pEnv
->
dbName
);
memcpy
(
jname
,
pPager
->
pEnv
->
dbName
,
dirLen
);
jname
[
dirLen
]
=
'/'
;
memcpy
(
jname
+
dirLen
+
1
,
name
,
strlen
(
name
));
if
(
tdbPagerRestore
(
pPager
,
jname
)
<
0
)
{
tdbCloseDir
(
&
pDir
);
tdbCloseDir
(
&
pDir
);
tdbError
(
"failed to restore file due to %s. jFileName:%s"
,
strerror
(
errno
),
name
);
tdbError
(
"failed to restore file due to %s. jFileName:%s"
,
strerror
(
errno
),
name
);
...
@@ -969,7 +984,12 @@ int tdbPagerRollback(SPager *pPager) {
...
@@ -969,7 +984,12 @@ int tdbPagerRollback(SPager *pPager) {
char
*
name
=
tdbDirEntryBaseName
(
tdbGetDirEntryName
(
pDirEntry
));
char
*
name
=
tdbDirEntryBaseName
(
tdbGetDirEntryName
(
pDirEntry
));
if
(
strncmp
(
TDB_MAINDB_NAME
"-journal"
,
name
,
16
)
==
0
)
{
if
(
strncmp
(
TDB_MAINDB_NAME
"-journal"
,
name
,
16
)
==
0
)
{
if
(
tdbOsRemove
(
name
)
<
0
&&
errno
!=
ENOENT
)
{
char
jname
[
TD_PATH_MAX
]
=
{
0
};
int
dirLen
=
strlen
(
pPager
->
pEnv
->
dbName
);
memcpy
(
jname
,
pPager
->
pEnv
->
dbName
,
dirLen
);
jname
[
dirLen
]
=
'/'
;
memcpy
(
jname
+
dirLen
+
1
,
name
,
strlen
(
name
));
if
(
tdbOsRemove
(
jname
)
<
0
&&
errno
!=
ENOENT
)
{
tdbCloseDir
(
&
pDir
);
tdbCloseDir
(
&
pDir
);
tdbError
(
"failed to remove file due to %s. jFileName:%s"
,
strerror
(
errno
),
name
);
tdbError
(
"failed to remove file due to %s. jFileName:%s"
,
strerror
(
errno
),
name
);
...
...
source/libs/tdb/src/db/tdbTable.c
浏览文件 @
fb628f7f
...
@@ -108,13 +108,13 @@ int tdbTbOpen(const char *tbname, int keyLen, int valLen, tdb_cmpr_fn_t keyCmprF
...
@@ -108,13 +108,13 @@ int tdbTbOpen(const char *tbname, int keyLen, int valLen, tdb_cmpr_fn_t keyCmprF
ASSERT
(
pPager
!=
NULL
);
ASSERT
(
pPager
!=
NULL
);
if
(
rollback
)
{
if
(
rollback
)
{
tdbPagerRollback
(
pPager
);
}
else
{
ret
=
tdbPagerRestoreJournals
(
pPager
);
ret
=
tdbPagerRestoreJournals
(
pPager
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
tdbOsFree
(
pTb
);
tdbOsFree
(
pTb
);
return
-
1
;
return
-
1
;
}
}
}
else
{
tdbPagerRollback
(
pPager
);
}
}
// pTb->pBt
// pTb->pBt
...
...
source/libs/transport/src/transCli.c
浏览文件 @
fb628f7f
...
@@ -1665,11 +1665,20 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) {
...
@@ -1665,11 +1665,20 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) {
if
(
pCtx
->
retryCode
!=
TSDB_CODE_SUCCESS
)
{
if
(
pCtx
->
retryCode
!=
TSDB_CODE_SUCCESS
)
{
int32_t
code
=
pResp
->
code
;
int32_t
code
=
pResp
->
code
;
// return internal code app
// return internal code app
if
(
code
==
TSDB_CODE_RPC_NETWORK_UNAVAIL
||
code
==
TSDB_CODE_RPC_BROKEN_LINK
)
{
if
(
code
==
TSDB_CODE_RPC_NETWORK_UNAVAIL
||
code
==
TSDB_CODE_RPC_BROKEN_LINK
||
code
==
TSDB_CODE_RPC_SOMENODE_NOT_CONNECTED
)
{
pResp
->
code
=
pCtx
->
retryCode
;
pResp
->
code
=
pCtx
->
retryCode
;
}
}
}
}
// check whole vnodes is offline on this vgroup
if
(
pCtx
->
epsetRetryCnt
>=
pCtx
->
epSet
.
numOfEps
||
pCtx
->
retryStep
>
0
)
{
if
(
pResp
->
code
==
TSDB_CODE_RPC_NETWORK_UNAVAIL
)
{
pResp
->
code
=
TSDB_CODE_RPC_SOMENODE_NOT_CONNECTED
;
}
else
if
(
pResp
->
code
==
TSDB_CODE_RPC_BROKEN_LINK
)
{
pResp
->
code
=
TSDB_CODE_RPC_SOMENODE_BROKEN_LINK
;
}
}
STraceId
*
trace
=
&
pResp
->
info
.
traceId
;
STraceId
*
trace
=
&
pResp
->
info
.
traceId
;
bool
hasEpSet
=
cliTryExtractEpSet
(
pResp
,
&
pCtx
->
epSet
);
bool
hasEpSet
=
cliTryExtractEpSet
(
pResp
,
&
pCtx
->
epSet
);
if
(
hasEpSet
)
{
if
(
hasEpSet
)
{
...
...
source/libs/transport/src/transSvr.c
浏览文件 @
fb628f7f
...
@@ -1001,6 +1001,13 @@ void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads,
...
@@ -1001,6 +1001,13 @@ void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads,
uv_loop_init
(
srv
->
loop
);
uv_loop_init
(
srv
->
loop
);
char
pipeName
[
PATH_MAX
];
char
pipeName
[
PATH_MAX
];
if
(
false
==
taosValidIpAndPort
(
srv
->
ip
,
srv
->
port
))
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
tError
(
"invalid ip/port, %d:%d, reason:%s"
,
srv
->
ip
,
srv
->
port
,
terrstr
());
goto
End
;
}
#if defined(WINDOWS) || defined(DARWIN)
#if defined(WINDOWS) || defined(DARWIN)
int
ret
=
uv_pipe_init
(
srv
->
loop
,
&
srv
->
pipeListen
,
0
);
int
ret
=
uv_pipe_init
(
srv
->
loop
,
&
srv
->
pipeListen
,
0
);
if
(
ret
!=
0
)
{
if
(
ret
!=
0
)
{
...
@@ -1087,12 +1094,6 @@ void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads,
...
@@ -1087,12 +1094,6 @@ void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads,
}
}
#endif
#endif
if
(
false
==
taosValidIpAndPort
(
srv
->
ip
,
srv
->
port
))
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
tError
(
"invalid ip/port, %d:%d, reason:%s"
,
srv
->
ip
,
srv
->
port
,
terrstr
());
goto
End
;
}
if
(
false
==
addHandleToAcceptloop
(
srv
))
{
if
(
false
==
addHandleToAcceptloop
(
srv
))
{
goto
End
;
goto
End
;
}
}
...
@@ -1185,8 +1186,8 @@ void transCloseServer(void* arg) {
...
@@ -1185,8 +1186,8 @@ void transCloseServer(void* arg) {
// impl later
// impl later
SServerObj
*
srv
=
arg
;
SServerObj
*
srv
=
arg
;
tDebug
(
"send quit msg to accept thread"
);
if
(
srv
->
inited
)
{
if
(
srv
->
inited
)
{
tDebug
(
"send quit msg to accept thread"
);
uv_async_send
(
srv
->
pAcceptAsync
);
uv_async_send
(
srv
->
pAcceptAsync
);
taosThreadJoin
(
srv
->
thread
,
NULL
);
taosThreadJoin
(
srv
->
thread
,
NULL
);
SRV_RELEASE_UV
(
srv
->
loop
);
SRV_RELEASE_UV
(
srv
->
loop
);
...
...
source/util/src/terror.c
浏览文件 @
fb628f7f
...
@@ -51,6 +51,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_RPC_FQDN_ERROR, "Unable to resolve FQD
...
@@ -51,6 +51,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_RPC_FQDN_ERROR, "Unable to resolve FQD
TAOS_DEFINE_ERROR
(
TSDB_CODE_RPC_PORT_EADDRINUSE
,
"Port already in use"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_RPC_PORT_EADDRINUSE
,
"Port already in use"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_RPC_BROKEN_LINK
,
"Conn is broken"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_RPC_BROKEN_LINK
,
"Conn is broken"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_RPC_TIMEOUT
,
"Conn read timeout"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_RPC_TIMEOUT
,
"Conn read timeout"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_RPC_SOMENODE_NOT_CONNECTED
,
"some vnode/qnode/mnode(s) out of service"
)
//common & util
//common & util
TAOS_DEFINE_ERROR
(
TSDB_CODE_TIME_UNSYNCED
,
"Client and server's time is not synchronized"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_TIME_UNSYNCED
,
"Client and server's time is not synchronized"
)
...
@@ -406,6 +407,8 @@ TAOS_DEFINE_ERROR(TSDB_CODE_SYN_PROPOSE_NOT_READY, "Sync not ready for pr
...
@@ -406,6 +407,8 @@ TAOS_DEFINE_ERROR(TSDB_CODE_SYN_PROPOSE_NOT_READY, "Sync not ready for pr
TAOS_DEFINE_ERROR
(
TSDB_CODE_SYN_STANDBY_NOT_READY
,
"Sync not ready for standby"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_SYN_STANDBY_NOT_READY
,
"Sync not ready for standby"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_SYN_BATCH_ERROR
,
"Sync batch error"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_SYN_BATCH_ERROR
,
"Sync batch error"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_SYN_RESTORING
,
"Sync is restoring"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_SYN_RESTORING
,
"Sync is restoring"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_SYN_INVALID_SNAPSHOT_MSG
,
"Sync invalid snapshot msg"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_SYN_BUFFER_FULL
,
"Sync buffer is full"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_SYN_INTERNAL_ERROR
,
"Sync internal error"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_SYN_INTERNAL_ERROR
,
"Sync internal error"
)
//tq
//tq
...
@@ -645,13 +648,10 @@ const char* tstrerror(int32_t err) {
...
@@ -645,13 +648,10 @@ const char* tstrerror(int32_t err) {
// this is a system errno
// this is a system errno
if
((
err
&
0x00ff0000
)
==
0x00ff0000
)
{
if
((
err
&
0x00ff0000
)
==
0x00ff0000
)
{
int32_t
code
=
err
&
0x0000ffff
;
int32_t
code
=
err
&
0x0000ffff
;
if
(
code
>=
0
&&
code
<
36
)
{
// strerror can handle any invalid code
// invalid code return Unknown error
return
strerror
(
code
);
return
strerror
(
code
);
}
else
{
return
"unknown err"
;
}
}
}
int32_t
s
=
0
;
int32_t
s
=
0
;
int32_t
e
=
sizeof
(
errors
)
/
sizeof
(
errors
[
0
]);
int32_t
e
=
sizeof
(
errors
)
/
sizeof
(
errors
[
0
]);
...
...
tests/parallel_test/cases.task
浏览文件 @
fb628f7f
...
@@ -681,8 +681,8 @@
...
@@ -681,8 +681,8 @@
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/create_wrong_topic.py
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/create_wrong_topic.py
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/dropDbR3ConflictTransaction.py -N 3
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/dropDbR3ConflictTransaction.py -N 3
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/basic5.py
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/basic5.py
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/subscribeDb.py
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/subscribeDb.py
-N 3 -n 3
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/subscribeDb0.py
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/subscribeDb0.py
-N 3 -n 3
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/subscribeDb1.py
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/subscribeDb1.py
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/subscribeDb2.py
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/subscribeDb2.py
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/subscribeDb3.py
,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/subscribeDb3.py
...
...
tests/script/sh/deploy.sh
浏览文件 @
fb628f7f
...
@@ -134,6 +134,7 @@ echo "mDebugFlag 143" >> $TAOS_CFG
...
@@ -134,6 +134,7 @@ echo "mDebugFlag 143" >> $TAOS_CFG
echo
"wDebugFlag 143"
>>
$TAOS_CFG
echo
"wDebugFlag 143"
>>
$TAOS_CFG
echo
"sDebugFlag 143"
>>
$TAOS_CFG
echo
"sDebugFlag 143"
>>
$TAOS_CFG
echo
"tsdbDebugFlag 143"
>>
$TAOS_CFG
echo
"tsdbDebugFlag 143"
>>
$TAOS_CFG
echo
"tdbDebugFlag 143"
>>
$TAOS_CFG
echo
"tqDebugFlag 143"
>>
$TAOS_CFG
echo
"tqDebugFlag 143"
>>
$TAOS_CFG
echo
"fsDebugFlag 143"
>>
$TAOS_CFG
echo
"fsDebugFlag 143"
>>
$TAOS_CFG
echo
"idxDebugFlag 143"
>>
$TAOS_CFG
echo
"idxDebugFlag 143"
>>
$TAOS_CFG
...
...
tests/script/test.sh
浏览文件 @
fb628f7f
...
@@ -10,13 +10,11 @@ set +e
...
@@ -10,13 +10,11 @@ set +e
#set -x
#set -x
FILE_NAME
=
FILE_NAME
=
RELEASE
=
0
ASYNC
=
0
VALGRIND
=
0
VALGRIND
=
0
UNIQUE
=
0
TEST
=
0
UNAME_BIN
=
`
which
uname
`
UNAME_BIN
=
`
which
uname
`
OS_TYPE
=
`
$UNAME_BIN
`
OS_TYPE
=
`
$UNAME_BIN
`
while
getopts
"f:
agvum
"
arg
while
getopts
"f:
tgv
"
arg
do
do
case
$arg
in
case
$arg
in
f
)
f
)
...
@@ -25,8 +23,8 @@ do
...
@@ -25,8 +23,8 @@ do
v
)
v
)
VALGRIND
=
1
VALGRIND
=
1
;;
;;
u
)
t
)
UNIQUE
=
1
TEST
=
1
;;
;;
g
)
g
)
VALGRIND
=
2
VALGRIND
=
2
...
@@ -140,6 +138,11 @@ if [ -n "$FILE_NAME" ]; then
...
@@ -140,6 +138,11 @@ if [ -n "$FILE_NAME" ]; then
result
=
$?
result
=
$?
echo
"Execute result:"
$result
echo
"Execute result:"
$result
if
[
$TEST
-eq
1
]
;
then
echo
"Exit without check asan errors"
exit
1
fi
if
[
$result
-eq
0
]
;
then
if
[
$result
-eq
0
]
;
then
$CODE_DIR
/sh/sigint_stop_dnodes.sh
$CODE_DIR
/sh/sigint_stop_dnodes.sh
$CODE_DIR
/sh/checkAsan.sh
$CODE_DIR
/sh/checkAsan.sh
...
...
tests/script/tsim/stream/basic3.sim
浏览文件 @
fb628f7f
system sh/stop_dnodes.sh
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c debugflag
-v
131
system sh/cfg.sh -n dnode1 -c debugflag 131
system sh/exec.sh -n dnode1 -s start
-v
system sh/exec.sh -n dnode1 -s start
sleep 5000
sleep 5000
...
...
tests/script/tsim/stream/sliding.sim
浏览文件 @
fb628f7f
...
@@ -672,6 +672,123 @@ if $data61 != 1 then
...
@@ -672,6 +672,123 @@ if $data61 != 1 then
goto loop5
goto loop5
endi
endi
print step 8
sql drop stream IF EXISTS streams4;
sql drop database IF EXISTS test4;
sql create database test4 vgroups 6;
sql use test4;
sql create stable st(ts timestamp, a int, b int, c int, d double) tags(ta int,tb int,tc int);
sql create table t1 using st tags(1,1,1);
sql create table t2 using st tags(2,2,2);
sql create stream streams4 trigger at_once into streamt4 as select _wstart as ts, count(*),min(a) c1 from st interval(10s) sliding(5s);
sql insert into t1 values(1648791213000,1,1,1,1.0);
sql insert into t1 values(1648791243000,2,1,1,1.0);
sql insert into t2 values(1648791273000,3,1,1,1.0);
sql insert into t2 values(1648791313000,4,1,1,1.0);
$loop_count = 0
loop6:
sleep 200
$loop_count = $loop_count + 1
if $loop_count == 10 then
return -1
endi
sql select * from streamt4 order by 1;
# row 0
if $rows != 8 then
print ====loop6=rows=$rows
goto loop6
endi
if $data01 != 1 then
print ====loop6=data01=$data01
goto loop6
endi
if $data02 != 1 then
print ====loop6=data02=$data02
return -1
endi
if $data11 != 1 then
print ====loop6=data11=$data11
goto loop6
endi
if $data12 != 1 then
print ====loop6=data12=$data12
return -1
endi
if $data21 != 1 then
print ====loop6=data21=$data21
goto loop6
endi
if $data22 != 2 then
print ====loop6=data22=$data22
return -1
endi
if $data31 != 1 then
print ====loop6=data31=$data31
goto loop6
endi
if $data32 != 2 then
print ====loop6=data32=$data32
return -1
endi
if $data41 != 1 then
print ====loop6=data41=$data41
goto loop6
endi
if $data42 != 3 then
print ====loop6=data42=$data42
return -1
endi
if $data51 != 1 then
print ====loop6=data51=$data51
goto loop6
endi
if $data52 != 3 then
print ====loop6=data52=$data52
return -1
endi
if $data61 != 1 then
print ====loop6=data61=$data61
return -1
endi
if $data62 != 4 then
print ====loop6=data62=$data62
return -1
endi
if $data71 != 1 then
print ====loop6=data71=$data71
return -1
endi
if $data72 != 4 then
print ====loop6=data72=$data72
return -1
endi
$loop_all = $loop_all + 1
$loop_all = $loop_all + 1
print ============loop_all=$loop_all
print ============loop_all=$loop_all
...
...
tests/system-test/7-tmq/subscribeDb.py
浏览文件 @
fb628f7f
...
@@ -61,7 +61,7 @@ class TDTestCase:
...
@@ -61,7 +61,7 @@ class TDTestCase:
def
insertConsumerInfo
(
self
,
consumerId
,
expectrowcnt
,
topicList
,
keyList
,
ifcheckdata
,
ifmanualcommit
,
cdbName
=
'cdb'
):
def
insertConsumerInfo
(
self
,
consumerId
,
expectrowcnt
,
topicList
,
keyList
,
ifcheckdata
,
ifmanualcommit
,
cdbName
=
'cdb'
):
sql
=
"insert into %s.consumeinfo values "
%
cdbName
sql
=
"insert into %s.consumeinfo values "
%
cdbName
sql
+=
"(now
, %d, '%s', '%s', %d, %d, %d)"
%
(
consumerId
,
topicList
,
keyList
,
expectrowcnt
,
ifcheckdata
,
ifmanualcommit
)
sql
+=
"(now
+ %ds, %d, '%s', '%s', %d, %d, %d)"
%
(
consumerId
,
consumerId
,
topicList
,
keyList
,
expectrowcnt
,
ifcheckdata
,
ifmanualcommit
)
tdLog
.
info
(
"consume info sql: %s"
%
sql
)
tdLog
.
info
(
"consume info sql: %s"
%
sql
)
tdSql
.
query
(
sql
)
tdSql
.
query
(
sql
)
...
@@ -174,12 +174,13 @@ class TDTestCase:
...
@@ -174,12 +174,13 @@ class TDTestCase:
'ctbNum'
:
10
,
\
'ctbNum'
:
10
,
\
'rowsPerTbl'
:
5000
,
\
'rowsPerTbl'
:
5000
,
\
'batchNum'
:
100
,
\
'batchNum'
:
100
,
\
'replica'
:
self
.
replicaVar
,
\
'startTs'
:
1640966400000
}
# 2022-01-01 00:00:00.000
'startTs'
:
1640966400000
}
# 2022-01-01 00:00:00.000
parameterDict
[
'cfg'
]
=
cfgPath
parameterDict
[
'cfg'
]
=
cfgPath
self
.
initConsumerTable
()
self
.
initConsumerTable
()
tdSql
.
execute
(
"create database if not exists %s vgroups %d
"
%
(
parameterDict
[
'dbName'
],
parameterDict
[
'vgroups
'
]))
tdSql
.
execute
(
"create database if not exists %s vgroups %d
replica %d"
%
(
parameterDict
[
'dbName'
],
parameterDict
[
'vgroups'
],
parameterDict
[
'replica
'
]))
prepareEnvThread
=
threading
.
Thread
(
target
=
self
.
prepareEnv
,
kwargs
=
parameterDict
)
prepareEnvThread
=
threading
.
Thread
(
target
=
self
.
prepareEnv
,
kwargs
=
parameterDict
)
prepareEnvThread
.
start
()
prepareEnvThread
.
start
()
...
@@ -271,12 +272,13 @@ class TDTestCase:
...
@@ -271,12 +272,13 @@ class TDTestCase:
'ctbNum'
:
10
,
\
'ctbNum'
:
10
,
\
'rowsPerTbl'
:
5000
,
\
'rowsPerTbl'
:
5000
,
\
'batchNum'
:
100
,
\
'batchNum'
:
100
,
\
'replica'
:
self
.
replicaVar
,
\
'startTs'
:
1640966400000
}
# 2022-01-01 00:00:00.000
'startTs'
:
1640966400000
}
# 2022-01-01 00:00:00.000
parameterDict
[
'cfg'
]
=
cfgPath
parameterDict
[
'cfg'
]
=
cfgPath
self
.
initConsumerTable
()
self
.
initConsumerTable
()
tdSql
.
execute
(
"create database if not exists %s vgroups %d
"
%
(
parameterDict
[
'dbName'
],
parameterDict
[
'vgroups
'
]))
tdSql
.
execute
(
"create database if not exists %s vgroups %d
replica %d"
%
(
parameterDict
[
'dbName'
],
parameterDict
[
'vgroups'
],
parameterDict
[
'replica
'
]))
prepareEnvThread
=
threading
.
Thread
(
target
=
self
.
prepareEnv
,
kwargs
=
parameterDict
)
prepareEnvThread
=
threading
.
Thread
(
target
=
self
.
prepareEnv
,
kwargs
=
parameterDict
)
prepareEnvThread
.
start
()
prepareEnvThread
.
start
()
...
@@ -337,6 +339,7 @@ class TDTestCase:
...
@@ -337,6 +339,7 @@ class TDTestCase:
'ctbNum'
:
10
,
\
'ctbNum'
:
10
,
\
'rowsPerTbl'
:
5000
,
\
'rowsPerTbl'
:
5000
,
\
'batchNum'
:
100
,
\
'batchNum'
:
100
,
\
'replica'
:
self
.
replicaVar
,
\
'startTs'
:
1640966400000
}
# 2022-01-01 00:00:00.000
'startTs'
:
1640966400000
}
# 2022-01-01 00:00:00.000
parameterDict
[
'cfg'
]
=
cfgPath
parameterDict
[
'cfg'
]
=
cfgPath
...
@@ -406,12 +409,13 @@ class TDTestCase:
...
@@ -406,12 +409,13 @@ class TDTestCase:
'ctbNum'
:
10
,
\
'ctbNum'
:
10
,
\
'rowsPerTbl'
:
5000
,
\
'rowsPerTbl'
:
5000
,
\
'batchNum'
:
100
,
\
'batchNum'
:
100
,
\
'replica'
:
self
.
replicaVar
,
\
'startTs'
:
1640966400000
}
# 2022-01-01 00:00:00.000
'startTs'
:
1640966400000
}
# 2022-01-01 00:00:00.000
parameterDict
[
'cfg'
]
=
cfgPath
parameterDict
[
'cfg'
]
=
cfgPath
self
.
initConsumerTable
()
self
.
initConsumerTable
()
tdSql
.
execute
(
"create database if not exists %s vgroups %d
"
%
(
parameterDict
[
'dbName'
],
parameterDict
[
'vgroups
'
]))
tdSql
.
execute
(
"create database if not exists %s vgroups %d
replica %d"
%
(
parameterDict
[
'dbName'
],
parameterDict
[
'vgroups'
],
parameterDict
[
'replica
'
]))
prepareEnvThread
=
threading
.
Thread
(
target
=
self
.
prepareEnv
,
kwargs
=
parameterDict
)
prepareEnvThread
=
threading
.
Thread
(
target
=
self
.
prepareEnv
,
kwargs
=
parameterDict
)
prepareEnvThread
.
start
()
prepareEnvThread
.
start
()
...
...
tests/system-test/7-tmq/subscribeDb0.py
浏览文件 @
fb628f7f
...
@@ -174,12 +174,13 @@ class TDTestCase:
...
@@ -174,12 +174,13 @@ class TDTestCase:
'ctbNum'
:
10
,
\
'ctbNum'
:
10
,
\
'rowsPerTbl'
:
5000
,
\
'rowsPerTbl'
:
5000
,
\
'batchNum'
:
100
,
\
'batchNum'
:
100
,
\
'replica'
:
self
.
replicaVar
,
\
'startTs'
:
1640966400000
}
# 2022-01-01 00:00:00.000
'startTs'
:
1640966400000
}
# 2022-01-01 00:00:00.000
parameterDict
[
'cfg'
]
=
cfgPath
parameterDict
[
'cfg'
]
=
cfgPath
self
.
initConsumerTable
()
self
.
initConsumerTable
()
tdSql
.
execute
(
"create database if not exists %s vgroups %d
"
%
(
parameterDict
[
'dbName'
],
parameterDict
[
'vgroups
'
]))
tdSql
.
execute
(
"create database if not exists %s vgroups %d
replica %d"
%
(
parameterDict
[
'dbName'
],
parameterDict
[
'vgroups'
],
parameterDict
[
'replica
'
]))
prepareEnvThread
=
threading
.
Thread
(
target
=
self
.
prepareEnv
,
kwargs
=
parameterDict
)
prepareEnvThread
=
threading
.
Thread
(
target
=
self
.
prepareEnv
,
kwargs
=
parameterDict
)
prepareEnvThread
.
start
()
prepareEnvThread
.
start
()
...
@@ -191,6 +192,7 @@ class TDTestCase:
...
@@ -191,6 +192,7 @@ class TDTestCase:
'ctbNum'
:
10
,
\
'ctbNum'
:
10
,
\
'rowsPerTbl'
:
5000
,
\
'rowsPerTbl'
:
5000
,
\
'batchNum'
:
100
,
\
'batchNum'
:
100
,
\
'replica'
:
self
.
replicaVar
,
\
'startTs'
:
1640966400000
}
# 2022-01-01 00:00:00.000
'startTs'
:
1640966400000
}
# 2022-01-01 00:00:00.000
parameterDict
[
'cfg'
]
=
cfgPath
parameterDict
[
'cfg'
]
=
cfgPath
...
@@ -254,12 +256,13 @@ class TDTestCase:
...
@@ -254,12 +256,13 @@ class TDTestCase:
'ctbNum'
:
10
,
\
'ctbNum'
:
10
,
\
'rowsPerTbl'
:
5000
,
\
'rowsPerTbl'
:
5000
,
\
'batchNum'
:
100
,
\
'batchNum'
:
100
,
\
'replica'
:
self
.
replicaVar
,
\
'startTs'
:
1640966400000
}
# 2022-01-01 00:00:00.000
'startTs'
:
1640966400000
}
# 2022-01-01 00:00:00.000
parameterDict
[
'cfg'
]
=
cfgPath
parameterDict
[
'cfg'
]
=
cfgPath
self
.
initConsumerTable
()
self
.
initConsumerTable
()
tdSql
.
execute
(
"create database if not exists %s vgroups %d
"
%
(
parameterDict
[
'dbName'
],
parameterDict
[
'vgroups
'
]))
tdSql
.
execute
(
"create database if not exists %s vgroups %d
replica %d"
%
(
parameterDict
[
'dbName'
],
parameterDict
[
'vgroups'
],
parameterDict
[
'replica
'
]))
prepareEnvThread
=
threading
.
Thread
(
target
=
self
.
prepareEnv
,
kwargs
=
parameterDict
)
prepareEnvThread
=
threading
.
Thread
(
target
=
self
.
prepareEnv
,
kwargs
=
parameterDict
)
prepareEnvThread
.
start
()
prepareEnvThread
.
start
()
...
...
tests/system-test/7-tmq/tmqCommon.py
浏览文件 @
fb628f7f
...
@@ -60,7 +60,7 @@ class TMQCom:
...
@@ -60,7 +60,7 @@ class TMQCom:
def
insertConsumerInfo
(
self
,
consumerId
,
expectrowcnt
,
topicList
,
keyList
,
ifcheckdata
,
ifmanualcommit
,
cdbName
=
'cdb'
):
def
insertConsumerInfo
(
self
,
consumerId
,
expectrowcnt
,
topicList
,
keyList
,
ifcheckdata
,
ifmanualcommit
,
cdbName
=
'cdb'
):
sql
=
"insert into %s.consumeinfo values "
%
cdbName
sql
=
"insert into %s.consumeinfo values "
%
cdbName
sql
+=
"(now
, %d, '%s', '%s', %d, %d, %d)"
%
(
consumerId
,
topicList
,
keyList
,
expectrowcnt
,
ifcheckdata
,
ifmanualcommit
)
sql
+=
"(now
+ %ds, %d, '%s', '%s', %d, %d, %d)"
%
(
consumerId
,
consumerId
,
topicList
,
keyList
,
expectrowcnt
,
ifcheckdata
,
ifmanualcommit
)
tdLog
.
info
(
"consume info sql: %s"
%
sql
)
tdLog
.
info
(
"consume info sql: %s"
%
sql
)
tdSql
.
query
(
sql
)
tdSql
.
query
(
sql
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录