Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
bae71438
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
bae71438
编写于
6月 21, 2022
作者:
G
Ganlin Zhao
浏览文件
操作
浏览文件
下载
差异文件
Merge branch '3.0' into fix/TD-16394
上级
a46abd97
55c524e8
变更
62
展开全部
隐藏空白更改
内联
并排
Showing
62 changed file
with
1752 addition
and
588 deletion
+1752
-588
include/client/taos.h
include/client/taos.h
+12
-2
include/common/tcommon.h
include/common/tcommon.h
+1
-0
include/common/tmsg.h
include/common/tmsg.h
+32
-0
include/common/tmsgdef.h
include/common/tmsgdef.h
+1
-1
include/libs/nodes/querynodes.h
include/libs/nodes/querynodes.h
+1
-1
include/libs/stream/tstream.h
include/libs/stream/tstream.h
+12
-9
source/client/inc/clientInt.h
source/client/inc/clientInt.h
+36
-26
source/client/src/clientMain.c
source/client/src/clientMain.c
+60
-51
source/client/src/clientSml.c
source/client/src/clientSml.c
+5
-3
source/client/src/tmq.c
source/client/src/tmq.c
+96
-16
source/client/test/smlTest.cpp
source/client/test/smlTest.cpp
+4
-4
source/common/src/tmsg.c
source/common/src/tmsg.c
+4
-2
source/common/src/tname.c
source/common/src/tname.c
+11
-4
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
+8
-6
source/dnode/mgmt/mgmt_mnode/src/mmWorker.c
source/dnode/mgmt/mgmt_mnode/src/mmWorker.c
+14
-12
source/dnode/mgmt/mgmt_snode/src/smHandle.c
source/dnode/mgmt/mgmt_snode/src/smHandle.c
+1
-1
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
+1
-1
source/dnode/mgmt/node_mgmt/src/dmTransport.c
source/dnode/mgmt/node_mgmt/src/dmTransport.c
+84
-79
source/dnode/mgmt/node_util/inc/dmUtil.h
source/dnode/mgmt/node_util/inc/dmUtil.h
+17
-9
source/dnode/mgmt/test/sut/src/sut.cpp
source/dnode/mgmt/test/sut/src/sut.cpp
+1
-0
source/dnode/mnode/impl/inc/mndDef.h
source/dnode/mnode/impl/inc/mndDef.h
+3
-1
source/dnode/mnode/impl/inc/mndInt.h
source/dnode/mnode/impl/inc/mndInt.h
+14
-7
source/dnode/mnode/impl/src/mndDef.c
source/dnode/mnode/impl/src/mndDef.c
+3
-0
source/dnode/mnode/impl/src/mndMain.c
source/dnode/mnode/impl/src/mndMain.c
+44
-34
source/dnode/mnode/impl/src/mndProfile.c
source/dnode/mnode/impl/src/mndProfile.c
+49
-50
source/dnode/mnode/impl/src/mndStream.c
source/dnode/mnode/impl/src/mndStream.c
+26
-11
source/dnode/mnode/impl/src/mndSubscribe.c
source/dnode/mnode/impl/src/mndSubscribe.c
+2
-0
source/dnode/mnode/impl/src/mndTopic.c
source/dnode/mnode/impl/src/mndTopic.c
+6
-0
source/dnode/snode/src/snode.c
source/dnode/snode/src/snode.c
+2
-2
source/dnode/vnode/src/inc/tq.h
source/dnode/vnode/src/inc/tq.h
+1
-0
source/dnode/vnode/src/inc/vnd.h
source/dnode/vnode/src/inc/vnd.h
+15
-7
source/dnode/vnode/src/tq/tq.c
source/dnode/vnode/src/tq/tq.c
+81
-7
source/dnode/vnode/src/tq/tqPush.c
source/dnode/vnode/src/tq/tqPush.c
+7
-7
source/dnode/vnode/src/tq/tqRead.c
source/dnode/vnode/src/tq/tqRead.c
+19
-0
source/dnode/vnode/src/vnd/vnodeSvr.c
source/dnode/vnode/src/vnd/vnodeSvr.c
+1
-1
source/libs/function/src/builtinsimpl.c
source/libs/function/src/builtinsimpl.c
+21
-20
source/libs/nodes/src/nodesCloneFuncs.c
source/libs/nodes/src/nodesCloneFuncs.c
+10
-0
source/libs/parser/src/parInsert.c
source/libs/parser/src/parInsert.c
+5
-16
source/libs/planner/src/planLogicCreater.c
source/libs/planner/src/planLogicCreater.c
+6
-2
source/libs/planner/src/planOptimizer.c
source/libs/planner/src/planOptimizer.c
+38
-5
source/libs/planner/src/planSpliter.c
source/libs/planner/src/planSpliter.c
+51
-2
source/libs/planner/test/planOtherTest.cpp
source/libs/planner/test/planOtherTest.cpp
+3
-1
source/libs/stream/src/stream.c
source/libs/stream/src/stream.c
+7
-2
source/libs/stream/src/streamExec.c
source/libs/stream/src/streamExec.c
+24
-11
source/libs/stream/src/streamTask.c
source/libs/stream/src/streamTask.c
+5
-3
source/libs/sync/inc/syncInt.h
source/libs/sync/inc/syncInt.h
+1
-0
source/libs/sync/inc/syncRaftCfg.h
source/libs/sync/inc/syncRaftCfg.h
+6
-6
source/libs/sync/inc/syncSnapshot.h
source/libs/sync/inc/syncSnapshot.h
+9
-9
source/libs/sync/src/syncAppendEntriesReply.c
source/libs/sync/src/syncAppendEntriesReply.c
+31
-14
source/libs/sync/src/syncIndexMgr.c
source/libs/sync/src/syncIndexMgr.c
+15
-4
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+31
-9
source/libs/sync/src/syncRaftCfg.c
source/libs/sync/src/syncRaftCfg.c
+10
-5
source/libs/sync/src/syncSnapshot.c
source/libs/sync/src/syncSnapshot.c
+13
-17
source/libs/sync/test/syncReconfigFinishTest.cpp
source/libs/sync/test/syncReconfigFinishTest.cpp
+13
-15
source/libs/transport/inc/transLog.h
source/libs/transport/inc/transLog.h
+8
-8
source/util/src/thash.c
source/util/src/thash.c
+13
-13
tests/pytest/util/boundary.py
tests/pytest/util/boundary.py
+44
-0
tests/pytest/util/common.py
tests/pytest/util/common.py
+411
-68
tests/system-test/2-query/twa.py
tests/system-test/2-query/twa.py
+150
-0
tests/system-test/7-tmq/stbFilter.py
tests/system-test/7-tmq/stbFilter.py
+96
-0
tests/system-test/7-tmq/tmqCommon.py
tests/system-test/7-tmq/tmqCommon.py
+56
-4
tests/system-test/fulltest.sh
tests/system-test/fulltest.sh
+1
-0
未找到文件。
include/client/taos.h
浏览文件 @
bae71438
...
...
@@ -187,8 +187,8 @@ DLL_EXPORT TAOS_ROW *taos_result_block(TAOS_RES *res);
DLL_EXPORT
const
char
*
taos_get_server_info
(
TAOS
*
taos
);
DLL_EXPORT
const
char
*
taos_get_client_info
();
DLL_EXPORT
const
char
*
taos_errstr
(
TAOS_RES
*
t
res
);
DLL_EXPORT
int
taos_errno
(
TAOS_RES
*
t
res
);
DLL_EXPORT
const
char
*
taos_errstr
(
TAOS_RES
*
res
);
DLL_EXPORT
int
taos_errno
(
TAOS_RES
*
res
);
DLL_EXPORT
void
taos_query_a
(
TAOS
*
taos
,
const
char
*
sql
,
__taos_async_fn_t
fp
,
void
*
param
);
DLL_EXPORT
void
taos_fetch_rows_a
(
TAOS_RES
*
res
,
__taos_async_fn_t
fp
,
void
*
param
);
...
...
@@ -252,6 +252,16 @@ DLL_EXPORT void tmq_conf_set_auto_commit_cb(tmq_conf_t *conf, tmq_comm
/* -------------------------TMQ MSG HANDLE INTERFACE---------------------- */
enum
tmq_res_t
{
TMQ_RES_INVALID
=
-
1
,
TMQ_RES_DATA
=
1
,
TMQ_RES_TABLE_META
=
2
,
};
typedef
enum
tmq_res_t
tmq_res_t
;
DLL_EXPORT
tmq_res_t
tmq_get_res_type
(
TAOS_RES
*
res
);
DLL_EXPORT
int32_t
tmq_get_raw_meta
(
TAOS_RES
*
res
,
const
void
**
raw_meta
,
int32_t
*
raw_meta_len
);
DLL_EXPORT
const
char
*
tmq_get_topic_name
(
TAOS_RES
*
res
);
DLL_EXPORT
const
char
*
tmq_get_db_name
(
TAOS_RES
*
res
);
DLL_EXPORT
int32_t
tmq_get_vgroup_id
(
TAOS_RES
*
res
);
...
...
include/common/tcommon.h
浏览文件 @
bae71438
...
...
@@ -34,6 +34,7 @@ enum {
enum
{
TMQ_MSG_TYPE__DUMMY
=
0
,
TMQ_MSG_TYPE__POLL_RSP
,
TMQ_MSG_TYPE__POLL_META_RSP
,
TMQ_MSG_TYPE__EP_RSP
,
TMQ_MSG_TYPE__END_RSP
,
};
...
...
include/common/tmsg.h
浏览文件 @
bae71438
...
...
@@ -1560,6 +1560,7 @@ typedef struct {
char
name
[
TSDB_TOPIC_FNAME_LEN
];
// accout.topic
int8_t
igExists
;
int8_t
subType
;
int8_t
withMeta
;
char
*
sql
;
char
subDbName
[
TSDB_DB_FNAME_LEN
];
union
{
...
...
@@ -2306,6 +2307,7 @@ typedef struct {
int64_t
newConsumerId
;
char
subKey
[
TSDB_SUBSCRIBE_KEY_LEN
];
int8_t
subType
;
int8_t
withMeta
;
char
*
qmsg
;
int64_t
suid
;
}
SMqRebVgReq
;
...
...
@@ -2318,6 +2320,7 @@ static FORCE_INLINE int32_t tEncodeSMqRebVgReq(void** buf, const SMqRebVgReq* pR
tlen
+=
taosEncodeFixedI64
(
buf
,
pReq
->
newConsumerId
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
subKey
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pReq
->
subType
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pReq
->
withMeta
);
if
(
pReq
->
subType
==
TOPIC_SUB_TYPE__COLUMN
)
{
tlen
+=
taosEncodeString
(
buf
,
pReq
->
qmsg
);
}
else
if
(
pReq
->
subType
==
TOPIC_SUB_TYPE__TABLE
)
{
...
...
@@ -2333,6 +2336,7 @@ static FORCE_INLINE void* tDecodeSMqRebVgReq(const void* buf, SMqRebVgReq* pReq)
buf
=
taosDecodeFixedI64
(
buf
,
&
pReq
->
newConsumerId
);
buf
=
taosDecodeStringTo
(
buf
,
pReq
->
subKey
);
buf
=
taosDecodeFixedI8
(
buf
,
&
pReq
->
subType
);
buf
=
taosDecodeFixedI8
(
buf
,
&
pReq
->
withMeta
);
if
(
pReq
->
subType
==
TOPIC_SUB_TYPE__COLUMN
)
{
buf
=
taosDecodeString
(
buf
,
&
pReq
->
qmsg
);
}
else
if
(
pReq
->
subType
==
TOPIC_SUB_TYPE__TABLE
)
{
...
...
@@ -2677,6 +2681,34 @@ static FORCE_INLINE void tDeleteSMqSubTopicEp(SMqSubTopicEp* pSubTopicEp) {
taosArrayDestroy
(
pSubTopicEp
->
vgs
);
}
typedef
struct
{
SMqRspHead
head
;
int64_t
reqOffset
;
int64_t
rspOffset
;
int16_t
resMsgType
;
int32_t
metaRspLen
;
void
*
metaRsp
;
}
SMqMetaRsp
;
static
FORCE_INLINE
int32_t
tEncodeSMqMetaRsp
(
void
**
buf
,
const
SMqMetaRsp
*
pRsp
)
{
int32_t
tlen
=
0
;
tlen
+=
taosEncodeFixedI64
(
buf
,
pRsp
->
reqOffset
);
tlen
+=
taosEncodeFixedI64
(
buf
,
pRsp
->
rspOffset
);
tlen
+=
taosEncodeFixedI16
(
buf
,
pRsp
->
resMsgType
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pRsp
->
metaRspLen
);
tlen
+=
taosEncodeBinary
(
buf
,
pRsp
->
metaRsp
,
pRsp
->
metaRspLen
);
return
tlen
;
}
static
FORCE_INLINE
void
*
tDecodeSMqMetaRsp
(
const
void
*
buf
,
SMqMetaRsp
*
pRsp
)
{
buf
=
taosDecodeFixedI64
(
buf
,
&
pRsp
->
reqOffset
);
buf
=
taosDecodeFixedI64
(
buf
,
&
pRsp
->
rspOffset
);
buf
=
taosDecodeFixedI16
(
buf
,
&
pRsp
->
resMsgType
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pRsp
->
metaRspLen
);
buf
=
taosDecodeBinary
(
buf
,
&
pRsp
->
metaRsp
,
pRsp
->
metaRspLen
);
return
(
void
*
)
buf
;
}
typedef
struct
{
SMqRspHead
head
;
int64_t
reqOffset
;
...
...
include/common/tmsgdef.h
浏览文件 @
bae71438
...
...
@@ -187,7 +187,6 @@ enum {
TD_DEF_MSG_TYPE
(
TDMT_VND_CONSUME
,
"vnode-consume"
,
SMqPollReq
,
SMqDataBlkRsp
)
TD_DEF_MSG_TYPE
(
TDMT_VND_STREAM_TRIGGER
,
"vnode-stream-trigger"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_STREAM_DISPATCH_WRITE
,
"vnode-stream-task-dispatch-write"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_STREAM_TASK_DROP
,
"vnode-stream-task-drop"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_CREATE_SMA
,
"vnode-create-sma"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_CANCEL_SMA
,
"vnode-cancel-sma"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_DROP_SMA
,
"vnode-drop-sma"
,
NULL
,
NULL
)
...
...
@@ -204,6 +203,7 @@ enum {
//shared by snode and vnode
TD_NEW_MSG_SEG
(
TDMT_STREAM_MSG
)
TD_DEF_MSG_TYPE
(
TDMT_STREAM_TASK_DEPLOY
,
"stream-task-deploy"
,
SStreamTaskDeployReq
,
SStreamTaskDeployRsp
)
TD_DEF_MSG_TYPE
(
TDMT_STREAM_TASK_DROP
,
"stream-task-drop"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_STREAM_TASK_RUN
,
"stream-task-run"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_STREAM_TASK_DISPATCH
,
"stream-task-dispatch"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_STREAM_TASK_RECOVER
,
"stream-task-recover"
,
NULL
,
NULL
)
...
...
include/libs/nodes/querynodes.h
浏览文件 @
bae71438
...
...
@@ -52,7 +52,7 @@ typedef struct SExprNode {
SArray
*
pAssociation
;
}
SExprNode
;
typedef
enum
EColumnType
{
COLUMN_TYPE_COLUMN
=
1
,
COLUMN_TYPE_TAG
}
EColumnType
;
typedef
enum
EColumnType
{
COLUMN_TYPE_COLUMN
=
1
,
COLUMN_TYPE_TAG
,
COLUMN_TYPE_TBNAME
}
EColumnType
;
typedef
struct
SColumnNode
{
SExprNode
node
;
// QUERY_NODE_COLUMN
...
...
include/libs/stream/tstream.h
浏览文件 @
bae71438
...
...
@@ -30,9 +30,14 @@ extern "C" {
typedef
struct
SStreamTask
SStreamTask
;
enum
{
TASK_STATUS__IDLE
=
1
,
TASK_STATUS__EXECUTING
,
TASK_STATUS__CLOSING
,
TASK_STATUS__NORMAL
=
0
,
TASK_STATUS__DROPPING
,
};
enum
{
TASK_EXEC_STATUS__IDLE
=
1
,
TASK_EXEC_STATUS__EXECUTING
,
TASK_EXEC_STATUS__CLOSING
,
};
enum
{
...
...
@@ -50,16 +55,12 @@ enum {
TASK_OUTPUT_STATUS__BLOCKED
,
};
enum
{
STREAM_CREATED_BY__USER
=
1
,
STREAM_CREATED_BY__SMA
,
};
enum
{
STREAM_INPUT__DATA_SUBMIT
=
1
,
STREAM_INPUT__DATA_BLOCK
,
STREAM_INPUT__TRIGGER
,
STREAM_INPUT__CHECKPOINT
,
STREAM_INPUT__DROP
,
};
typedef
struct
{
...
...
@@ -237,7 +238,9 @@ struct SStreamTask {
int64_t
streamId
;
int32_t
taskId
;
int8_t
inputType
;
int8_t
status
;
int8_t
taskStatus
;
int8_t
execStatus
;
int8_t
execType
;
int8_t
sinkType
;
...
...
source/client/inc/clientInt.h
浏览文件 @
bae71438
...
...
@@ -20,9 +20,9 @@
extern
"C"
{
#endif
#include "catalog.h"
#include "parser.h"
#include "planner.h"
#include "catalog.h"
#include "query.h"
#include "taos.h"
#include "tcommon.h"
...
...
@@ -51,10 +51,12 @@ extern "C" {
enum
{
RES_TYPE__QUERY
=
1
,
RES_TYPE__TMQ
,
RES_TYPE__TMQ_META
,
};
#define TD_RES_QUERY(res) (*(int8_t*)res == RES_TYPE__QUERY)
#define TD_RES_TMQ(res) (*(int8_t*)res == RES_TYPE__TMQ)
#define TD_RES_QUERY(res) (*(int8_t*)res == RES_TYPE__QUERY)
#define TD_RES_TMQ(res) (*(int8_t*)res == RES_TYPE__TMQ)
#define TD_RES_TMQ_META(res) (*(int8_t*)res == RES_TYPE__TMQ_META)
typedef
struct
SAppInstInfo
SAppInstInfo
;
...
...
@@ -66,9 +68,9 @@ typedef struct {
int64_t
reportBytes
;
// not implemented
int64_t
startTime
;
// ctl
SRWLatch
lock
;
// lock is used in serialization
SRWLatch
lock
;
// lock is used in serialization
SAppInstInfo
*
pAppInstInfo
;
SHashObj
*
activeInfo
;
// hash<SClientHbKey, SClientHbReq>
SHashObj
*
activeInfo
;
// hash<SClientHbKey, SClientHbReq>
}
SAppHbMgr
;
typedef
int32_t
(
*
FHbRspHandle
)(
SAppHbMgr
*
pAppHbMgr
,
SClientHbRsp
*
pRsp
);
...
...
@@ -76,13 +78,13 @@ typedef int32_t (*FHbRspHandle)(SAppHbMgr* pAppHbMgr, SClientHbRsp* pRsp);
typedef
int32_t
(
*
FHbReqHandle
)(
SClientHbKey
*
connKey
,
void
*
param
,
SClientHbReq
*
req
);
typedef
struct
{
int8_t
inited
;
int64_t
appId
;
int8_t
inited
;
int64_t
appId
;
// ctl
int8_t
threadStop
;
TdThread
thread
;
TdThreadMutex
lock
;
// used when app init and cleanup
SHashObj
*
appSummary
;
TdThreadMutex
lock
;
// used when app init and cleanup
SHashObj
*
appSummary
;
SArray
*
appHbMgrs
;
// SArray<SAppHbMgr*> one for each cluster
FHbReqHandle
reqHandle
[
CONN_TYPE__MAX
];
FHbRspHandle
rspHandle
[
CONN_TYPE__MAX
];
...
...
@@ -129,7 +131,7 @@ typedef struct STscObj {
int8_t
connType
;
int32_t
acctId
;
uint32_t
connId
;
TAOS
*
id
;
// ref ID returned by taosAddRef
TAOS
*
id
;
// ref ID returned by taosAddRef
TdThreadMutex
mutex
;
// used to protect the operation on db
int32_t
numOfReqs
;
// number of sqlObj bound to this connection
SAppInstInfo
*
pAppInfo
;
...
...
@@ -188,6 +190,14 @@ typedef struct {
SReqResultInfo
resInfo
;
}
SMqRspObj
;
typedef
struct
{
int8_t
resType
;
char
topic
[
TSDB_TOPIC_FNAME_LEN
];
char
db
[
TSDB_DB_FNAME_LEN
];
int32_t
vgId
;
SMqMetaRsp
metaRsp
;
}
SMqMetaRspObj
;
typedef
struct
SRequestObj
{
int8_t
resType
;
// query or tmq
uint64_t
requestId
;
...
...
@@ -206,9 +216,9 @@ typedef struct SRequestObj {
SRequestSendRecvBody
body
;
bool
stableQuery
;
bool
killed
;
uint32_t
prevCode
;
//
previous error code: todo refactor, add update flag for catalog
uint32_t
retry
;
bool
killed
;
uint32_t
prevCode
;
//
previous error code: todo refactor, add update flag for catalog
uint32_t
retry
;
}
SRequestObj
;
typedef
struct
SSyncQueryParam
{
...
...
@@ -216,15 +226,15 @@ typedef struct SSyncQueryParam {
SRequestObj
*
pRequest
;
}
SSyncQueryParam
;
void
*
doAsyncFetchRows
(
SRequestObj
*
pRequest
,
bool
setupOneRowPtr
,
bool
convertUcs4
);
void
*
doFetchRows
(
SRequestObj
*
pRequest
,
bool
setupOneRowPtr
,
bool
convertUcs4
);
void
*
doAsyncFetchRows
(
SRequestObj
*
pRequest
,
bool
setupOneRowPtr
,
bool
convertUcs4
);
void
*
doFetchRows
(
SRequestObj
*
pRequest
,
bool
setupOneRowPtr
,
bool
convertUcs4
);
void
doSetOneRowPtr
(
SReqResultInfo
*
pResultInfo
);
void
setResPrecision
(
SReqResultInfo
*
pResInfo
,
int32_t
precision
);
int32_t
setQueryResultFromRsp
(
SReqResultInfo
*
pResultInfo
,
const
SRetrieveTableRsp
*
pRsp
,
bool
convertUcs4
,
bool
freeAfterUse
);
void
setResSchemaInfo
(
SReqResultInfo
*
pResInfo
,
const
SSchema
*
pSchema
,
int32_t
numOfCols
);
void
doFreeReqResultInfo
(
SReqResultInfo
*
pResInfo
);
void
doSetOneRowPtr
(
SReqResultInfo
*
pResultInfo
);
void
setResPrecision
(
SReqResultInfo
*
pResInfo
,
int32_t
precision
);
int32_t
setQueryResultFromRsp
(
SReqResultInfo
*
pResultInfo
,
const
SRetrieveTableRsp
*
pRsp
,
bool
convertUcs4
,
bool
freeAfterUse
);
void
setResSchemaInfo
(
SReqResultInfo
*
pResInfo
,
const
SSchema
*
pSchema
,
int32_t
numOfCols
);
void
doFreeReqResultInfo
(
SReqResultInfo
*
pResInfo
);
SRequestObj
*
execQuery
(
STscObj
*
pTscObj
,
const
char
*
sql
,
int
sqlLen
);
static
FORCE_INLINE
SReqResultInfo
*
tmqGetCurResInfo
(
TAOS_RES
*
res
)
{
...
...
@@ -289,7 +299,7 @@ bool persistConnForSpecificMsg(void* parenct, tmsg_t msgType);
void
processMsgFromServer
(
void
*
parent
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
);
STscObj
*
taos_connect_internal
(
const
char
*
ip
,
const
char
*
user
,
const
char
*
pass
,
const
char
*
auth
,
const
char
*
db
,
uint16_t
port
,
int
connType
);
uint16_t
port
,
int
connType
);
SRequestObj
*
launchQuery
(
STscObj
*
pTscObj
,
const
char
*
sql
,
int
sqlLen
);
...
...
@@ -299,7 +309,7 @@ int32_t getPlan(SRequestObj* pRequest, SQuery* pQuery, SQueryPlan** pPlan, SArra
int32_t
buildRequest
(
STscObj
*
pTscObj
,
const
char
*
sql
,
int
sqlLen
,
SRequestObj
**
pRequest
);
void
taos_close_internal
(
void
*
taos
);
void
taos_close_internal
(
void
*
taos
);
// --- heartbeat
// global, called by mgmt
...
...
@@ -320,12 +330,12 @@ void hbMgrInitMqHbRspHandle();
SRequestObj
*
launchQueryImpl
(
SRequestObj
*
pRequest
,
SQuery
*
pQuery
,
bool
keepQuery
,
void
**
res
);
int32_t
scheduleQuery
(
SRequestObj
*
pRequest
,
SQueryPlan
*
pDag
,
SArray
*
pNodeList
);
void
launchAsyncQuery
(
SRequestObj
*
pRequest
,
SQuery
*
pQuery
,
SMetaData
*
pResultMeta
);
void
launchAsyncQuery
(
SRequestObj
*
pRequest
,
SQuery
*
pQuery
,
SMetaData
*
pResultMeta
);
int32_t
refreshMeta
(
STscObj
*
pTscObj
,
SRequestObj
*
pRequest
);
int32_t
updateQnodeList
(
SAppInstInfo
*
pInfo
,
SArray
*
pNodeList
);
void
doAsyncQuery
(
SRequestObj
*
pRequest
,
bool
forceUpdateMeta
);
int32_t
removeMeta
(
STscObj
*
pTscObj
,
SArray
*
tbList
);
// todo move to clientImpl.c and become a static function
int32_t
handleAlterTbExecRes
(
void
*
res
,
struct
SCatalog
*
pCatalog
);
// todo move to xxx
int32_t
removeMeta
(
STscObj
*
pTscObj
,
SArray
*
tbList
);
// todo move to clientImpl.c and become a static function
int32_t
handleAlterTbExecRes
(
void
*
res
,
struct
SCatalog
*
pCatalog
);
// todo move to xxx
bool
qnodeRequired
(
SRequestObj
*
pRequest
);
#ifdef __cplusplus
...
...
source/client/src/clientMain.c
浏览文件 @
bae71438
...
...
@@ -17,6 +17,7 @@
#include "clientInt.h"
#include "clientLog.h"
#include "clientStmt.h"
#include "functionMgt.h"
#include "os.h"
#include "query.h"
#include "scheduler.h"
...
...
@@ -25,7 +26,6 @@
#include "tref.h"
#include "trpc.h"
#include "version.h"
#include "functionMgt.h"
#define TSC_VAR_NOT_RELEASE 1
#define TSC_VAR_RELEASED 0
...
...
@@ -97,11 +97,11 @@ TAOS *taos_connect(const char *ip, const char *user, const char *pass, const cha
pass
=
TSDB_DEFAULT_PASS
;
}
STscObj
*
pObj
=
taos_connect_internal
(
ip
,
user
,
pass
,
NULL
,
db
,
port
,
CONN_TYPE__QUERY
);
STscObj
*
pObj
=
taos_connect_internal
(
ip
,
user
,
pass
,
NULL
,
db
,
port
,
CONN_TYPE__QUERY
);
if
(
pObj
)
{
return
pObj
->
id
;
}
return
NULL
;
}
...
...
@@ -111,41 +111,40 @@ void taos_close_internal(void *taos) {
}
STscObj
*
pTscObj
=
(
STscObj
*
)
taos
;
tscDebug
(
"0x%"
PRIx64
" try to close connection, numOfReq:%d"
,
*
(
int64_t
*
)
pTscObj
->
id
,
pTscObj
->
numOfReqs
);
tscDebug
(
"0x%"
PRIx64
" try to close connection, numOfReq:%d"
,
*
(
int64_t
*
)
pTscObj
->
id
,
pTscObj
->
numOfReqs
);
taosRemoveRef
(
clientConnRefPool
,
*
(
int64_t
*
)
pTscObj
->
id
);
taosRemoveRef
(
clientConnRefPool
,
*
(
int64_t
*
)
pTscObj
->
id
);
}
void
taos_close
(
TAOS
*
taos
)
{
if
(
taos
==
NULL
)
{
return
;
}
STscObj
*
pObj
=
acquireTscObj
(
*
(
int64_t
*
)
taos
);
STscObj
*
pObj
=
acquireTscObj
(
*
(
int64_t
*
)
taos
);
if
(
NULL
==
pObj
)
{
return
;
}
taos_close_internal
(
pObj
);
releaseTscObj
(
*
(
int64_t
*
)
taos
);
releaseTscObj
(
*
(
int64_t
*
)
taos
);
taosMemoryFree
(
taos
);
}
int
taos_errno
(
TAOS_RES
*
tres
)
{
if
(
tres
==
NULL
)
{
int
taos_errno
(
TAOS_RES
*
res
)
{
if
(
res
==
NULL
||
TD_RES_TMQ_META
(
res
))
{
return
terrno
;
}
if
(
TD_RES_TMQ
(
t
res
))
{
if
(
TD_RES_TMQ
(
res
))
{
return
0
;
}
return
((
SRequestObj
*
)
t
res
)
->
code
;
return
((
SRequestObj
*
)
res
)
->
code
;
}
const
char
*
taos_errstr
(
TAOS_RES
*
res
)
{
if
(
res
==
NULL
)
{
if
(
res
==
NULL
||
TD_RES_TMQ_META
(
res
)
)
{
return
(
const
char
*
)
tstrerror
(
terrno
);
}
...
...
@@ -179,11 +178,15 @@ void taos_free_result(TAOS_RES *res) {
if
(
pRsp
->
rsp
.
withSchema
)
taosArrayDestroyP
(
pRsp
->
rsp
.
blockSchema
,
(
FDelete
)
tDeleteSSchemaWrapper
);
pRsp
->
resInfo
.
pRspMsg
=
NULL
;
doFreeReqResultInfo
(
&
pRsp
->
resInfo
);
}
else
if
(
TD_RES_TMQ_META
(
res
))
{
SMqMetaRspObj
*
pRspObj
=
(
SMqMetaRspObj
*
)
res
;
taosMemoryFree
(
pRspObj
->
metaRsp
.
metaRsp
);
taosMemoryFree
(
pRspObj
);
}
}
int
taos_field_count
(
TAOS_RES
*
res
)
{
if
(
res
==
NULL
)
{
if
(
res
==
NULL
||
TD_RES_TMQ_META
(
res
)
)
{
return
0
;
}
...
...
@@ -194,7 +197,7 @@ int taos_field_count(TAOS_RES *res) {
int
taos_num_fields
(
TAOS_RES
*
res
)
{
return
taos_field_count
(
res
);
}
TAOS_FIELD
*
taos_fetch_fields
(
TAOS_RES
*
res
)
{
if
(
taos_num_fields
(
res
)
==
0
)
{
if
(
taos_num_fields
(
res
)
==
0
||
TD_RES_TMQ_META
(
res
)
)
{
return
NULL
;
}
...
...
@@ -215,8 +218,8 @@ TAOS_RES *taos_query(TAOS *taos, const char *sql) {
terrno
=
TSDB_CODE_TSC_DISCONNECTED
;
return
NULL
;
}
STscObj
*
pTscObj
=
acquireTscObj
(
*
(
int64_t
*
)
taos
);
STscObj
*
pTscObj
=
acquireTscObj
(
*
(
int64_t
*
)
taos
);
if
(
pTscObj
==
NULL
||
sql
==
NULL
)
{
terrno
=
TSDB_CODE_TSC_DISCONNECTED
;
return
NULL
;
...
...
@@ -229,21 +232,21 @@ TAOS_RES *taos_query(TAOS *taos, const char *sql) {
taos_query_a
(
taos
,
sql
,
syncQueryFn
,
param
);
tsem_wait
(
&
param
->
sem
);
releaseTscObj
(
*
(
int64_t
*
)
taos
);
releaseTscObj
(
*
(
int64_t
*
)
taos
);
return
param
->
pRequest
;
#else
size_t
sqlLen
=
strlen
(
sql
);
if
(
sqlLen
>
(
size_t
)
TSDB_MAX_ALLOWED_SQL_LEN
)
{
releaseTscObj
(
*
(
int64_t
*
)
taos
);
releaseTscObj
(
*
(
int64_t
*
)
taos
);
tscError
(
"sql string exceeds max length:%d"
,
TSDB_MAX_ALLOWED_SQL_LEN
);
terrno
=
TSDB_CODE_TSC_EXCEED_SQL_LIMIT
;
return
NULL
;
}
TAOS_RES
*
pRes
=
execQuery
(
pTscObj
,
sql
,
sqlLen
);
TAOS_RES
*
pRes
=
execQuery
(
pTscObj
,
sql
,
sqlLen
);
releaseTscObj
(
*
(
int64_t
*
)
taos
);
releaseTscObj
(
*
(
int64_t
*
)
taos
);
return
pRes
;
#endif
...
...
@@ -380,7 +383,7 @@ int taos_print_row(char *str, TAOS_ROW row, TAOS_FIELD *fields, int num_fields)
}
int
*
taos_fetch_lengths
(
TAOS_RES
*
res
)
{
if
(
res
==
NULL
)
{
if
(
res
==
NULL
||
TD_RES_TMQ_META
(
res
)
)
{
return
NULL
;
}
...
...
@@ -389,7 +392,7 @@ int *taos_fetch_lengths(TAOS_RES *res) {
}
TAOS_ROW
*
taos_result_block
(
TAOS_RES
*
res
)
{
if
(
res
==
NULL
)
{
if
(
res
==
NULL
||
TD_RES_TMQ_META
(
res
)
)
{
terrno
=
TSDB_CODE_INVALID_PARA
;
return
NULL
;
}
...
...
@@ -438,7 +441,7 @@ const char *taos_data_type(int type) {
const
char
*
taos_get_client_info
()
{
return
version
;
}
int
taos_affected_rows
(
TAOS_RES
*
res
)
{
if
(
res
==
NULL
||
TD_RES_TMQ
(
res
))
{
if
(
res
==
NULL
||
TD_RES_TMQ
(
res
)
||
TD_RES_TMQ_META
(
res
)
)
{
return
0
;
}
...
...
@@ -448,7 +451,7 @@ int taos_affected_rows(TAOS_RES *res) {
}
int
taos_result_precision
(
TAOS_RES
*
res
)
{
if
(
res
==
NULL
)
{
if
(
res
==
NULL
||
TD_RES_TMQ_META
(
res
)
)
{
return
TSDB_TIME_PRECISION_MILLI
;
}
...
...
@@ -463,15 +466,15 @@ int taos_result_precision(TAOS_RES *res) {
}
int
taos_select_db
(
TAOS
*
taos
,
const
char
*
db
)
{
STscObj
*
pObj
=
acquireTscObj
(
*
(
int64_t
*
)
taos
);
STscObj
*
pObj
=
acquireTscObj
(
*
(
int64_t
*
)
taos
);
if
(
pObj
==
NULL
)
{
releaseTscObj
(
*
(
int64_t
*
)
taos
);
releaseTscObj
(
*
(
int64_t
*
)
taos
);
terrno
=
TSDB_CODE_TSC_DISCONNECTED
;
return
TSDB_CODE_TSC_DISCONNECTED
;
}
if
(
db
==
NULL
||
strlen
(
db
)
==
0
)
{
releaseTscObj
(
*
(
int64_t
*
)
taos
);
releaseTscObj
(
*
(
int64_t
*
)
taos
);
terrno
=
TSDB_CODE_TSC_INVALID_INPUT
;
return
terrno
;
}
...
...
@@ -483,19 +486,19 @@ int taos_select_db(TAOS *taos, const char *db) {
int32_t
code
=
taos_errno
(
pRequest
);
taos_free_result
(
pRequest
);
releaseTscObj
(
*
(
int64_t
*
)
taos
);
releaseTscObj
(
*
(
int64_t
*
)
taos
);
return
code
;
}
void
taos_stop_query
(
TAOS_RES
*
res
)
{
if
(
res
==
NULL
)
{
if
(
res
==
NULL
||
TD_RES_TMQ
(
res
)
||
TD_RES_TMQ_META
(
res
)
)
{
return
;
}
SRequestObj
*
pRequest
=
(
SRequestObj
*
)
res
;
pRequest
->
killed
=
true
;
int32_t
numOfFields
=
taos_num_fields
(
pRequest
);
int32_t
numOfFields
=
taos_num_fields
(
pRequest
);
// It is not a query, no need to stop.
if
(
numOfFields
==
0
)
{
tscDebug
(
"request %"
PRIx64
" no need to be killed since not query"
,
pRequest
->
requestId
);
...
...
@@ -510,6 +513,9 @@ void taos_stop_query(TAOS_RES *res) {
}
bool
taos_is_null
(
TAOS_RES
*
res
,
int32_t
row
,
int32_t
col
)
{
if
(
res
==
NULL
||
TD_RES_TMQ_META
(
res
))
{
return
true
;
}
SReqResultInfo
*
pResultInfo
=
tscGetCurResInfo
(
res
);
if
(
col
>=
pResultInfo
->
numOfCols
||
col
<
0
||
row
>=
pResultInfo
->
numOfRows
||
row
<
0
)
{
return
true
;
...
...
@@ -532,7 +538,7 @@ int taos_fetch_block(TAOS_RES *res, TAOS_ROW *rows) {
}
int
taos_fetch_block_s
(
TAOS_RES
*
res
,
int
*
numOfRows
,
TAOS_ROW
*
rows
)
{
if
(
res
==
NULL
)
{
if
(
res
==
NULL
||
TD_RES_TMQ_META
(
res
)
)
{
return
0
;
}
...
...
@@ -575,7 +581,7 @@ int taos_fetch_block_s(TAOS_RES *res, int *numOfRows, TAOS_ROW *rows) {
}
int
taos_fetch_raw_block
(
TAOS_RES
*
res
,
int
*
numOfRows
,
void
**
pData
)
{
if
(
res
==
NULL
)
{
if
(
res
==
NULL
||
TD_RES_TMQ_META
(
res
)
)
{
return
0
;
}
...
...
@@ -615,7 +621,7 @@ int taos_fetch_raw_block(TAOS_RES *res, int *numOfRows, void **pData) {
}
int
*
taos_get_column_data_offset
(
TAOS_RES
*
res
,
int
columnIndex
)
{
if
(
res
==
NULL
)
{
if
(
res
==
NULL
||
TD_RES_TMQ_META
(
res
)
)
{
return
0
;
}
...
...
@@ -636,7 +642,7 @@ int *taos_get_column_data_offset(TAOS_RES *res, int columnIndex) {
int
taos_validate_sql
(
TAOS
*
taos
,
const
char
*
sql
)
{
return
true
;
}
void
taos_reset_current_db
(
TAOS
*
taos
)
{
STscObj
*
pTscObj
=
acquireTscObj
(
*
(
int64_t
*
)
taos
);
STscObj
*
pTscObj
=
acquireTscObj
(
*
(
int64_t
*
)
taos
);
if
(
pTscObj
==
NULL
)
{
terrno
=
TSDB_CODE_TSC_DISCONNECTED
;
return
;
...
...
@@ -644,17 +650,17 @@ void taos_reset_current_db(TAOS *taos) {
resetConnectDB
(
pTscObj
);
releaseTscObj
(
*
(
int64_t
*
)
taos
);
releaseTscObj
(
*
(
int64_t
*
)
taos
);
}
const
char
*
taos_get_server_info
(
TAOS
*
taos
)
{
STscObj
*
pTscObj
=
acquireTscObj
(
*
(
int64_t
*
)
taos
);
STscObj
*
pTscObj
=
acquireTscObj
(
*
(
int64_t
*
)
taos
);
if
(
pTscObj
==
NULL
)
{
terrno
=
TSDB_CODE_TSC_DISCONNECTED
;
return
NULL
;
}
releaseTscObj
(
*
(
int64_t
*
)
taos
);
releaseTscObj
(
*
(
int64_t
*
)
taos
);
return
pTscObj
->
ver
;
}
...
...
@@ -682,7 +688,7 @@ static void destorySqlParseWrapper(SqlParseWrapper *pWrapper) {
void
retrieveMetaCallback
(
SMetaData
*
pResultMeta
,
void
*
param
,
int32_t
code
)
{
tscDebug
(
"enter meta callback, code %s"
,
tstrerror
(
code
));
SqlParseWrapper
*
pWrapper
=
(
SqlParseWrapper
*
)
param
;
SQuery
*
pQuery
=
pWrapper
->
pQuery
;
SRequestObj
*
pRequest
=
pWrapper
->
pRequest
;
...
...
@@ -723,11 +729,11 @@ void retrieveMetaCallback(SMetaData *pResultMeta, void *param, int32_t code) {
}
void
taos_query_a
(
TAOS
*
taos
,
const
char
*
sql
,
__taos_async_fn_t
fp
,
void
*
param
)
{
STscObj
*
pTscObj
=
acquireTscObj
(
*
(
int64_t
*
)
taos
);
STscObj
*
pTscObj
=
acquireTscObj
(
*
(
int64_t
*
)
taos
);
if
(
pTscObj
==
NULL
||
sql
==
NULL
||
NULL
==
fp
)
{
terrno
=
TSDB_CODE_INVALID_PARA
;
if
(
pTscObj
)
{
releaseTscObj
(
*
(
int64_t
*
)
taos
);
releaseTscObj
(
*
(
int64_t
*
)
taos
);
}
else
{
terrno
=
TSDB_CODE_TSC_DISCONNECTED
;
}
...
...
@@ -745,7 +751,7 @@ void taos_query_a(TAOS *taos, const char *sql, __taos_async_fn_t fp, void *param
}
SRequestObj
*
pRequest
=
NULL
;
int32_t
code
=
buildRequest
(
pTscObj
,
sql
,
sqlLen
,
&
pRequest
);
int32_t
code
=
buildRequest
(
pTscObj
,
sql
,
sqlLen
,
&
pRequest
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
terrno
=
code
;
fp
(
param
,
NULL
,
terrno
);
...
...
@@ -849,8 +855,8 @@ static void fetchCallback(void *pResult, void *param, int32_t code) {
SReqResultInfo
*
pResultInfo
=
&
pRequest
->
body
.
resInfo
;
tscDebug
(
"0x%"
PRIx64
" enter scheduler fetch cb, code:%d - %s, reqId:0x%"
PRIx64
,
pRequest
->
self
,
code
,
tstrerror
(
code
),
pRequest
->
requestId
);
tscDebug
(
"0x%"
PRIx64
" enter scheduler fetch cb, code:%d - %s, reqId:0x%"
PRIx64
,
pRequest
->
self
,
code
,
tstrerror
(
code
),
pRequest
->
requestId
);
pResultInfo
->
pData
=
pResult
;
pResultInfo
->
numOfRows
=
0
;
...
...
@@ -884,6 +890,7 @@ static void fetchCallback(void *pResult, void *param, int32_t code) {
void
taos_fetch_rows_a
(
TAOS_RES
*
res
,
__taos_async_fn_t
fp
,
void
*
param
)
{
ASSERT
(
res
!=
NULL
&&
fp
!=
NULL
);
ASSERT
(
TD_RES_QUERY
(
res
));
SRequestObj
*
pRequest
=
res
;
pRequest
->
body
.
fetchFp
=
fp
;
...
...
@@ -910,6 +917,7 @@ void taos_fetch_rows_a(TAOS_RES *res, __taos_async_fn_t fp, void *param) {
void
taos_fetch_raw_block_a
(
TAOS_RES
*
res
,
__taos_async_fn_t
fp
,
void
*
param
)
{
ASSERT
(
res
!=
NULL
&&
fp
!=
NULL
);
ASSERT
(
TD_RES_QUERY
(
res
));
SRequestObj
*
pRequest
=
res
;
pRequest
->
body
.
resInfo
.
convertUcs4
=
false
;
...
...
@@ -923,6 +931,7 @@ void taos_fetch_raw_block_a(TAOS_RES *res, __taos_async_fn_t fp, void *param) {
const
void
*
taos_get_raw_block
(
TAOS_RES
*
res
)
{
ASSERT
(
res
!=
NULL
);
ASSERT
(
TD_RES_QUERY
(
res
));
SRequestObj
*
pRequest
=
res
;
return
pRequest
->
body
.
resInfo
.
pData
;
...
...
@@ -949,16 +958,16 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) {
}
TAOS_STMT
*
taos_stmt_init
(
TAOS
*
taos
)
{
STscObj
*
pObj
=
acquireTscObj
(
*
(
int64_t
*
)
taos
);
STscObj
*
pObj
=
acquireTscObj
(
*
(
int64_t
*
)
taos
);
if
(
NULL
==
pObj
)
{
tscError
(
"invalid parameter for %s"
,
__FUNCTION__
);
terrno
=
TSDB_CODE_TSC_DISCONNECTED
;
return
NULL
;
}
TAOS_STMT
*
pStmt
=
stmtInit
(
pObj
);
releaseTscObj
(
*
(
int64_t
*
)
taos
);
TAOS_STMT
*
pStmt
=
stmtInit
(
pObj
);
releaseTscObj
(
*
(
int64_t
*
)
taos
);
return
pStmt
;
}
...
...
source/client/src/clientSml.c
浏览文件 @
bae71438
...
...
@@ -2389,17 +2389,19 @@ static int32_t isSchemalessDb(STscObj *taos, SRequestObj *request) {
static
void
smlInsertCallback
(
void
*
param
,
void
*
res
,
int32_t
code
)
{
SRequestObj
*
pRequest
=
(
SRequestObj
*
)
res
;
SSmlHandle
*
info
=
(
SSmlHandle
*
)
param
;
int32_t
rows
=
taos_affected_rows
(
pRequest
);
uDebug
(
"SML:0x%"
PRIx64
" result. code:%d, msg:%s"
,
info
->
id
,
pRequest
->
code
,
pRequest
->
msgBuf
);
// lock
taosThreadSpinLock
(
&
info
->
params
->
lock
);
info
->
params
->
request
->
body
.
resInfo
.
numOfRows
+=
rows
;
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
taosThreadSpinLock
(
&
info
->
params
->
lock
);
info
->
params
->
request
->
code
=
code
;
taosThreadSpinUnlock
(
&
info
->
params
->
lock
);
}
taosThreadSpinUnlock
(
&
info
->
params
->
lock
);
// unlock
printf
(
"SML:0x%"
PRIx64
" insert finished, code: %d, total: %d
\n
"
,
info
->
id
,
code
,
info
->
affectedRows
);
uDebug
(
"SML:0x%"
PRIx64
" insert finished, code: %d, rows: %d, total: %d"
,
info
->
id
,
code
,
rows
,
info
->
affectedRows
);
Params
*
pParam
=
info
->
params
;
bool
isLast
=
info
->
isLast
;
info
->
cost
.
endTime
=
taosGetTimestampUs
();
...
...
source/client/src/tmq.c
浏览文件 @
bae71438
...
...
@@ -149,7 +149,10 @@ typedef struct {
int32_t
epoch
;
SMqClientVg
*
vgHandle
;
SMqClientTopic
*
topicHandle
;
SMqDataBlkRsp
msg
;
union
{
SMqDataBlkRsp
dataRsp
;
SMqMetaRsp
metaRsp
;
};
}
SMqPollRspWrapper
;
typedef
struct
{
...
...
@@ -401,8 +404,17 @@ int32_t tmqCommitInner2(tmq_t* tmq, const TAOS_RES* msg, int8_t automatic, int8_
int32_t
code
=
-
1
;
if
(
msg
!=
NULL
)
{
SMqRspObj
*
pRspObj
=
(
SMqRspObj
*
)
msg
;
if
(
!
TD_RES_TMQ
(
pRspObj
))
{
char
*
topic
;
int32_t
vgId
;
if
(
TD_RES_TMQ
(
msg
))
{
SMqRspObj
*
pRspObj
=
(
SMqRspObj
*
)
msg
;
topic
=
pRspObj
->
topic
;
vgId
=
pRspObj
->
vgId
;
}
else
if
(
TD_RES_TMQ_META
(
msg
))
{
SMqMetaRspObj
*
pMetaRspObj
=
(
SMqMetaRspObj
*
)
msg
;
topic
=
pMetaRspObj
->
topic
;
vgId
=
pMetaRspObj
->
vgId
;
}
else
{
return
TSDB_CODE_TMQ_INVALID_MSG
;
}
...
...
@@ -421,10 +433,10 @@ int32_t tmqCommitInner2(tmq_t* tmq, const TAOS_RES* msg, int8_t automatic, int8_
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
tmq
->
clientTopics
);
i
++
)
{
SMqClientTopic
*
pTopic
=
taosArrayGet
(
tmq
->
clientTopics
,
i
);
if
(
strcmp
(
pTopic
->
topicName
,
pRspObj
->
topic
)
==
0
)
{
if
(
strcmp
(
pTopic
->
topicName
,
topic
)
==
0
)
{
for
(
int32_t
j
=
0
;
j
<
taosArrayGetSize
(
pTopic
->
vgs
);
j
++
)
{
SMqClientVg
*
pVg
=
taosArrayGet
(
pTopic
->
vgs
,
j
);
if
(
pVg
->
vgId
==
pRspObj
->
vgId
)
{
if
(
pVg
->
vgId
==
vgId
)
{
if
(
pVg
->
currentOffset
<
0
||
pVg
->
committedOffset
==
pVg
->
currentOffset
)
{
tscDebug
(
"consumer %ld skip commit for topic %s vg %d, current offset is %ld, committed offset is %ld"
,
tmq
->
consumerId
,
pTopic
->
topicName
,
pVg
->
vgId
,
pVg
->
currentOffset
,
pVg
->
committedOffset
);
...
...
@@ -1131,6 +1143,11 @@ int32_t tmqPollCb(void* param, const SDataBuf* pMsg, int32_t code) {
tscWarn
(
"mismatch rsp from vg %d, epoch %d, current epoch %d"
,
vgId
,
msgEpoch
,
tmqEpoch
);
}
// handle meta rsp
int8_t
rspType
=
((
SMqRspHead
*
)
pMsg
->
pData
)
->
mqMsgType
;
if
(
rspType
==
TMQ_MSG_TYPE__POLL_META_RSP
)
{
}
SMqPollRspWrapper
*
pRspWrapper
=
taosAllocateQitem
(
sizeof
(
SMqPollRspWrapper
),
DEF_QITEM
);
if
(
pRspWrapper
==
NULL
)
{
taosMemoryFree
(
pMsg
->
pData
);
...
...
@@ -1138,17 +1155,23 @@ int32_t tmqPollCb(void* param, const SDataBuf* pMsg, int32_t code) {
goto
CREATE_MSG_FAIL
;
}
pRspWrapper
->
tmqRspType
=
TMQ_MSG_TYPE__POLL_RSP
;
pRspWrapper
->
tmqRspType
=
rspType
;
pRspWrapper
->
vgHandle
=
pVg
;
pRspWrapper
->
topicHandle
=
pTopic
;
memcpy
(
&
pRspWrapper
->
msg
,
pMsg
->
pData
,
sizeof
(
SMqRspHead
));
memcpy
(
&
pRspWrapper
->
dataRsp
,
pMsg
->
pData
,
sizeof
(
SMqRspHead
));
if
(
rspType
==
TMQ_MSG_TYPE__POLL_RSP
)
{
tDecodeSMqDataBlkRsp
(
POINTER_SHIFT
(
pMsg
->
pData
,
sizeof
(
SMqRspHead
)),
&
pRspWrapper
->
dataRsp
);
}
else
{
ASSERT
(
rspType
==
TMQ_MSG_TYPE__POLL_META_RSP
);
tDecodeSMqMetaRsp
(
POINTER_SHIFT
(
pMsg
->
pData
,
sizeof
(
SMqRspHead
)),
&
pRspWrapper
->
metaRsp
);
}
tDecodeSMqDataBlkRsp
(
POINTER_SHIFT
(
pMsg
->
pData
,
sizeof
(
SMqRspHead
)),
&
pRspWrapper
->
msg
);
taosMemoryFree
(
pMsg
->
pData
);
tscDebug
(
"consumer %ld recv poll: vg %d, req offset %ld, rsp offset %ld"
,
tmq
->
consumerId
,
pVg
->
vgId
,
pRspWrapper
->
msg
.
reqOffset
,
pRspWrapper
->
msg
.
rspOffset
);
pRspWrapper
->
dataRsp
.
reqOffset
,
pRspWrapper
->
dataRsp
.
rspOffset
);
taosWriteQitem
(
tmq
->
mqueue
,
pRspWrapper
);
tsem_post
(
&
tmq
->
rspSem
);
...
...
@@ -1516,6 +1539,17 @@ SMqPollReq* tmqBuildConsumeReqImpl(tmq_t* tmq, int64_t timeout, SMqClientTopic*
return
pReq
;
}
SMqMetaRspObj
*
tmqBuildMetaRspFromWrapper
(
SMqPollRspWrapper
*
pWrapper
)
{
SMqMetaRspObj
*
pRspObj
=
taosMemoryCalloc
(
1
,
sizeof
(
SMqMetaRspObj
));
pRspObj
->
resType
=
RES_TYPE__TMQ
;
tstrncpy
(
pRspObj
->
topic
,
pWrapper
->
topicHandle
->
topicName
,
TSDB_TOPIC_FNAME_LEN
);
tstrncpy
(
pRspObj
->
db
,
pWrapper
->
topicHandle
->
db
,
TSDB_DB_FNAME_LEN
);
pRspObj
->
vgId
=
pWrapper
->
vgHandle
->
vgId
;
memcpy
(
&
pRspObj
->
metaRsp
,
&
pWrapper
->
metaRsp
,
sizeof
(
SMqMetaRsp
));
return
pRspObj
;
}
SMqRspObj
*
tmqBuildRspFromWrapper
(
SMqPollRspWrapper
*
pWrapper
)
{
SMqRspObj
*
pRspObj
=
taosMemoryCalloc
(
1
,
sizeof
(
SMqRspObj
));
pRspObj
->
resType
=
RES_TYPE__TMQ
;
...
...
@@ -1523,11 +1557,11 @@ SMqRspObj* tmqBuildRspFromWrapper(SMqPollRspWrapper* pWrapper) {
tstrncpy
(
pRspObj
->
db
,
pWrapper
->
topicHandle
->
db
,
TSDB_DB_FNAME_LEN
);
pRspObj
->
vgId
=
pWrapper
->
vgHandle
->
vgId
;
pRspObj
->
resIter
=
-
1
;
memcpy
(
&
pRspObj
->
rsp
,
&
pWrapper
->
msg
,
sizeof
(
SMqDataBlkRsp
));
memcpy
(
&
pRspObj
->
rsp
,
&
pWrapper
->
dataRsp
,
sizeof
(
SMqDataBlkRsp
));
pRspObj
->
resInfo
.
totalRows
=
0
;
pRspObj
->
resInfo
.
precision
=
TSDB_TIME_PRECISION_MILLI
;
if
(
!
pWrapper
->
msg
.
withSchema
)
{
if
(
!
pWrapper
->
dataRsp
.
withSchema
)
{
setResSchemaInfo
(
&
pRspObj
->
resInfo
,
pWrapper
->
topicHandle
->
schema
.
pSchema
,
pWrapper
->
topicHandle
->
schema
.
nCols
);
}
...
...
@@ -1643,12 +1677,12 @@ SMqRspObj* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout, bool pollIfReset) {
SMqPollRspWrapper
*
pollRspWrapper
=
(
SMqPollRspWrapper
*
)
rspWrapper
;
/*atomic_sub_fetch_32(&tmq->readyRequest, 1);*/
int32_t
consumerEpoch
=
atomic_load_32
(
&
tmq
->
epoch
);
if
(
pollRspWrapper
->
msg
.
head
.
epoch
==
consumerEpoch
)
{
if
(
pollRspWrapper
->
dataRsp
.
head
.
epoch
==
consumerEpoch
)
{
SMqClientVg
*
pVg
=
pollRspWrapper
->
vgHandle
;
/*printf("vg %d offset %ld up to %ld\n", pVg->vgId, pVg->currentOffset, rspMsg->msg.rspOffset);*/
pVg
->
currentOffset
=
pollRspWrapper
->
msg
.
rspOffset
;
pVg
->
currentOffset
=
pollRspWrapper
->
dataRsp
.
rspOffset
;
atomic_store_32
(
&
pVg
->
vgStatus
,
TMQ_VG_STATUS__IDLE
);
if
(
pollRspWrapper
->
msg
.
blockNum
==
0
)
{
if
(
pollRspWrapper
->
dataRsp
.
blockNum
==
0
)
{
taosFreeQitem
(
pollRspWrapper
);
rspWrapper
=
NULL
;
continue
;
...
...
@@ -1658,8 +1692,25 @@ SMqRspObj* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout, bool pollIfReset) {
taosFreeQitem
(
pollRspWrapper
);
return
pRsp
;
}
else
{
tscDebug
(
"msg discard since epoch mismatch: msg epoch %d, consumer epoch %d
\n
"
,
pollRspWrapper
->
msg
.
head
.
epoch
,
consumerEpoch
);
tscDebug
(
"msg discard since epoch mismatch: msg epoch %d, consumer epoch %d
\n
"
,
pollRspWrapper
->
dataRsp
.
head
.
epoch
,
consumerEpoch
);
taosFreeQitem
(
pollRspWrapper
);
}
}
else
if
(
rspWrapper
->
tmqRspType
==
TMQ_MSG_TYPE__POLL_META_RSP
)
{
SMqPollRspWrapper
*
pollRspWrapper
=
(
SMqPollRspWrapper
*
)
rspWrapper
;
int32_t
consumerEpoch
=
atomic_load_32
(
&
tmq
->
epoch
);
if
(
pollRspWrapper
->
dataRsp
.
head
.
epoch
==
consumerEpoch
)
{
SMqClientVg
*
pVg
=
pollRspWrapper
->
vgHandle
;
/*printf("vg %d offset %ld up to %ld\n", pVg->vgId, pVg->currentOffset, rspMsg->msg.rspOffset);*/
pVg
->
currentOffset
=
pollRspWrapper
->
dataRsp
.
rspOffset
;
atomic_store_32
(
&
pVg
->
vgStatus
,
TMQ_VG_STATUS__IDLE
);
// build rsp
SMqRspObj
*
pRsp
=
tmqBuildRspFromWrapper
(
pollRspWrapper
);
taosFreeQitem
(
pollRspWrapper
);
return
pRsp
;
}
else
{
tscDebug
(
"msg discard since epoch mismatch: msg epoch %d, consumer epoch %d
\n
"
,
pollRspWrapper
->
dataRsp
.
head
.
epoch
,
consumerEpoch
);
taosFreeQitem
(
pollRspWrapper
);
}
}
else
{
...
...
@@ -1747,10 +1798,23 @@ const char* tmq_err2str(int32_t err) {
}
}
tmq_res_t
tmq_get_res_type
(
TAOS_RES
*
res
)
{
if
(
TD_RES_TMQ
(
res
))
{
return
TMQ_RES_DATA
;
}
else
if
(
TD_RES_TMQ_META
(
res
))
{
return
TMQ_RES_TABLE_META
;
}
else
{
return
TMQ_RES_INVALID
;
}
}
const
char
*
tmq_get_topic_name
(
TAOS_RES
*
res
)
{
if
(
TD_RES_TMQ
(
res
))
{
SMqRspObj
*
pRspObj
=
(
SMqRspObj
*
)
res
;
return
strchr
(
pRspObj
->
topic
,
'.'
)
+
1
;
}
else
if
(
TD_RES_TMQ_META
(
res
))
{
SMqMetaRspObj
*
pMetaRspObj
=
(
SMqMetaRspObj
*
)
res
;
return
strchr
(
pMetaRspObj
->
topic
,
'.'
)
+
1
;
}
else
{
return
NULL
;
}
...
...
@@ -1760,6 +1824,9 @@ const char* tmq_get_db_name(TAOS_RES* res) {
if
(
TD_RES_TMQ
(
res
))
{
SMqRspObj
*
pRspObj
=
(
SMqRspObj
*
)
res
;
return
strchr
(
pRspObj
->
db
,
'.'
)
+
1
;
}
else
if
(
TD_RES_TMQ_META
(
res
))
{
SMqMetaRspObj
*
pMetaRspObj
=
(
SMqMetaRspObj
*
)
res
;
return
strchr
(
pMetaRspObj
->
db
,
'.'
)
+
1
;
}
else
{
return
NULL
;
}
...
...
@@ -1769,6 +1836,9 @@ int32_t tmq_get_vgroup_id(TAOS_RES* res) {
if
(
TD_RES_TMQ
(
res
))
{
SMqRspObj
*
pRspObj
=
(
SMqRspObj
*
)
res
;
return
pRspObj
->
vgId
;
}
else
if
(
TD_RES_TMQ_META
(
res
))
{
SMqMetaRspObj
*
pMetaRspObj
=
(
SMqMetaRspObj
*
)
res
;
return
pMetaRspObj
->
vgId
;
}
else
{
return
-
1
;
}
...
...
@@ -1786,6 +1856,16 @@ const char* tmq_get_table_name(TAOS_RES* res) {
return
NULL
;
}
int32_t
tmq_get_raw_meta
(
TAOS_RES
*
res
,
const
void
**
raw_meta
,
int32_t
*
raw_meta_len
)
{
if
(
TD_RES_TMQ_META
(
res
))
{
SMqMetaRspObj
*
pMetaRspObj
=
(
SMqMetaRspObj
*
)
res
;
*
raw_meta
=
pMetaRspObj
->
metaRsp
.
metaRsp
;
*
raw_meta_len
=
pMetaRspObj
->
metaRsp
.
metaRspLen
;
return
0
;
}
return
-
1
;
}
void
tmq_commit_async
(
tmq_t
*
tmq
,
const
TAOS_RES
*
msg
,
tmq_commit_cb
*
cb
,
void
*
param
)
{
tmqCommitInner2
(
tmq
,
msg
,
0
,
1
,
cb
,
param
);
}
...
...
source/client/test/smlTest.cpp
浏览文件 @
bae71438
...
...
@@ -1272,10 +1272,10 @@ TEST(testCase, sml_dup_time_Test) {
const char *sql[] = {
//"test_ms,t0=t c0=f 1626006833641",
"ubzlsr,id=qmtcvgd,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" c0=false,c1=1i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"xcxvwjvf\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000",
"ubzlsr,id=qmtcvgd,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" c0=T,c1=2i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"fixrzcuq\",c8=L\"ncharColValue\",c9=7u64 162600683
3
639000000",
"ubzlsr,id=qmtcvgd,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" c0=t,c1=3i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"iupzdqub\",c8=L\"ncharColValue\",c9=7u64 162600683
3
639000000",
"ubzlsr,id=qmtcvgd,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" c0=t,c1=4i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"yvvtzzof\",c8=L\"ncharColValue\",c9=7u64 162600683
3
639000000",
"ubzlsr,id=qmtcvgd,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" c0=t,c1=5i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"vbxpilkj\",c8=L\"ncharColValue\",c9=7u64 162600683
3
639000000"
"ubzlsr,id=qmtcvgd,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" c0=T,c1=2i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"fixrzcuq\",c8=L\"ncharColValue\",c9=7u64 162600683
4
639000000",
"ubzlsr,id=qmtcvgd,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" c0=t,c1=3i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"iupzdqub\",c8=L\"ncharColValue\",c9=7u64 162600683
5
639000000",
"ubzlsr,id=qmtcvgd,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" c0=t,c1=4i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"yvvtzzof\",c8=L\"ncharColValue\",c9=7u64 162600683
6
639000000",
"ubzlsr,id=qmtcvgd,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" c0=t,c1=5i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"vbxpilkj\",c8=L\"ncharColValue\",c9=7u64 162600683
7
639000000"
};
pRes = taos_query(taos, "use dup_time");
taos_free_result(pRes);
...
...
source/common/src/tmsg.c
浏览文件 @
bae71438
...
...
@@ -127,7 +127,7 @@ int32_t tEncodeSEpSet(SEncoder *pEncoder, const SEpSet *pEp) {
if
(
tEncodeI8
(
pEncoder
,
pEp
->
numOfEps
)
<
0
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
TSDB_MAX_REPLICA
;
i
++
)
{
if
(
tEncodeU16
(
pEncoder
,
pEp
->
eps
[
i
].
port
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
pEncoder
,
pEp
->
eps
[
i
].
fqdn
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
WithLen
(
pEncoder
,
pEp
->
eps
[
i
].
fqdn
,
TSDB_FQDN_LEN
)
<
0
)
return
-
1
;
}
return
0
;
}
...
...
@@ -2956,6 +2956,7 @@ int32_t tSerializeSCMCreateTopicReq(void *buf, int32_t bufLen, const SCMCreateTo
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
name
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
igExists
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
subType
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
withMeta
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
subDbName
)
<
0
)
return
-
1
;
if
(
TOPIC_SUB_TYPE__DB
==
pReq
->
subType
)
{
}
else
if
(
TOPIC_SUB_TYPE__TABLE
==
pReq
->
subType
)
{
...
...
@@ -2985,6 +2986,7 @@ int32_t tDeserializeSCMCreateTopicReq(void *buf, int32_t bufLen, SCMCreateTopicR
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
name
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
igExists
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
subType
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
withMeta
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
subDbName
)
<
0
)
return
-
1
;
if
(
TOPIC_SUB_TYPE__DB
==
pReq
->
subType
)
{
}
else
if
(
TOPIC_SUB_TYPE__TABLE
==
pReq
->
subType
)
{
...
...
@@ -3052,7 +3054,7 @@ int32_t tSerializeSConnectReq(void *buf, int32_t bufLen, SConnectReq *pReq) {
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
app
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
db
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
user
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
passwd
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
WithLen
(
&
encoder
,
pReq
->
passwd
,
TSDB_PASSWORD_LEN
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
&
encoder
,
pReq
->
startTime
)
<
0
)
return
-
1
;
tEndEncode
(
&
encoder
);
...
...
source/common/src/tname.c
浏览文件 @
bae71438
...
...
@@ -312,8 +312,10 @@ void buildChildTableName(RandTableName* rName) {
taosStringBuilderAppendStringLen
(
&
sb
,
rName
->
sTableName
,
rName
->
sTableNameLen
);
taosArraySort
(
rName
->
tags
,
compareKv
);
for
(
int
j
=
0
;
j
<
taosArrayGetSize
(
rName
->
tags
);
++
j
)
{
taosStringBuilderAppendChar
(
&
sb
,
','
);
SSmlKv
*
tagKv
=
taosArrayGetP
(
rName
->
tags
,
j
);
taosStringBuilderAppendStringLen
(
&
sb
,
tagKv
->
key
,
tagKv
->
keyLen
);
taosStringBuilderAppendChar
(
&
sb
,
'='
);
if
(
IS_VAR_DATA_TYPE
(
tagKv
->
type
))
{
taosStringBuilderAppendStringLen
(
&
sb
,
tagKv
->
value
,
tagKv
->
length
);
}
else
{
...
...
@@ -326,9 +328,14 @@ void buildChildTableName(RandTableName* rName) {
tMD5Init
(
&
context
);
tMD5Update
(
&
context
,
(
uint8_t
*
)
keyJoined
,
(
uint32_t
)
len
);
tMD5Final
(
&
context
);
uint64_t
digest1
=
*
(
uint64_t
*
)(
context
.
digest
);
uint64_t
digest2
=
*
(
uint64_t
*
)(
context
.
digest
+
8
);
snprintf
(
rName
->
childTableName
,
TSDB_TABLE_NAME_LEN
,
"t_%016"
PRIx64
"%016"
PRIx64
,
digest1
,
digest2
);
char
temp
[
8
]
=
{
0
};
rName
->
childTableName
[
0
]
=
't'
;
rName
->
childTableName
[
1
]
=
'_'
;
for
(
int
i
=
0
;
i
<
16
;
i
++
){
sprintf
(
temp
,
"%02x"
,
context
.
digest
[
i
]);
strcat
(
rName
->
childTableName
,
temp
);
}
taosStringBuilderDestroy
(
&
sb
);
rName
->
uid
=
digest1
;
rName
->
uid
=
*
(
uint64_t
*
)(
context
.
digest
)
;
}
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
浏览文件 @
bae71438
...
...
@@ -73,6 +73,7 @@ int32_t mmProcessGetLoadsReq(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) {
}
int32_t
mmProcessCreateReq
(
const
SMgmtInputOpt
*
pInput
,
SRpcMsg
*
pMsg
)
{
const
STraceId
*
trace
=
&
pMsg
->
info
.
traceId
;
SDCreateMnodeReq
createReq
=
{
0
};
if
(
tDeserializeSDCreateMnodeReq
(
pMsg
->
pCont
,
pMsg
->
contLen
,
&
createReq
)
!=
0
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
...
...
@@ -81,7 +82,7 @@ int32_t mmProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) {
if
(
createReq
.
replica
!=
1
)
{
terrno
=
TSDB_CODE_INVALID_OPTION
;
dError
(
"failed to create mnode since %s"
,
terrstr
());
d
G
Error
(
"failed to create mnode since %s"
,
terrstr
());
return
-
1
;
}
...
...
@@ -91,7 +92,7 @@ int32_t mmProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) {
mgmt
.
path
=
pInput
->
path
;
mgmt
.
name
=
pInput
->
name
;
if
(
mmWriteFile
(
&
mgmt
,
&
createReq
.
replicas
[
0
],
deployed
)
!=
0
)
{
dError
(
"failed to write mnode file since %s"
,
terrstr
());
d
G
Error
(
"failed to write mnode file since %s"
,
terrstr
());
return
-
1
;
}
...
...
@@ -99,7 +100,8 @@ int32_t mmProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) {
}
int32_t
mmProcessDropReq
(
const
SMgmtInputOpt
*
pInput
,
SRpcMsg
*
pMsg
)
{
SDDropMnodeReq
dropReq
=
{
0
};
const
STraceId
*
trace
=
&
pMsg
->
info
.
traceId
;
SDDropMnodeReq
dropReq
=
{
0
};
if
(
tDeserializeSCreateDropMQSBNodeReq
(
pMsg
->
pCont
,
pMsg
->
contLen
,
&
dropReq
)
!=
0
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
return
-
1
;
...
...
@@ -107,7 +109,7 @@ int32_t mmProcessDropReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) {
if
(
pInput
->
pData
->
dnodeId
!=
0
&&
dropReq
.
dnodeId
!=
pInput
->
pData
->
dnodeId
)
{
terrno
=
TSDB_CODE_INVALID_OPTION
;
dError
(
"failed to drop mnode since %s"
,
terrstr
());
d
G
Error
(
"failed to drop mnode since %s"
,
terrstr
());
return
-
1
;
}
...
...
@@ -117,7 +119,7 @@ int32_t mmProcessDropReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) {
mgmt
.
path
=
pInput
->
path
;
mgmt
.
name
=
pInput
->
name
;
if
(
mmWriteFile
(
&
mgmt
,
NULL
,
deployed
)
!=
0
)
{
dError
(
"failed to write mnode file since %s"
,
terrstr
());
d
G
Error
(
"failed to write mnode file since %s"
,
terrstr
());
return
-
1
;
}
...
...
@@ -216,7 +218,7 @@ SArray *mmGetMsgHandles() {
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_MQ_VG_DELETE_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_DROP_TASK
,
mmPutMsgToFetchQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_STREAM_TASK_DEPLOY_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_
VND_
STREAM_TASK_DROP_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_STREAM_TASK_DROP_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_ALTER_CONFIG_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_ALTER_REPLICA_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_ALTER_CONFIRM_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
...
...
source/dnode/mgmt/mgmt_mnode/src/mmWorker.c
浏览文件 @
bae71438
...
...
@@ -18,7 +18,6 @@
static
inline
int32_t
mmAcquire
(
SMnodeMgmt
*
pMgmt
)
{
int32_t
code
=
0
;
taosThreadRwlockRdlock
(
&
pMgmt
->
lock
);
if
(
pMgmt
->
stopped
)
{
code
=
-
1
;
...
...
@@ -48,7 +47,8 @@ static inline void mmSendRsp(SRpcMsg *pMsg, int32_t code) {
static
void
mmProcessRpcMsg
(
SQueueInfo
*
pInfo
,
SRpcMsg
*
pMsg
)
{
SMnodeMgmt
*
pMgmt
=
pInfo
->
ahandle
;
int32_t
code
=
-
1
;
STraceId
*
trace
=
&
pMsg
->
info
.
traceId
;
const
STraceId
*
trace
=
&
pMsg
->
info
.
traceId
;
dGTrace
(
"msg:%p, get from mnode queue"
,
pMsg
);
switch
(
pMsg
->
msgType
)
{
...
...
@@ -72,7 +72,7 @@ static void mmProcessRpcMsg(SQueueInfo *pInfo, SRpcMsg *pMsg) {
mndPostProcessQueryMsg
(
pMsg
);
}
dTrace
(
"msg:%p, is freed, code:0x%x"
,
pMsg
,
code
);
d
G
Trace
(
"msg:%p, is freed, code:0x%x"
,
pMsg
,
code
);
rpcFreeCont
(
pMsg
->
pCont
);
taosFreeQitem
(
pMsg
);
}
...
...
@@ -80,7 +80,9 @@ static void mmProcessRpcMsg(SQueueInfo *pInfo, SRpcMsg *pMsg) {
static
void
mmProcessSyncMsg
(
SQueueInfo
*
pInfo
,
SRpcMsg
*
pMsg
)
{
SMnodeMgmt
*
pMgmt
=
pInfo
->
ahandle
;
pMsg
->
info
.
node
=
pMgmt
->
pMnode
;
dTrace
(
"msg:%p, get from mnode-sync queue"
,
pMsg
);
const
STraceId
*
trace
=
&
pMsg
->
info
.
traceId
;
dGTrace
(
"msg:%p, get from mnode-sync queue"
,
pMsg
);
SMsgHead
*
pHead
=
pMsg
->
pCont
;
pHead
->
contLen
=
ntohl
(
pHead
->
contLen
);
...
...
@@ -88,20 +90,22 @@ static void mmProcessSyncMsg(SQueueInfo *pInfo, SRpcMsg *pMsg) {
int32_t
code
=
mndProcessSyncMsg
(
pMsg
);
dTrace
(
"msg:%p, is freed, code:0x%x"
,
pMsg
,
code
);
d
G
Trace
(
"msg:%p, is freed, code:0x%x"
,
pMsg
,
code
);
rpcFreeCont
(
pMsg
->
pCont
);
taosFreeQitem
(
pMsg
);
}
static
inline
int32_t
mmPutMsgToWorker
(
SMnodeMgmt
*
pMgmt
,
SSingleWorker
*
pWorker
,
SRpcMsg
*
pMsg
)
{
const
STraceId
*
trace
=
&
pMsg
->
info
.
traceId
;
if
(
mmAcquire
(
pMgmt
)
==
0
)
{
dTrace
(
"msg:%p, put into %s queue, type:%s"
,
pMsg
,
pWorker
->
name
,
TMSG_INFO
(
pMsg
->
msgType
));
d
G
Trace
(
"msg:%p, put into %s queue, type:%s"
,
pMsg
,
pWorker
->
name
,
TMSG_INFO
(
pMsg
->
msgType
));
taosWriteQitem
(
pWorker
->
queue
,
pMsg
);
mmRelease
(
pMgmt
);
return
0
;
}
else
{
dTrace
(
"msg:%p, failed to put into %s queue since %s, type:%s"
,
pMsg
,
pWorker
->
name
,
terrstr
(),
TMSG_INFO
(
pMsg
->
msgType
));
d
G
Trace
(
"msg:%p, failed to put into %s queue since %s, type:%s"
,
pMsg
,
pWorker
->
name
,
terrstr
(),
TMSG_INFO
(
pMsg
->
msgType
));
return
-
1
;
}
}
...
...
@@ -121,19 +125,17 @@ int32_t mmPutMsgToReadQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) {
int32_t
mmPutMsgToQueryQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
pMsg
->
info
.
node
=
pMgmt
->
pMnode
;
if
(
mndPreProcessQueryMsg
(
pMsg
)
!=
0
)
{
dError
(
"msg:%p, failed to pre-process in mnode since %s, type:%s"
,
pMsg
,
terrstr
(),
TMSG_INFO
(
pMsg
->
msgType
));
const
STraceId
*
trace
=
&
pMsg
->
info
.
traceId
;
dGError
(
"msg:%p, failed to pre-process in mnode since %s, type:%s"
,
pMsg
,
terrstr
(),
TMSG_INFO
(
pMsg
->
msgType
));
return
-
1
;
}
return
mmPutMsgToWorker
(
pMgmt
,
&
pMgmt
->
queryWorker
,
pMsg
);
}
int32_t
mmPutMsgToFetchQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
pMsg
->
info
.
node
=
pMgmt
->
pMnode
;
return
mmPutMsgToWorker
(
pMgmt
,
&
pMgmt
->
fetchWorker
,
pMsg
);
}
int32_t
mmPutMsgToMonitorQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
return
mmPutMsgToWorker
(
pMgmt
,
&
pMgmt
->
monitorWorker
,
pMsg
);
}
...
...
source/dnode/mgmt/mgmt_snode/src/smHandle.c
浏览文件 @
bae71438
...
...
@@ -95,7 +95,7 @@ SArray *smGetMsgHandles() {
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MON_SM_INFO
,
smPutNodeMsgToMonitorQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_STREAM_TASK_DEPLOY
,
smPutNodeMsgToMgmtQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_
VND_
STREAM_TASK_DROP
,
smPutNodeMsgToMgmtQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_STREAM_TASK_DROP
,
smPutNodeMsgToMgmtQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_STREAM_TASK_RUN
,
smPutNodeMsgToSharedQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_STREAM_TASK_DISPATCH
,
smPutNodeMsgToSharedQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_STREAM_TASK_DISPATCH_RSP
,
smPutNodeMsgToSharedQueue
,
1
)
==
NULL
)
goto
_OVER
;
...
...
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
浏览文件 @
bae71438
...
...
@@ -351,7 +351,7 @@ SArray *vmGetMsgHandles() {
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_QUERY_HEARTBEAT
,
vmPutMsgToFetchQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_STREAM_TRIGGER
,
vmPutMsgToFetchQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_
VND_
STREAM_TASK_DROP
,
vmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_STREAM_TASK_DROP
,
vmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_STREAM_TASK_DEPLOY
,
vmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_STREAM_TASK_RUN
,
vmPutMsgToFetchQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_STREAM_TASK_DISPATCH
,
vmPutMsgToFetchQueue
,
0
)
==
NULL
)
goto
_OVER
;
...
...
source/dnode/mgmt/node_mgmt/src/dmTransport.c
浏览文件 @
bae71438
...
...
@@ -17,9 +17,44 @@
#include "dmMgmt.h"
#include "qworker.h"
static
void
dmSendRedirectRsp
(
SRpcMsg
*
pMsg
,
const
SEpSet
*
pNewEpSet
);
static
void
dmSendRsp
(
SRpcMsg
*
pMsg
);
static
void
dmBuildMnodeRedirectRsp
(
SDnode
*
pDnode
,
SRpcMsg
*
pMsg
);
static
inline
void
dmSendRsp
(
SRpcMsg
*
pMsg
)
{
SMgmtWrapper
*
pWrapper
=
pMsg
->
info
.
wrapper
;
if
(
InChildProc
(
pWrapper
))
{
dmPutToProcPQueue
(
&
pWrapper
->
proc
,
pMsg
,
DND_FUNC_RSP
);
}
else
{
rpcSendResponse
(
pMsg
);
}
}
static
inline
void
dmBuildMnodeRedirectRsp
(
SDnode
*
pDnode
,
SRpcMsg
*
pMsg
)
{
SEpSet
epSet
=
{
0
};
dmGetMnodeEpSetForRedirect
(
&
pDnode
->
data
,
pMsg
,
&
epSet
);
const
int32_t
contLen
=
tSerializeSEpSet
(
NULL
,
0
,
&
epSet
);
pMsg
->
pCont
=
rpcMallocCont
(
contLen
);
if
(
pMsg
->
pCont
==
NULL
)
{
pMsg
->
code
=
TSDB_CODE_OUT_OF_MEMORY
;
}
else
{
tSerializeSEpSet
(
pMsg
->
pCont
,
contLen
,
&
epSet
);
pMsg
->
contLen
=
contLen
;
}
}
static
inline
void
dmSendRedirectRsp
(
SRpcMsg
*
pMsg
,
const
SEpSet
*
pNewEpSet
)
{
SRpcMsg
rsp
=
{.
code
=
TSDB_CODE_RPC_REDIRECT
,
.
info
=
pMsg
->
info
};
int32_t
contLen
=
tSerializeSEpSet
(
NULL
,
0
,
pNewEpSet
);
rsp
.
pCont
=
rpcMallocCont
(
contLen
);
if
(
rsp
.
pCont
==
NULL
)
{
pMsg
->
code
=
TSDB_CODE_OUT_OF_MEMORY
;
}
else
{
tSerializeSEpSet
(
rsp
.
pCont
,
contLen
,
pNewEpSet
);
rsp
.
contLen
=
contLen
;
}
dmSendRsp
(
&
rsp
);
rpcFreeCont
(
pMsg
->
pCont
);
pMsg
->
pCont
=
NULL
;
}
int32_t
dmProcessNodeMsg
(
SMgmtWrapper
*
pWrapper
,
SRpcMsg
*
pMsg
)
{
NodeMsgFp
msgFp
=
pWrapper
->
msgFps
[
TMSG_INDEX
(
pMsg
->
msgType
)];
...
...
@@ -28,31 +63,38 @@ int32_t dmProcessNodeMsg(SMgmtWrapper *pWrapper, SRpcMsg *pMsg) {
return
-
1
;
}
dTrace
(
"msg:%p, will be processed by %s"
,
pMsg
,
pWrapper
->
name
);
const
STraceId
*
trace
=
&
pMsg
->
info
.
traceId
;
dGTrace
(
"msg:%p, will be processed by %s"
,
pMsg
,
pWrapper
->
name
);
pMsg
->
info
.
wrapper
=
pWrapper
;
return
(
*
msgFp
)(
pWrapper
->
pMgmt
,
pMsg
);
}
static
void
dmProcessRpcMsg
(
SDnode
*
pDnode
,
SRpcMsg
*
pRpc
,
SEpSet
*
pEpSet
)
{
SDnodeTrans
*
pTrans
=
&
pDnode
->
trans
;
SDnodeTrans
*
pTrans
=
&
pDnode
->
trans
;
int32_t
code
=
-
1
;
SRpcMsg
*
pMsg
=
NULL
;
SRpcMsg
*
pMsg
=
NULL
;
SMgmtWrapper
*
pWrapper
=
NULL
;
SDnodeHandle
*
pHandle
=
&
pTrans
->
msgHandles
[
TMSG_INDEX
(
pRpc
->
msgType
)];
STraceId
*
trace
=
&
pRpc
->
info
.
traceId
;
const
STraceId
*
trace
=
&
pRpc
->
info
.
traceId
;
dGTrace
(
"msg:%s is received, handle:%p len:%d code:0x%x app:%p refId:%"
PRId64
,
TMSG_INFO
(
pRpc
->
msgType
),
pRpc
->
info
.
handle
,
pRpc
->
contLen
,
pRpc
->
code
,
pRpc
->
info
.
ahandle
,
pRpc
->
info
.
refId
);
if
(
pRpc
->
msgType
==
TDMT_DND_NET_TEST
)
{
dmProcessNetTestReq
(
pDnode
,
pRpc
);
return
;
}
else
if
(
pRpc
->
msgType
==
TDMT_MND_SYSTABLE_RETRIEVE_RSP
||
pRpc
->
msgType
==
TDMT_VND_FETCH_RSP
)
{
qWorkerProcessFetchRsp
(
NULL
,
NULL
,
pRpc
,
0
);
return
;
}
else
if
(
pRpc
->
msgType
==
TDMT_MND_STATUS_RSP
&&
pEpSet
!=
NULL
)
{
dmSetMnodeEpSet
(
&
pDnode
->
data
,
pEpSet
);
}
else
{
switch
(
pRpc
->
msgType
)
{
case
TDMT_DND_NET_TEST
:
dmProcessNetTestReq
(
pDnode
,
pRpc
);
return
;
case
TDMT_MND_SYSTABLE_RETRIEVE_RSP
:
case
TDMT_VND_FETCH_RSP
:
qWorkerProcessFetchRsp
(
NULL
,
NULL
,
pRpc
,
0
);
return
;
case
TDMT_MND_STATUS_RSP
:
if
(
pEpSet
!=
NULL
)
{
dmSetMnodeEpSet
(
&
pDnode
->
data
,
pEpSet
);
}
break
;
default:
break
;
}
if
(
pDnode
->
status
!=
DND_STAT_RUNNING
)
{
...
...
@@ -73,39 +115,43 @@ static void dmProcessRpcMsg(SDnode *pDnode, SRpcMsg *pRpc, SEpSet *pEpSet) {
if
(
pHandle
->
defaultNtype
==
NODE_END
)
{
terrno
=
TSDB_CODE_MSG_NOT_PROCESSED
;
goto
_OVER
;
}
else
{
pWrapper
=
&
pDnode
->
wrappers
[
pHandle
->
defaultNtype
];
if
(
pHandle
->
needCheckVgId
)
{
if
(
pRpc
->
contLen
>
0
)
{
SMsgHead
*
pHead
=
pRpc
->
pCont
;
int32_t
vgId
=
ntohl
(
pHead
->
vgId
);
if
(
vgId
==
QNODE_HANDLE
)
{
}
pWrapper
=
&
pDnode
->
wrappers
[
pHandle
->
defaultNtype
];
if
(
pHandle
->
needCheckVgId
)
{
if
(
pRpc
->
contLen
>
0
)
{
const
SMsgHead
*
pHead
=
pRpc
->
pCont
;
const
int32_t
vgId
=
ntohl
(
pHead
->
vgId
);
switch
(
vgId
)
{
case
QNODE_HANDLE
:
pWrapper
=
&
pDnode
->
wrappers
[
QNODE
];
}
else
if
(
vgId
==
SNODE_HANDLE
)
{
break
;
case
SNODE_HANDLE
:
pWrapper
=
&
pDnode
->
wrappers
[
SNODE
];
}
else
if
(
vgId
==
MNODE_HANDLE
)
{
break
;
case
MNODE_HANDLE
:
pWrapper
=
&
pDnode
->
wrappers
[
MNODE
];
}
else
{
}
}
else
{
terrno
=
TSDB_CODE_INVALID_MSG_LEN
;
goto
_OVER
;
break
;
default:
break
;
}
}
else
{
terrno
=
TSDB_CODE_INVALID_MSG_LEN
;
goto
_OVER
;
}
}
if
(
dmMarkWrapper
(
pWrapper
)
!=
0
)
{
pWrapper
=
NULL
;
goto
_OVER
;
}
else
{
pRpc
->
info
.
wrapper
=
pWrapper
;
}
pRpc
->
info
.
wrapper
=
pWrapper
;
pMsg
=
taosAllocateQitem
(
sizeof
(
SRpcMsg
),
RPC_QITEM
);
if
(
pMsg
==
NULL
)
goto
_OVER
;
memcpy
(
pMsg
,
pRpc
,
sizeof
(
SRpcMsg
));
dTrace
(
"msg:%p, is created, type:%s handle:%p"
,
pMsg
,
TMSG_INFO
(
pRpc
->
msgType
),
pMsg
->
info
.
handle
);
memcpy
(
pMsg
,
pRpc
,
sizeof
(
SRpcMsg
));
dGTrace
(
"msg:%p, is created, type:%s handle:%p"
,
pMsg
,
TMSG_INFO
(
pRpc
->
msgType
),
pMsg
->
info
.
handle
);
if
(
InParentProc
(
pWrapper
))
{
code
=
dmPutToProcCQueue
(
&
pWrapper
->
proc
,
pMsg
,
DND_FUNC_REQ
);
...
...
@@ -115,13 +161,11 @@ static void dmProcessRpcMsg(SDnode *pDnode, SRpcMsg *pRpc, SEpSet *pEpSet) {
_OVER:
if
(
code
!=
0
)
{
dTrace
(
"failed to process msg:%p since %s, handle:%p"
,
pMsg
,
terrstr
(),
pRpc
->
info
.
handle
);
if
(
terrno
!=
0
)
code
=
terrno
;
dGTrace
(
"msg:%p, failed to process since %s"
,
pMsg
,
terrstr
());
if
(
IsReq
(
pRpc
))
{
SRpcMsg
rsp
=
{.
code
=
code
,
.
info
=
pRpc
->
info
};
if
((
code
==
TSDB_CODE_NODE_NOT_DEPLOYED
||
code
==
TSDB_CODE_APP_NOT_READY
)
&&
pRpc
->
msgType
>
TDMT_MND_MSG
&&
pRpc
->
msgType
<
TDMT_VND_MSG
)
{
dmBuildMnodeRedirectRsp
(
pDnode
,
&
rsp
);
...
...
@@ -135,7 +179,7 @@ _OVER:
}
if
(
pMsg
!=
NULL
)
{
dTrace
(
"msg:%p, is freed"
,
pMsg
);
d
G
Trace
(
"msg:%p, is freed"
,
pMsg
);
taosFreeQitem
(
pMsg
);
}
rpcFreeCont
(
pRpc
->
pCont
);
...
...
@@ -149,11 +193,11 @@ int32_t dmInitMsgHandle(SDnode *pDnode) {
for
(
EDndNodeType
ntype
=
DNODE
;
ntype
<
NODE_END
;
++
ntype
)
{
SMgmtWrapper
*
pWrapper
=
&
pDnode
->
wrappers
[
ntype
];
SArray
*
pArray
=
(
*
pWrapper
->
func
.
getHandlesFp
)();
SArray
*
pArray
=
(
*
pWrapper
->
func
.
getHandlesFp
)();
if
(
pArray
==
NULL
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pArray
);
++
i
)
{
SMgmtHandle
*
pMgmt
=
taosArrayGet
(
pArray
,
i
);
SMgmtHandle
*
pMgmt
=
taosArrayGet
(
pArray
,
i
);
SDnodeHandle
*
pHandle
=
&
pTrans
->
msgHandles
[
TMSG_INDEX
(
pMgmt
->
msgType
)];
if
(
pMgmt
->
needCheckVgId
)
{
pHandle
->
needCheckVgId
=
pMgmt
->
needCheckVgId
;
...
...
@@ -184,45 +228,6 @@ static inline int32_t dmSendReq(const SEpSet *pEpSet, SRpcMsg *pMsg) {
}
}
static
inline
void
dmSendRsp
(
SRpcMsg
*
pMsg
)
{
SMgmtWrapper
*
pWrapper
=
pMsg
->
info
.
wrapper
;
if
(
InChildProc
(
pWrapper
))
{
dmPutToProcPQueue
(
&
pWrapper
->
proc
,
pMsg
,
DND_FUNC_RSP
);
}
else
{
rpcSendResponse
(
pMsg
);
}
}
static
void
dmBuildMnodeRedirectRsp
(
SDnode
*
pDnode
,
SRpcMsg
*
pMsg
)
{
SEpSet
epSet
=
{
0
};
dmGetMnodeEpSetForRedirect
(
&
pDnode
->
data
,
pMsg
,
&
epSet
);
int32_t
contLen
=
tSerializeSEpSet
(
NULL
,
0
,
&
epSet
);
pMsg
->
pCont
=
rpcMallocCont
(
contLen
);
if
(
pMsg
->
pCont
==
NULL
)
{
pMsg
->
code
=
TSDB_CODE_OUT_OF_MEMORY
;
}
else
{
tSerializeSEpSet
(
pMsg
->
pCont
,
contLen
,
&
epSet
);
pMsg
->
contLen
=
contLen
;
}
}
static
inline
void
dmSendRedirectRsp
(
SRpcMsg
*
pMsg
,
const
SEpSet
*
pNewEpSet
)
{
SRpcMsg
rsp
=
{.
code
=
TSDB_CODE_RPC_REDIRECT
,
.
info
=
pMsg
->
info
};
int32_t
contLen
=
tSerializeSEpSet
(
NULL
,
0
,
pNewEpSet
);
rsp
.
pCont
=
rpcMallocCont
(
contLen
);
if
(
rsp
.
pCont
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
}
else
{
tSerializeSEpSet
(
rsp
.
pCont
,
contLen
,
pNewEpSet
);
rsp
.
contLen
=
contLen
;
}
dmSendRsp
(
&
rsp
);
rpcFreeCont
(
pMsg
->
pCont
);
pMsg
->
pCont
=
NULL
;
}
static
inline
void
dmRegisterBrokenLinkArg
(
SRpcMsg
*
pMsg
)
{
SMgmtWrapper
*
pWrapper
=
pMsg
->
info
.
wrapper
;
if
(
InChildProc
(
pWrapper
))
{
...
...
source/dnode/mgmt/node_util/inc/dmUtil.h
浏览文件 @
bae71438
...
...
@@ -40,18 +40,27 @@
#include "wal.h"
#include "libs/function/function.h"
// clang-format off
#ifdef __cplusplus
extern
"C"
{
#endif
#define dFatal(...) { if (dDebugFlag & DEBUG_FATAL) { taosPrintLog("DND FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); }}
#define dError(...) { if (dDebugFlag & DEBUG_ERROR) { taosPrintLog("DND ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }}
#define dWarn(...) { if (dDebugFlag & DEBUG_WARN) { taosPrintLog("DND WARN ", DEBUG_WARN, 255, __VA_ARGS__); }}
#define dInfo(...) { if (dDebugFlag & DEBUG_INFO) { taosPrintLog("DND ", DEBUG_INFO, 255, __VA_ARGS__); }}
#define dDebug(...) { if (dDebugFlag & DEBUG_DEBUG) { taosPrintLog("DND ", DEBUG_DEBUG, dDebugFlag, __VA_ARGS__); }}
#define dTrace(...) { if (dDebugFlag & DEBUG_TRACE) { taosPrintLog("DND ", DEBUG_TRACE, dDebugFlag, __VA_ARGS__); }}
#define dGTrace(param, ...) do { char buf[40] = {0}; TRACE_TO_STR(trace, buf); dTrace(param ",GTID: %s", __VA_ARGS__, buf);} while(0)
// clang-format off
#define dFatal(...) { if (dDebugFlag & DEBUG_FATAL) { taosPrintLog("DND FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); }}
#define dError(...) { if (dDebugFlag & DEBUG_ERROR) { taosPrintLog("DND ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }}
#define dWarn(...) { if (dDebugFlag & DEBUG_WARN) { taosPrintLog("DND WARN ", DEBUG_WARN, 255, __VA_ARGS__); }}
#define dInfo(...) { if (dDebugFlag & DEBUG_INFO) { taosPrintLog("DND ", DEBUG_INFO, 255, __VA_ARGS__); }}
#define dDebug(...) { if (dDebugFlag & DEBUG_DEBUG) { taosPrintLog("DND ", DEBUG_DEBUG, dDebugFlag, __VA_ARGS__); }}
#define dTrace(...) { if (dDebugFlag & DEBUG_TRACE) { taosPrintLog("DND ", DEBUG_TRACE, dDebugFlag, __VA_ARGS__); }}
#define dGFatal(param, ...) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); dFatal(param ", gtid:%s", __VA_ARGS__, buf);}
#define dGError(param, ...) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); dError(param ", gtid:%s", __VA_ARGS__, buf);}
#define dGWarn(param, ...) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); dWarn (param ", gtid:%s", __VA_ARGS__, buf);}
#define dGInfo(param, ...) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); dInfo (param ", gtid:%s", __VA_ARGS__, buf);}
#define dGDebug(param, ...) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); dDebug(param ", gtid:%s", __VA_ARGS__, buf);}
#define dGTrace(param, ...) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); dTrace(param ", gtid:%s", __VA_ARGS__, buf);}
// clang-format on
typedef
enum
{
DNODE
=
0
,
...
...
@@ -185,4 +194,3 @@ void dmSetMnodeEpSet(SDnodeData *pData, SEpSet *pEpSet);
#endif
#endif
/*_TD_DM_INT_H_*/
// clang-format on
source/dnode/mgmt/test/sut/src/sut.cpp
浏览文件 @
bae71438
...
...
@@ -102,6 +102,7 @@ int32_t Testbase::SendShowReq(int8_t showType, const char* tb, const char* db) {
ASSERT
(
pRsp
->
pCont
!=
nullptr
);
if
(
pRsp
->
contLen
==
0
)
return
-
1
;
if
(
pRsp
->
code
!=
0
)
return
-
1
;
showRsp
=
(
SRetrieveMetaTableRsp
*
)
pRsp
->
pCont
;
showRsp
->
handle
=
htobe64
(
showRsp
->
handle
);
// show Id
...
...
source/dnode/mnode/impl/inc/mndDef.h
浏览文件 @
bae71438
...
...
@@ -420,7 +420,8 @@ typedef struct {
int64_t
uid
;
int64_t
dbUid
;
int32_t
version
;
int8_t
subType
;
// column, db or stable
int8_t
subType
;
// column, db or stable
int8_t
withMeta
;
// TODO
SRWLatch
lock
;
int32_t
sqlLen
;
int32_t
astLen
;
...
...
@@ -487,6 +488,7 @@ typedef struct {
int64_t
dbUid
;
int32_t
vgNum
;
int8_t
subType
;
int8_t
withMeta
;
int64_t
stbUid
;
SHashObj
*
consumerHash
;
// consumerId -> SMqConsumerEp
SArray
*
unassignedVgs
;
// SArray<SMqVgEp*>
...
...
source/dnode/mnode/impl/inc/mndInt.h
浏览文件 @
bae71438
...
...
@@ -34,13 +34,20 @@ extern "C" {
#endif
// clang-format off
#define mFatal(...) { if (mDebugFlag & DEBUG_FATAL) { taosPrintLog("MND FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); }}
#define mError(...) { if (mDebugFlag & DEBUG_ERROR) { taosPrintLog("MND ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }}
#define mWarn(...) { if (mDebugFlag & DEBUG_WARN) { taosPrintLog("MND WARN ", DEBUG_WARN, 255, __VA_ARGS__); }}
#define mInfo(...) { if (mDebugFlag & DEBUG_INFO) { taosPrintLog("MND ", DEBUG_INFO, 255, __VA_ARGS__); }}
#define mDebug(...) { if (mDebugFlag & DEBUG_DEBUG) { taosPrintLog("MND ", DEBUG_DEBUG, mDebugFlag, __VA_ARGS__); }}
#define mTrace(...) { if (mDebugFlag & DEBUG_TRACE) { taosPrintLog("MND ", DEBUG_TRACE, mDebugFlag, __VA_ARGS__); }}
#define mGTrace(param, ...) do { char buf[40] = {0}; TRACE_TO_STR(trace, buf); mTrace(param ", GTID: %s", __VA_ARGS__, buf);} while(0)
#define mFatal(...) { if (mDebugFlag & DEBUG_FATAL) { taosPrintLog("MND FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); }}
#define mError(...) { if (mDebugFlag & DEBUG_ERROR) { taosPrintLog("MND ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }}
#define mWarn(...) { if (mDebugFlag & DEBUG_WARN) { taosPrintLog("MND WARN ", DEBUG_WARN, 255, __VA_ARGS__); }}
#define mInfo(...) { if (mDebugFlag & DEBUG_INFO) { taosPrintLog("MND ", DEBUG_INFO, 255, __VA_ARGS__); }}
#define mDebug(...) { if (mDebugFlag & DEBUG_DEBUG) { taosPrintLog("MND ", DEBUG_DEBUG, mDebugFlag, __VA_ARGS__); }}
#define mTrace(...) { if (mDebugFlag & DEBUG_TRACE) { taosPrintLog("MND ", DEBUG_TRACE, mDebugFlag, __VA_ARGS__); }}
#define mGFatal(param, ...) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); mFatal(param ", gtid:%s", __VA_ARGS__, buf);}
#define mGError(param, ...) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); mError(param ", gtid:%s", __VA_ARGS__, buf);}
#define mGWarn(param, ...) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); mWarn (param ", gtid:%s", __VA_ARGS__, buf);}
#define mGInfo(param, ...) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); mInfo (param ", gtid:%s", __VA_ARGS__, buf);}
#define mGDebug(param, ...) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); mDebug(param ", gtid:%s", __VA_ARGS__, buf);}
#define mGTrace(param, ...) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); mTrace(param ", gtid:%s", __VA_ARGS__, buf);}
// clang-format on
...
...
source/dnode/mnode/impl/src/mndDef.c
浏览文件 @
bae71438
...
...
@@ -381,6 +381,7 @@ SMqSubscribeObj *tCloneSubscribeObj(const SMqSubscribeObj *pSub) {
pSubNew
->
dbUid
=
pSub
->
dbUid
;
pSubNew
->
stbUid
=
pSub
->
stbUid
;
pSubNew
->
subType
=
pSub
->
subType
;
pSubNew
->
withMeta
=
pSub
->
withMeta
;
pSubNew
->
vgNum
=
pSub
->
vgNum
;
pSubNew
->
consumerHash
=
taosHashInit
(
64
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
false
,
HASH_NO_LOCK
);
...
...
@@ -414,6 +415,7 @@ int32_t tEncodeSubscribeObj(void **buf, const SMqSubscribeObj *pSub) {
tlen
+=
taosEncodeFixedI64
(
buf
,
pSub
->
dbUid
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pSub
->
vgNum
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pSub
->
subType
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pSub
->
withMeta
);
tlen
+=
taosEncodeFixedI64
(
buf
,
pSub
->
stbUid
);
void
*
pIter
=
NULL
;
...
...
@@ -440,6 +442,7 @@ void *tDecodeSubscribeObj(const void *buf, SMqSubscribeObj *pSub) {
buf
=
taosDecodeFixedI64
(
buf
,
&
pSub
->
dbUid
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pSub
->
vgNum
);
buf
=
taosDecodeFixedI8
(
buf
,
&
pSub
->
subType
);
buf
=
taosDecodeFixedI8
(
buf
,
&
pSub
->
withMeta
);
buf
=
taosDecodeFixedI64
(
buf
,
&
pSub
->
stbUid
);
int32_t
sz
;
...
...
source/dnode/mnode/impl/src/mndMain.c
浏览文件 @
bae71438
...
...
@@ -59,22 +59,28 @@ static void *mndBuildTimerMsg(int32_t *pContLen) {
static
void
mndPullupTrans
(
SMnode
*
pMnode
)
{
int32_t
contLen
=
0
;
void
*
pReq
=
mndBuildTimerMsg
(
&
contLen
);
SRpcMsg
rpcMsg
=
{.
msgType
=
TDMT_MND_TRANS_TIMER
,
.
pCont
=
pReq
,
.
contLen
=
contLen
};
tmsgPutToQueue
(
&
pMnode
->
msgCb
,
WRITE_QUEUE
,
&
rpcMsg
);
if
(
pReq
!=
NULL
)
{
SRpcMsg
rpcMsg
=
{.
msgType
=
TDMT_MND_TRANS_TIMER
,
.
pCont
=
pReq
,
.
contLen
=
contLen
};
tmsgPutToQueue
(
&
pMnode
->
msgCb
,
WRITE_QUEUE
,
&
rpcMsg
);
}
}
static
void
mndCalMqRebalance
(
SMnode
*
pMnode
)
{
int32_t
contLen
=
0
;
void
*
pReq
=
mndBuildTimerMsg
(
&
contLen
);
SRpcMsg
rpcMsg
=
{.
msgType
=
TDMT_MND_MQ_TIMER
,
.
pCont
=
pReq
,
.
contLen
=
contLen
};
tmsgPutToQueue
(
&
pMnode
->
msgCb
,
READ_QUEUE
,
&
rpcMsg
);
if
(
pReq
!=
NULL
)
{
SRpcMsg
rpcMsg
=
{.
msgType
=
TDMT_MND_MQ_TIMER
,
.
pCont
=
pReq
,
.
contLen
=
contLen
};
tmsgPutToQueue
(
&
pMnode
->
msgCb
,
READ_QUEUE
,
&
rpcMsg
);
}
}
static
void
mndPullupTelem
(
SMnode
*
pMnode
)
{
int32_t
contLen
=
0
;
void
*
pReq
=
mndBuildTimerMsg
(
&
contLen
);
SRpcMsg
rpcMsg
=
{.
msgType
=
TDMT_MND_TELEM_TIMER
,
.
pCont
=
pReq
,
.
contLen
=
contLen
};
tmsgPutToQueue
(
&
pMnode
->
msgCb
,
READ_QUEUE
,
&
rpcMsg
);
if
(
pReq
!=
NULL
)
{
SRpcMsg
rpcMsg
=
{.
msgType
=
TDMT_MND_TELEM_TIMER
,
.
pCont
=
pReq
,
.
contLen
=
contLen
};
tmsgPutToQueue
(
&
pMnode
->
msgCb
,
READ_QUEUE
,
&
rpcMsg
);
}
}
static
void
mndPushTtlTime
(
SMnode
*
pMnode
)
{
...
...
@@ -89,10 +95,11 @@ static void mndPushTtlTime(SMnode *pMnode) {
int32_t
contLen
=
sizeof
(
SMsgHead
)
+
sizeof
(
int32_t
);
SMsgHead
*
pHead
=
rpcMallocCont
(
contLen
);
if
(
pHead
==
NULL
)
{
mError
(
"ttl time malloc err. contLen:%d"
,
contLen
);
sdbCancelFetch
(
pSdb
,
pIter
);
sdbRelease
(
pSdb
,
pVgroup
);
continue
;
}
pHead
->
contLen
=
htonl
(
contLen
);
pHead
->
vgId
=
htonl
(
pVgroup
->
vgId
);
...
...
@@ -100,13 +107,13 @@ static void mndPushTtlTime(SMnode *pMnode) {
*
(
int32_t
*
)(
POINTER_SHIFT
(
pHead
,
sizeof
(
SMsgHead
)))
=
htonl
(
t
);
SRpcMsg
rpcMsg
=
{.
msgType
=
TDMT_VND_DROP_TTL_TABLE
,
.
pCont
=
pHead
,
.
contLen
=
contLen
};
SEpSet
epSet
=
mndGetVgroupEpset
(
pMnode
,
pVgroup
);
int32_t
code
=
tmsgSendReq
(
&
epSet
,
&
rpcMsg
);
if
(
code
!=
0
)
{
mError
(
"ttl time seed err. code:%d"
,
code
);
mError
(
"failed to send ttl time seed msg, code:0x%x"
,
code
);
}
else
{
mInfo
(
"send ttl time seed msg, time:%d"
,
t
);
}
mError
(
"ttl time seed succ. time:%d"
,
t
);
sdbRelease
(
pSdb
,
pVgroup
);
}
}
...
...
@@ -117,7 +124,7 @@ static void *mndThreadFp(void *param) {
setThreadName
(
"mnode-timer"
);
while
(
1
)
{
if
(
lastTime
%
(
864000
)
==
0
)
{
// sleep 1 day for ttl
if
(
lastTime
%
864000
==
0
)
{
mndPushTtlTime
(
pMnode
);
}
...
...
@@ -549,23 +556,25 @@ int32_t mndProcessSyncMsg(SRpcMsg *pMsg) {
static
int32_t
mndCheckMnodeState
(
SRpcMsg
*
pMsg
)
{
if
(
!
IsReq
(
pMsg
))
return
0
;
if
(
mndAcquireRpcRef
(
pMsg
->
info
.
node
)
==
0
)
return
0
;
if
(
pMsg
->
msgType
==
TDMT_MND_MQ_TIMER
||
pMsg
->
msgType
==
TDMT_MND_TELEM_TIMER
||
pMsg
->
msgType
==
TDMT_MND_TRANS_TIMER
)
{
return
-
1
;
}
if
(
pMsg
->
msgType
!=
TDMT_MND_MQ_TIMER
&&
pMsg
->
msgType
!=
TDMT_MND_TELEM_TIMER
&&
pMsg
->
msgType
!=
TDMT_MND_TRANS_TIMER
)
{
mError
(
"msg:%p, failed to check mnode state since %s, type:%s"
,
pMsg
,
terrstr
(),
TMSG_INFO
(
pMsg
->
msgType
));
const
STraceId
*
trace
=
&
pMsg
->
info
.
traceId
;
mGError
(
"msg:%p, failed to check mnode state since %s, type:%s"
,
pMsg
,
terrstr
(),
TMSG_INFO
(
pMsg
->
msgType
));
SEpSet
epSet
=
{
0
};
mndGetMnodeEpSet
(
pMsg
->
info
.
node
,
&
epSet
);
SEpSet
epSet
=
{
0
};
mndGetMnodeEpSet
(
pMsg
->
info
.
node
,
&
epSet
);
int32_t
contLen
=
tSerializeSEpSet
(
NULL
,
0
,
&
epSet
);
pMsg
->
info
.
rsp
=
rpcMallocCont
(
contLen
);
if
(
pMsg
->
info
.
rsp
!=
NULL
)
{
tSerializeSEpSet
(
pMsg
->
info
.
rsp
,
contLen
,
&
epSet
);
pMsg
->
info
.
rspLen
=
contLen
;
terrno
=
TSDB_CODE_RPC_REDIRECT
;
}
else
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
}
int32_t
contLen
=
tSerializeSEpSet
(
NULL
,
0
,
&
epSet
);
pMsg
->
info
.
rsp
=
rpcMallocCont
(
contLen
);
if
(
pMsg
->
info
.
rsp
!=
NULL
)
{
tSerializeSEpSet
(
pMsg
->
info
.
rsp
,
contLen
,
&
epSet
);
pMsg
->
info
.
rspLen
=
contLen
;
terrno
=
TSDB_CODE_RPC_REDIRECT
;
}
else
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
}
return
-
1
;
...
...
@@ -575,17 +584,20 @@ static int32_t mndCheckMsgContent(SRpcMsg *pMsg) {
if
(
!
IsReq
(
pMsg
))
return
0
;
if
(
pMsg
->
contLen
!=
0
&&
pMsg
->
pCont
!=
NULL
)
return
0
;
mError
(
"msg:%p, failed to check msg, cont:%p contLen:%d, app:%p type:%s"
,
pMsg
,
pMsg
->
pCont
,
pMsg
->
contLen
,
const
STraceId
*
trace
=
&
pMsg
->
info
.
traceId
;
mGError
(
"msg:%p, failed to check msg, cont:%p contLen:%d, app:%p type:%s"
,
pMsg
,
pMsg
->
pCont
,
pMsg
->
contLen
,
pMsg
->
info
.
ahandle
,
TMSG_INFO
(
pMsg
->
msgType
));
terrno
=
TSDB_CODE_INVALID_MSG_LEN
;
return
-
1
;
}
int32_t
mndProcessRpcMsg
(
SRpcMsg
*
pMsg
)
{
SMnode
*
pMnode
=
pMsg
->
info
.
node
;
SMnode
*
pMnode
=
pMsg
->
info
.
node
;
const
STraceId
*
trace
=
&
pMsg
->
info
.
traceId
;
MndMsgFp
fp
=
pMnode
->
msgFp
[
TMSG_INDEX
(
pMsg
->
msgType
)];
if
(
fp
==
NULL
)
{
mError
(
"msg:%p, failed to get msg handle, app:%p type:%s"
,
pMsg
,
pMsg
->
info
.
ahandle
,
TMSG_INFO
(
pMsg
->
msgType
));
m
G
Error
(
"msg:%p, failed to get msg handle, app:%p type:%s"
,
pMsg
,
pMsg
->
info
.
ahandle
,
TMSG_INFO
(
pMsg
->
msgType
));
terrno
=
TSDB_CODE_MSG_NOT_PROCESSED
;
return
-
1
;
}
...
...
@@ -593,18 +605,17 @@ int32_t mndProcessRpcMsg(SRpcMsg *pMsg) {
if
(
mndCheckMsgContent
(
pMsg
)
!=
0
)
return
-
1
;
if
(
mndCheckMnodeState
(
pMsg
)
!=
0
)
return
-
1
;
STraceId
*
trace
=
&
pMsg
->
info
.
traceId
;
mGTrace
(
"msg:%p, start to process in mnode, app:%p type:%s"
,
pMsg
,
pMsg
->
info
.
ahandle
,
TMSG_INFO
(
pMsg
->
msgType
));
int32_t
code
=
(
*
fp
)(
pMsg
);
mndReleaseRpcRef
(
pMnode
);
if
(
code
==
TSDB_CODE_ACTION_IN_PROGRESS
)
{
mTrace
(
"msg:%p, won't response immediately since in progress"
,
pMsg
);
m
G
Trace
(
"msg:%p, won't response immediately since in progress"
,
pMsg
);
}
else
if
(
code
==
0
)
{
mTrace
(
"msg:%p, successfully processed"
,
pMsg
);
m
G
Trace
(
"msg:%p, successfully processed"
,
pMsg
);
}
else
{
mError
(
"msg:%p, failed to process since %s, app:%p type:%s"
,
pMsg
,
terrstr
(),
pMsg
->
info
.
ahandle
,
TMSG_INFO
(
pMsg
->
msgType
));
m
G
Error
(
"msg:%p, failed to process since %s, app:%p type:%s"
,
pMsg
,
terrstr
(),
pMsg
->
info
.
ahandle
,
TMSG_INFO
(
pMsg
->
msgType
));
}
return
code
;
...
...
@@ -620,7 +631,6 @@ void mndSetMsgHandle(SMnode *pMnode, tmsg_t msgType, MndMsgFp fp) {
// Note: uid 0 is reserved
int64_t
mndGenerateUid
(
char
*
name
,
int32_t
len
)
{
int32_t
hashval
=
MurmurHash3_32
(
name
,
len
);
do
{
int64_t
us
=
taosGetTimestampUs
();
int64_t
x
=
(
us
&
0x000000FFFFFFFFFF
)
<<
24
;
...
...
source/dnode/mnode/impl/src/mndProfile.c
浏览文件 @
bae71438
...
...
@@ -122,30 +122,33 @@ static SConnObj *mndCreateConn(SMnode *pMnode, const char *user, int8_t connType
int32_t
pid
,
const
char
*
app
,
int64_t
startTime
)
{
SProfileMgmt
*
pMgmt
=
&
pMnode
->
profileMgmt
;
char
connStr
[
255
]
=
{
0
};
int32_t
len
=
snprintf
(
connStr
,
sizeof
(
connStr
),
"%s%d%d%d%s"
,
user
,
ip
,
port
,
pid
,
app
);
char
connStr
[
255
]
=
{
0
};
int32_t
len
=
snprintf
(
connStr
,
sizeof
(
connStr
),
"%s%d%d%d%s"
,
user
,
ip
,
port
,
pid
,
app
);
uint32_t
connId
=
mndGenerateUid
(
connStr
,
len
);
if
(
startTime
==
0
)
startTime
=
taosGetTimestampMs
();
SConnObj
connObj
=
{.
id
=
connId
,
.
connType
=
connType
,
.
appStartTimeMs
=
startTime
,
.
pid
=
pid
,
.
ip
=
ip
,
.
port
=
port
,
.
killed
=
0
,
.
loginTimeMs
=
taosGetTimestampMs
(),
.
lastAccessTimeMs
=
0
,
.
killId
=
0
,
.
numOfQueries
=
0
,
.
pQueries
=
NULL
};
SConnObj
connObj
=
{
.
id
=
connId
,
.
connType
=
connType
,
.
appStartTimeMs
=
startTime
,
.
pid
=
pid
,
.
ip
=
ip
,
.
port
=
port
,
.
killed
=
0
,
.
loginTimeMs
=
taosGetTimestampMs
(),
.
lastAccessTimeMs
=
0
,
.
killId
=
0
,
.
numOfQueries
=
0
,
.
pQueries
=
NULL
,
};
connObj
.
lastAccessTimeMs
=
connObj
.
loginTimeMs
;
tstrncpy
(
connObj
.
user
,
user
,
TSDB_USER_LEN
);
tstrncpy
(
connObj
.
app
,
app
,
TSDB_APP_NAME_LEN
);
int32_t
keepTime
=
tsShellActivityTimer
*
3
;
SConnObj
*
pConn
=
taosCachePut
(
pMgmt
->
connCache
,
&
connId
,
sizeof
(
uint32_t
),
&
connObj
,
sizeof
(
connObj
),
keepTime
*
1000
);
SConnObj
*
pConn
=
taosCachePut
(
pMgmt
->
connCache
,
&
connId
,
sizeof
(
uint32_t
),
&
connObj
,
sizeof
(
connObj
),
keepTime
*
1000
);
if
(
pConn
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
mError
(
"conn:%d, failed to put into cache since %s, user:%s"
,
connId
,
user
,
terrstr
());
...
...
@@ -174,7 +177,6 @@ static SConnObj *mndAcquireConn(SMnode *pMnode, uint32_t connId) {
}
pConn
->
lastAccessTimeMs
=
taosGetTimestampMs
();
mTrace
(
"conn:%u, acquired from cache, data:%p"
,
pConn
->
id
,
pConn
);
return
pConn
;
}
...
...
@@ -207,13 +209,14 @@ static void mndCancelGetNextConn(SMnode *pMnode, void *pIter) {
}
static
int32_t
mndProcessConnectReq
(
SRpcMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
info
.
node
;
SUserObj
*
pUser
=
NULL
;
SDbObj
*
pDb
=
NULL
;
SConnObj
*
pConn
=
NULL
;
int32_t
code
=
-
1
;
SConnectReq
connReq
=
{
0
};
char
ip
[
30
]
=
{
0
};
SMnode
*
pMnode
=
pReq
->
info
.
node
;
SUserObj
*
pUser
=
NULL
;
SDbObj
*
pDb
=
NULL
;
SConnObj
*
pConn
=
NULL
;
int32_t
code
=
-
1
;
SConnectReq
connReq
=
{
0
};
char
ip
[
30
]
=
{
0
};
const
STraceId
*
trace
=
&
pReq
->
info
.
traceId
;
if
(
tDeserializeSConnectReq
(
pReq
->
pCont
,
pReq
->
contLen
,
&
connReq
)
!=
0
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
...
...
@@ -224,11 +227,11 @@ static int32_t mndProcessConnectReq(SRpcMsg *pReq) {
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
info
.
conn
.
user
);
if
(
pUser
==
NULL
)
{
mError
(
"user:%s, failed to login while acquire user since %s"
,
pReq
->
info
.
conn
.
user
,
terrstr
());
m
G
Error
(
"user:%s, failed to login while acquire user since %s"
,
pReq
->
info
.
conn
.
user
,
terrstr
());
goto
CONN_OVER
;
}
if
(
0
!=
strncmp
(
connReq
.
passwd
,
pUser
->
pass
,
TSDB_PASSWORD_LEN
-
1
))
{
mError
(
"user:%s, failed to auth while acquire user, input:%s"
,
pReq
->
info
.
conn
.
user
,
connReq
.
passwd
);
m
G
Error
(
"user:%s, failed to auth while acquire user, input:%s"
,
pReq
->
info
.
conn
.
user
,
connReq
.
passwd
);
code
=
TSDB_CODE_RPC_AUTH_FAILURE
;
goto
CONN_OVER
;
}
...
...
@@ -239,8 +242,8 @@ static int32_t mndProcessConnectReq(SRpcMsg *pReq) {
pDb
=
mndAcquireDb
(
pMnode
,
db
);
if
(
pDb
==
NULL
)
{
terrno
=
TSDB_CODE_MND_INVALID_DB
;
mError
(
"user:%s, failed to login from %s while use db:%s since %s"
,
pReq
->
info
.
conn
.
user
,
ip
,
connReq
.
db
,
terrstr
());
m
G
Error
(
"user:%s, failed to login from %s while use db:%s since %s"
,
pReq
->
info
.
conn
.
user
,
ip
,
connReq
.
db
,
terrstr
());
goto
CONN_OVER
;
}
}
...
...
@@ -248,7 +251,7 @@ static int32_t mndProcessConnectReq(SRpcMsg *pReq) {
pConn
=
mndCreateConn
(
pMnode
,
pReq
->
info
.
conn
.
user
,
connReq
.
connType
,
pReq
->
info
.
conn
.
clientIp
,
pReq
->
info
.
conn
.
clientPort
,
connReq
.
pid
,
connReq
.
app
,
connReq
.
startTime
);
if
(
pConn
==
NULL
)
{
mError
(
"user:%s, failed to login from %s while create connection since %s"
,
pReq
->
info
.
conn
.
user
,
ip
,
terrstr
());
m
G
Error
(
"user:%s, failed to login from %s while create connection since %s"
,
pReq
->
info
.
conn
.
user
,
ip
,
terrstr
());
goto
CONN_OVER
;
}
...
...
@@ -273,7 +276,7 @@ static int32_t mndProcessConnectReq(SRpcMsg *pReq) {
pReq
->
info
.
rspLen
=
contLen
;
pReq
->
info
.
rsp
=
pRsp
;
mDebug
(
"user:%s, login from %s:%d, conn:%u, app:%s"
,
pReq
->
info
.
conn
.
user
,
ip
,
pConn
->
port
,
pConn
->
id
,
connReq
.
app
);
m
G
Debug
(
"user:%s, login from %s:%d, conn:%u, app:%s"
,
pReq
->
info
.
conn
.
user
,
ip
,
pConn
->
port
,
pConn
->
id
,
connReq
.
app
);
code
=
0
;
...
...
@@ -302,7 +305,7 @@ static int32_t mndSaveQueryList(SConnObj *pConn, SQueryHbReqBasic *pBasic) {
return
TSDB_CODE_SUCCESS
;
}
static
SAppObj
*
mndCreateApp
(
SMnode
*
pMnode
,
uint32_t
clientIp
,
SAppHbReq
*
pReq
)
{
static
SAppObj
*
mndCreateApp
(
SMnode
*
pMnode
,
uint32_t
clientIp
,
SAppHbReq
*
pReq
)
{
SProfileMgmt
*
pMgmt
=
&
pMnode
->
profileMgmt
;
SAppObj
app
;
...
...
@@ -314,22 +317,19 @@ static SAppObj *mndCreateApp(SMnode *pMnode, uint32_t clientIp, SAppHbReq* pReq)
memcpy
(
&
app
.
summary
,
&
pReq
->
summary
,
sizeof
(
pReq
->
summary
));
app
.
lastAccessTimeMs
=
taosGetTimestampMs
();
int32_t
keepTime
=
tsShellActivityTimer
*
3
;
const
int32_t
keepTime
=
tsShellActivityTimer
*
3
;
SAppObj
*
pApp
=
taosCachePut
(
pMgmt
->
appCache
,
&
pReq
->
appId
,
sizeof
(
pReq
->
appId
),
&
app
,
sizeof
(
app
),
keepTime
*
1000
);
if
(
pApp
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
mError
(
"failed to app %"
PRIx64
" into cache since %s"
,
pReq
->
appId
,
terrstr
());
return
NULL
;
}
mTrace
(
"app %"
PRIx64
" is put into cache"
,
pReq
->
appId
);
return
pApp
;
}
static
void
mndFreeApp
(
SAppObj
*
pApp
)
{
mTrace
(
"app %"
PRIx64
" is destroyed"
,
pApp
->
appId
);
}
static
void
mndFreeApp
(
SAppObj
*
pApp
)
{
mTrace
(
"app %"
PRIx64
" is destroyed"
,
pApp
->
appId
);
}
static
SAppObj
*
mndAcquireApp
(
SMnode
*
pMnode
,
int64_t
appId
)
{
SProfileMgmt
*
pMgmt
=
&
pMnode
->
profileMgmt
;
...
...
@@ -356,7 +356,7 @@ static void mndReleaseApp(SMnode *pMnode, SAppObj *pApp) {
void
*
mndGetNextApp
(
SMnode
*
pMnode
,
SCacheIter
*
pIter
)
{
SAppObj
*
pApp
=
NULL
;
bool
hasNext
=
taosCacheIterNext
(
pIter
);
bool
hasNext
=
taosCacheIterNext
(
pIter
);
if
(
hasNext
)
{
size_t
dataLen
=
0
;
pApp
=
taosCacheIterGetData
(
pIter
,
&
dataLen
);
...
...
@@ -439,8 +439,8 @@ static SClientHbRsp *mndMqHbBuildRsp(SMnode *pMnode, SClientHbReq *pReq) {
}
static
int32_t
mndUpdateAppInfo
(
SMnode
*
pMnode
,
SClientHbReq
*
pHbReq
,
SRpcConnInfo
*
connInfo
)
{
SAppHbReq
*
pReq
=
&
pHbReq
->
app
;
SAppObj
*
pApp
=
mndAcquireApp
(
pMnode
,
pReq
->
appId
);
SAppHbReq
*
pReq
=
&
pHbReq
->
app
;
SAppObj
*
pApp
=
mndAcquireApp
(
pMnode
,
pReq
->
appId
);
if
(
pApp
==
NULL
)
{
pApp
=
mndCreateApp
(
pMnode
,
connInfo
->
clientIp
,
pReq
);
if
(
pApp
==
NULL
)
{
...
...
@@ -448,7 +448,7 @@ static int32_t mndUpdateAppInfo(SMnode *pMnode, SClientHbReq *pHbReq, SRpcConnIn
return
-
1
;
}
else
{
mDebug
(
"a new app %"
PRIx64
"created"
,
pReq
->
appId
);
mndReleaseApp
(
pMnode
,
pApp
);
mndReleaseApp
(
pMnode
,
pApp
);
return
TSDB_CODE_SUCCESS
;
}
}
...
...
@@ -464,7 +464,7 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb
SClientHbBatchRsp
*
pBatchRsp
)
{
SProfileMgmt
*
pMgmt
=
&
pMnode
->
profileMgmt
;
SClientHbRsp
hbRsp
=
{.
connKey
=
pHbReq
->
connKey
,
.
status
=
0
,
.
info
=
NULL
,
.
query
=
NULL
};
SRpcConnInfo
connInfo
=
pMsg
->
info
.
conn
;
SRpcConnInfo
connInfo
=
pMsg
->
info
.
conn
;
mndUpdateAppInfo
(
pMnode
,
pHbReq
,
&
connInfo
);
...
...
@@ -637,9 +637,9 @@ static int32_t mndProcessKillQueryReq(SRpcMsg *pReq) {
}
mInfo
(
"kill query msg is received, queryId:%s"
,
killReq
.
queryStrId
);
int32_t
connId
=
0
;
int32_t
connId
=
0
;
uint64_t
queryId
=
0
;
char
*
p
=
strchr
(
killReq
.
queryStrId
,
':'
);
char
*
p
=
strchr
(
killReq
.
queryStrId
,
':'
);
if
(
NULL
==
p
)
{
mError
(
"invalid query id %s"
,
killReq
.
queryStrId
);
terrno
=
TSDB_CODE_MND_INVALID_QUERY_ID
;
...
...
@@ -853,12 +853,12 @@ static int32_t mndRetrieveQueries(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *p
}
static
int32_t
mndRetrieveApps
(
SRpcMsg
*
pReq
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rows
)
{
SMnode
*
pMnode
=
pReq
->
info
.
node
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int32_t
numOfRows
=
0
;
int32_t
cols
=
0
;
SAppObj
*
pApp
=
NULL
;
SMnode
*
pMnode
=
pReq
->
info
.
node
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int32_t
numOfRows
=
0
;
int32_t
cols
=
0
;
SAppObj
*
pApp
=
NULL
;
if
(
pShow
->
pIter
==
NULL
)
{
SProfileMgmt
*
pMgmt
=
&
pMnode
->
profileMgmt
;
pShow
->
pIter
=
taosCacheCreateIter
(
pMgmt
->
appCache
);
...
...
@@ -931,7 +931,6 @@ static int32_t mndRetrieveApps(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlo
return
numOfRows
;
}
static
void
mndCancelGetNextQuery
(
SMnode
*
pMnode
,
void
*
pIter
)
{
if
(
pIter
!=
NULL
)
{
taosCacheDestroyIter
(
pIter
);
...
...
source/dnode/mnode/impl/src/mndStream.c
浏览文件 @
bae71438
...
...
@@ -54,9 +54,10 @@ int32_t mndInitStream(SMnode *pMnode) {
};
mndSetMsgHandle
(
pMnode
,
TDMT_MND_CREATE_STREAM
,
mndProcessCreateStreamReq
);
mndSetMsgHandle
(
pMnode
,
TDMT_STREAM_TASK_DEPLOY_RSP
,
mndTransProcessRsp
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_DROP_STREAM
,
mndProcessDropStreamReq
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_DROP_STREAM_RSP
,
mndTransProcessRsp
);
mndSetMsgHandle
(
pMnode
,
TDMT_STREAM_TASK_DEPLOY_RSP
,
mndTransProcessRsp
);
mndSetMsgHandle
(
pMnode
,
TDMT_STREAM_TASK_DROP_RSP
,
mndTransProcessRsp
);
mndAddShowRetrieveHandle
(
pMnode
,
TSDB_MGMT_TABLE_STREAMS
,
mndRetrieveStream
);
mndAddShowFreeIterHandle
(
pMnode
,
TSDB_MGMT_TABLE_STREAMS
,
mndCancelGetNextStream
);
...
...
@@ -477,7 +478,7 @@ static int32_t mndPersistTaskDropReq(STrans *pTrans, SStreamTask *pTask) {
memcpy
(
&
action
.
epSet
,
&
pTask
->
epSet
,
sizeof
(
SEpSet
));
action
.
pCont
=
pReq
;
action
.
contLen
=
sizeof
(
SVDropStreamTaskReq
);
action
.
msgType
=
TDMT_
VND_
STREAM_TASK_DROP
;
action
.
msgType
=
TDMT_STREAM_TASK_DROP
;
if
(
mndTransAppendRedoAction
(
pTrans
,
&
action
)
!=
0
)
{
taosMemoryFree
(
pReq
);
return
-
1
;
...
...
@@ -670,20 +671,24 @@ _OVER:
static
int32_t
mndProcessDropStreamReq
(
SRpcMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
info
.
node
;
int32_t
code
=
-
1
;
SStreamObj
*
pStream
=
NULL
;
/*SDbObj *pDb = NULL;*/
/*SUserObj *pUser = NULL;*/
SMDropStreamReq
dropReq
=
*
(
SMDropStreamReq
*
)
pReq
->
pCont
;
SMDropStreamReq
dropReq
=
{
0
};
if
(
tDeserializeSMDropStreamReq
(
pReq
->
pCont
,
pReq
->
contLen
,
&
dropReq
)
<
0
)
{
ASSERT
(
0
);
terrno
=
TSDB_CODE_INVALID_MSG
;
return
-
1
;
}
pStream
=
mndAcquireStream
(
pMnode
,
dropReq
.
name
);
if
(
pStream
==
NULL
)
{
if
(
dropReq
.
igNotExists
)
{
mDebug
(
"stream:%s, not exist, ignore not exist is set"
,
dropReq
.
name
);
code
=
0
;
goto
DROP_STREAM_OVER
;
sdbRelease
(
pMnode
->
pSdb
,
pStream
)
;
return
-
1
;
}
else
{
terrno
=
TSDB_CODE_MND_STREAM_NOT_EXIST
;
return
-
1
;
...
...
@@ -701,14 +706,16 @@ static int32_t mndProcessDropStreamReq(SRpcMsg *pReq) {
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_RETRY
,
TRN_CONFLICT_NOTHING
,
pReq
);
if
(
pTrans
==
NULL
)
{
mError
(
"stream:%s, failed to drop since %s"
,
dropReq
.
name
,
terrstr
());
return
code
;
sdbRelease
(
pMnode
->
pSdb
,
pStream
);
return
-
1
;
}
mDebug
(
"trans:%d, used to drop stream:%s"
,
pTrans
->
id
,
dropReq
.
name
);
// drop all tasks
if
(
mndDropStreamTasks
(
pMnode
,
pTrans
,
pStream
)
<
0
)
{
mError
(
"stream:%s, failed to drop task since %s"
,
dropReq
.
name
,
terrstr
());
return
code
;
sdbRelease
(
pMnode
->
pSdb
,
pStream
);
return
-
1
;
}
// drop stream
...
...
@@ -717,8 +724,16 @@ static int32_t mndProcessDropStreamReq(SRpcMsg *pReq) {
return
-
1
;
}
DROP_STREAM_OVER:
return
code
;
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
{
mError
(
"trans:%d, failed to prepare drop stream trans since %s"
,
pTrans
->
id
,
terrstr
());
sdbRelease
(
pMnode
->
pSdb
,
pStream
);
mndTransDrop
(
pTrans
);
return
-
1
;
}
sdbRelease
(
pMnode
->
pSdb
,
pStream
);
return
TSDB_CODE_ACTION_IN_PROGRESS
;
}
int32_t
mndDropStreamByDb
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pDb
)
{
...
...
source/dnode/mnode/impl/src/mndSubscribe.c
浏览文件 @
bae71438
...
...
@@ -96,6 +96,7 @@ static SMqSubscribeObj *mndCreateSub(SMnode *pMnode, const SMqTopicObj *pTopic,
pSub
->
dbUid
=
pTopic
->
dbUid
;
pSub
->
stbUid
=
pTopic
->
stbUid
;
pSub
->
subType
=
pTopic
->
subType
;
pSub
->
withMeta
=
pTopic
->
withMeta
;
ASSERT
(
pSub
->
unassignedVgs
->
size
==
0
);
ASSERT
(
taosHashGetSize
(
pSub
->
consumerHash
)
==
0
);
...
...
@@ -120,6 +121,7 @@ static int32_t mndBuildSubChangeReq(void **pBuf, int32_t *pLen, const SMqSubscri
req
.
vgId
=
pRebVg
->
pVgEp
->
vgId
;
req
.
qmsg
=
pRebVg
->
pVgEp
->
qmsg
;
req
.
subType
=
pSub
->
subType
;
req
.
withMeta
=
pSub
->
withMeta
;
req
.
suid
=
pSub
->
stbUid
;
strncpy
(
req
.
subKey
,
pSub
->
key
,
TSDB_SUBSCRIBE_KEY_LEN
);
...
...
source/dnode/mnode/impl/src/mndTopic.c
浏览文件 @
bae71438
...
...
@@ -141,6 +141,7 @@ SSdbRaw *mndTopicActionEncode(SMqTopicObj *pTopic) {
SDB_SET_INT64
(
pRaw
,
dataPos
,
pTopic
->
dbUid
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
pTopic
->
version
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT8
(
pRaw
,
dataPos
,
pTopic
->
subType
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT8
(
pRaw
,
dataPos
,
pTopic
->
withMeta
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT64
(
pRaw
,
dataPos
,
pTopic
->
stbUid
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
pTopic
->
sqlLen
,
TOPIC_ENCODE_OVER
);
...
...
@@ -208,6 +209,7 @@ SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw) {
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pTopic
->
dbUid
,
TOPIC_DECODE_OVER
);
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pTopic
->
version
,
TOPIC_DECODE_OVER
);
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
pTopic
->
subType
,
TOPIC_DECODE_OVER
);
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
pTopic
->
withMeta
,
TOPIC_DECODE_OVER
);
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pTopic
->
stbUid
,
TOPIC_DECODE_OVER
);
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pTopic
->
sqlLen
,
TOPIC_DECODE_OVER
);
...
...
@@ -357,6 +359,10 @@ static int32_t mndCreateTopic(SMnode *pMnode, SRpcMsg *pReq, SCMCreateTopicReq *
topicObj
.
sql
=
strdup
(
pCreate
->
sql
);
topicObj
.
sqlLen
=
strlen
(
pCreate
->
sql
)
+
1
;
topicObj
.
subType
=
pCreate
->
subType
;
topicObj
.
withMeta
=
pCreate
->
withMeta
;
if
(
topicObj
.
withMeta
)
{
ASSERT
(
topicObj
.
subType
!=
TOPIC_SUB_TYPE__COLUMN
);
}
if
(
pCreate
->
subType
==
TOPIC_SUB_TYPE__COLUMN
)
{
topicObj
.
ast
=
strdup
(
pCreate
->
ast
);
...
...
source/dnode/snode/src/snode.c
浏览文件 @
bae71438
...
...
@@ -92,7 +92,7 @@ static int32_t sndProcessTaskDeployReq(SSnode *pNode, SRpcMsg *pMsg) {
}
tDecoderClear
(
&
decoder
);
pTask
->
status
=
TASK
_STATUS__IDLE
;
pTask
->
execStatus
=
TASK_EXEC
_STATUS__IDLE
;
pTask
->
inputQueue
=
streamQueueOpen
();
pTask
->
outputQueue
=
streamQueueOpen
();
...
...
@@ -205,7 +205,7 @@ int32_t sndProcessUMsg(SSnode *pSnode, SRpcMsg *pMsg) {
switch
(
pMsg
->
msgType
)
{
case
TDMT_STREAM_TASK_DEPLOY
:
return
sndProcessTaskDeployReq
(
pSnode
,
pMsg
);
case
TDMT_
VND_
STREAM_TASK_DROP
:
case
TDMT_STREAM_TASK_DROP
:
return
sndProcessTaskDropReq
(
pSnode
,
pMsg
);
default:
ASSERT
(
0
);
...
...
source/dnode/vnode/src/inc/tq.h
浏览文件 @
bae71438
...
...
@@ -114,6 +114,7 @@ typedef struct {
char
subKey
[
TSDB_SUBSCRIBE_KEY_LEN
];
int64_t
consumerId
;
int32_t
epoch
;
int8_t
fetchMeta
;
// reader
SWalReadHandle
*
pWalReader
;
...
...
source/dnode/vnode/src/inc/vnd.h
浏览文件 @
bae71438
...
...
@@ -26,13 +26,21 @@ extern "C" {
#endif
// clang-format off
#define vFatal(...) do { if (vDebugFlag & DEBUG_FATAL) { taosPrintLog("VND FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); }} while(0)
#define vError(...) do { if (vDebugFlag & DEBUG_ERROR) { taosPrintLog("VND ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }} while(0)
#define vWarn(...) do { if (vDebugFlag & DEBUG_WARN) { taosPrintLog("VND WARN ", DEBUG_WARN, 255, __VA_ARGS__); }} while(0)
#define vInfo(...) do { if (vDebugFlag & DEBUG_INFO) { taosPrintLog("VND ", DEBUG_INFO, 255, __VA_ARGS__); }} while(0)
#define vDebug(...) do { if (vDebugFlag & DEBUG_DEBUG) { taosPrintLog("VND ", DEBUG_DEBUG, vDebugFlag, __VA_ARGS__); }} while(0)
#define vTrace(...) do { if (vDebugFlag & DEBUG_TRACE) { taosPrintLog("VND ", DEBUG_TRACE, vDebugFlag, __VA_ARGS__); }} while(0)
#define vGTrace(param, ...) do { char buf[40] = {0}; TRACE_TO_STR(trace, buf); vTrace(param " GTID: %s", __VA_ARGS__, buf);} while(0)//#define vDye(...) do
#define vFatal(...) { if (vDebugFlag & DEBUG_FATAL) { taosPrintLog("VND FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); }}
#define vError(...) { if (vDebugFlag & DEBUG_ERROR) { taosPrintLog("VND ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }}
#define vWarn(...) { if (vDebugFlag & DEBUG_WARN) { taosPrintLog("VND WARN ", DEBUG_WARN, 255, __VA_ARGS__); }}
#define vInfo(...) { if (vDebugFlag & DEBUG_INFO) { taosPrintLog("VND ", DEBUG_INFO, 255, __VA_ARGS__); }}
#define vDebug(...) { if (vDebugFlag & DEBUG_DEBUG) { taosPrintLog("VND ", DEBUG_DEBUG, vDebugFlag, __VA_ARGS__); }}
#define vTrace(...) { if (vDebugFlag & DEBUG_TRACE) { taosPrintLog("VND ", DEBUG_TRACE, vDebugFlag, __VA_ARGS__); }}
#define vGFatal(param, ...) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); vFatal(param ", gtid:%s", __VA_ARGS__, buf);}
#define vGError(param, ...) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); vError(param ", gtid:%s", __VA_ARGS__, buf);}
#define vGWarn(param, ...) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); vWarn (param ", gtid:%s", __VA_ARGS__, buf);}
#define vGInfo(param, ...) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); vInfo (param ", gtid:%s", __VA_ARGS__, buf);}
#define vGDebug(param, ...) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); vDebug(param ", gtid:%s", __VA_ARGS__, buf);}
#define vGTrace(param, ...) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); vTrace(param ", gtid:%s", __VA_ARGS__, buf);}
// clang-format on
// vnodeCfg.c
...
...
source/dnode/vnode/src/tq/tq.c
浏览文件 @
bae71438
...
...
@@ -85,6 +85,34 @@ void tqClose(STQ* pTq) {
}
}
int32_t
tqSendMetaPollRsp
(
STQ
*
pTq
,
const
SRpcMsg
*
pMsg
,
const
SMqPollReq
*
pReq
,
const
SMqMetaRsp
*
pRsp
)
{
int32_t
tlen
=
sizeof
(
SMqRspHead
)
+
tEncodeSMqMetaRsp
(
NULL
,
pRsp
);
void
*
buf
=
rpcMallocCont
(
tlen
);
if
(
buf
==
NULL
)
{
return
-
1
;
}
((
SMqRspHead
*
)
buf
)
->
mqMsgType
=
TMQ_MSG_TYPE__POLL_META_RSP
;
((
SMqRspHead
*
)
buf
)
->
epoch
=
pReq
->
epoch
;
((
SMqRspHead
*
)
buf
)
->
consumerId
=
pReq
->
consumerId
;
void
*
abuf
=
POINTER_SHIFT
(
buf
,
sizeof
(
SMqRspHead
));
tEncodeSMqMetaRsp
(
&
abuf
,
pRsp
);
SRpcMsg
resp
=
{
.
info
=
pMsg
->
info
,
.
pCont
=
buf
,
.
contLen
=
tlen
,
.
code
=
0
,
};
tmsgSendRsp
(
&
resp
);
tqDebug
(
"vg %d from consumer %ld (epoch %d) send rsp, res msg type %d, reqOffset: %ld, rspOffset: %ld"
,
TD_VID
(
pTq
->
pVnode
),
pReq
->
consumerId
,
pReq
->
epoch
,
pRsp
->
resMsgType
,
pRsp
->
reqOffset
,
pRsp
->
rspOffset
);
return
0
;
}
int32_t
tqSendPollRsp
(
STQ
*
pTq
,
const
SRpcMsg
*
pMsg
,
const
SMqPollReq
*
pReq
,
const
SMqDataBlkRsp
*
pRsp
)
{
int32_t
tlen
=
sizeof
(
SMqRspHead
)
+
tEncodeSMqDataBlkRsp
(
NULL
,
pRsp
);
void
*
buf
=
rpcMallocCont
(
tlen
);
...
...
@@ -250,8 +278,23 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
/*ASSERT(0);*/
}
}
else
{
// TODO
ASSERT
(
0
);
ASSERT
(
pHandle
->
fetchMeta
);
ASSERT
(
pHead
->
msgType
==
TDMT_VND_CREATE_STB
||
pHead
->
msgType
==
TDMT_VND_ALTER_STB
||
pHead
->
msgType
==
TDMT_VND_DROP_STB
||
pHead
->
msgType
==
TDMT_VND_CREATE_TABLE
||
pHead
->
msgType
==
TDMT_VND_ALTER_TABLE
||
pHead
->
msgType
==
TDMT_VND_DROP_TABLE
||
pHead
->
msgType
==
TDMT_VND_DROP_TTL_TABLE
);
// return
SMqMetaRsp
metaRsp
=
{
0
};
metaRsp
.
reqOffset
=
pReq
->
currentOffset
;
metaRsp
.
rspOffset
=
fetchOffset
;
metaRsp
.
resMsgType
=
pHead
->
msgType
;
metaRsp
.
metaRspLen
=
pHead
->
bodyLen
;
metaRsp
.
metaRsp
=
pHead
->
body
;
if
(
tqSendMetaPollRsp
(
pTq
,
pMsg
,
pReq
,
&
metaRsp
)
<
0
)
{
code
=
-
1
;
}
code
=
0
;
goto
OVER
;
}
// TODO batch optimization:
...
...
@@ -276,7 +319,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
if
(
tqSendPollRsp
(
pTq
,
pMsg
,
pReq
,
&
rsp
)
<
0
)
{
code
=
-
1
;
}
OVER:
// TODO wrap in destroy func
taosArrayDestroy
(
rsp
.
blockDataLen
);
taosArrayDestroyP
(
rsp
.
blockData
,
(
FDelete
)
taosMemoryFree
);
...
...
@@ -384,7 +427,7 @@ int32_t tqProcessTaskDeployReq(STQ* pTq, char* msg, int32_t msgLen) {
}
tDecoderClear
(
&
decoder
);
pTask
->
status
=
TASK
_STATUS__IDLE
;
pTask
->
execStatus
=
TASK_EXEC
_STATUS__IDLE
;
pTask
->
inputQueue
=
streamQueueOpen
();
pTask
->
outputQueue
=
streamQueueOpen
();
...
...
@@ -459,6 +502,9 @@ int32_t tqProcessStreamTrigger(STQ* pTq, SSubmitReq* pReq) {
pIter
=
taosHashIterate
(
pTq
->
pStreamTasks
,
pIter
);
if
(
pIter
==
NULL
)
break
;
SStreamTask
*
pTask
=
*
(
SStreamTask
**
)
pIter
;
if
(
atomic_load_8
(
&
pTask
->
taskStatus
)
==
TASK_STATUS__DROPPING
)
{
continue
;
}
if
(
pTask
->
inputType
!=
STREAM_INPUT__DATA_SUBMIT
)
continue
;
if
(
!
failed
)
{
...
...
@@ -487,6 +533,9 @@ int32_t tqProcessTaskRunReq(STQ* pTq, SRpcMsg* pMsg) {
SStreamTaskRunReq
*
pReq
=
pMsg
->
pCont
;
int32_t
taskId
=
pReq
->
taskId
;
SStreamTask
*
pTask
=
*
(
SStreamTask
**
)
taosHashGet
(
pTq
->
pStreamTasks
,
&
taskId
,
sizeof
(
int32_t
));
if
(
atomic_load_8
(
&
pTask
->
taskStatus
)
!=
TASK_STATUS__NORMAL
)
{
return
0
;
}
streamProcessRunReq
(
pTask
);
return
0
;
}
...
...
@@ -501,9 +550,12 @@ int32_t tqProcessTaskDispatchReq(STQ* pTq, SRpcMsg* pMsg) {
tDecodeStreamDispatchReq
(
&
decoder
,
&
req
);
int32_t
taskId
=
req
.
taskId
;
SStreamTask
*
pTask
=
*
(
SStreamTask
**
)
taosHashGet
(
pTq
->
pStreamTasks
,
&
taskId
,
sizeof
(
int32_t
));
SRpcMsg
rsp
=
{
.
info
=
pMsg
->
info
,
.
code
=
0
,
if
(
atomic_load_8
(
&
pTask
->
taskStatus
)
!=
TASK_STATUS__NORMAL
)
{
return
0
;
}
SRpcMsg
rsp
=
{
.
info
=
pMsg
->
info
,
.
code
=
0
,
};
streamProcessDispatchReq
(
pTask
,
&
req
,
&
rsp
);
return
0
;
...
...
@@ -513,6 +565,9 @@ int32_t tqProcessTaskRecoverReq(STQ* pTq, SRpcMsg* pMsg) {
SStreamTaskRecoverReq
*
pReq
=
pMsg
->
pCont
;
int32_t
taskId
=
pReq
->
taskId
;
SStreamTask
*
pTask
=
*
(
SStreamTask
**
)
taosHashGet
(
pTq
->
pStreamTasks
,
&
taskId
,
sizeof
(
int32_t
));
if
(
atomic_load_8
(
&
pTask
->
taskStatus
)
!=
TASK_STATUS__NORMAL
)
{
return
0
;
}
streamProcessRecoverReq
(
pTask
,
pReq
,
pMsg
);
return
0
;
}
...
...
@@ -521,6 +576,9 @@ int32_t tqProcessTaskDispatchRsp(STQ* pTq, SRpcMsg* pMsg) {
SStreamDispatchRsp
*
pRsp
=
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
));
int32_t
taskId
=
pRsp
->
taskId
;
SStreamTask
*
pTask
=
*
(
SStreamTask
**
)
taosHashGet
(
pTq
->
pStreamTasks
,
&
taskId
,
sizeof
(
int32_t
));
if
(
atomic_load_8
(
&
pTask
->
taskStatus
)
!=
TASK_STATUS__NORMAL
)
{
return
0
;
}
streamProcessDispatchRsp
(
pTask
,
pRsp
);
return
0
;
}
...
...
@@ -529,16 +587,32 @@ int32_t tqProcessTaskRecoverRsp(STQ* pTq, SRpcMsg* pMsg) {
SStreamTaskRecoverRsp
*
pRsp
=
pMsg
->
pCont
;
int32_t
taskId
=
pRsp
->
taskId
;
SStreamTask
*
pTask
=
*
(
SStreamTask
**
)
taosHashGet
(
pTq
->
pStreamTasks
,
&
taskId
,
sizeof
(
int32_t
));
if
(
atomic_load_8
(
&
pTask
->
taskStatus
)
!=
TASK_STATUS__NORMAL
)
{
return
0
;
}
streamProcessRecoverRsp
(
pTask
,
pRsp
);
return
0
;
}
int32_t
tqProcessTaskDropReq
(
STQ
*
pTq
,
char
*
msg
,
int32_t
msgLen
)
{
SVDropStreamTaskReq
*
pReq
=
(
SVDropStreamTaskReq
*
)
msg
;
SStreamTask
*
pTask
=
*
(
SStreamTask
**
)
taosHashGet
(
pTq
->
pStreamTasks
,
&
pReq
->
taskId
,
sizeof
(
int32_t
));
atomic_store_8
(
&
pTask
->
taskStatus
,
TASK_STATUS__DROPPING
);
// todo
// clear queue
// push drop req into queue
// launch exec to free memory
// remove from hash
return
0
;
#if 0
int32_t code = taosHashRemove(pTq->pStreamTasks, &pReq->taskId, sizeof(int32_t));
// set status dropping
ASSERT(code == 0);
if (code == 0) {
// sendrsp
}
return code;
#endif
}
source/dnode/vnode/src/tq/tqPush.c
浏览文件 @
bae71438
...
...
@@ -45,9 +45,9 @@ static int32_t tqLoopExecFromQueue(STQ* pTq, STqHandle* pHandle, SStreamDataSubm
int32_t
tqExecFromInputQ
(
STQ
*
pTq
,
STqHandle
*
pHandle
)
{
SMqDataBlkRsp
rsp
=
{
0
};
// 1. guard and set status executing
int8_t
execStatus
=
atomic_val_compare_exchange_8
(
&
pHandle
->
pushHandle
.
execStatus
,
TASK_STATUS__IDLE
,
TASK
_STATUS__EXECUTING
);
if
(
execStatus
==
TASK_STATUS__IDLE
)
{
int8_t
execStatus
=
atomic_val_compare_exchange_8
(
&
pHandle
->
pushHandle
.
execStatus
,
TASK_EXEC_STATUS__IDLE
,
TASK_EXEC
_STATUS__EXECUTING
);
if
(
execStatus
==
TASK_
EXEC_
STATUS__IDLE
)
{
SStreamDataSubmit
*
pSubmit
=
NULL
;
// 2. check processedVer
// 2.1. if not missed, get msg from queue
...
...
@@ -68,18 +68,18 @@ int32_t tqExecFromInputQ(STQ* pTq, STqHandle* pHandle) {
goto
SEND_RSP
;
}
// set exec status closing
atomic_store_8
(
&
pHandle
->
pushHandle
.
execStatus
,
TASK_STATUS__CLOSING
);
atomic_store_8
(
&
pHandle
->
pushHandle
.
execStatus
,
TASK_
EXEC_
STATUS__CLOSING
);
// second run
if
(
tqLoopExecFromQueue
(
pTq
,
pHandle
,
&
pSubmit
,
&
rsp
)
==
0
)
{
goto
SEND_RSP
;
}
// set exec status idle
atomic_store_8
(
&
pHandle
->
pushHandle
.
execStatus
,
TASK_STATUS__IDLE
);
atomic_store_8
(
&
pHandle
->
pushHandle
.
execStatus
,
TASK_
EXEC_
STATUS__IDLE
);
}
SEND_RSP:
// 4. if get result
// 4.1 set exec input status blocked and exec status idle
atomic_store_8
(
&
pHandle
->
pushHandle
.
execStatus
,
TASK_STATUS__IDLE
);
atomic_store_8
(
&
pHandle
->
pushHandle
.
execStatus
,
TASK_
EXEC_
STATUS__IDLE
);
// 4.2 rpc send
rsp
.
rspOffset
=
pHandle
->
pushHandle
.
processedVer
;
/*if (tqSendPollRsp(pTq, pMsg, pReq, &rsp) < 0) {*/
...
...
@@ -150,7 +150,7 @@ int32_t tqEnqueueAll(STQ* pTq, SSubmitReq* pReq) {
continue
;
}
int8_t
execStatus
=
atomic_load_8
(
&
pHandle
->
pushHandle
.
execStatus
);
if
(
execStatus
==
TASK_
STATUS__IDLE
||
execStatus
==
TASK
_STATUS__CLOSING
)
{
if
(
execStatus
==
TASK_
EXEC_STATUS__IDLE
||
execStatus
==
TASK_EXEC
_STATUS__CLOSING
)
{
tqSendExecReq
(
pTq
,
pHandle
);
}
}
...
...
source/dnode/vnode/src/tq/tqRead.c
浏览文件 @
bae71438
...
...
@@ -42,6 +42,25 @@ int64_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, SWalHead*
code
=
0
;
goto
END
;
}
else
{
if
(
pHandle
->
fetchMeta
)
{
SWalReadHead
*
pHead
=
&
((
*
ppHeadWithCkSum
)
->
head
);
if
(
pHead
->
msgType
==
TDMT_VND_CREATE_STB
||
pHead
->
msgType
==
TDMT_VND_ALTER_STB
||
pHead
->
msgType
==
TDMT_VND_DROP_STB
||
pHead
->
msgType
==
TDMT_VND_CREATE_TABLE
||
pHead
->
msgType
==
TDMT_VND_ALTER_TABLE
||
pHead
->
msgType
==
TDMT_VND_DROP_TABLE
||
pHead
->
msgType
==
TDMT_VND_DROP_TTL_TABLE
)
{
code
=
walFetchBody
(
pHandle
->
pWalReader
,
ppHeadWithCkSum
);
if
(
code
<
0
)
{
ASSERT
(
0
);
*
fetchOffset
=
offset
;
code
=
-
1
;
goto
END
;
}
*
fetchOffset
=
offset
;
code
=
0
;
goto
END
;
}
}
code
=
walSkipFetchBody
(
pHandle
->
pWalReader
,
*
ppHeadWithCkSum
);
if
(
code
<
0
)
{
ASSERT
(
0
);
...
...
source/dnode/vnode/src/vnd/vnodeSvr.c
浏览文件 @
bae71438
...
...
@@ -172,7 +172,7 @@ int32_t vnodeProcessWriteReq(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRp
goto
_err
;
}
}
break
;
case
TDMT_
VND_
STREAM_TASK_DROP
:
{
case
TDMT_STREAM_TASK_DROP
:
{
if
(
tqProcessTaskDropReq
(
pVnode
->
pTq
,
pMsg
->
pCont
,
pMsg
->
contLen
)
<
0
)
{
goto
_err
;
}
...
...
source/libs/function/src/builtinsimpl.c
浏览文件 @
bae71438
...
...
@@ -195,13 +195,13 @@ typedef struct SMavgInfo {
}
SMavgInfo
;
typedef
struct
SSampleInfo
{
int32_t
samples
;
int32_t
totalPoints
;
int32_t
numSampled
;
uint8_t
colType
;
int16_t
colBytes
;
char
*
data
;
int64_t
*
timestamp
;
int32_t
samples
;
int32_t
totalPoints
;
int32_t
numSampled
;
uint8_t
colType
;
int16_t
colBytes
;
char
*
data
;
STuplePos
*
tuplePos
;
}
SSampleInfo
;
typedef
struct
STailItem
{
...
...
@@ -4348,7 +4348,7 @@ bool getSampleFuncEnv(SFunctionNode* pFunc, SFuncExecEnv* pEnv) {
SColumnNode
*
pCol
=
(
SColumnNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
0
);
SValueNode
*
pVal
=
(
SValueNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
1
);
int32_t
numOfSamples
=
pVal
->
datum
.
i
;
pEnv
->
calcMemSize
=
sizeof
(
SSampleInfo
)
+
numOfSamples
*
(
pCol
->
node
.
resType
.
bytes
+
sizeof
(
int64_t
));
pEnv
->
calcMemSize
=
sizeof
(
SSampleInfo
)
+
numOfSamples
*
(
pCol
->
node
.
resType
.
bytes
+
sizeof
(
STuplePos
));
return
true
;
}
...
...
@@ -4369,25 +4369,30 @@ bool sampleFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo)
return
false
;
}
pInfo
->
data
=
(
char
*
)
pInfo
+
sizeof
(
SSampleInfo
);
pInfo
->
t
imestamp
=
(
int64_t
*
)((
char
*
)
pInfo
+
sizeof
(
SSampleInfo
)
+
pInfo
->
samples
*
pInfo
->
colBytes
);
pInfo
->
t
uplePos
=
(
STuplePos
*
)((
char
*
)
pInfo
+
sizeof
(
SSampleInfo
)
+
pInfo
->
samples
*
pInfo
->
colBytes
);
return
true
;
}
static
void
sampleAssignResult
(
SSampleInfo
*
pInfo
,
char
*
data
,
TSKEY
ts
,
int32_t
index
)
{
static
void
sampleAssignResult
(
SSampleInfo
*
pInfo
,
char
*
data
,
int32_t
index
)
{
assignVal
(
pInfo
->
data
+
index
*
pInfo
->
colBytes
,
data
,
pInfo
->
colBytes
,
pInfo
->
colType
);
*
(
pInfo
->
timestamp
+
index
)
=
ts
;
}
static
void
doReservoirSample
(
S
SampleInfo
*
pInfo
,
char
*
data
,
TSKEY
ts
,
int32_t
index
)
{
static
void
doReservoirSample
(
S
qlFunctionCtx
*
pCtx
,
SSampleInfo
*
pInfo
,
char
*
data
,
int32_t
index
)
{
pInfo
->
totalPoints
++
;
if
(
pInfo
->
numSampled
<
pInfo
->
samples
)
{
sampleAssignResult
(
pInfo
,
data
,
ts
,
pInfo
->
numSampled
);
sampleAssignResult
(
pInfo
,
data
,
pInfo
->
numSampled
);
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
saveTupleData
(
pCtx
,
index
,
pCtx
->
pSrcBlock
,
pInfo
->
tuplePos
+
pInfo
->
numSampled
*
sizeof
(
STuplePos
));
}
pInfo
->
numSampled
++
;
}
else
{
int32_t
j
=
taosRand
()
%
(
pInfo
->
totalPoints
);
if
(
j
<
pInfo
->
samples
)
{
sampleAssignResult
(
pInfo
,
data
,
ts
,
j
);
sampleAssignResult
(
pInfo
,
data
,
j
);
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
copyTupleData
(
pCtx
,
index
,
pCtx
->
pSrcBlock
,
pInfo
->
tuplePos
+
j
*
sizeof
(
STuplePos
));
}
}
}
}
...
...
@@ -4398,11 +4403,6 @@ int32_t sampleFunction(SqlFunctionCtx* pCtx) {
SInputColumnInfoData
*
pInput
=
&
pCtx
->
input
;
TSKEY
*
tsList
=
NULL
;
if
(
pInput
->
pPTS
!=
NULL
)
{
tsList
=
(
int64_t
*
)
pInput
->
pPTS
->
pData
;
}
SColumnInfoData
*
pInputCol
=
pInput
->
pData
[
0
];
for
(
int32_t
i
=
pInput
->
startRowIndex
;
i
<
pInput
->
numOfRows
+
pInput
->
startRowIndex
;
i
+=
1
)
{
if
(
colDataIsNull_s
(
pInputCol
,
i
))
{
...
...
@@ -4410,7 +4410,7 @@ int32_t sampleFunction(SqlFunctionCtx* pCtx) {
}
char
*
data
=
colDataGetData
(
pInputCol
,
i
);
doReservoirSample
(
p
Info
,
data
,
/*tsList[i]*/
0
,
i
);
doReservoirSample
(
p
Ctx
,
pInfo
,
data
,
i
);
}
SET_VAL
(
pResInfo
,
pInfo
->
numSampled
,
pInfo
->
numSampled
);
...
...
@@ -4429,6 +4429,7 @@ int32_t sampleFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
int32_t
currentRow
=
pBlock
->
info
.
rows
;
for
(
int32_t
i
=
0
;
i
<
pInfo
->
numSampled
;
++
i
)
{
colDataAppend
(
pCol
,
currentRow
+
i
,
pInfo
->
data
+
i
*
pInfo
->
colBytes
,
false
);
setSelectivityValue
(
pCtx
,
pBlock
,
pInfo
->
tuplePos
+
i
*
sizeof
(
STuplePos
),
currentRow
+
i
);
}
return
pInfo
->
numSampled
;
...
...
source/libs/nodes/src/nodesCloneFuncs.c
浏览文件 @
bae71438
...
...
@@ -557,6 +557,14 @@ static SNode* physiSessionCopy(const SSessionWinodwPhysiNode* pSrc, SSessionWino
return
(
SNode
*
)
pDst
;
}
static
SNode
*
physiPartitionCopy
(
const
SPartitionPhysiNode
*
pSrc
,
SPartitionPhysiNode
*
pDst
)
{
COPY_BASE_OBJECT_FIELD
(
node
,
physiNodeCopy
);
CLONE_NODE_LIST_FIELD
(
pExprs
);
CLONE_NODE_LIST_FIELD
(
pPartitionKeys
);
CLONE_NODE_LIST_FIELD
(
pTargets
);
return
(
SNode
*
)
pDst
;
}
static
SNode
*
dataBlockDescCopy
(
const
SDataBlockDescNode
*
pSrc
,
SDataBlockDescNode
*
pDst
)
{
COPY_SCALAR_FIELD
(
dataBlockId
);
CLONE_NODE_LIST_FIELD
(
pSlots
);
...
...
@@ -702,6 +710,8 @@ SNode* nodesCloneNode(const SNode* pNode) {
case
QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_SESSION
:
case
QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_SESSION
:
return
physiSessionCopy
((
const
SSessionWinodwPhysiNode
*
)
pNode
,
(
SSessionWinodwPhysiNode
*
)
pDst
);
case
QUERY_NODE_PHYSICAL_PLAN_PARTITION
:
return
physiPartitionCopy
((
const
SPartitionPhysiNode
*
)
pNode
,
(
SPartitionPhysiNode
*
)
pDst
);
default:
break
;
}
...
...
source/libs/parser/src/parInsert.c
浏览文件 @
bae71438
...
...
@@ -257,7 +257,7 @@ static int32_t checkAuth(SInsertParseContext* pCxt, char* pDbFname, bool* pPass)
if
(
pBasicCtx
->
async
)
{
return
getUserAuthFromCache
(
pCxt
->
pMetaCache
,
pBasicCtx
->
pUser
,
pDbFname
,
AUTH_TYPE_WRITE
,
pPass
);
}
SRequestConnInfo
conn
=
{.
pTrans
=
pBasicCtx
->
pTransporter
,
SRequestConnInfo
conn
=
{.
pTrans
=
pBasicCtx
->
pTransporter
,
.
requestId
=
pBasicCtx
->
requestId
,
.
requestObjRefId
=
pBasicCtx
->
requestRid
,
.
mgmtEps
=
pBasicCtx
->
mgmtEpSet
};
...
...
@@ -270,11 +270,11 @@ static int32_t getTableSchema(SInsertParseContext* pCxt, SName* pTbName, bool is
if
(
pBasicCtx
->
async
)
{
return
getTableMetaFromCache
(
pCxt
->
pMetaCache
,
pTbName
,
pTableMeta
);
}
SRequestConnInfo
conn
=
{.
pTrans
=
pBasicCtx
->
pTransporter
,
SRequestConnInfo
conn
=
{.
pTrans
=
pBasicCtx
->
pTransporter
,
.
requestId
=
pBasicCtx
->
requestId
,
.
requestObjRefId
=
pBasicCtx
->
requestRid
,
.
mgmtEps
=
pBasicCtx
->
mgmtEpSet
};
if
(
isStb
)
{
return
catalogGetSTableMeta
(
pBasicCtx
->
pCatalog
,
&
conn
,
pTbName
,
pTableMeta
);
}
...
...
@@ -286,7 +286,7 @@ static int32_t getTableVgroup(SInsertParseContext* pCxt, SName* pTbName, SVgroup
if
(
pBasicCtx
->
async
)
{
return
getTableVgroupFromCache
(
pCxt
->
pMetaCache
,
pTbName
,
pVg
);
}
SRequestConnInfo
conn
=
{.
pTrans
=
pBasicCtx
->
pTransporter
,
SRequestConnInfo
conn
=
{.
pTrans
=
pBasicCtx
->
pTransporter
,
.
requestId
=
pBasicCtx
->
requestId
,
.
requestObjRefId
=
pBasicCtx
->
requestRid
,
.
mgmtEps
=
pBasicCtx
->
mgmtEpSet
};
...
...
@@ -322,7 +322,7 @@ static int32_t getDBCfg(SInsertParseContext* pCxt, const char* pDbFName, SDbCfgI
if
(
pBasicCtx
->
async
)
{
CHECK_CODE
(
getDbCfgFromCache
(
pCxt
->
pMetaCache
,
pDbFName
,
pInfo
));
}
else
{
SRequestConnInfo
conn
=
{.
pTrans
=
pBasicCtx
->
pTransporter
,
SRequestConnInfo
conn
=
{.
pTrans
=
pBasicCtx
->
pTransporter
,
.
requestId
=
pBasicCtx
->
requestId
,
.
requestObjRefId
=
pBasicCtx
->
requestRid
,
.
mgmtEps
=
pBasicCtx
->
mgmtEpSet
};
...
...
@@ -1315,15 +1315,6 @@ static void destroyInsertParseContext(SInsertParseContext* pCxt) {
destroyBlockArrayList
(
pCxt
->
pVgDataBlocks
);
}
static
int32_t
checkSchemalessDb
(
SInsertParseContext
*
pCxt
,
char
*
pDbName
)
{
// SDbCfgInfo pInfo = {0};
// char fullName[TSDB_TABLE_FNAME_LEN];
// snprintf(fullName, sizeof(fullName), "%d.%s", pCxt->pComCxt->acctId, pDbName);
// CHECK_CODE(getDBCfg(pCxt, fullName, &pInfo));
// return pInfo.schemaless ? TSDB_CODE_SML_INVALID_DB_CONF : TSDB_CODE_SUCCESS;
return
TSDB_CODE_SUCCESS
;
}
// tb_name
// [USING stb_name [(tag1_name, ...)] TAGS (tag1_value, ...)]
// [(field1_name, ...)]
...
...
@@ -1377,8 +1368,6 @@ static int32_t parseInsertBody(SInsertParseContext* pCxt) {
SName
name
;
CHECK_CODE
(
createSName
(
&
name
,
&
tbnameToken
,
pCxt
->
pComCxt
->
acctId
,
pCxt
->
pComCxt
->
db
,
&
pCxt
->
msg
));
CHECK_CODE
(
checkSchemalessDb
(
pCxt
,
name
.
dbname
));
tNameExtractFullName
(
&
name
,
tbFName
);
CHECK_CODE
(
taosHashPut
(
pCxt
->
pTableNameHashObj
,
tbFName
,
strlen
(
tbFName
),
&
name
,
sizeof
(
SName
)));
char
dbFName
[
TSDB_DB_FNAME_LEN
];
...
...
source/libs/planner/src/planLogicCreater.c
浏览文件 @
bae71438
...
...
@@ -56,8 +56,12 @@ static EDealRes doRewriteExpr(SNode** pNode, void* pContext) {
pCol
->
node
.
resType
=
pToBeRewrittenExpr
->
resType
;
strcpy
(
pCol
->
node
.
aliasName
,
pToBeRewrittenExpr
->
aliasName
);
strcpy
(
pCol
->
colName
,
((
SExprNode
*
)
pExpr
)
->
aliasName
);
if
(
QUERY_NODE_FUNCTION
==
nodeType
(
pExpr
)
&&
FUNCTION_TYPE_WSTARTTS
==
((
SFunctionNode
*
)
pExpr
)
->
funcType
)
{
pCol
->
colId
=
PRIMARYKEY_TIMESTAMP_COL_ID
;
if
(
QUERY_NODE_FUNCTION
==
nodeType
(
pExpr
))
{
if
(
FUNCTION_TYPE_WSTARTTS
==
((
SFunctionNode
*
)
pExpr
)
->
funcType
)
{
pCol
->
colId
=
PRIMARYKEY_TIMESTAMP_COL_ID
;
}
else
if
(
FUNCTION_TYPE_TBNAME
==
((
SFunctionNode
*
)
pExpr
)
->
funcType
)
{
pCol
->
colType
=
COLUMN_TYPE_TBNAME
;
}
}
nodesDestroyNode
(
*
pNode
);
*
pNode
=
(
SNode
*
)
pCol
;
...
...
source/libs/planner/src/planOptimizer.c
浏览文件 @
bae71438
...
...
@@ -1042,7 +1042,7 @@ static int32_t smaOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubplan)
static
EDealRes
partTagsOptHasColImpl
(
SNode
*
pNode
,
void
*
pContext
)
{
if
(
QUERY_NODE_COLUMN
==
nodeType
(
pNode
))
{
if
(
COLUMN_TYPE_TAG
!=
((
SColumnNode
*
)
pNode
)
->
colType
)
{
if
(
COLUMN_TYPE_TAG
!=
((
SColumnNode
*
)
pNode
)
->
colType
&&
COLUMN_TYPE_TBNAME
!=
((
SColumnNode
*
)
pNode
)
->
colType
)
{
*
(
bool
*
)
pContext
=
true
;
return
DEAL_RES_END
;
}
...
...
@@ -1057,9 +1057,9 @@ static bool partTagsOptHasCol(SNodeList* pPartKeys) {
}
static
bool
partTagsIsOptimizableNode
(
SLogicNode
*
pNode
)
{
return
((
QUERY_NODE_LOGIC_PLAN_PARTITION
==
nodeType
(
pNode
)
/*
||
return
((
QUERY_NODE_LOGIC_PLAN_PARTITION
==
nodeType
(
pNode
)
||
(
QUERY_NODE_LOGIC_PLAN_AGG
==
nodeType
(
pNode
)
&&
NULL
!=
((
SAggLogicNode
*
)
pNode
)
->
pGroupKeys
&&
NULL != ((SAggLogicNode*)pNode)->pAggFuncs)
*/
)
&&
NULL
!=
((
SAggLogicNode
*
)
pNode
)
->
pAggFuncs
))
&&
1
==
LIST_LENGTH
(
pNode
->
pChildren
)
&&
QUERY_NODE_LOGIC_PLAN_SCAN
==
nodeType
(
nodesListGetNode
(
pNode
->
pChildren
,
0
)));
}
...
...
@@ -1080,6 +1080,28 @@ static bool partTagsOptMayBeOptimized(SLogicNode* pNode) {
return
!
partTagsOptHasCol
(
partTagsGetPartKeys
(
pNode
));
}
static
EDealRes
partTagsOptRebuildTbanmeImpl
(
SNode
**
pNode
,
void
*
pContext
)
{
if
(
QUERY_NODE_COLUMN
==
nodeType
(
*
pNode
)
&&
COLUMN_TYPE_TBNAME
==
((
SColumnNode
*
)
*
pNode
)
->
colType
)
{
SFunctionNode
*
pFunc
=
(
SFunctionNode
*
)
nodesMakeNode
(
QUERY_NODE_FUNCTION
);
if
(
NULL
==
pFunc
)
{
*
(
int32_t
*
)
pContext
=
TSDB_CODE_OUT_OF_MEMORY
;
return
DEAL_RES_ERROR
;
}
strcpy
(
pFunc
->
functionName
,
"tbname"
);
pFunc
->
funcType
=
FUNCTION_TYPE_TBNAME
;
nodesDestroyNode
(
*
pNode
);
*
pNode
=
(
SNode
*
)
pFunc
;
return
DEAL_RES_IGNORE_CHILD
;
}
return
DEAL_RES_CONTINUE
;
}
static
int32_t
partTagsOptRebuildTbanme
(
SNodeList
*
pPartKeys
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
nodesRewriteExprs
(
pPartKeys
,
partTagsOptRebuildTbanmeImpl
,
&
code
);
return
code
;
}
static
int32_t
partTagsOptimize
(
SOptimizeContext
*
pCxt
,
SLogicSubplan
*
pLogicSubplan
)
{
SLogicNode
*
pNode
=
optFindPossibleNode
(
pLogicSubplan
->
pNode
,
partTagsOptMayBeOptimized
);
if
(
NULL
==
pNode
)
{
...
...
@@ -1096,7 +1118,18 @@ static int32_t partTagsOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSub
nodesDestroyNode
((
SNode
*
)
pNode
);
}
}
else
{
TSWAP
(((
SAggLogicNode
*
)
pNode
)
->
pGroupKeys
,
pScan
->
pPartTags
);
SNode
*
pGroupKey
=
NULL
;
FOREACH
(
pGroupKey
,
((
SAggLogicNode
*
)
pNode
)
->
pGroupKeys
)
{
code
=
nodesListMakeStrictAppend
(
&
pScan
->
pPartTags
,
nodesCloneNode
(
nodesListGetNode
(((
SGroupingSetNode
*
)
pGroupKey
)
->
pParameterList
,
0
)));
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
break
;
}
}
DESTORY_LIST
(((
SAggLogicNode
*
)
pNode
)
->
pGroupKeys
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
partTagsOptRebuildTbanme
(
pScan
->
pPartTags
);
}
return
code
;
}
...
...
@@ -1184,7 +1217,7 @@ static const SOptimizeRule optimizeRuleSet[] = {
{.
pName
=
"ConditionPushDown"
,
.
optimizeFunc
=
cpdOptimize
},
{.
pName
=
"OrderByPrimaryKey"
,
.
optimizeFunc
=
opkOptimize
},
{.
pName
=
"SmaIndex"
,
.
optimizeFunc
=
smaOptimize
},
{.
pName
=
"PartitionByTags"
,
.
optimizeFunc
=
partTagsOptimize
},
// {.pName = "PartitionTags",
.optimizeFunc = partTagsOptimize},
{.
pName
=
"EliminateProject"
,
.
optimizeFunc
=
eliminateProjOptimize
}
};
// clang-format on
...
...
source/libs/planner/src/planSpliter.c
浏览文件 @
bae71438
...
...
@@ -176,7 +176,7 @@ static bool stbSplNeedSplit(bool streamQuery, SLogicNode* pNode) {
return
!
stbSplHasGatherExecFunc
(((
SAggLogicNode
*
)
pNode
)
->
pAggFuncs
)
&&
stbSplHasMultiTbScan
(
streamQuery
,
pNode
);
case
QUERY_NODE_LOGIC_PLAN_WINDOW
:
{
SWindowLogicNode
*
pWindow
=
(
SWindowLogicNode
*
)
pNode
;
if
(
WINDOW_TYPE_STATE
==
pWindow
->
winType
||
(
!
streamQuery
&&
WINDOW_TYPE_SESSION
==
pWindow
->
winType
)
)
{
if
(
WINDOW_TYPE_STATE
==
pWindow
->
winType
||
(
!
streamQuery
&&
WINDOW_TYPE_SESSION
==
pWindow
->
winType
))
{
return
false
;
}
return
!
stbSplHasGatherExecFunc
(
pWindow
->
pFuncs
)
&&
stbSplHasMultiTbScan
(
streamQuery
,
pNode
);
...
...
@@ -380,6 +380,7 @@ static int32_t stbSplCreateExchangeNode(SSplitContext* pCxt, SLogicNode* pParent
SExchangeLogicNode
*
pExchange
=
NULL
;
int32_t
code
=
splCreateExchangeNode
(
pCxt
,
pPartChild
,
&
pExchange
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
pExchange
->
node
.
pParent
=
pParent
;
code
=
nodesListMakeAppend
(
&
pParent
->
pChildren
,
(
SNode
*
)
pExchange
);
}
return
code
;
...
...
@@ -484,7 +485,27 @@ static int32_t stbSplSplitSession(SSplitContext* pCxt, SStableSplitInfo* pInfo)
}
}
static
int32_t
stbSplSplitWindowNode
(
SSplitContext
*
pCxt
,
SStableSplitInfo
*
pInfo
)
{
static
SNodeList
*
stbSplGetPartKeys
(
SLogicNode
*
pNode
)
{
if
(
QUERY_NODE_LOGIC_PLAN_SCAN
==
nodeType
(
pNode
))
{
return
((
SScanLogicNode
*
)
pNode
)
->
pPartTags
;
}
else
{
return
NULL
;
}
}
static
bool
stbSplIsPartTbanme
(
SNodeList
*
pPartKeys
)
{
if
(
NULL
==
pPartKeys
||
1
!=
LIST_LENGTH
(
pPartKeys
))
{
return
false
;
}
SNode
*
pPartKey
=
nodesListGetNode
(
pPartKeys
,
0
);
return
QUERY_NODE_FUNCTION
==
nodeType
(
pPartKey
)
&&
FUNCTION_TYPE_TBNAME
==
((
SFunctionNode
*
)
pPartKey
)
->
funcType
;
}
static
bool
stbSplIsMultiTableWinodw
(
SWindowLogicNode
*
pWindow
)
{
return
stbSplIsPartTbanme
(
stbSplGetPartKeys
((
SLogicNode
*
)
nodesListGetNode
(
pWindow
->
node
.
pChildren
,
0
)));
}
static
int32_t
stbSplSplitWindowForMergeTable
(
SSplitContext
*
pCxt
,
SStableSplitInfo
*
pInfo
)
{
switch
(((
SWindowLogicNode
*
)
pInfo
->
pSplitNode
)
->
winType
)
{
case
WINDOW_TYPE_INTERVAL
:
return
stbSplSplitInterval
(
pCxt
,
pInfo
);
...
...
@@ -496,6 +517,34 @@ static int32_t stbSplSplitWindowNode(SSplitContext* pCxt, SStableSplitInfo* pInf
return
TSDB_CODE_PLAN_INTERNAL_ERROR
;
}
static
int32_t
stbSplSplitWindowForMultiTable
(
SSplitContext
*
pCxt
,
SStableSplitInfo
*
pInfo
)
{
if
(
pCxt
->
pPlanCxt
->
streamQuery
)
{
SPLIT_FLAG_SET_MASK
(
pInfo
->
pSubplan
->
splitFlag
,
SPLIT_FLAG_STABLE_SPLIT
);
return
TSDB_CODE_SUCCESS
;
}
SExchangeLogicNode
*
pExchange
=
NULL
;
int32_t
code
=
splCreateExchangeNode
(
pCxt
,
pInfo
->
pSplitNode
,
&
pExchange
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
replaceLogicNode
(
pInfo
->
pSubplan
,
pInfo
->
pSplitNode
,
(
SLogicNode
*
)
pExchange
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodesListMakeStrictAppend
(
&
pInfo
->
pSubplan
->
pChildren
,
(
SNode
*
)
splCreateScanSubplan
(
pCxt
,
pInfo
->
pSplitNode
,
SPLIT_FLAG_STABLE_SPLIT
));
}
pInfo
->
pSubplan
->
subplanType
=
SUBPLAN_TYPE_MERGE
;
++
(
pCxt
->
groupId
);
return
code
;
}
static
int32_t
stbSplSplitWindowNode
(
SSplitContext
*
pCxt
,
SStableSplitInfo
*
pInfo
)
{
if
(
stbSplIsMultiTableWinodw
((
SWindowLogicNode
*
)
pInfo
->
pSplitNode
))
{
return
stbSplSplitWindowForMultiTable
(
pCxt
,
pInfo
);
}
else
{
return
stbSplSplitWindowForMergeTable
(
pCxt
,
pInfo
);
}
}
static
int32_t
stbSplCreatePartAggNode
(
SAggLogicNode
*
pMergeAgg
,
SLogicNode
**
pOutput
)
{
SNodeList
*
pFunc
=
pMergeAgg
->
pAggFuncs
;
pMergeAgg
->
pAggFuncs
=
NULL
;
...
...
source/libs/planner/test/planOtherTest.cpp
浏览文件 @
bae71438
...
...
@@ -37,7 +37,9 @@ TEST_F(PlanOtherTest, createStream) {
TEST_F
(
PlanOtherTest
,
createStreamUseSTable
)
{
useDb
(
"root"
,
"test"
);
run
(
"create stream if not exists s1 as select count(*) from st1 interval(10s)"
);
run
(
"CREATE STREAM IF NOT EXISTS s1 as SELECT COUNT(*) FROM st1 INTERVAL(10s)"
);
run
(
"CREATE STREAM IF NOT EXISTS s1 as SELECT COUNT(*) FROM st1 PARTITION BY TBNAME INTERVAL(10s)"
);
}
TEST_F
(
PlanOtherTest
,
createSmaIndex
)
{
...
...
source/libs/stream/src/stream.c
浏览文件 @
bae71438
...
...
@@ -50,6 +50,10 @@ void streamCleanUp() {
void
streamTriggerByTimer
(
void
*
param
,
void
*
tmrId
)
{
SStreamTask
*
pTask
=
(
void
*
)
param
;
if
(
atomic_load_8
(
&
pTask
->
taskStatus
)
==
TASK_STATUS__DROPPING
)
{
return
;
}
if
(
atomic_load_8
(
&
pTask
->
triggerStatus
)
==
TASK_TRIGGER_STATUS__ACTIVE
)
{
SStreamTrigger
*
trigger
=
taosAllocateQitem
(
sizeof
(
SStreamTrigger
),
DEF_QITEM
);
if
(
trigger
==
NULL
)
return
;
...
...
@@ -82,8 +86,8 @@ int32_t streamSetupTrigger(SStreamTask* pTask) {
}
int32_t
streamLaunchByWrite
(
SStreamTask
*
pTask
,
int32_t
vgId
)
{
int8_t
execStatus
=
atomic_load_8
(
&
pTask
->
s
tatus
);
if
(
execStatus
==
TASK_
STATUS__IDLE
||
execStatus
==
TASK
_STATUS__CLOSING
)
{
int8_t
execStatus
=
atomic_load_8
(
&
pTask
->
execS
tatus
);
if
(
execStatus
==
TASK_
EXEC_STATUS__IDLE
||
execStatus
==
TASK_EXEC
_STATUS__CLOSING
)
{
SStreamTaskRunReq
*
pRunReq
=
rpcMallocCont
(
sizeof
(
SStreamTaskRunReq
));
if
(
pRunReq
==
NULL
)
return
-
1
;
...
...
@@ -188,6 +192,7 @@ int32_t streamProcessDispatchRsp(SStreamTask* pTask, SStreamDispatchRsp* pRsp) {
int32_t
streamProcessRunReq
(
SStreamTask
*
pTask
)
{
streamExec
(
pTask
,
pTask
->
pMsgCb
);
if
(
pTask
->
dispatchType
!=
TASK_DISPATCH__NONE
)
{
streamDispatch
(
pTask
,
pTask
->
pMsgCb
);
}
...
...
source/libs/stream/src/streamExec.c
浏览文件 @
bae71438
...
...
@@ -33,6 +33,9 @@ static int32_t streamTaskExecImpl(SStreamTask* pTask, void* data, SArray* pRes)
ASSERT
(
pTask
->
inputType
==
STREAM_INPUT__DATA_BLOCK
);
SArray
*
blocks
=
pBlock
->
blocks
;
qSetMultiStreamInput
(
exec
,
blocks
->
pData
,
blocks
->
size
,
STREAM_DATA_TYPE_SSDATA_BLOCK
,
false
);
}
else
if
(
pItem
->
type
==
STREAM_INPUT__DROP
)
{
// TODO exec drop
return
0
;
}
// exec
...
...
@@ -58,6 +61,10 @@ static SArray* streamExecForQall(SStreamTask* pTask, SArray* pRes) {
streamTaskExecImpl
(
pTask
,
data
,
pRes
);
if
(
pTask
->
taskStatus
==
TASK_STATUS__DROPPING
)
{
return
NULL
;
}
if
(
taosArrayGetSize
(
pRes
)
!=
0
)
{
SStreamDataBlock
*
qRes
=
taosAllocateQitem
(
sizeof
(
SStreamDataBlock
),
DEF_QITEM
);
if
(
qRes
==
NULL
)
{
...
...
@@ -75,12 +82,17 @@ static SArray* streamExecForQall(SStreamTask* pTask, SArray* pRes) {
return
NULL
;
}
if
(
pTask
->
inputType
==
STREAM_INPUT__DATA_SUBMIT
)
{
streamDataSubmitRefDec
((
SStreamDataSubmit
*
)
data
);
if
(
((
SStreamQueueItem
*
)
data
)
->
type
==
STREAM_INPUT__TRIGGER
)
{
blockDataDestroy
(((
SStreamTrigger
*
)
data
)
->
pBlock
);
taosFreeQitem
(
data
);
}
else
{
taosArrayDestroyEx
(((
SStreamDataBlock
*
)
data
)
->
blocks
,
(
FDelete
)
tDeleteSSDataBlock
);
taosFreeQitem
(
data
);
if
(
pTask
->
inputType
==
STREAM_INPUT__DATA_SUBMIT
)
{
streamDataSubmitRefDec
((
SStreamDataSubmit
*
)
data
);
taosFreeQitem
(
data
);
}
else
{
taosArrayDestroyEx
(((
SStreamDataBlock
*
)
data
)
->
blocks
,
(
FDelete
)
tDeleteSSDataBlock
);
taosFreeQitem
(
data
);
}
}
streamQueueProcessSuccess
(
pTask
->
inputQueue
);
return
taosArrayInit
(
0
,
sizeof
(
SSDataBlock
));
...
...
@@ -94,25 +106,26 @@ int32_t streamExec(SStreamTask* pTask, SMsgCb* pMsgCb) {
SArray
*
pRes
=
taosArrayInit
(
0
,
sizeof
(
SSDataBlock
));
if
(
pRes
==
NULL
)
return
-
1
;
while
(
1
)
{
int8_t
execStatus
=
atomic_val_compare_exchange_8
(
&
pTask
->
status
,
TASK_STATUS__IDLE
,
TASK_STATUS__EXECUTING
);
if
(
execStatus
==
TASK_STATUS__IDLE
)
{
int8_t
execStatus
=
atomic_val_compare_exchange_8
(
&
pTask
->
execStatus
,
TASK_EXEC_STATUS__IDLE
,
TASK_EXEC_STATUS__EXECUTING
);
if
(
execStatus
==
TASK_EXEC_STATUS__IDLE
)
{
// first run
pRes
=
streamExecForQall
(
pTask
,
pRes
);
if
(
pRes
==
NULL
)
goto
FAIL
;
// set status closing
atomic_store_8
(
&
pTask
->
status
,
TASK
_STATUS__CLOSING
);
atomic_store_8
(
&
pTask
->
execStatus
,
TASK_EXEC
_STATUS__CLOSING
);
// second run, make sure inputQ and qall are cleared
pRes
=
streamExecForQall
(
pTask
,
pRes
);
if
(
pRes
==
NULL
)
goto
FAIL
;
taosArrayDestroy
(
pRes
);
atomic_store_8
(
&
pTask
->
status
,
TASK
_STATUS__IDLE
);
atomic_store_8
(
&
pTask
->
execStatus
,
TASK_EXEC
_STATUS__IDLE
);
return
0
;
}
else
if
(
execStatus
==
TASK_STATUS__CLOSING
)
{
}
else
if
(
execStatus
==
TASK_
EXEC_
STATUS__CLOSING
)
{
continue
;
}
else
if
(
execStatus
==
TASK_STATUS__EXECUTING
)
{
}
else
if
(
execStatus
==
TASK_
EXEC_
STATUS__EXECUTING
)
{
ASSERT
(
taosArrayGetSize
(
pRes
)
==
0
);
taosArrayDestroy
(
pRes
);
return
0
;
...
...
@@ -122,7 +135,7 @@ int32_t streamExec(SStreamTask* pTask, SMsgCb* pMsgCb) {
}
FAIL:
if
(
pRes
)
taosArrayDestroy
(
pRes
);
atomic_store_8
(
&
pTask
->
status
,
TASK
_STATUS__IDLE
);
atomic_store_8
(
&
pTask
->
execStatus
,
TASK_EXEC
_STATUS__IDLE
);
return
-
1
;
}
source/libs/stream/src/streamTask.c
浏览文件 @
bae71438
...
...
@@ -23,7 +23,7 @@ SStreamTask* tNewSStreamTask(int64_t streamId) {
}
pTask
->
taskId
=
tGenIdPI32
();
pTask
->
streamId
=
streamId
;
pTask
->
status
=
TASK
_STATUS__IDLE
;
pTask
->
execStatus
=
TASK_EXEC
_STATUS__IDLE
;
pTask
->
inputStatus
=
TASK_INPUT_STATUS__NORMAL
;
pTask
->
outputStatus
=
TASK_OUTPUT_STATUS__NORMAL
;
...
...
@@ -35,7 +35,8 @@ int32_t tEncodeSStreamTask(SEncoder* pEncoder, const SStreamTask* pTask) {
if
(
tEncodeI64
(
pEncoder
,
pTask
->
streamId
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
pTask
->
taskId
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pEncoder
,
pTask
->
inputType
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pEncoder
,
pTask
->
status
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pEncoder
,
pTask
->
taskStatus
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pEncoder
,
pTask
->
execStatus
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pEncoder
,
pTask
->
execType
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pEncoder
,
pTask
->
sinkType
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pEncoder
,
pTask
->
dispatchType
)
<
0
)
return
-
1
;
...
...
@@ -83,7 +84,8 @@ int32_t tDecodeSStreamTask(SDecoder* pDecoder, SStreamTask* pTask) {
if
(
tDecodeI64
(
pDecoder
,
&
pTask
->
streamId
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pDecoder
,
&
pTask
->
taskId
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pDecoder
,
&
pTask
->
inputType
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pDecoder
,
&
pTask
->
status
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pDecoder
,
&
pTask
->
taskStatus
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pDecoder
,
&
pTask
->
execStatus
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pDecoder
,
&
pTask
->
execType
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pDecoder
,
&
pTask
->
sinkType
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pDecoder
,
&
pTask
->
dispatchType
)
<
0
)
return
-
1
;
...
...
source/libs/sync/inc/syncInt.h
浏览文件 @
bae71438
...
...
@@ -253,6 +253,7 @@ void syncNodePrint(SSyncNode* pObj);
void
syncNodePrint2
(
char
*
s
,
SSyncNode
*
pObj
);
void
syncNodeLog
(
SSyncNode
*
pObj
);
void
syncNodeLog2
(
char
*
s
,
SSyncNode
*
pObj
);
void
syncNodeLog3
(
char
*
s
,
SSyncNode
*
pObj
);
#ifdef __cplusplus
}
...
...
source/libs/sync/inc/syncRaftCfg.h
浏览文件 @
bae71438
...
...
@@ -27,7 +27,7 @@ extern "C" {
#include "syncInt.h"
#include "taosdef.h"
#define CONFIG_FILE_LEN
1024
#define CONFIG_FILE_LEN
2048
#define MAX_CONFIG_INDEX_COUNT 512
...
...
@@ -49,14 +49,14 @@ int32_t raftCfgClose(SRaftCfg *pRaftCfg);
int32_t
raftCfgPersist
(
SRaftCfg
*
pRaftCfg
);
int32_t
raftCfgAddConfigIndex
(
SRaftCfg
*
pRaftCfg
,
SyncIndex
configIndex
);
cJSON
*
syncCfg2Json
(
SSyncCfg
*
pSyncCfg
);
char
*
syncCfg2Str
(
SSyncCfg
*
pSyncCfg
);
char
*
syncCfg2SimpleStr
(
SSyncCfg
*
pSyncCfg
);
cJSON
*
syncCfg2Json
(
SSyncCfg
*
pSyncCfg
);
char
*
syncCfg2Str
(
SSyncCfg
*
pSyncCfg
);
char
*
syncCfg2SimpleStr
(
SSyncCfg
*
pSyncCfg
);
int32_t
syncCfgFromJson
(
const
cJSON
*
pRoot
,
SSyncCfg
*
pSyncCfg
);
int32_t
syncCfgFromStr
(
const
char
*
s
,
SSyncCfg
*
pSyncCfg
);
cJSON
*
raftCfg2Json
(
SRaftCfg
*
pRaftCfg
);
char
*
raftCfg2Str
(
SRaftCfg
*
pRaftCfg
);
cJSON
*
raftCfg2Json
(
SRaftCfg
*
pRaftCfg
);
char
*
raftCfg2Str
(
SRaftCfg
*
pRaftCfg
);
int32_t
raftCfgFromJson
(
const
cJSON
*
pRoot
,
SRaftCfg
*
pRaftCfg
);
int32_t
raftCfgFromStr
(
const
char
*
s
,
SRaftCfg
*
pRaftCfg
);
...
...
source/libs/sync/inc/syncSnapshot.h
浏览文件 @
bae71438
...
...
@@ -39,8 +39,8 @@ typedef struct SSyncSnapshotSender {
bool
start
;
int32_t
seq
;
int32_t
ack
;
void
*
pReader
;
void
*
pCurrentBlock
;
void
*
pReader
;
void
*
pCurrentBlock
;
int32_t
blockLen
;
SSnapshot
snapshot
;
SSyncCfg
lastConfig
;
...
...
@@ -55,19 +55,19 @@ typedef struct SSyncSnapshotSender {
SSyncSnapshotSender
*
snapshotSenderCreate
(
SSyncNode
*
pSyncNode
,
int32_t
replicaIndex
);
void
snapshotSenderDestroy
(
SSyncSnapshotSender
*
pSender
);
bool
snapshotSenderIsStart
(
SSyncSnapshotSender
*
pSender
);
void
snapshotSenderStart
(
SSyncSnapshotSender
*
pSender
);
void
snapshotSenderStart
(
SSyncSnapshotSender
*
pSender
,
SSnapshot
snapshot
,
void
*
pReader
);
void
snapshotSenderStop
(
SSyncSnapshotSender
*
pSender
);
int32_t
snapshotSend
(
SSyncSnapshotSender
*
pSender
);
int32_t
snapshotReSend
(
SSyncSnapshotSender
*
pSender
);
cJSON
*
snapshotSender2Json
(
SSyncSnapshotSender
*
pSender
);
char
*
snapshotSender2Str
(
SSyncSnapshotSender
*
pSender
);
char
*
snapshotSender2SimpleStr
(
SSyncSnapshotSender
*
pSender
,
char
*
event
);
cJSON
*
snapshotSender2Json
(
SSyncSnapshotSender
*
pSender
);
char
*
snapshotSender2Str
(
SSyncSnapshotSender
*
pSender
);
char
*
snapshotSender2SimpleStr
(
SSyncSnapshotSender
*
pSender
,
char
*
event
);
typedef
struct
SSyncSnapshotReceiver
{
bool
start
;
int32_t
ack
;
void
*
pWriter
;
void
*
pWriter
;
SyncTerm
term
;
SyncTerm
privateTerm
;
SSnapshot
snapshot
;
...
...
@@ -83,8 +83,8 @@ void snapshotReceiverStart(SSyncSnapshotReceiver *pReceiver, SyncTerm privateT
bool
snapshotReceiverIsStart
(
SSyncSnapshotReceiver
*
pReceiver
);
void
snapshotReceiverStop
(
SSyncSnapshotReceiver
*
pReceiver
,
bool
apply
);
cJSON
*
snapshotReceiver2Json
(
SSyncSnapshotReceiver
*
pReceiver
);
char
*
snapshotReceiver2Str
(
SSyncSnapshotReceiver
*
pReceiver
);
char
*
snapshotReceiver2SimpleStr
(
SSyncSnapshotReceiver
*
pReceiver
,
char
*
event
);
char
*
snapshotReceiver2Str
(
SSyncSnapshotReceiver
*
pReceiver
);
char
*
snapshotReceiver2SimpleStr
(
SSyncSnapshotReceiver
*
pReceiver
,
char
*
event
);
int32_t
syncNodeOnSnapshotSendCb
(
SSyncNode
*
ths
,
SyncSnapshotSend
*
pMsg
);
int32_t
syncNodeOnSnapshotRspCb
(
SSyncNode
*
ths
,
SyncSnapshotRsp
*
pMsg
);
...
...
source/libs/sync/src/syncAppendEntriesReply.c
浏览文件 @
bae71438
...
...
@@ -173,21 +173,44 @@ int32_t syncNodeOnAppendEntriesReplySnapshotCb(SSyncNode* ths, SyncAppendEntries
// get sender
SSyncSnapshotSender
*
pSender
=
syncNodeGetSnapshotSender
(
ths
,
&
(
pMsg
->
srcId
));
ASSERT
(
pSender
!=
NULL
);
bool
hasSnapshot
=
syncNodeHasSnapshot
(
ths
);
SSnapshot
snapshot
;
ths
->
pFsm
->
FpGetSnapshotInfo
(
ths
->
pFsm
,
&
snapshot
);
// start sending snapshot first time
// start here, stop by receiver
if
(
hasSnapshot
&&
nextIndex
<=
snapshot
.
lastApplyIndex
+
1
&&
!
snapshotSenderIsStart
(
pSender
)
&&
pMsg
->
privateTerm
<
pSender
->
privateTerm
)
{
snapshotSenderStart
(
pSender
);
SSnapshot
snapshot
;
void
*
pReader
=
NULL
;
ths
->
pFsm
->
FpGetSnapshot
(
ths
->
pFsm
,
&
snapshot
,
NULL
,
&
pReader
);
if
(
snapshot
.
lastApplyIndex
>=
SYNC_INDEX_BEGIN
&&
nextIndex
<=
snapshot
.
lastApplyIndex
+
1
&&
!
snapshotSenderIsStart
(
pSender
)
&&
pMsg
->
privateTerm
<
pSender
->
privateTerm
)
{
// has snapshot
ASSERT
(
pReader
!=
NULL
);
snapshotSenderStart
(
pSender
,
snapshot
,
pReader
);
char
*
eventLog
=
snapshotSender2SimpleStr
(
pSender
,
"snapshot sender start"
);
syncNodeEventLog
(
ths
,
eventLog
);
taosMemoryFree
(
eventLog
);
}
else
{
// no snapshot
if
(
pReader
!=
NULL
)
{
ths
->
pFsm
->
FpSnapshotStopRead
(
ths
->
pFsm
,
pReader
);
}
}
/*
bool hasSnapshot = syncNodeHasSnapshot(ths);
SSnapshot snapshot;
ths->pFsm->FpGetSnapshotInfo(ths->pFsm, &snapshot);
// start sending snapshot first time
// start here, stop by receiver
if (hasSnapshot && nextIndex <= snapshot.lastApplyIndex + 1 && !snapshotSenderIsStart(pSender) &&
pMsg->privateTerm < pSender->privateTerm) {
snapshotSenderStart(pSender);
char* eventLog = snapshotSender2SimpleStr(pSender, "snapshot sender start");
syncNodeEventLog(ths, eventLog);
taosMemoryFree(eventLog);
}
*/
SyncIndex
sentryIndex
=
pSender
->
snapshot
.
lastApplyIndex
+
1
;
// update nextIndex to sentryIndex
...
...
@@ -207,12 +230,6 @@ int32_t syncNodeOnAppendEntriesReplySnapshotCb(SSyncNode* ths, SyncAppendEntries
syncIndexMgrLog2
(
"recv SyncAppendEntriesReply, after pNextIndex:"
,
ths
->
pNextIndex
);
syncIndexMgrLog2
(
"recv SyncAppendEntriesReply, after pMatchIndex:"
,
ths
->
pMatchIndex
);
if
(
gRaftDetailLog
)
{
SSnapshot
snapshot
;
ths
->
pFsm
->
FpGetSnapshotInfo
(
ths
->
pFsm
,
&
snapshot
);
sTrace
(
"recv SyncAppendEntriesReply, after snapshot.lastApplyIndex:%ld, snapshot.lastApplyTerm:%lu"
,
snapshot
.
lastApplyIndex
,
snapshot
.
lastApplyTerm
);
}
return
ret
;
}
\ No newline at end of file
source/libs/sync/src/syncIndexMgr.c
浏览文件 @
bae71438
...
...
@@ -63,7 +63,12 @@ void syncIndexMgrSetIndex(SSyncIndexMgr *pSyncIndexMgr, const SRaftId *pRaftId,
}
// maybe config change
assert
(
0
);
// assert(0);
char
host
[
128
];
uint16_t
port
;
syncUtilU642Addr
(
pRaftId
->
addr
,
host
,
sizeof
(
host
),
&
port
);
sError
(
"vgId:%d index mgr set for %s:%d, index:%"
PRId64
" error"
,
pSyncIndexMgr
->
pSyncNode
->
vgId
,
host
,
port
,
index
);
}
SyncIndex
syncIndexMgrGetIndex
(
SSyncIndexMgr
*
pSyncIndexMgr
,
const
SRaftId
*
pRaftId
)
{
...
...
@@ -73,7 +78,9 @@ SyncIndex syncIndexMgrGetIndex(SSyncIndexMgr *pSyncIndexMgr, const SRaftId *pRaf
return
idx
;
}
}
assert
(
0
);
syncNodeLog3
(
"syncIndexMgrGetIndex"
,
pSyncIndexMgr
->
pSyncNode
);
ASSERT
(
0
);
}
cJSON
*
syncIndexMgr2Json
(
SSyncIndexMgr
*
pSyncIndexMgr
)
{
...
...
@@ -119,7 +126,7 @@ cJSON *syncIndexMgr2Json(SSyncIndexMgr *pSyncIndexMgr) {
char
*
syncIndexMgr2Str
(
SSyncIndexMgr
*
pSyncIndexMgr
)
{
cJSON
*
pJson
=
syncIndexMgr2Json
(
pSyncIndexMgr
);
char
*
serialized
=
cJSON_Print
(
pJson
);
char
*
serialized
=
cJSON_Print
(
pJson
);
cJSON_Delete
(
pJson
);
return
serialized
;
}
...
...
@@ -162,7 +169,11 @@ void syncIndexMgrSetTerm(SSyncIndexMgr *pSyncIndexMgr, const SRaftId *pRaftId, S
}
// maybe config change
assert
(
0
);
// assert(0);
char
host
[
128
];
uint16_t
port
;
syncUtilU642Addr
(
pRaftId
->
addr
,
host
,
sizeof
(
host
),
&
port
);
sError
(
"vgId:%d index mgr set for %s:%d, term:%lu error"
,
pSyncIndexMgr
->
pSyncNode
->
vgId
,
host
,
port
,
term
);
}
SyncTerm
syncIndexMgrGetTerm
(
SSyncIndexMgr
*
pSyncIndexMgr
,
const
SRaftId
*
pRaftId
)
{
...
...
source/libs/sync/src/syncMain.c
浏览文件 @
bae71438
...
...
@@ -1282,6 +1282,9 @@ cJSON* syncNode2Json(const SSyncNode* pSyncNode) {
// snapshot receivers
cJSON
*
pReceivers
=
cJSON_CreateArray
();
cJSON_AddItemToObject
(
pRoot
,
"receiver"
,
snapshotReceiver2Json
(
pSyncNode
->
pNewNodeReceiver
));
// changing
cJSON_AddNumberToObject
(
pRoot
,
"changing"
,
pSyncNode
->
changing
);
}
cJSON
*
pJson
=
cJSON_CreateObject
();
...
...
@@ -1304,26 +1307,31 @@ void syncNodeEventLog(const SSyncNode* pSyncNode, char* str) {
pSyncNode
->
pFsm
->
FpGetSnapshotInfo
(
pSyncNode
->
pFsm
,
&
snapshot
);
}
SyncIndex
logLastIndex
=
pSyncNode
->
pLogStore
->
syncLogLastIndex
(
pSyncNode
->
pLogStore
);
SyncIndex
logBeginIndex
=
pSyncNode
->
pLogStore
->
syncLogBeginIndex
(
pSyncNode
->
pLogStore
);
if
(
userStrLen
<
256
)
{
char
logBuf
[
128
+
256
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"vgId:%d, sync %s %s, term:%lu, commit:%ld, lastlog:%ld, lastsnapshot:%ld, standby:%d, replica-num:%d, "
"vgId:%d, sync %s %s, term:%lu, commit:%ld, beginlog:%ld, lastlog:%ld, lastsnapshot:%ld, standby:%d, "
"replica-num:%d, "
"lconfig:%ld, changing:%d"
,
pSyncNode
->
vgId
,
syncUtilState2String
(
pSyncNode
->
state
),
str
,
pSyncNode
->
pRaftStore
->
currentTerm
,
pSyncNode
->
commitIndex
,
logLastIndex
,
snapshot
.
lastApplyIndex
,
pSyncNode
->
pRaftCfg
->
isStandBy
,
pSyncNode
->
replicaNum
,
pSyncNode
->
pRaftCfg
->
lastConfigIndex
,
pSyncNode
->
changing
);
pSyncNode
->
commitIndex
,
logBeginIndex
,
logLastIndex
,
snapshot
.
lastApplyIndex
,
pSyncNode
->
pRaftCfg
->
isStandBy
,
pSyncNode
->
replicaNum
,
pSyncNode
->
pRaftCfg
->
lastConfigIndex
,
pSyncNode
->
changing
);
sDebug
(
"%s"
,
logBuf
);
}
else
{
int
len
=
128
+
userStrLen
;
char
*
s
=
(
char
*
)
taosMemoryMalloc
(
len
);
snprintf
(
s
,
len
,
"vgId:%d, sync %s %s, term:%lu, commit:%ld, lastlog:%ld, lastsnapshot:%ld, standby:%d, replica-num:%d, "
"vgId:%d, sync %s %s, term:%lu, commit:%ld, beginlog:%ld, lastlog:%ld, lastsnapshot:%ld, standby:%d, "
"replica-num:%d, "
"lconfig:%ld, changing:%d"
,
pSyncNode
->
vgId
,
syncUtilState2String
(
pSyncNode
->
state
),
str
,
pSyncNode
->
pRaftStore
->
currentTerm
,
pSyncNode
->
commitIndex
,
logLastIndex
,
snapshot
.
lastApplyIndex
,
pSyncNode
->
pRaftCfg
->
isStandBy
,
pSyncNode
->
replicaNum
,
pSyncNode
->
pRaftCfg
->
lastConfigIndex
,
pSyncNode
->
changing
);
pSyncNode
->
commitIndex
,
logBeginIndex
,
logLastIndex
,
snapshot
.
lastApplyIndex
,
pSyncNode
->
pRaftCfg
->
isStandBy
,
pSyncNode
->
replicaNum
,
pSyncNode
->
pRaftCfg
->
lastConfigIndex
,
pSyncNode
->
changing
);
sDebug
(
"%s"
,
s
);
taosMemoryFree
(
s
);
}
...
...
@@ -1400,7 +1408,7 @@ void syncNodeDoConfigChange(SSyncNode* pSyncNode, SSyncCfg* pNewConfig, SyncInde
pSyncNode
->
pRaftCfg
->
isStandBy
=
1
;
// set standby
}
//
persist
last config index
//
add
last config index
raftCfgAddConfigIndex
(
pSyncNode
->
pRaftCfg
,
lastConfigChangeIndex
);
if
(
IamInNew
)
{
...
...
@@ -1827,7 +1835,11 @@ SyncIndex syncNodeSyncStartIndex(SSyncNode* pSyncNode) {
SyncIndex
syncNodeGetPreIndex
(
SSyncNode
*
pSyncNode
,
SyncIndex
index
)
{
ASSERT
(
index
>=
SYNC_INDEX_BEGIN
);
SyncIndex
syncStartIndex
=
syncNodeSyncStartIndex
(
pSyncNode
);
ASSERT
(
index
<=
syncStartIndex
);
if
(
index
>
syncStartIndex
)
{
syncNodeLog3
(
"syncNodeGetPreIndex"
,
pSyncNode
);
ASSERT
(
0
);
}
SyncIndex
preIndex
=
index
-
1
;
return
preIndex
;
...
...
@@ -1836,7 +1848,11 @@ SyncIndex syncNodeGetPreIndex(SSyncNode* pSyncNode, SyncIndex index) {
SyncTerm
syncNodeGetPreTerm
(
SSyncNode
*
pSyncNode
,
SyncIndex
index
)
{
ASSERT
(
index
>=
SYNC_INDEX_BEGIN
);
SyncIndex
syncStartIndex
=
syncNodeSyncStartIndex
(
pSyncNode
);
ASSERT
(
index
<=
syncStartIndex
);
if
(
index
>
syncStartIndex
)
{
syncNodeLog3
(
"syncNodeGetPreTerm"
,
pSyncNode
);
ASSERT
(
0
);
}
if
(
index
==
SYNC_INDEX_BEGIN
)
{
return
0
;
...
...
@@ -1929,6 +1945,12 @@ void syncNodeLog2(char* s, SSyncNode* pObj) {
}
}
void
syncNodeLog3
(
char
*
s
,
SSyncNode
*
pObj
)
{
char
*
serialized
=
syncNode2Str
(
pObj
);
sTraceLong
(
"syncNodeLog3 | len:%lu | %s | %s"
,
strlen
(
serialized
),
s
,
serialized
);
taosMemoryFree
(
serialized
);
}
// ------ local funciton ---------
// enqueue message ----
static
void
syncNodeEqPingTimer
(
void
*
param
,
void
*
tmrId
)
{
...
...
source/libs/sync/src/syncRaftCfg.c
浏览文件 @
bae71438
...
...
@@ -53,7 +53,12 @@ int32_t raftCfgPersist(SRaftCfg *pRaftCfg) {
char
buf
[
CONFIG_FILE_LEN
]
=
{
0
};
memset
(
buf
,
0
,
sizeof
(
buf
));
ASSERT
(
strlen
(
s
)
+
1
<=
CONFIG_FILE_LEN
);
if
(
strlen
(
s
)
+
1
>
CONFIG_FILE_LEN
)
{
sError
(
"too long config str:%s"
,
s
);
ASSERT
(
0
);
}
snprintf
(
buf
,
sizeof
(
buf
),
"%s"
,
s
);
int64_t
ret
=
taosWriteFile
(
pRaftCfg
->
pFile
,
buf
,
sizeof
(
buf
));
assert
(
ret
==
sizeof
(
buf
));
...
...
@@ -96,14 +101,14 @@ cJSON *syncCfg2Json(SSyncCfg *pSyncCfg) {
char
*
syncCfg2Str
(
SSyncCfg
*
pSyncCfg
)
{
cJSON
*
pJson
=
syncCfg2Json
(
pSyncCfg
);
char
*
serialized
=
cJSON_Print
(
pJson
);
char
*
serialized
=
cJSON_Print
(
pJson
);
cJSON_Delete
(
pJson
);
return
serialized
;
}
char
*
syncCfg2SimpleStr
(
SSyncCfg
*
pSyncCfg
)
{
int32_t
len
=
512
;
char
*
s
=
taosMemoryMalloc
(
len
);
char
*
s
=
taosMemoryMalloc
(
len
);
memset
(
s
,
0
,
len
);
snprintf
(
s
,
len
,
"{replica-num:%d, my-index:%d, "
,
pSyncCfg
->
replicaNum
,
pSyncCfg
->
myIndex
);
...
...
@@ -196,7 +201,7 @@ cJSON *raftCfg2Json(SRaftCfg *pRaftCfg) {
char
*
raftCfg2Str
(
SRaftCfg
*
pRaftCfg
)
{
cJSON
*
pJson
=
raftCfg2Json
(
pRaftCfg
);
char
*
serialized
=
cJSON_Print
(
pJson
);
char
*
serialized
=
cJSON_Print
(
pJson
);
cJSON_Delete
(
pJson
);
return
serialized
;
}
...
...
@@ -262,7 +267,7 @@ int32_t raftCfgFromJson(const cJSON *pRoot, SRaftCfg *pRaftCfg) {
(
pRaftCfg
->
configIndexArr
)[
i
]
=
atoll
(
pIndex
->
valuestring
);
}
cJSON
*
pJsonSyncCfg
=
cJSON_GetObjectItem
(
pJson
,
"SSyncCfg"
);
cJSON
*
pJsonSyncCfg
=
cJSON_GetObjectItem
(
pJson
,
"SSyncCfg"
);
int32_t
code
=
syncCfgFromJson
(
pJsonSyncCfg
,
&
(
pRaftCfg
->
cfg
));
ASSERT
(
code
==
0
);
...
...
source/libs/sync/src/syncSnapshot.c
浏览文件 @
bae71438
...
...
@@ -67,7 +67,7 @@ void snapshotSenderDestroy(SSyncSnapshotSender *pSender) {
bool
snapshotSenderIsStart
(
SSyncSnapshotSender
*
pSender
)
{
return
pSender
->
start
;
}
// begin send snapshot (current term, seq begin)
void
snapshotSenderStart
(
SSyncSnapshotSender
*
pSender
)
{
void
snapshotSenderStart
(
SSyncSnapshotSender
*
pSender
,
SSnapshot
snapshot
,
void
*
pReader
)
{
ASSERT
(
!
snapshotSenderIsStart
(
pSender
));
pSender
->
seq
=
SYNC_SNAPSHOT_SEQ_BEGIN
;
...
...
@@ -75,8 +75,18 @@ void snapshotSenderStart(SSyncSnapshotSender *pSender) {
// open snapshot reader
ASSERT
(
pSender
->
pReader
==
NULL
);
int32_t
ret
=
pSender
->
pSyncNode
->
pFsm
->
FpSnapshotStartRead
(
pSender
->
pSyncNode
->
pFsm
,
&
(
pSender
->
pReader
));
ASSERT
(
ret
==
0
);
pSender
->
pReader
=
pReader
;
pSender
->
snapshot
=
snapshot
;
/*
// open snapshot reader
ASSERT(pSender->pReader == NULL);
int32_t ret = pSender->pSyncNode->pFsm->FpSnapshotStartRead(pSender->pSyncNode->pFsm, &(pSender->pReader));
ASSERT(ret == 0);
// get current snapshot info
pSender->pSyncNode->pFsm->FpGetSnapshotInfo(pSender->pSyncNode->pFsm, &(pSender->snapshot));
*/
if
(
pSender
->
pCurrentBlock
!=
NULL
)
{
taosMemoryFree
(
pSender
->
pCurrentBlock
);
...
...
@@ -84,21 +94,7 @@ void snapshotSenderStart(SSyncSnapshotSender *pSender) {
pSender
->
blockLen
=
0
;
// get current snapshot info
pSender
->
pSyncNode
->
pFsm
->
FpGetSnapshotInfo
(
pSender
->
pSyncNode
->
pFsm
,
&
(
pSender
->
snapshot
));
sTrace
(
"snapshotSenderStart lastApplyIndex:%ld, lastApplyTerm:%lu, lastConfigIndex:%ld"
,
pSender
->
snapshot
.
lastApplyIndex
,
pSender
->
snapshot
.
lastApplyTerm
,
pSender
->
snapshot
.
lastConfigIndex
);
if
(
pSender
->
snapshot
.
lastConfigIndex
!=
SYNC_INDEX_INVALID
)
{
/*
SSyncRaftEntry *pEntry = NULL;
int32_t code = pSender->pSyncNode->pLogStore->syncLogGetEntry(pSender->pSyncNode->pLogStore,
pSender->snapshot.lastConfigIndex, &pEntry);
ASSERT(code == 0);
ASSERT(pEntry != NULL);
*/
SSyncRaftEntry
*
pEntry
=
pSender
->
pSyncNode
->
pLogStore
->
getEntry
(
pSender
->
pSyncNode
->
pLogStore
,
pSender
->
snapshot
.
lastConfigIndex
);
ASSERT
(
pEntry
!=
NULL
);
...
...
source/libs/sync/test/syncReconfigFinishTest.cpp
浏览文件 @
bae71438
...
...
@@ -14,8 +14,8 @@ void logTest() {
sFatal
(
"--- sync log test: fatal"
);
}
SSyncCfg
*
createSyncOldCfg
()
{
SSyncCfg
*
pCfg
=
(
SSyncCfg
*
)
taosMemoryMalloc
(
sizeof
(
SSyncCfg
));
SSyncCfg
*
createSyncOldCfg
()
{
SSyncCfg
*
pCfg
=
(
SSyncCfg
*
)
taosMemoryMalloc
(
sizeof
(
SSyncCfg
));
memset
(
pCfg
,
0
,
sizeof
(
SSyncCfg
));
pCfg
->
replicaNum
=
3
;
...
...
@@ -28,8 +28,8 @@ SSyncCfg* createSyncOldCfg() {
return
pCfg
;
}
SSyncCfg
*
createSyncNewCfg
()
{
SSyncCfg
*
pCfg
=
(
SSyncCfg
*
)
taosMemoryMalloc
(
sizeof
(
SSyncCfg
));
SSyncCfg
*
createSyncNewCfg
()
{
SSyncCfg
*
pCfg
=
(
SSyncCfg
*
)
taosMemoryMalloc
(
sizeof
(
SSyncCfg
));
memset
(
pCfg
,
0
,
sizeof
(
SSyncCfg
));
pCfg
->
replicaNum
=
3
;
...
...
@@ -44,9 +44,9 @@ SSyncCfg* createSyncNewCfg() {
SyncReconfigFinish
*
createMsg
()
{
SyncReconfigFinish
*
pMsg
=
syncReconfigFinishBuild
(
1234
);
SSyncCfg
*
pOld
=
createSyncOldCfg
();
SSyncCfg
*
pNew
=
createSyncNewCfg
();
SSyncCfg
*
pOld
=
createSyncOldCfg
();
SSyncCfg
*
pNew
=
createSyncNewCfg
();
pMsg
->
oldCfg
=
*
pOld
;
pMsg
->
newCfg
=
*
pNew
;
...
...
@@ -60,18 +60,16 @@ SyncReconfigFinish *createMsg() {
return
pMsg
;
}
void
test1
()
{
SyncReconfigFinish
*
pMsg
=
createMsg
();
syncReconfigFinishLog2
((
char
*
)
"test1:"
,
pMsg
);
syncReconfigFinishDestroy
(
pMsg
);
}
void
test2
()
{
SyncReconfigFinish
*
pMsg
=
createMsg
();
uint32_t
len
=
pMsg
->
bytes
;
char
*
serialized
=
(
char
*
)
taosMemoryMalloc
(
len
);
uint32_t
len
=
pMsg
->
bytes
;
char
*
serialized
=
(
char
*
)
taosMemoryMalloc
(
len
);
syncReconfigFinishSerialize
(
pMsg
,
serialized
,
len
);
SyncReconfigFinish
*
pMsg2
=
syncReconfigFinishBuild
(
1000
);
syncReconfigFinishDeserialize
(
serialized
,
len
,
pMsg2
);
...
...
@@ -84,8 +82,8 @@ void test2() {
void
test3
()
{
SyncReconfigFinish
*
pMsg
=
createMsg
();
uint32_t
len
;
char
*
serialized
=
syncReconfigFinishSerialize2
(
pMsg
,
&
len
);
uint32_t
len
;
char
*
serialized
=
syncReconfigFinishSerialize2
(
pMsg
,
&
len
);
SyncReconfigFinish
*
pMsg2
=
syncReconfigFinishDeserialize2
(
serialized
,
len
);
syncReconfigFinishLog2
((
char
*
)
"test3: SyncReconfigFinishSerialize2 -> syncReconfigFinishDeserialize2 "
,
pMsg2
);
...
...
@@ -96,7 +94,7 @@ void test3() {
void
test4
()
{
SyncReconfigFinish
*
pMsg
=
createMsg
();
SRpcMsg
rpcMsg
;
SRpcMsg
rpcMsg
;
syncReconfigFinish2RpcMsg
(
pMsg
,
&
rpcMsg
);
SyncReconfigFinish
*
pMsg2
=
(
SyncReconfigFinish
*
)
taosMemoryMalloc
(
rpcMsg
.
contLen
);
syncReconfigFinishFromRpcMsg
(
&
rpcMsg
,
pMsg2
);
...
...
@@ -109,7 +107,7 @@ void test4() {
void
test5
()
{
SyncReconfigFinish
*
pMsg
=
createMsg
();
SRpcMsg
rpcMsg
;
SRpcMsg
rpcMsg
;
syncReconfigFinish2RpcMsg
(
pMsg
,
&
rpcMsg
);
SyncReconfigFinish
*
pMsg2
=
syncReconfigFinishFromRpcMsg2
(
&
rpcMsg
);
syncReconfigFinishLog2
((
char
*
)
"test5: syncReconfigFinish2RpcMsg -> syncReconfigFinishFromRpcMsg2 "
,
pMsg2
);
...
...
source/libs/transport/inc/transLog.h
浏览文件 @
bae71438
...
...
@@ -24,16 +24,16 @@ extern "C" {
#include "tlog.h"
#include "ttrace.h"
#define tFatal(...)
do {if (rpcDebugFlag & DEBUG_FATAL){ taosPrintLog("RPC FATAL ", DEBUG_FATAL, rpcDebugFlag, __VA_ARGS__); }} while (0)
#define tError(...)
do { if (rpcDebugFlag & DEBUG_ERROR){ taosPrintLog("RPC ERROR ", DEBUG_ERROR, rpcDebugFlag, __VA_ARGS__); } } while(0)
#define tWarn(...)
do { if (rpcDebugFlag & DEBUG_WARN) { taosPrintLog("RPC WARN ", DEBUG_WARN, rpcDebugFlag, __VA_ARGS__); }} while(0)
#define tInfo(...)
do { if (rpcDebugFlag & DEBUG_INFO) { taosPrintLog("RPC ", DEBUG_INFO, rpcDebugFlag, __VA_ARGS__); }} while(0)
#define tDebug(...)
do {if (rpcDebugFlag & DEBUG_DEBUG){ taosPrintLog("RPC ", DEBUG_DEBUG, rpcDebugFlag, __VA_ARGS__); }} while(0)
#define tTrace(...)
do {if (rpcDebugFlag & DEBUG_TRACE){ taosPrintLog("RPC ", DEBUG_TRACE, rpcDebugFlag, __VA_ARGS__); }} while(0)
#define tDump(x, y)
do {if (rpcDebugFlag & DEBUG_DUMP) { taosDumpData((unsigned char *)x, y); } } while(0)
#define tFatal(...)
{ if (rpcDebugFlag & DEBUG_FATAL) { taosPrintLog("RPC FATAL ", DEBUG_FATAL, rpcDebugFlag, __VA_ARGS__); }}
#define tError(...)
{ if (rpcDebugFlag & DEBUG_ERROR ){ taosPrintLog("RPC ERROR ", DEBUG_ERROR, rpcDebugFlag, __VA_ARGS__); }}
#define tWarn(...)
{ if (rpcDebugFlag & DEBUG_WARN) { taosPrintLog("RPC WARN ", DEBUG_WARN, rpcDebugFlag, __VA_ARGS__); }}
#define tInfo(...)
{ if (rpcDebugFlag & DEBUG_INFO) { taosPrintLog("RPC ", DEBUG_INFO, rpcDebugFlag, __VA_ARGS__); }}
#define tDebug(...)
{ if (rpcDebugFlag & DEBUG_DEBUG) { taosPrintLog("RPC ", DEBUG_DEBUG, rpcDebugFlag, __VA_ARGS__); }}
#define tTrace(...)
{ if (rpcDebugFlag & DEBUG_TRACE) { taosPrintLog("RPC ", DEBUG_TRACE, rpcDebugFlag, __VA_ARGS__); }}
#define tDump(x, y)
{ if (rpcDebugFlag & DEBUG_DUMP) { taosDumpData((unsigned char *)x, y); } }
//#define tTR(param, ...) do { char buf[40] = {0};TRACE_TO_STR(trace, buf);tTrace("TRID: %s "param, buf, __VA_ARGS__);} while(0)
#define tGTrace(param, ...)
do { char buf[40] = {0}; TRACE_TO_STR(trace, buf); tTrace(param ", GTID: %s", __VA_ARGS__, buf);} while(0)
#define tGTrace(param, ...)
{ char buf[40] = {0}; TRACE_TO_STR(trace, buf); tTrace(param ", gtid:%s", __VA_ARGS__, buf);}
// clang-format on
#ifdef __cplusplus
...
...
source/util/src/thash.c
浏览文件 @
bae71438
...
...
@@ -31,12 +31,12 @@
#define GET_HASH_NODE_DATA(_n) ((char *)(_n) + sizeof(SHashNode))
#define GET_HASH_PNODE(_n) ((SHashNode *)((char *)(_n) - sizeof(SHashNode)))
#define FREE_HASH_NODE(_fp, _n) \
do { \
if (_fp != NULL) { \
(_fp)(
_n);
\
} \
taosMemoryFreeClear(_n); \
#define FREE_HASH_NODE(_fp, _n)
\
do {
\
if (_fp != NULL) {
\
(_fp)(
GET_HASH_NODE_DATA(_n));
\
}
\
taosMemoryFreeClear(_n);
\
} while (0);
struct
SHashNode
{
...
...
@@ -56,7 +56,7 @@ typedef struct SHashEntry {
}
SHashEntry
;
struct
SHashObj
{
SHashEntry
**
hashList
;
SHashEntry
**
hashList
;
size_t
capacity
;
// number of slots
int64_t
size
;
// number of elements in hash table
_hash_fn_t
hashFp
;
// hash function
...
...
@@ -65,7 +65,7 @@ struct SHashObj {
SRWLatch
lock
;
// read-write spin lock
SHashLockTypeE
type
;
// lock type
bool
enableUpdate
;
// enable update
SArray
*
pMemBlock
;
// memory block allocated for SHashEntry
SArray
*
pMemBlock
;
// memory block allocated for SHashEntry
_hash_before_fn_t
callbackFp
;
// function invoked before return the value to caller
};
...
...
@@ -633,7 +633,7 @@ void taosHashTableResize(SHashObj *pHashObj) {
}
int64_t
st
=
taosGetTimestampUs
();
void
*
pNewEntryList
=
taosMemoryRealloc
(
pHashObj
->
hashList
,
sizeof
(
void
*
)
*
newCapacity
);
void
*
pNewEntryList
=
taosMemoryRealloc
(
pHashObj
->
hashList
,
sizeof
(
void
*
)
*
newCapacity
);
if
(
pNewEntryList
==
NULL
)
{
// uDebug("cache resize failed due to out of memory, capacity remain:%zu", pHashObj->capacity);
return
;
...
...
@@ -642,7 +642,7 @@ void taosHashTableResize(SHashObj *pHashObj) {
pHashObj
->
hashList
=
pNewEntryList
;
size_t
inc
=
newCapacity
-
pHashObj
->
capacity
;
void
*
p
=
taosMemoryCalloc
(
inc
,
sizeof
(
SHashEntry
));
void
*
p
=
taosMemoryCalloc
(
inc
,
sizeof
(
SHashEntry
));
for
(
int32_t
i
=
0
;
i
<
inc
;
++
i
)
{
pHashObj
->
hashList
[
i
+
pHashObj
->
capacity
]
=
(
void
*
)((
char
*
)
p
+
i
*
sizeof
(
SHashEntry
));
...
...
@@ -653,9 +653,9 @@ void taosHashTableResize(SHashObj *pHashObj) {
pHashObj
->
capacity
=
newCapacity
;
for
(
int32_t
idx
=
0
;
idx
<
pHashObj
->
capacity
;
++
idx
)
{
SHashEntry
*
pe
=
pHashObj
->
hashList
[
idx
];
SHashNode
*
pNode
;
SHashNode
*
pNext
;
SHashNode
*
pPrev
=
NULL
;
SHashNode
*
pNode
;
SHashNode
*
pNext
;
SHashNode
*
pPrev
=
NULL
;
if
(
pe
->
num
==
0
)
{
assert
(
pe
->
next
==
NULL
);
...
...
tests/pytest/util/boundary.py
0 → 100644
浏览文件 @
bae71438
class
DataBoundary
:
def
__init__
(
self
):
self
.
TINYINT_BOUNDARY
=
[
-
128
,
127
]
self
.
SMALLINT_BOUNDARY
=
[
-
32768
,
32767
]
self
.
INT_BOUNDARY
=
[
-
2147483648
,
2147483647
]
self
.
BIGINT_BOUNDARY
=
[
-
9223372036854775808
,
9223372036854775807
]
self
.
UTINYINT_BOUNDARY
=
[
0
,
255
]
self
.
USMALLINT_BOUNDARY
=
[
0
,
65535
]
self
.
UINT_BOUNDARY
=
[
0
,
4294967295
]
self
.
UBIGINT_BOUNDARY
=
[
0
,
18446744073709551615
]
self
.
FLOAT_BOUNDARY
=
[
-
3.40E+38
,
3.40E+38
]
self
.
DOUBLE_BOUNDARY
=
[
-
1.7e+308
,
1.7e+308
]
self
.
BOOL_BOUNDARY
=
[
True
,
False
]
self
.
BINARY_MAX_LENGTH
=
16374
self
.
NCHAR_MAX_LENGTH
=
4093
self
.
DBNAME_MAX_LENGTH
=
64
self
.
STBNAME_MAX_LENGTH
=
192
self
.
TBNAME_MAX_LENGTH
=
192
self
.
CHILD_TBNAME_MAX_LENGTH
=
192
self
.
TAG_KEY_MAX_LENGTH
=
64
self
.
COL_KEY_MAX_LENGTH
=
64
self
.
MAX_TAG_COUNT
=
128
self
.
MAX_TAG_COL_COUNT
=
4096
self
.
mnodeShmSize
=
[
6292480
,
2147483647
]
self
.
mnodeShmSize_default
=
6292480
self
.
vnodeShmSize
=
[
6292480
,
2147483647
]
self
.
vnodeShmSize_default
=
31458304
self
.
DB_PARAM_BUFFER_CONFIG
=
{
"create_name"
:
"buffer"
,
"query_name"
:
"buffer"
,
"vnode_json_key"
:
"szBuf"
,
"boundary"
:
[
3
,
16384
],
"default"
:
96
}
self
.
DB_PARAM_CACHELAST_CONFIG
=
{
"create_name"
:
"cachelast"
,
"query_name"
:
"cache_model"
,
"vnode_json_key"
:
""
,
"boundary"
:
[
0
,
1
,
2
,
3
],
"default"
:
0
}
self
.
DB_PARAM_COMP_CONFIG
=
{
"create_name"
:
"comp"
,
"query_name"
:
"compression"
,
"vnode_json_key"
:
""
,
"boundary"
:
[
0
,
1
,
2
],
"default"
:
2
}
self
.
DB_PARAM_DURATION_CONFIG
=
{
"create_name"
:
"duration"
,
"query_name"
:
"duration"
,
"vnode_json_key"
:
"daysPerFile"
,
"boundary"
:
[
1
,
3650
,
'60m'
,
'5256000m'
,
'1h'
,
'87600h'
,
'1d'
,
'3650d'
],
"default"
:
"14400m"
}
self
.
DB_PARAM_FSYNC_CONFIG
=
{
"create_name"
:
"fsync"
,
"query_name"
:
"fsync"
,
"vnode_json_key"
:
""
,
"boundary"
:
[
0
,
180000
],
"default"
:
3000
}
self
.
DB_PARAM_KEEP_CONFIG
=
{
"create_name"
:
"keep"
,
"query_name"
:
"fsync"
,
"vnode_json_key"
:
""
,
"boundary"
:
[
1
,
365000
,
'1440m'
,
'525600000m'
,
'24h'
,
'8760000h'
,
'1d'
,
'365000d'
],
"default"
:
"5256000m,5256000m,5256000m"
}
self
.
DB_PARAM_MAXROWS_CONFIG
=
{
"create_name"
:
"maxrows"
,
"query_name"
:
"maxrows"
,
"vnode_json_key"
:
"maxRows"
,
"boundary"
:
[
200
,
10000
],
"default"
:
4096
}
self
.
DB_PARAM_MINROWS_CONFIG
=
{
"create_name"
:
"minrows"
,
"query_name"
:
"minrows"
,
"vnode_json_key"
:
"minRows"
,
"boundary"
:
[
10
,
1000
],
"default"
:
100
}
self
.
DB_PARAM_NTABLES_CONFIG
=
{
"create_name"
:
"ntables"
,
"query_name"
:
"ntables"
,
"vnode_json_key"
:
""
,
"boundary"
:
0
,
"default"
:
0
}
self
.
DB_PARAM_PAGES_CONFIG
=
{
"create_name"
:
"pages"
,
"query_name"
:
"pages"
,
"vnode_json_key"
:
"szCache"
,
"boundary"
:
[
64
],
"default"
:
256
}
self
.
DB_PARAM_PAGESIZE_CONFIG
=
{
"create_name"
:
"pagesize"
,
"query_name"
:
"pagesize"
,
"vnode_json_key"
:
"szPage"
,
"boundary"
:
[
1
,
16384
],
"default"
:
4
}
self
.
DB_PARAM_PRECISION_CONFIG
=
{
"create_name"
:
"precision"
,
"query_name"
:
"precision"
,
"vnode_json_key"
:
""
,
"boundary"
:
[
'ms'
,
'us'
,
'ns'
],
"default"
:
"ms"
}
self
.
DB_PARAM_REPLICA_CONFIG
=
{
"create_name"
:
"replica"
,
"query_name"
:
"replica"
,
"vnode_json_key"
:
""
,
"boundary"
:
[
1
],
"default"
:
1
}
self
.
DB_PARAM_SINGLE_STABLE_CONFIG
=
{
"create_name"
:
"single_stable"
,
"query_name"
:
"single_stable_model"
,
"vnode_json_key"
:
""
,
"boundary"
:
[
0
,
1
],
"default"
:
0
}
self
.
DB_PARAM_STRICT_CONFIG
=
{
"create_name"
:
"strict"
,
"query_name"
:
"strict"
,
"vnode_json_key"
:
""
,
"boundary"
:
{
"no_strict"
:
0
,
"strict"
:
1
},
"default"
:
"no_strict"
}
self
.
DB_PARAM_VGROUPS_CONFIG
=
{
"create_name"
:
"vgroups"
,
"query_name"
:
"vgroups"
,
"vnode_json_key"
:
""
,
"boundary"
:
[
1
,
32
],
"default"
:
2
}
self
.
DB_PARAM_WAL_CONFIG
=
{
"create_name"
:
"wal"
,
"query_name"
:
"wal"
,
"vnode_json_key"
:
""
,
"boundary"
:
[
1
,
2
],
"default"
:
1
}
\ No newline at end of file
tests/pytest/util/common.py
浏览文件 @
bae71438
此差异已折叠。
点击以展开。
tests/system-test/2-query/twa.py
0 → 100644
浏览文件 @
bae71438
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
import
numpy
as
np
import
random
,
os
,
sys
import
platform
import
math
class
TDTestCase
:
updatecfgDict
=
{
'debugFlag'
:
143
,
"cDebugFlag"
:
143
,
"uDebugFlag"
:
143
,
"rpcDebugFlag"
:
143
,
"tmrDebugFlag"
:
143
,
"jniDebugFlag"
:
143
,
"simDebugFlag"
:
143
,
"dDebugFlag"
:
143
,
"dDebugFlag"
:
143
,
"vDebugFlag"
:
143
,
"mDebugFlag"
:
143
,
"qDebugFlag"
:
143
,
"wDebugFlag"
:
143
,
"sDebugFlag"
:
143
,
"tsdbDebugFlag"
:
143
,
"tqDebugFlag"
:
143
,
"fsDebugFlag"
:
143
,
"fnDebugFlag"
:
143
,
"maxTablesPerVnode"
:
2
,
"minTablesPerVnode"
:
2
,
"tableIncStepPerVnode"
:
2
}
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
self
.
vnode_disbutes
=
None
self
.
ts
=
1537146000000
self
.
tb_nums
=
20
self
.
row_nums
=
100
self
.
time_step
=
1000
def
prepare_datas_of_distribute
(
self
):
# prepate datas for 20 tables distributed at different vgroups
tdSql
.
execute
(
"create database if not exists testdb keep 3650 duration 1000 vgroups 5"
)
tdSql
.
execute
(
" use testdb "
)
tdSql
.
execute
(
'''create table stb1
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
tags (t0 timestamp, t1 int, t2 bigint, t3 smallint, t4 tinyint, t5 float, t6 double, t7 bool, t8 binary(16),t9 nchar(32))
'''
)
for
i
in
range
(
self
.
tb_nums
):
tdSql
.
execute
(
f
'create table ct
{
i
+
1
}
using stb1 tags ( now(),
{
1
*
i
}
,
{
11111
*
i
}
,
{
111
*
i
}
,
{
11
*
i
}
,
{
1.11
*
i
}
,
{
11.11
*
i
}
,
{
i
%
2
}
, "binary
{
i
}
", "nchar
{
i
}
" )'
)
ts
=
self
.
ts
for
j
in
range
(
self
.
row_nums
):
ts
+=
j
*
self
.
time_step
tdSql
.
execute
(
f
"insert into ct
{
i
+
1
}
values(
{
ts
}
, 1, 11111, 111, 1, 1.11, 11.11, 2, 'binary
{
j
}
', 'nchar
{
j
}
', now()+
{
1
*
j
}
a )"
)
tdSql
.
execute
(
"insert into ct1 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) "
)
tdSql
.
execute
(
"insert into ct1 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) "
)
tdSql
.
execute
(
"insert into ct1 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) "
)
tdLog
.
info
(
" prepare data for distributed_aggregate done! "
)
def
twa_support_types
(
self
):
tdSql
.
query
(
"desc stb1 "
)
schema_list
=
tdSql
.
queryResult
for
col_type
in
schema_list
:
if
col_type
[
1
]
in
[
"TINYINT"
,
"SMALLINT"
,
"BIGINT"
,
"INT"
,
"FLOAT"
,
"DOUBLE"
]:
tdSql
.
query
(
f
" select twa(
{
col_type
[
0
]
}
) from stb1 partition by tbname "
)
else
:
tdSql
.
error
(
f
" select twa(
{
col_type
[
0
]
}
) from stb1 partition by tbname "
)
def
check_distribute_datas
(
self
):
# get vgroup_ids of all
tdSql
.
query
(
"show vgroups "
)
vgroups
=
tdSql
.
queryResult
vnode_tables
=
{}
for
vgroup_id
in
vgroups
:
vnode_tables
[
vgroup_id
[
0
]]
=
[]
# check sub_table of per vnode ,make sure sub_table has been distributed
tdSql
.
query
(
"show tables like 'ct%'"
)
table_names
=
tdSql
.
queryResult
tablenames
=
[]
for
table_name
in
table_names
:
vnode_tables
[
table_name
[
6
]].
append
(
table_name
[
0
])
self
.
vnode_disbutes
=
vnode_tables
count
=
0
for
k
,
v
in
vnode_tables
.
items
():
if
len
(
v
)
>=
2
:
count
+=
1
if
count
<
2
:
tdLog
.
exit
(
" the datas of all not satisfy sub_table has been distributed "
)
def
distribute_twa_query
(
self
):
# basic filter
tdSql
.
query
(
" select twa(c1) from ct1 "
)
tdSql
.
checkData
(
0
,
0
,
1.000000000
)
tdSql
.
query
(
" select twa(c1) from stb1 partition by tbname "
)
tdSql
.
checkRows
(
self
.
tb_nums
)
tdSql
.
checkData
(
0
,
0
,
1.000000000
)
tdSql
.
query
(
" select twa(c2) from stb1 group by tbname "
)
tdSql
.
checkRows
(
self
.
tb_nums
)
tdSql
.
checkData
(
0
,
0
,
11111.000000000
)
tdSql
.
query
(
"select twa(c1+c2) from stb1 partition by tbname "
)
tdSql
.
checkData
(
0
,
0
,
11112.000000000
)
tdSql
.
query
(
"select twa(c1) from stb1 partition by t1"
)
tdSql
.
checkRows
(
self
.
tb_nums
)
tdSql
.
checkData
(
0
,
0
,
1.000000000
)
# union all
tdSql
.
query
(
" select twa(c1) from stb1 partition by tbname union all select twa(c1) from stb1 partition by tbname "
)
tdSql
.
checkRows
(
40
)
tdSql
.
checkData
(
0
,
0
,
1.000000000
)
# join
tdSql
.
execute
(
" create database if not exists db "
)
tdSql
.
execute
(
" use db "
)
tdSql
.
execute
(
" create stable st (ts timestamp , c1 int ,c2 float) tags(t1 int) "
)
tdSql
.
execute
(
" create table tb1 using st tags(1) "
)
tdSql
.
execute
(
" create table tb2 using st tags(2) "
)
for
i
in
range
(
10
):
ts
=
i
*
10
+
self
.
ts
tdSql
.
execute
(
f
" insert into tb1 values(
{
ts
}
,
{
i
}
,
{
i
}
.0)"
)
tdSql
.
execute
(
f
" insert into tb2 values(
{
ts
}
,
{
i
}
,
{
i
}
.0)"
)
tdSql
.
query
(
" select twa(tb1.c1), twa(tb2.c2) from tb1, tb2 where tb1.ts=tb2.ts "
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
4.500000000
)
tdSql
.
checkData
(
0
,
1
,
4.500000000
)
# group by
tdSql
.
execute
(
" use testdb "
)
# mixup with other functions
tdSql
.
query
(
" select twa(c1),twa(c2),max(c1),elapsed(ts) from stb1 "
)
tdSql
.
checkData
(
0
,
0
,
1.000000000
)
tdSql
.
checkData
(
0
,
1
,
11111.000000000
)
tdSql
.
checkData
(
0
,
2
,
1
)
def
run
(
self
):
self
.
prepare_datas_of_distribute
()
self
.
check_distribute_datas
()
self
.
twa_support_types
()
self
.
distribute_twa_query
()
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tests/system-test/7-tmq/stbFilter.py
0 → 100644
浏览文件 @
bae71438
import
taos
import
sys
import
time
import
socket
import
os
import
threading
from
util.log
import
*
from
util.sql
import
*
from
util.cases
import
*
from
util.dnodes
import
*
from
util.common
import
*
sys
.
path
.
append
(
"./7-tmq"
)
from
tmqCommon
import
*
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
f
"start to excute
{
__file__
}
"
)
tdSql
.
init
(
conn
.
cursor
())
#tdSql.init(conn.cursor(), logSql) # output sql.txt file
def
tmqCase1
(
self
):
tdLog
.
printNoPrefix
(
"======== test case 1: "
)
paraDict
=
{
'dbName'
:
'db1'
,
'dropFlag'
:
1
,
'event'
:
''
,
'vgroups'
:
4
,
'stbName'
:
'stb'
,
'colPrefix'
:
'c'
,
'tagPrefix'
:
't'
,
'colSchema'
:
[{
'type'
:
'INT'
,
'count'
:
1
},
{
'type'
:
'binary'
,
'len'
:
20
,
'count'
:
1
}],
'tagSchema'
:
[{
'type'
:
'INT'
,
'count'
:
1
},
{
'type'
:
'binary'
,
'len'
:
20
,
'count'
:
1
}],
'ctbPrefix'
:
'ctb'
,
'ctbNum'
:
10
,
'rowsPerTbl'
:
10000
,
'batchNum'
:
100
,
'startTs'
:
1640966400000
,
# 2022-01-01 00:00:00.000
'pollDelay'
:
10
,
'showMsg'
:
1
,
'showRow'
:
1
}
tmqCom
.
initConsumerTable
()
tdCom
.
create_database
(
tdSql
,
paraDict
[
"dbName"
],
paraDict
[
"dropFlag"
])
tdLog
.
info
(
"create stb"
)
tdCom
.
create_stable
(
tdSql
,
dbname
=
paraDict
[
"dbName"
],
stbname
=
paraDict
[
"stbName"
],
column_elm_list
=
paraDict
[
'colSchema'
],
tag_elm_list
=
paraDict
[
'tagSchema'
])
tdLog
.
info
(
"create ctb"
)
tdCom
.
create_ctable
(
tdSql
,
dbname
=
paraDict
[
"dbName"
],
stbname
=
paraDict
[
"stbName"
],
tag_elm_list
=
paraDict
[
'tagSchema'
],
count
=
paraDict
[
"ctbNum"
],
default_ctbname_prefix
=
paraDict
[
'ctbPrefix'
])
tdLog
.
info
(
"insert data"
)
tmqCom
.
insert_data
(
tdSql
,
paraDict
[
"dbName"
],
paraDict
[
"ctbPrefix"
],
paraDict
[
"ctbNum"
],
paraDict
[
"rowsPerTbl"
],
paraDict
[
"batchNum"
],
paraDict
[
"startTs"
])
tdLog
.
info
(
"create topics from db"
)
topicName
=
'topic_%s_%s'
%
(
paraDict
[
'dbName'
],
paraDict
[
'stbName'
])
tdSql
.
execute
(
"create topic %s as select ts, c1, c2 from %s.%s where c1 %% 4 == 0"
%
(
topicName
,
paraDict
[
'dbName'
],
paraDict
[
'stbName'
]))
tdLog
.
info
(
"insert consume info to consume processor"
)
consumerId
=
0
expectrowcnt
=
paraDict
[
"rowsPerTbl"
]
*
paraDict
[
"ctbNum"
]
topicList
=
topicName
ifcheckdata
=
0
ifManualCommit
=
1
keyList
=
'group.id:cgrp1, enable.auto.commit:false, auto.commit.interval.ms:6000, auto.offset.reset:earliest'
tmqCom
.
insertConsumerInfo
(
consumerId
,
expectrowcnt
,
topicList
,
keyList
,
ifcheckdata
,
ifManualCommit
)
tdLog
.
info
(
"start consume processor"
)
tmqCom
.
startTmqSimProcess
(
paraDict
[
'pollDelay'
],
paraDict
[
"dbName"
],
paraDict
[
'showMsg'
],
paraDict
[
'showRow'
])
tdLog
.
info
(
"wait the consume result"
)
expectRows
=
1
resultList
=
tmqCom
.
selectConsumeResult
(
expectRows
)
totalConsumeRows
=
0
for
i
in
range
(
expectRows
):
totalConsumeRows
+=
resultList
[
i
]
if
totalConsumeRows
!=
expectrowcnt
/
4
:
tdLog
.
info
(
"act consume rows: %d, expect consume rows: %d"
%
(
totalConsumeRows
,
expectrowcnt
/
4
))
tdLog
.
exit
(
"tmq consume rows error!"
)
time
.
sleep
(
10
)
tdSql
.
query
(
"drop topic %s"
%
topicName
)
tdLog
.
printNoPrefix
(
"======== test case 1 end ...... "
)
def
run
(
self
):
tdSql
.
prepare
()
self
.
tmqCase1
()
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
f
"
{
__file__
}
successfully executed"
)
event
=
threading
.
Event
()
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tests/system-test/7-tmq/tmqCommon.py
浏览文件 @
bae71438
...
...
@@ -92,13 +92,65 @@ class TMQCom:
tdLog
.
info
(
shellCmd
)
os
.
system
(
shellCmd
)
def
getStartConsumeNotifyFromTmqsim
(
self
,
cdbName
=
'cdb'
):
while
1
:
tdSql
.
query
(
"select * from %s.notifyinfo"
%
cdbName
)
#tdLog.info("row: %d, %l64d, %l64d"%(tdSql.getData(0, 1),tdSql.getData(0, 2),tdSql.getData(0, 3))
if
(
tdSql
.
getRows
()
==
1
)
and
(
tdSql
.
getData
(
0
,
1
)
==
0
):
break
else
:
time
.
sleep
(
0.1
)
return
def
getStartCommitNotifyFromTmqsim
(
self
,
cdbName
=
'cdb'
):
while
1
:
tdSql
.
query
(
"select * from %s.notifyinfo"
%
cdbName
)
#tdLog.info("row: %d, %l64d, %l64d"%(tdSql.getData(0, 1),tdSql.getData(0, 2),tdSql.getData(0, 3))
if
tdSql
.
getRows
()
==
2
:
print
(
tdSql
.
getData
(
0
,
1
),
tdSql
.
getData
(
1
,
1
))
if
tdSql
.
getData
(
1
,
1
)
==
1
:
break
time
.
sleep
(
0.1
)
return
def
insert_data
(
self
,
tsql
,
dbName
,
stbName
,
ctbNum
,
rowsPerTbl
,
batchNum
,
startTs
):
tdLog
.
debug
(
"start to insert data ............"
)
tsql
.
execute
(
"use %s"
%
dbName
)
pre_insert
=
"insert into "
sql
=
pre_insert
t
=
time
.
time
()
startTs
=
int
(
round
(
t
*
1000
))
#tdLog.debug("doing insert data into stable:%s rows:%d ..."%(stbName, allRows))
for
i
in
range
(
ctbNum
):
sql
+=
" %s%d values "
%
(
stbName
,
i
)
for
j
in
range
(
rowsPerTbl
):
sql
+=
"(%d, %d, 'tmqrow_%d') "
%
(
startTs
+
j
,
j
,
j
)
if
(
j
>
0
)
and
((
j
%
batchNum
==
0
)
or
(
j
==
rowsPerTbl
-
1
)):
tsql
.
execute
(
sql
)
if
j
<
rowsPerTbl
-
1
:
sql
=
"insert into %s%d values "
%
(
stbName
,
i
)
else
:
sql
=
"insert into "
#end sql
if
sql
!=
pre_insert
:
#print("insert sql:%s"%sql)
tsql
.
execute
(
sql
)
tdLog
.
debug
(
"insert data ............ [OK]"
)
return
def
syncCreateDbStbCtbInsertData
(
self
,
tsql
,
paraDict
):
tdCom
.
create_database
(
tsql
,
paraDict
[
"dbName"
],
paraDict
[
"dropFlag"
]
,
paraDict
[
'precision'
]
)
tdCom
.
create_stable
(
tsql
,
paraDict
[
"dbName"
],
paraDict
[
"stbName"
],
paraDict
[
"columnDict"
],
paraDict
[
"tagDict"
])
tdCom
.
create_ctable
s
(
tsql
,
paraDict
[
"dbName"
],
paraDict
[
"stbName"
],
paraDict
[
"ctbNum"
],
paraDict
[
"tagDict"
])
tdCom
.
create_database
(
tsql
,
paraDict
[
"dbName"
],
paraDict
[
"dropFlag"
])
tdCom
.
create_stable
(
tsql
,
dbname
=
paraDict
[
"dbName"
],
stbname
=
paraDict
[
"stbName"
],
column_elm_list
=
paraDict
[
'colSchema'
],
tag_elm_list
=
paraDict
[
'tagSchema'
])
tdCom
.
create_ctable
(
tsql
,
dbname
=
paraDict
[
"dbName"
],
stbname
=
paraDict
[
"stbName"
],
tag_elm_list
=
paraDict
[
'tagSchema'
],
count
=
paraDict
[
"ctbNum"
],
default_ctbname_prefix
=
paraDict
[
'ctbPrefix'
])
if
"event"
in
paraDict
and
type
(
paraDict
[
'event'
])
==
type
(
threading
.
Event
()):
paraDict
[
"event"
].
set
()
tdCom
.
insert_data
(
tsql
,
paraDict
[
"dbName"
],
paraDict
[
"stbName"
],
paraDict
[
"ctbNum"
],
paraDict
[
"rowsPerTbl"
],
paraDict
[
"batchNum"
],
paraDict
[
"startTs"
])
ctbPrefix
=
paraDict
[
'ctbPrefix'
]
ctbNum
=
paraDict
[
"ctbNum"
]
for
i
in
range
(
ctbNum
):
tbName
=
'%s%s'
%
(
ctbPrefix
,
i
)
tdCom
.
insert_rows
(
tsql
,
dbname
=
paraDict
[
"dbName"
],
tbname
=
tbName
,
start_ts_value
=
paraDict
[
'startTs'
],
count
=
paraDict
[
'rowsPerTbl'
])
return
def
threadFunction
(
self
,
**
paraDict
):
...
...
tests/system-test/fulltest.sh
浏览文件 @
bae71438
...
...
@@ -108,6 +108,7 @@ python3 ./test.py -f 2-query/distribute_agg_spread.py
python3 ./test.py
-f
2-query/distribute_agg_apercentile.py
python3 ./test.py
-f
2-query/distribute_agg_avg.py
python3 ./test.py
-f
2-query/distribute_agg_stddev.py
python3 ./test.py
-f
2-query/twa.py
python3 ./test.py
-f
6-cluster/5dnode1mnode.py
python3 ./test.py
-f
6-cluster/5dnode2mnode.py
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录