Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
5a9ed58b
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看板
提交
5a9ed58b
编写于
6月 04, 2022
作者:
X
Xiaoyu Wang
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/3.0' into feature/3.0_wxy
上级
6e6c9bda
0ef1a19b
变更
77
展开全部
显示空白变更内容
内联
并排
Showing
77 changed file
with
3292 addition
and
1684 deletion
+3292
-1684
include/client/taos.h
include/client/taos.h
+0
-1
include/common/tdataformat.h
include/common/tdataformat.h
+16
-24
include/common/tmsg.h
include/common/tmsg.h
+1
-0
include/common/tmsgcb.h
include/common/tmsgcb.h
+2
-2
include/common/tmsgdef.h
include/common/tmsgdef.h
+84
-88
include/common/ttypes.h
include/common/ttypes.h
+46
-41
include/libs/scheduler/scheduler.h
include/libs/scheduler/scheduler.h
+1
-3
include/util/tutil.h
include/util/tutil.h
+3
-1
source/client/inc/clientInt.h
source/client/inc/clientInt.h
+16
-4
source/client/src/clientEnv.c
source/client/src/clientEnv.c
+6
-3
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+151
-92
source/client/src/clientMain.c
source/client/src/clientMain.c
+205
-16
source/client/src/clientMsgHandler.c
source/client/src/clientMsgHandler.c
+42
-17
source/client/src/clientSml.c
source/client/src/clientSml.c
+2
-2
source/client/src/clientStmt.c
source/client/src/clientStmt.c
+2
-3
source/client/test/clientTests.cpp
source/client/test/clientTests.cpp
+74
-14
source/client/test/smlTest.cpp
source/client/test/smlTest.cpp
+15
-15
source/common/src/systable.c
source/common/src/systable.c
+1
-1
source/common/src/tdataformat.c
source/common/src/tdataformat.c
+268
-435
source/common/src/tmsg.c
source/common/src/tmsg.c
+1
-0
source/common/src/tmsgcb.c
source/common/src/tmsgcb.c
+8
-28
source/dnode/mgmt/mgmt_mnode/inc/mmInt.h
source/dnode/mgmt/mgmt_mnode/inc/mmInt.h
+1
-4
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
+2
-2
source/dnode/mgmt/mgmt_mnode/src/mmInt.c
source/dnode/mgmt/mgmt_mnode/src/mmInt.c
+1
-4
source/dnode/mgmt/mgmt_mnode/src/mmWorker.c
source/dnode/mgmt/mgmt_mnode/src/mmWorker.c
+27
-29
source/dnode/mgmt/mgmt_qnode/inc/qmInt.h
source/dnode/mgmt/mgmt_qnode/inc/qmInt.h
+1
-2
source/dnode/mgmt/mgmt_qnode/src/qmInt.c
source/dnode/mgmt/mgmt_qnode/src/qmInt.c
+1
-2
source/dnode/mgmt/mgmt_qnode/src/qmWorker.c
source/dnode/mgmt/mgmt_qnode/src/qmWorker.c
+14
-12
source/dnode/mgmt/mgmt_vnode/inc/vmInt.h
source/dnode/mgmt/mgmt_vnode/inc/vmInt.h
+26
-31
source/dnode/mgmt/mgmt_vnode/src/vmFile.c
source/dnode/mgmt/mgmt_vnode/src/vmFile.c
+7
-5
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
+53
-53
source/dnode/mgmt/mgmt_vnode/src/vmInt.c
source/dnode/mgmt/mgmt_vnode/src/vmInt.c
+6
-15
source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
+73
-135
source/dnode/mgmt/node_mgmt/src/dmMgmt.c
source/dnode/mgmt/node_mgmt/src/dmMgmt.c
+3
-3
source/dnode/mgmt/node_mgmt/src/dmTransport.c
source/dnode/mgmt/node_mgmt/src/dmTransport.c
+1
-0
source/dnode/mgmt/test/mnode/dmnode.cpp
source/dnode/mgmt/test/mnode/dmnode.cpp
+4
-4
source/dnode/mnode/impl/src/mndDb.c
source/dnode/mnode/impl/src/mndDb.c
+3
-0
source/dnode/mnode/impl/src/mndFunc.c
source/dnode/mnode/impl/src/mndFunc.c
+1
-1
source/dnode/mnode/impl/src/mndMnode.c
source/dnode/mnode/impl/src/mndMnode.c
+4
-4
source/dnode/mnode/impl/test/acct/CMakeLists.txt
source/dnode/mnode/impl/test/acct/CMakeLists.txt
+4
-6
source/dnode/mnode/impl/test/func/CMakeLists.txt
source/dnode/mnode/impl/test/func/CMakeLists.txt
+2
-2
source/dnode/mnode/impl/test/profile/CMakeLists.txt
source/dnode/mnode/impl/test/profile/CMakeLists.txt
+2
-2
source/dnode/mnode/impl/test/show/CMakeLists.txt
source/dnode/mnode/impl/test/show/CMakeLists.txt
+2
-2
source/dnode/vnode/CMakeLists.txt
source/dnode/vnode/CMakeLists.txt
+0
-1
source/dnode/vnode/src/meta/metaQuery.c
source/dnode/vnode/src/meta/metaQuery.c
+19
-11
source/dnode/vnode/src/meta/metaTable.c
source/dnode/vnode/src/meta/metaTable.c
+36
-32
source/dnode/vnode/src/tsdb/tsdbCommit.c
source/dnode/vnode/src/tsdb/tsdbCommit.c
+12
-0
source/dnode/vnode/src/tsdb/tsdbCommit2.c
source/dnode/vnode/src/tsdb/tsdbCommit2.c
+0
-28
source/dnode/vnode/src/tsdb/tsdbMemTable2.c
source/dnode/vnode/src/tsdb/tsdbMemTable2.c
+93
-273
source/dnode/vnode/src/vnd/vnodeSvr.c
source/dnode/vnode/src/vnd/vnodeSvr.c
+2
-2
source/libs/catalog/inc/catalogInt.h
source/libs/catalog/inc/catalogInt.h
+1
-1
source/libs/catalog/src/catalog.c
source/libs/catalog/src/catalog.c
+9
-4
source/libs/catalog/src/ctgAsync.c
source/libs/catalog/src/ctgAsync.c
+19
-33
source/libs/function/src/builtins.c
source/libs/function/src/builtins.c
+7
-1
source/libs/function/src/builtinsimpl.c
source/libs/function/src/builtinsimpl.c
+6
-5
source/libs/index/src/indexFilter.c
source/libs/index/src/indexFilter.c
+50
-29
source/libs/index/test/CMakeLists.txt
source/libs/index/test/CMakeLists.txt
+8
-10
source/libs/parser/src/parAstParser.c
source/libs/parser/src/parAstParser.c
+4
-0
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+0
-4
source/libs/parser/test/parSelectTest.cpp
source/libs/parser/test/parSelectTest.cpp
+2
-0
source/libs/parser/test/parTestMain.cpp
source/libs/parser/test/parTestMain.cpp
+1
-0
source/libs/planner/test/CMakeLists.txt
source/libs/planner/test/CMakeLists.txt
+2
-2
source/libs/planner/test/planTestMain.cpp
source/libs/planner/test/planTestMain.cpp
+2
-0
source/libs/qworker/test/qworkerTests.cpp
source/libs/qworker/test/qworkerTests.cpp
+16
-17
source/libs/scalar/src/sclfunc.c
source/libs/scalar/src/sclfunc.c
+8
-8
source/libs/scheduler/src/schDbg.c
source/libs/scheduler/src/schDbg.c
+0
-9
source/libs/scheduler/src/schJob.c
source/libs/scheduler/src/schJob.c
+4
-5
source/libs/scheduler/src/scheduler.c
source/libs/scheduler/src/scheduler.c
+23
-17
source/libs/transport/src/transCli.c
source/libs/transport/src/transCli.c
+0
-1
tests/pytest/util/dnodes.py
tests/pytest/util/dnodes.py
+1
-1
tests/script/jenkins/basic.txt
tests/script/jenkins/basic.txt
+2
-1
tests/script/tsim/db/alter_replica_13.sim
tests/script/tsim/db/alter_replica_13.sim
+0
-1
tests/script/tsim/db/alter_replica_31.sim
tests/script/tsim/db/alter_replica_31.sim
+146
-0
tests/script/tsim/sync/3Replica5VgElect.sim
tests/script/tsim/sync/3Replica5VgElect.sim
+1
-0
tests/script/tsim/sync/3Replica5VgElect3mnode.sim
tests/script/tsim/sync/3Replica5VgElect3mnode.sim
+906
-0
tests/script/tsim/sync/3Replica5VgElect3mnodedrop.sim
tests/script/tsim/sync/3Replica5VgElect3mnodedrop.sim
+627
-0
tests/script/tsim/testsuit.sim
tests/script/tsim/testsuit.sim
+103
-80
未找到文件。
include/client/taos.h
浏览文件 @
5a9ed58b
...
...
@@ -162,7 +162,6 @@ DLL_EXPORT int taos_stmt_affected_rows(TAOS_STMT *stmt);
DLL_EXPORT
int
taos_stmt_affected_rows_once
(
TAOS_STMT
*
stmt
);
DLL_EXPORT
TAOS_RES
*
taos_query
(
TAOS
*
taos
,
const
char
*
sql
);
DLL_EXPORT
TAOS_RES
*
taos_query_l
(
TAOS
*
taos
,
const
char
*
sql
,
int
sqlLen
);
DLL_EXPORT
TAOS_ROW
taos_fetch_row
(
TAOS_RES
*
res
);
DLL_EXPORT
int
taos_result_precision
(
TAOS_RES
*
res
);
// get the time precision of result
...
...
include/common/tdataformat.h
浏览文件 @
5a9ed58b
...
...
@@ -46,6 +46,7 @@ void tTSchemaDestroy(STSchema *pTSchema);
#define COL_VAL_NULL(CID) ((SColVal){.cid = (CID), .isNull = 1})
#define COL_VAL_VALUE(CID, V) ((SColVal){.cid = (CID), .value = (V)})
int32_t
tTSRowNew
(
STSRowBuilder
*
pBuilder
,
SArray
*
pArray
,
STSchema
*
pTSchema
,
STSRow2
**
ppRow
);
int32_t
tTSRowClone
(
const
STSRow2
*
pRow
,
STSRow2
**
ppRow
);
void
tTSRowFree
(
STSRow2
*
pRow
);
void
tTSRowGet
(
STSRow2
*
pRow
,
STSchema
*
pTSchema
,
int32_t
iCol
,
SColVal
*
pColVal
);
...
...
@@ -54,19 +55,19 @@ int32_t tPutTSRow(uint8_t *p, STSRow2 *pRow);
int32_t
tGetTSRow
(
uint8_t
*
p
,
STSRow2
*
pRow
);
// STSRowBuilder
#
if 0
int32_t tTSRowBuilderInit(STSRowBuilder *pBuilder, int32_t sver, int32_t nCols, SSchema *pSchema);
void tTSRowBuilderClear(STSRowBuilder *pBuilder);
void tTSRowBuilderReset(STSRowBuilder *pBuilder);
int32_t tTSRowBuilderPut(STSRowBuilder *pBuilder, int32_t cid, uint8_t *pData, uint32_t nData);
int32_t tTSRowBuilderGetRow(STSRowBuilder *pBuilder, const STSRow2 **ppRow);
#endif
#
define tsRowBuilderInit() ((STSRowBuilder){0})
#define tsRowBuilderClear(B) \
do { \
if ((B)->pBuf) { \
taosMemoryFree((B)->pBuf); \
} \
} while (0)
// STag
int32_t
tTagNew
(
SArray
*
pArray
,
int32_t
version
,
int8_t
isJson
,
STag
**
ppTag
);
void
tTagFree
(
STag
*
pTag
);
bool
tTagGet
(
const
STag
*
pTag
,
STagVal
*
pTagVal
);
char
*
tTagValToData
(
const
STagVal
*
pTagVal
,
bool
isJson
);
char
*
tTagValToData
(
const
STagVal
*
pTagVal
,
bool
isJson
);
int32_t
tEncodeTag
(
SEncoder
*
pEncoder
,
const
STag
*
pTag
);
int32_t
tDecodeTag
(
SDecoder
*
pDecoder
,
STag
**
ppTag
);
int32_t
tTagToValArray
(
const
STag
*
pTag
,
SArray
**
ppArray
);
...
...
@@ -106,17 +107,9 @@ struct STSRow2 {
};
struct
STSRowBuilder
{
STSchema
*
pTSchema
;
int32_t
szBitMap1
;
int32_t
szBitMap2
;
int32_t
szKVBuf
;
uint8_t
*
pKVBuf
;
int32_t
szTPBuf
;
uint8_t
*
pTPBuf
;
int32_t
iCol
;
int32_t
vlenKV
;
int32_t
vlenTP
;
STSRow2
row
;
STSRow2
tsRow
;
int32_t
szBuf
;
uint8_t
*
pBuf
;
};
struct
SValue
{
...
...
@@ -422,4 +415,3 @@ int32_t tdMergeDataCols(SDataCols *target, SDataCols *source, int32_t rowsToM
#endif
#endif
/*_TD_COMMON_DATA_FORMAT_H_*/
include/common/tmsg.h
浏览文件 @
5a9ed58b
...
...
@@ -241,6 +241,7 @@ typedef struct {
int32_t
schemaLen
;
// schema length, if length is 0, no schema exists
int16_t
numOfRows
;
// total number of rows in current submit block
// head of SSubmitBlk
int32_t
numOfBlocks
;
const
void
*
pMsg
;
}
SSubmitMsgIter
;
...
...
include/common/tmsgcb.h
浏览文件 @
5a9ed58b
...
...
@@ -38,7 +38,7 @@ typedef enum {
QUEUE_MAX
,
}
EQueueType
;
typedef
int32_t
(
*
PutToQueueFp
)(
void
*
pMgmt
,
SRpcMsg
*
pMsg
);
typedef
int32_t
(
*
PutToQueueFp
)(
void
*
pMgmt
,
EQueueType
qtype
,
SRpcMsg
*
pMsg
);
typedef
int32_t
(
*
GetQueueSizeFp
)(
void
*
pMgmt
,
int32_t
vgId
,
EQueueType
qtype
);
typedef
int32_t
(
*
SendReqFp
)(
const
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
);
typedef
void
(
*
SendRspFp
)(
SRpcMsg
*
pMsg
);
...
...
@@ -50,7 +50,7 @@ typedef void (*ReportStartup)(const char* name, const char* desc);
typedef
struct
{
void
*
mgmt
;
void
*
clientRpc
;
PutToQueueFp
queueFps
[
QUEUE_MAX
]
;
PutToQueueFp
putToQueueFp
;
GetQueueSizeFp
qsizeFp
;
SendReqFp
sendReqFp
;
SendRspFp
sendRspFp
;
...
...
include/common/tmsgdef.h
浏览文件 @
5a9ed58b
...
...
@@ -70,106 +70,102 @@ enum {
// Requests handled by DNODE
TD_NEW_MSG_SEG
(
TDMT_DND_MSG
)
TD_DEF_MSG_TYPE
(
TDMT_DND_CREATE_MNODE
,
"dnode-create-mnode"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_DND_ALTER_MNODE
,
"dnode-alter-mnode"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_DND_DROP_MNODE
,
"dnode-drop-mnode"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_DND_CREATE_QNODE
,
"dnode-create-qnode"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_DND_ALTER_QNODE
,
"dnode-alter-qnode"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_DND_DROP_QNODE
,
"dnode-drop-qnode"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_DND_CREATE_SNODE
,
"dnode-create-snode"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_DND_ALTER_SNODE
,
"dnode-alter-snode"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_DND_DROP_SNODE
,
"dnode-drop-snode"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_DND_CREATE_BNODE
,
"dnode-create-bnode"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_DND_ALTER_BNODE
,
"dnode-alter-bnode"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_DND_DROP_BNODE
,
"dnode-drop-bnode"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_DND_CREATE_VNODE
,
"
dnode-
create-vnode"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_DND_DROP_VNODE
,
"d
node-d
rop-vnode"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_DND_
CONFIG_DNODE
,
"dnode-config-dnode
"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_DND_
SERVER_STATUS
,
"dnode-server-status
"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_DND_
NET_TEST
,
"dnode-net-test
"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_DND_CREATE_VNODE
,
"create-vnode"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_DND_DROP_VNODE
,
"drop-vnode"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_DND_
SERVER_STATUS
,
"server-status
"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_DND_
NET_TEST
,
"net-test
"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_DND_
CONFIG_DNODE
,
"config-dnode
"
,
NULL
,
NULL
)
// Requests handled by MNODE
TD_NEW_MSG_SEG
(
TDMT_MND_MSG
)
TD_DEF_MSG_TYPE
(
TDMT_MND_CONNECT
,
"
mnode-
connect"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_CREATE_ACCT
,
"
mnode-
create-acct"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_ALTER_ACCT
,
"
mnode-
alter-acct"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_DROP_ACCT
,
"
mnode-
drop-acct"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_CREATE_USER
,
"
mnode-
create-user"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_ALTER_USER
,
"
mnode-
alter-user"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_DROP_USER
,
"
mnode-
drop-user"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_GET_USER_AUTH
,
"
mnode-
get-user-auth"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_CREATE_DNODE
,
"
mnode-
create-dnode"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_CONFIG_DNODE
,
"
mnode-
config-dnode"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_ALTER_DNODE
,
"
mnode-
alter-dnode"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_DROP_DNODE
,
"
mnode-
drop-dnode"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_CREATE_MNODE
,
"
mnode-
create-mnode"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_ALTER_MNODE
,
"
mnode-
alter-mnode"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_DROP_MNODE
,
"
mnode-
drop-mnode"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_CREATE_QNODE
,
"
mnode-
create-qnode"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_ALTER_QNODE
,
"
mnode-
alter-qnode"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_DROP_QNODE
,
"
mnode-
drop-qnode"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_CREATE_SNODE
,
"
mnode-
create-snode"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_ALTER_SNODE
,
"
mnode-
alter-snode"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_DROP_SNODE
,
"
mnode-
drop-snode"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_CREATE_BNODE
,
"
mnode-
create-bnode"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_ALTER_BNODE
,
"
mnode-
alter-bnode"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_DROP_BNODE
,
"
mnode-
drop-bnode"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_CREATE_DB
,
"
mnode-
create-db"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_DROP_DB
,
"
mnode-
drop-db"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_USE_DB
,
"
mnode-
use-db"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_ALTER_DB
,
"
mnode-
alter-db"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_SYNC_DB
,
"
mnode-
sync-db"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_COMPACT_DB
,
"
mnode-
compact-db"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_CREATE_FUNC
,
"
mnode-
create-func"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_RETRIEVE_FUNC
,
"
mnode-
retrieve-func"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_DROP_FUNC
,
"
mnode-
drop-func"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_CREATE_STB
,
"
mnode-
create-stb"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_ALTER_STB
,
"
mnode-
alter-stb"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_DROP_STB
,
"
mnode-
drop-stb"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_CREATE_SMA
,
"
mnode-
create-sma"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_DROP_SMA
,
"
mnode-
drop-sma"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_TABLE_META
,
"
mnode-
table-meta"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_VGROUP_LIST
,
"
mnode-
vgroup-list"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_QNODE_LIST
,
"
mnode-
qnode-list"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_KILL_QUERY
,
"
mnode-
kill-query"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_KILL_CONN
,
"
mnode-
kill-conn"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_HEARTBEAT
,
"
mnode-
heartbeat"
,
SClientHbBatchReq
,
SClientHbBatchRsp
)
TD_DEF_MSG_TYPE
(
TDMT_MND_SHOW
,
"
mnode-
show"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_SYSTABLE_RETRIEVE
,
"
mnode-
systable-retrieve"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_STATUS
,
"
mnode-
status"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_TRANS_TIMER
,
"
mnode-
trans-tmr"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_KILL_TRANS
,
"
mnode-
kill-trans"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_TELEM_TIMER
,
"
mnode-
telem-tmr"
,
SMTimerReq
,
SMTimerReq
)
TD_DEF_MSG_TYPE
(
TDMT_MND_GRANT
,
"
mnode-
grant"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_AUTH
,
"
mnode-
auth"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_CREATE_TOPIC
,
"
mnode-
create-topic"
,
SMCreateTopicReq
,
SMCreateTopicRsp
)
TD_DEF_MSG_TYPE
(
TDMT_MND_ALTER_TOPIC
,
"
mnode-
alter-topic"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_DROP_TOPIC
,
"
mnode-
drop-topic"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_SUBSCRIBE
,
"
mnode-
subscribe"
,
SCMSubscribeReq
,
SCMSubscribeRsp
)
TD_DEF_MSG_TYPE
(
TDMT_MND_MQ_ASK_EP
,
"m
node-m
q-ask-ep"
,
SMqAskEpReq
,
SMqAskEpRsp
)
TD_DEF_MSG_TYPE
(
TDMT_MND_MQ_TIMER
,
"m
node-m
q-tmr"
,
SMTimerReq
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_MQ_CONSUMER_LOST
,
"m
node-m
q-consumer-lost"
,
SMqConsumerLostMsg
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_MQ_CONSUMER_RECOVER
,
"m
node-m
q-consumer-recover"
,
SMqConsumerRecoverMsg
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_MQ_DO_REBALANCE
,
"m
node-m
q-do-rebalance"
,
SMqDoRebalanceMsg
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_MQ_DROP_CGROUP
,
"m
node-m
q-drop-cgroup"
,
SMqDropCGroupReq
,
SMqDropCGroupRsp
)
TD_DEF_MSG_TYPE
(
TDMT_MND_MQ_COMMIT_OFFSET
,
"m
node-m
q-commit-offset"
,
SMqCMCommitOffsetReq
,
SMqCMCommitOffsetRsp
)
TD_DEF_MSG_TYPE
(
TDMT_MND_CREATE_STREAM
,
"
mnode-
create-stream"
,
SCMCreateStreamReq
,
SCMCreateStreamRsp
)
TD_DEF_MSG_TYPE
(
TDMT_MND_ALTER_STREAM
,
"
mnode-
alter-stream"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_DROP_STREAM
,
"
mnode-
drop-stream"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_CREATE_INDEX
,
"
mnode-
create-index"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_DROP_INDEX
,
"
mnode-
drop-index"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_GET_DB_CFG
,
"
mnode-
get-db-cfg"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_GET_INDEX
,
"
mnode-
get-index"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_APPLY_MSG
,
"
mnode-
apply-msg"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_CONNECT
,
"connect"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_CREATE_ACCT
,
"create-acct"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_ALTER_ACCT
,
"alter-acct"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_DROP_ACCT
,
"drop-acct"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_CREATE_USER
,
"create-user"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_ALTER_USER
,
"alter-user"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_DROP_USER
,
"drop-user"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_GET_USER_AUTH
,
"get-user-auth"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_CREATE_DNODE
,
"create-dnode"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_CONFIG_DNODE
,
"config-dnode"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_ALTER_DNODE
,
"alter-dnode"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_DROP_DNODE
,
"drop-dnode"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_CREATE_MNODE
,
"create-mnode"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_ALTER_MNODE
,
"alter-mnode"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_DROP_MNODE
,
"drop-mnode"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_CREATE_QNODE
,
"create-qnode"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_ALTER_QNODE
,
"alter-qnode"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_DROP_QNODE
,
"drop-qnode"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_CREATE_SNODE
,
"create-snode"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_ALTER_SNODE
,
"alter-snode"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_DROP_SNODE
,
"drop-snode"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_CREATE_BNODE
,
"create-bnode"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_ALTER_BNODE
,
"alter-bnode"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_DROP_BNODE
,
"drop-bnode"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_CREATE_DB
,
"create-db"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_DROP_DB
,
"drop-db"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_USE_DB
,
"use-db"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_ALTER_DB
,
"alter-db"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_SYNC_DB
,
"sync-db"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_COMPACT_DB
,
"compact-db"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_CREATE_FUNC
,
"create-func"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_RETRIEVE_FUNC
,
"retrieve-func"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_DROP_FUNC
,
"drop-func"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_CREATE_STB
,
"create-stb"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_ALTER_STB
,
"alter-stb"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_DROP_STB
,
"drop-stb"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_CREATE_SMA
,
"create-sma"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_DROP_SMA
,
"drop-sma"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_TABLE_META
,
"table-meta"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_VGROUP_LIST
,
"vgroup-list"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_QNODE_LIST
,
"qnode-list"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_KILL_QUERY
,
"kill-query"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_KILL_CONN
,
"kill-conn"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_HEARTBEAT
,
"heartbeat"
,
SClientHbBatchReq
,
SClientHbBatchRsp
)
TD_DEF_MSG_TYPE
(
TDMT_MND_SHOW
,
"show"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_SYSTABLE_RETRIEVE
,
"systable-retrieve"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_STATUS
,
"status"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_TRANS_TIMER
,
"trans-tmr"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_KILL_TRANS
,
"kill-trans"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_TELEM_TIMER
,
"telem-tmr"
,
SMTimerReq
,
SMTimerReq
)
TD_DEF_MSG_TYPE
(
TDMT_MND_GRANT
,
"grant"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_AUTH
,
"auth"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_CREATE_TOPIC
,
"create-topic"
,
SMCreateTopicReq
,
SMCreateTopicRsp
)
TD_DEF_MSG_TYPE
(
TDMT_MND_ALTER_TOPIC
,
"alter-topic"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_DROP_TOPIC
,
"drop-topic"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_SUBSCRIBE
,
"subscribe"
,
SCMSubscribeReq
,
SCMSubscribeRsp
)
TD_DEF_MSG_TYPE
(
TDMT_MND_MQ_ASK_EP
,
"mq-ask-ep"
,
SMqAskEpReq
,
SMqAskEpRsp
)
TD_DEF_MSG_TYPE
(
TDMT_MND_MQ_TIMER
,
"mq-tmr"
,
SMTimerReq
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_MQ_CONSUMER_LOST
,
"mq-consumer-lost"
,
SMqConsumerLostMsg
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_MQ_CONSUMER_RECOVER
,
"mq-consumer-recover"
,
SMqConsumerRecoverMsg
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_MQ_DO_REBALANCE
,
"mq-do-rebalance"
,
SMqDoRebalanceMsg
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_MQ_DROP_CGROUP
,
"mq-drop-cgroup"
,
SMqDropCGroupReq
,
SMqDropCGroupRsp
)
TD_DEF_MSG_TYPE
(
TDMT_MND_MQ_COMMIT_OFFSET
,
"mq-commit-offset"
,
SMqCMCommitOffsetReq
,
SMqCMCommitOffsetRsp
)
TD_DEF_MSG_TYPE
(
TDMT_MND_CREATE_STREAM
,
"create-stream"
,
SCMCreateStreamReq
,
SCMCreateStreamRsp
)
TD_DEF_MSG_TYPE
(
TDMT_MND_ALTER_STREAM
,
"alter-stream"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_DROP_STREAM
,
"drop-stream"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_CREATE_INDEX
,
"create-index"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_DROP_INDEX
,
"drop-index"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_GET_DB_CFG
,
"get-db-cfg"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_GET_INDEX
,
"get-index"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_APPLY_MSG
,
"apply-msg"
,
NULL
,
NULL
)
// Requests handled by VNODE
TD_NEW_MSG_SEG
(
TDMT_VND_MSG
)
TD_DEF_MSG_TYPE
(
TDMT_VND_SUBMIT
,
"
vnode-
submit"
,
SSubmitReq
,
SSubmitRsp
)
TD_DEF_MSG_TYPE
(
TDMT_VND_QUERY
,
"
vnode-
query"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_FETCH
,
"
vnode-
fetch"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_CREATE_TABLE
,
"
vnode-
create-table"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_ALTER_TABLE
,
"
vnode-
alter-table"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_DROP_TABLE
,
"
vnode-
drop-table"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_UPDATE_TAG_VAL
,
"
vnode-
update-tag-val"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_SUBMIT
,
"submit"
,
SSubmitReq
,
SSubmitRsp
)
TD_DEF_MSG_TYPE
(
TDMT_VND_QUERY
,
"query"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_FETCH
,
"fetch"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_CREATE_TABLE
,
"create-table"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_ALTER_TABLE
,
"alter-table"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_DROP_TABLE
,
"drop-table"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_UPDATE_TAG_VAL
,
"update-tag-val"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_TABLE_META
,
"vnode-table-meta"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_TABLES_META
,
"vnode-tables-meta"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_CREATE_STB
,
"vnode-create-stb"
,
SVCreateStbReq
,
NULL
)
...
...
include/common/ttypes.h
浏览文件 @
5a9ed58b
...
...
@@ -49,7 +49,8 @@ typedef struct {
#define varDataCopy(dst, v) memcpy((dst), (void *)(v), varDataTLen(v))
#define varDataLenByData(v) (*(VarDataLenT *)(((char *)(v)) - VARSTR_HEADER_SIZE))
#define varDataSetLen(v, _len) (((VarDataLenT *)(v))[0] = (VarDataLenT)(_len))
#define IS_VAR_DATA_TYPE(t) (((t) == TSDB_DATA_TYPE_VARCHAR) || ((t) == TSDB_DATA_TYPE_NCHAR) || ((t) == TSDB_DATA_TYPE_JSON))
#define IS_VAR_DATA_TYPE(t) \
(((t) == TSDB_DATA_TYPE_VARCHAR) || ((t) == TSDB_DATA_TYPE_NCHAR) || ((t) == TSDB_DATA_TYPE_JSON))
#define IS_STR_DATA_TYPE(t) (((t) == TSDB_DATA_TYPE_VARCHAR) || ((t) == TSDB_DATA_TYPE_NCHAR))
#define varDataNetLen(v) (htons(((VarDataLenT *)(v))[0]))
...
...
@@ -179,15 +180,19 @@ typedef struct {
} \
} while (0)
//TODO: use varchar(0) to represent NULL type
#define IS_VAR_NULL_TYPE(_t, _b) ((_t) == TSDB_DATA_TYPE_VARCHAR && (_b) == 0)
#define IS_NULL_TYPE(_t) ((_t) == TSDB_DATA_TYPE_NULL)
#define IS_SIGNED_NUMERIC_TYPE(_t) ((_t) >= TSDB_DATA_TYPE_TINYINT && (_t) <= TSDB_DATA_TYPE_BIGINT)
#define IS_UNSIGNED_NUMERIC_TYPE(_t) ((_t) >= TSDB_DATA_TYPE_UTINYINT && (_t) <= TSDB_DATA_TYPE_UBIGINT)
#define IS_FLOAT_TYPE(_t) ((_t) == TSDB_DATA_TYPE_FLOAT || (_t) == TSDB_DATA_TYPE_DOUBLE)
#define IS_INTEGER_TYPE(_t) ((IS_SIGNED_NUMERIC_TYPE(_t)) || (IS_UNSIGNED_NUMERIC_TYPE(_t)))
#define IS_NUMERIC_TYPE(_t) ((IS_SIGNED_NUMERIC_TYPE(_t)) || (IS_UNSIGNED_NUMERIC_TYPE(_t)) || (IS_FLOAT_TYPE(_t)))
#define IS_MATHABLE_TYPE(_t) (IS_NUMERIC_TYPE(_t) || (_t) == (TSDB_DATA_TYPE_BOOL) || (_t) == (TSDB_DATA_TYPE_TIMESTAMP))
#define IS_MATHABLE_TYPE(_t) \
(IS_NUMERIC_TYPE(_t) || (_t) == (TSDB_DATA_TYPE_BOOL) || (_t) == (TSDB_DATA_TYPE_TIMESTAMP))
#define IS_VALID_TINYINT(_t) ((_t) >= INT8_MIN && (_t) <= INT8_MAX)
#define IS_VALID_SMALLINT(_t) ((_t) >= INT16_MIN && (_t) <= INT16_MAX)
...
...
@@ -244,7 +249,7 @@ typedef struct tDataTypeDescriptor {
int16_t
type
;
int16_t
nameLen
;
int32_t
bytes
;
char
*
name
;
char
*
name
;
int64_t
minValue
;
int64_t
maxValue
;
int32_t
(
*
compFunc
)(
const
char
*
const
input
,
int32_t
inputSize
,
const
int32_t
nelements
,
char
*
const
output
,
...
...
include/libs/scheduler/scheduler.h
浏览文件 @
5a9ed58b
...
...
@@ -100,7 +100,7 @@ int32_t schedulerExecJob(void *transport, SArray *nodeList, SQueryPlan *pDag, in
*/
int32_t
schedulerFetchRows
(
int64_t
job
,
void
**
data
);
int32_t
schedulerAsyncFetchRows
(
int64_t
job
,
schedulerFetchCallback
fp
,
void
*
param
);
void
schedulerAsyncFetchRows
(
int64_t
job
,
schedulerFetchCallback
fp
,
void
*
param
);
int32_t
schedulerGetTasksStatus
(
int64_t
job
,
SArray
*
pSub
);
...
...
@@ -121,8 +121,6 @@ void schedulerFreeJob(int64_t job);
void
schedulerDestroy
(
void
);
void
schdExecCallback
(
SQueryResult
*
pResult
,
void
*
param
,
int32_t
code
);
void
schdFetchCallback
(
void
*
pResult
,
void
*
param
,
int32_t
code
);
#ifdef __cplusplus
}
...
...
include/util/tutil.h
浏览文件 @
5a9ed58b
...
...
@@ -57,11 +57,13 @@ static FORCE_INLINE void taosEncryptPass_c(uint8_t *inBuf, size_t len, char *tar
tMD5Init
(
&
context
);
tMD5Update
(
&
context
,
inBuf
,
(
uint32_t
)
len
);
tMD5Final
(
&
context
);
char
buf
[
TSDB_PASSWORD_LEN
+
1
];
sprintf
(
target
,
"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x"
,
context
.
digest
[
0
],
sprintf
(
buf
,
"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x"
,
context
.
digest
[
0
],
context
.
digest
[
1
],
context
.
digest
[
2
],
context
.
digest
[
3
],
context
.
digest
[
4
],
context
.
digest
[
5
],
context
.
digest
[
6
],
context
.
digest
[
7
],
context
.
digest
[
8
],
context
.
digest
[
9
],
context
.
digest
[
10
],
context
.
digest
[
11
],
context
.
digest
[
12
],
context
.
digest
[
13
],
context
.
digest
[
14
],
context
.
digest
[
15
]);
memcpy
(
target
,
buf
,
TSDB_PASSWORD_LEN
);
}
#ifdef __cplusplus
...
...
source/client/inc/clientInt.h
浏览文件 @
5a9ed58b
...
...
@@ -46,6 +46,8 @@ extern "C" {
#define ERROR_MSG_BUF_DEFAULT_SIZE 512
#define HEARTBEAT_INTERVAL 1500 // ms
#define SYNC_ON_TOP_OF_ASYNC 0
enum
{
RES_TYPE__QUERY
=
1
,
RES_TYPE__TMQ
,
...
...
@@ -183,7 +185,9 @@ typedef struct SReqResultInfo {
typedef
struct
SRequestSendRecvBody
{
tsem_t
rspSem
;
// not used now
void
*
fp
;
__taos_async_fn_t
queryFp
;
__taos_async_fn_t
fetchFp
;
void
*
param
;
SDataBuf
requestMsg
;
int64_t
queryJob
;
// query job, created according to sql query DAG.
struct
SQueryPlan
*
pDag
;
// the query dag, generated according to the sql statement.
...
...
@@ -219,13 +223,21 @@ typedef struct SRequestObj {
SRequestSendRecvBody
body
;
}
SRequestObj
;
typedef
struct
SSyncQueryParam
{
tsem_t
sem
;
SRequestObj
*
pRequest
;
}
SSyncQueryParam
;
void
*
doAsyncFetchRow
(
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
);
SRequestObj
*
execQuery
(
STscObj
*
pTscObj
,
const
char
*
sql
,
int
sqlLen
);
static
FORCE_INLINE
SReqResultInfo
*
tmqGetCurResInfo
(
TAOS_RES
*
res
)
{
SMqRspObj
*
msg
=
(
SMqRspObj
*
)
res
;
...
...
@@ -271,7 +283,7 @@ int32_t releaseTscObj(int64_t rid);
uint64_t
generateRequestId
();
void
*
createRequest
(
STscObj
*
pObj
,
__taos_async_fn_t
fp
,
void
*
param
,
int32_t
type
);
void
*
createRequest
(
STscObj
*
pObj
,
void
*
param
,
int32_t
type
);
void
destroyRequest
(
SRequestObj
*
pRequest
);
SRequestObj
*
acquireRequest
(
int64_t
rid
);
int32_t
releaseRequest
(
int64_t
rid
);
...
...
@@ -319,9 +331,9 @@ int hbAddConnInfo(SAppHbMgr* pAppHbMgr, SClientHbKey connKey, void* key, void* v
// --- mq
void
hbMgrInitMqHbRspHandle
();
SRequestObj
*
launchQueryImpl
(
SRequestObj
*
pRequest
,
SQuery
*
pQuery
,
int32_t
code
,
bool
keepQuery
,
void
**
res
);
int32_t
getQueryPlan
(
SRequestObj
*
pRequest
,
SQuery
*
pQuery
,
SArray
**
pNodeList
);
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
);
int32_t
refreshMeta
(
STscObj
*
pTscObj
,
SRequestObj
*
pRequest
);
int32_t
updateQnodeList
(
SAppInstInfo
*
pInfo
,
SArray
*
pNodeList
);
...
...
source/client/src/clientEnv.c
浏览文件 @
5a9ed58b
...
...
@@ -13,10 +13,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "os.h"
#include "catalog.h"
#include "functionMgt.h"
#include "clientInt.h"
#include "clientLog.h"
#include "os.h"
#include "query.h"
#include "scheduler.h"
#include "tcache.h"
...
...
@@ -171,7 +172,7 @@ STscObj *acquireTscObj(int64_t rid) { return (STscObj *)taosAcquireRef(clientCon
int32_t
releaseTscObj
(
int64_t
rid
)
{
return
taosReleaseRef
(
clientConnRefPool
,
rid
);
}
void
*
createRequest
(
STscObj
*
pObj
,
__taos_async_fn_t
fp
,
void
*
param
,
int32_t
type
)
{
void
*
createRequest
(
STscObj
*
pObj
,
void
*
param
,
int32_t
type
)
{
assert
(
pObj
!=
NULL
);
SRequestObj
*
pRequest
=
(
SRequestObj
*
)
taosMemoryCalloc
(
1
,
sizeof
(
SRequestObj
));
...
...
@@ -185,9 +186,10 @@ void *createRequest(STscObj *pObj, __taos_async_fn_t fp, void *param, int32_t ty
pRequest
->
requestId
=
generateRequestId
();
pRequest
->
metric
.
start
=
taosGetTimestampUs
();
pRequest
->
body
.
param
=
param
;
pRequest
->
type
=
type
;
pRequest
->
pTscObj
=
pObj
;
pRequest
->
body
.
fp
=
fp
;
// not used it yet
pRequest
->
msgBuf
=
taosMemoryCalloc
(
1
,
ERROR_MSG_BUF_DEFAULT_SIZE
);
pRequest
->
msgBufLen
=
ERROR_MSG_BUF_DEFAULT_SIZE
;
tsem_init
(
&
pRequest
->
body
.
rspSem
,
0
,
0
);
...
...
@@ -288,6 +290,7 @@ void taos_init_imp(void) {
taosSetCoreDump
(
true
);
initTaskQueue
();
fmFuncMgtInit
();
clientConnRefPool
=
taosOpenRef
(
200
,
destroyTscObj
);
clientReqRefPool
=
taosOpenRef
(
40960
,
doDestroyRequest
);
...
...
source/client/src/clientImpl.c
浏览文件 @
5a9ed58b
...
...
@@ -133,7 +133,7 @@ TAOS* taos_connect_internal(const char* ip, const char* user, const char* pass,
}
int32_t
buildRequest
(
STscObj
*
pTscObj
,
const
char
*
sql
,
int
sqlLen
,
SRequestObj
**
pRequest
)
{
*
pRequest
=
createRequest
(
pTscObj
,
NULL
,
NULL
,
TSDB_SQL_SELECT
);
*
pRequest
=
createRequest
(
pTscObj
,
NULL
,
TSDB_SQL_SELECT
);
if
(
*
pRequest
==
NULL
)
{
tscError
(
"failed to malloc sqlObj"
);
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
...
...
@@ -192,6 +192,7 @@ int32_t parseSql(SRequestObj* pRequest, bool topicQuery, SQuery** pQuery, SStmtC
setResPrecision
(
&
pRequest
->
body
.
resInfo
,
(
*
pQuery
)
->
precision
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
||
NEED_CLIENT_HANDLE_ERROR
(
code
))
{
TSWAP
(
pRequest
->
dbList
,
(
*
pQuery
)
->
pDbList
);
TSWAP
(
pRequest
->
tableList
,
(
*
pQuery
)
->
pTableList
);
...
...
@@ -230,6 +231,29 @@ int32_t execDdlQuery(SRequestObj* pRequest, SQuery* pQuery) {
return
TSDB_CODE_SUCCESS
;
}
static
SAppInstInfo
*
getAppInfo
(
SRequestObj
*
pRequest
)
{
return
pRequest
->
pTscObj
->
pAppInfo
;
}
int32_t
asyncExecDdlQuery
(
SRequestObj
*
pRequest
,
SQuery
*
pQuery
)
{
// drop table if exists not_exists_table
if
(
NULL
==
pQuery
->
pCmdMsg
)
{
return
TSDB_CODE_SUCCESS
;
}
SCmdMsgInfo
*
pMsgInfo
=
pQuery
->
pCmdMsg
;
pRequest
->
type
=
pMsgInfo
->
msgType
;
pRequest
->
body
.
requestMsg
=
(
SDataBuf
){.
pData
=
pMsgInfo
->
pMsg
,
.
len
=
pMsgInfo
->
msgLen
,
.
handle
=
NULL
};
pMsgInfo
->
pMsg
=
NULL
;
// pMsg transferred to SMsgSendInfo management
SAppInstInfo
*
pAppInfo
=
getAppInfo
(
pRequest
);
SMsgSendInfo
*
pSendMsg
=
buildMsgInfoImpl
(
pRequest
);
int64_t
transporterId
=
0
;
asyncSendMsgToServer
(
pAppInfo
->
pTransporter
,
&
pMsgInfo
->
epSet
,
&
transporterId
,
pSendMsg
);
return
TSDB_CODE_SUCCESS
;
}
int
compareQueryNodeLoad
(
const
void
*
elem1
,
const
void
*
elem2
)
{
SQueryNodeLoad
*
node1
=
(
SQueryNodeLoad
*
)
elem1
;
SQueryNodeLoad
*
node2
=
(
SQueryNodeLoad
*
)
elem2
;
...
...
@@ -286,9 +310,11 @@ int32_t getQnodeList(SRequestObj* pRequest, SArray** pNodeList) {
int32_t
getPlan
(
SRequestObj
*
pRequest
,
SQuery
*
pQuery
,
SQueryPlan
**
pPlan
,
SArray
**
pNodeList
)
{
pRequest
->
type
=
pQuery
->
msgType
;
SAppInstInfo
*
pAppInfo
=
getAppInfo
(
pRequest
);
SPlanContext
cxt
=
{.
queryId
=
pRequest
->
requestId
,
.
acctId
=
pRequest
->
pTscObj
->
acctId
,
.
mgmtEpSet
=
getEpSet_s
(
&
p
Request
->
pTscObj
->
p
AppInfo
->
mgmtEp
),
.
mgmtEpSet
=
getEpSet_s
(
&
pAppInfo
->
mgmtEp
),
.
pAstRoot
=
pQuery
->
pRoot
,
.
showRewrite
=
pQuery
->
showRewrite
,
.
pMsg
=
pRequest
->
msgBuf
,
...
...
@@ -298,6 +324,7 @@ int32_t getPlan(SRequestObj* pRequest, SQuery* pQuery, SQueryPlan** pPlan, SArra
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
qCreateQueryPlan
(
&
cxt
,
pPlan
,
*
pNodeList
);
}
return
code
;
}
...
...
@@ -388,7 +415,7 @@ int32_t scheduleAsyncQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNod
int32_t
scheduleQuery
(
SRequestObj
*
pRequest
,
SQueryPlan
*
pDag
,
SArray
*
pNodeList
)
{
void
*
pTransporter
=
pRequest
->
pTscObj
->
pAppInfo
->
pTransporter
;
SQueryResult
res
=
{
.
code
=
0
,
.
numOfRows
=
0
};
SQueryResult
res
=
{
0
};
int32_t
code
=
schedulerExecJob
(
pTransporter
,
pNodeList
,
pDag
,
&
pRequest
->
body
.
queryJob
,
pRequest
->
sqlstr
,
pRequest
->
metric
.
start
,
&
res
);
...
...
@@ -417,10 +444,6 @@ int32_t scheduleQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList
return
pRequest
->
code
;
}
int32_t
getQueryPlan
(
SRequestObj
*
pRequest
,
SQuery
*
pQuery
,
SArray
**
pNodeList
)
{
return
getPlan
(
pRequest
,
pQuery
,
&
pRequest
->
body
.
pDag
,
pNodeList
);
}
int32_t
handleSubmitExecRes
(
SRequestObj
*
pRequest
,
void
*
res
,
SCatalog
*
pCatalog
,
SEpSet
*
epset
)
{
int32_t
code
=
0
;
SArray
*
pArray
=
NULL
;
...
...
@@ -523,8 +546,16 @@ int32_t handleExecRes(SRequestObj* pRequest) {
return
code
;
}
SRequestObj
*
launchQueryImpl
(
SRequestObj
*
pRequest
,
SQuery
*
pQuery
,
int32_t
code
,
bool
keepQuery
,
void
**
res
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
void
schedulerExecCb
(
SQueryResult
*
pResult
,
void
*
param
,
int32_t
code
)
{
SRequestObj
*
pRequest
=
(
SRequestObj
*
)
param
;
// return to client
pRequest
->
body
.
queryFp
(
pRequest
->
body
.
param
,
pRequest
,
code
);
}
SRequestObj
*
launchQueryImpl
(
SRequestObj
*
pRequest
,
SQuery
*
pQuery
,
bool
keepQuery
,
void
**
res
)
{
int32_t
code
=
0
;
switch
(
pQuery
->
execMode
)
{
case
QUERY_EXEC_MODE_LOCAL
:
code
=
execLocalCmd
(
pRequest
,
pQuery
);
...
...
@@ -547,7 +578,6 @@ SRequestObj* launchQueryImpl(SRequestObj* pRequest, SQuery* pQuery, int32_t code
default:
break
;
}
}
if
(
!
keepQuery
)
{
qDestroyQuery
(
pQuery
);
...
...
@@ -583,7 +613,70 @@ SRequestObj* launchQuery(STscObj* pTscObj, const char* sql, int sqlLen) {
return
pRequest
;
}
return
launchQueryImpl
(
pRequest
,
pQuery
,
code
,
false
,
NULL
);
return
launchQueryImpl
(
pRequest
,
pQuery
,
false
,
NULL
);
}
void
launchAsyncQuery
(
SRequestObj
*
pRequest
,
SQuery
*
pQuery
)
{
void
*
pRes
=
NULL
;
int32_t
code
=
0
;
switch
(
pQuery
->
execMode
)
{
case
QUERY_EXEC_MODE_LOCAL
:
code
=
execLocalCmd
(
pRequest
,
pQuery
);
break
;
case
QUERY_EXEC_MODE_RPC
:
code
=
asyncExecDdlQuery
(
pRequest
,
pQuery
);
break
;
case
QUERY_EXEC_MODE_SCHEDULE
:
{
SArray
*
pNodeList
=
taosArrayInit
(
4
,
sizeof
(
struct
SQueryNodeAddr
));
pRequest
->
type
=
pQuery
->
msgType
;
SPlanContext
cxt
=
{.
queryId
=
pRequest
->
requestId
,
.
acctId
=
pRequest
->
pTscObj
->
acctId
,
.
mgmtEpSet
=
getEpSet_s
(
&
pRequest
->
pTscObj
->
pAppInfo
->
mgmtEp
),
.
pAstRoot
=
pQuery
->
pRoot
,
.
showRewrite
=
pQuery
->
showRewrite
,
.
pMsg
=
pRequest
->
msgBuf
,
.
msgLen
=
ERROR_MSG_BUF_DEFAULT_SIZE
};
SAppInstInfo
*
pAppInfo
=
getAppInfo
(
pRequest
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
qCreateQueryPlan
(
&
cxt
,
&
pRequest
->
body
.
pDag
,
pNodeList
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
schedulerAsyncExecJob
(
pAppInfo
->
pTransporter
,
pNodeList
,
pRequest
->
body
.
pDag
,
&
pRequest
->
body
.
queryJob
,
pRequest
->
sqlstr
,
pRequest
->
metric
.
start
,
schedulerExecCb
,
pRequest
);
// if (NULL != pRes) {
// code = validateSversion(pRequest, pRes);
// }
}
taosArrayDestroy
(
pNodeList
);
break
;
}
case
QUERY_EXEC_MODE_EMPTY_RESULT
:
pRequest
->
type
=
TSDB_SQL_RETRIEVE_EMPTY_RESULT
;
break
;
default:
break
;
}
// if (!keepQuery) {
// qDestroyQuery(pQuery);
// }
if
(
NULL
!=
pRequest
&&
TSDB_CODE_SUCCESS
!=
code
)
{
pRequest
->
code
=
terrno
;
}
// if (res) {
// *res = pRes;
// } else {
// freeRequestRes(pRequest, pRes);
// pRes = NULL;
}
int32_t
refreshMeta
(
STscObj
*
pTscObj
,
SRequestObj
*
pRequest
)
{
...
...
@@ -666,17 +759,6 @@ SRequestObj* execQuery(STscObj* pTscObj, const char* sql, int sqlLen) {
return
pRequest
;
}
TAOS_RES
*
taos_query_l
(
TAOS
*
taos
,
const
char
*
sql
,
int
sqlLen
)
{
STscObj
*
pTscObj
=
(
STscObj
*
)
taos
;
if
(
sqlLen
>
(
size_t
)
TSDB_MAX_ALLOWED_SQL_LEN
)
{
tscError
(
"sql string exceeds max length:%d"
,
TSDB_MAX_ALLOWED_SQL_LEN
);
terrno
=
TSDB_CODE_TSC_EXCEED_SQL_LIMIT
;
return
NULL
;
}
return
execQuery
(
pTscObj
,
sql
,
sqlLen
);
}
int
initEpSetFromCfg
(
const
char
*
firstEp
,
const
char
*
secondEp
,
SCorEpSet
*
pEpSet
)
{
pEpSet
->
version
=
0
;
...
...
@@ -726,7 +808,7 @@ STscObj* taosConnectImpl(const char* user, const char* auth, const char* db, __t
return
pTscObj
;
}
SRequestObj
*
pRequest
=
createRequest
(
pTscObj
,
fp
,
param
,
TDMT_MND_CONNECT
);
SRequestObj
*
pRequest
=
createRequest
(
pTscObj
,
param
,
TDMT_MND_CONNECT
);
if
(
pRequest
==
NULL
)
{
destroyTscObj
(
pTscObj
);
terrno
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
...
...
@@ -843,7 +925,6 @@ void updateTargetEpSet(SMsgSendInfo* pSendInfo, STscObj* pTscObj, SRpcMsg* pMsg,
void
processMsgFromServer
(
void
*
parent
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
)
{
SMsgSendInfo
*
pSendInfo
=
(
SMsgSendInfo
*
)
pMsg
->
info
.
ahandle
;
assert
(
pMsg
->
info
.
ahandle
!=
NULL
);
SRequestObj
*
pRequest
=
NULL
;
STscObj
*
pTscObj
=
NULL
;
if
(
pSendInfo
->
requestObjRefId
!=
0
)
{
...
...
@@ -923,7 +1004,7 @@ void doSetOneRowPtr(SReqResultInfo* pResultInfo) {
int32_t
bytes
=
pResultInfo
->
fields
[
i
].
bytes
;
if
(
IS_VAR_DATA_TYPE
(
type
))
{
if
(
pCol
->
offset
[
pResultInfo
->
current
]
!=
-
1
)
{
if
(
!
IS_VAR_NULL_TYPE
(
type
,
bytes
)
&&
pCol
->
offset
[
pResultInfo
->
current
]
!=
-
1
)
{
char
*
pStart
=
pResultInfo
->
pCol
[
i
].
offset
[
pResultInfo
->
current
]
+
pResultInfo
->
pCol
[
i
].
pData
;
pResultInfo
->
length
[
i
]
=
varDataLen
(
pStart
);
...
...
@@ -944,7 +1025,7 @@ void doSetOneRowPtr(SReqResultInfo* pResultInfo) {
}
}
void
*
do
Async
FetchRows
(
SRequestObj
*
pRequest
,
bool
setupOneRowPtr
,
bool
convertUcs4
)
{
void
*
doFetchRows
(
SRequestObj
*
pRequest
,
bool
setupOneRowPtr
,
bool
convertUcs4
)
{
assert
(
pRequest
!=
NULL
);
SReqResultInfo
*
pResultInfo
=
&
pRequest
->
body
.
resInfo
;
...
...
@@ -955,17 +1036,8 @@ void* doAsyncFetchRows(SRequestObj* pRequest, bool setupOneRowPtr, bool convertU
return
NULL
;
}
tsem_init
(
&
schdRspSem
,
0
,
0
);
SReqResultInfo
*
pResInfo
=
&
pRequest
->
body
.
resInfo
;
SSchdFetchParam
param
=
{.
pData
=
(
void
**
)
&
pResInfo
->
pData
,
.
code
=
&
pRequest
->
code
};
pRequest
->
code
=
schedulerAsyncFetchRows
(
pRequest
->
body
.
queryJob
,
schdFetchCallback
,
&
param
);
if
(
pRequest
->
code
!=
TSDB_CODE_SUCCESS
)
{
pResultInfo
->
numOfRows
=
0
;
return
NULL
;
}
tsem_wait
(
&
schdRspSem
);
pRequest
->
code
=
schedulerFetchRows
(
pRequest
->
body
.
queryJob
,
(
void
**
)
&
pResInfo
->
pData
);
if
(
pRequest
->
code
!=
TSDB_CODE_SUCCESS
)
{
pResultInfo
->
numOfRows
=
0
;
return
NULL
;
...
...
@@ -994,8 +1066,12 @@ void* doAsyncFetchRows(SRequestObj* pRequest, bool setupOneRowPtr, bool convertU
return
pResultInfo
->
row
;
}
void
*
doFetchRows
(
SRequestObj
*
pRequest
,
bool
setupOneRowPtr
,
bool
convertUcs4
)
{
// return doAsyncFetchRows(pRequest, setupOneRowPtr, convertUcs4);
static
void
syncFetchFn
(
void
*
param
,
TAOS_RES
*
res
,
int32_t
numOfRows
)
{
SSyncQueryParam
*
pParam
=
param
;
tsem_post
(
&
pParam
->
sem
);
}
void
*
doAsyncFetchRow
(
SRequestObj
*
pRequest
,
bool
setupOneRowPtr
,
bool
convertUcs4
)
{
assert
(
pRequest
!=
NULL
);
SReqResultInfo
*
pResultInfo
=
&
pRequest
->
body
.
resInfo
;
...
...
@@ -1006,29 +1082,12 @@ void* doFetchRows(SRequestObj* pRequest, bool setupOneRowPtr, bool convertUcs4)
return
NULL
;
}
SReqResultInfo
*
pResInfo
=
&
pRequest
->
body
.
resInfo
;
pRequest
->
code
=
schedulerFetchRows
(
pRequest
->
body
.
queryJob
,
(
void
**
)
&
pResInfo
->
pData
);
if
(
pRequest
->
code
!=
TSDB_CODE_SUCCESS
)
{
pResultInfo
->
numOfRows
=
0
;
return
NULL
;
SSyncQueryParam
*
pParam
=
pRequest
->
body
.
param
;
taos_fetch_rows_a
(
pRequest
,
syncFetchFn
,
pParam
);
tsem_wait
(
&
pParam
->
sem
);
}
pRequest
->
code
=
setQueryResultFromRsp
(
&
pRequest
->
body
.
resInfo
,
(
SRetrieveTableRsp
*
)
pResInfo
->
pData
,
convertUcs4
,
true
);
if
(
pRequest
->
code
!=
TSDB_CODE_SUCCESS
)
{
pResultInfo
->
numOfRows
=
0
;
return
NULL
;
}
tscDebug
(
"0x%"
PRIx64
" fetch results, numOfRows:%d total Rows:%"
PRId64
", complete:%d, reqId:0x%"
PRIx64
,
pRequest
->
self
,
pResInfo
->
numOfRows
,
pResInfo
->
totalRows
,
pResInfo
->
completed
,
pRequest
->
requestId
);
if
(
pResultInfo
->
numOfRows
==
0
)
{
return
NULL
;
}
}
if
(
setupOneRowPtr
)
{
if
(
pRequest
->
code
==
TSDB_CODE_SUCCESS
&&
setupOneRowPtr
)
{
doSetOneRowPtr
(
pResultInfo
);
pResultInfo
->
current
+=
1
;
}
...
...
source/client/src/clientMain.c
浏览文件 @
5a9ed58b
...
...
@@ -175,12 +175,39 @@ TAOS_FIELD *taos_fetch_fields(TAOS_RES *res) {
return
pResInfo
->
userFields
;
}
static
void
syncQueryFn
(
void
*
param
,
void
*
res
,
int32_t
code
)
{
SSyncQueryParam
*
pParam
=
param
;
pParam
->
pRequest
=
res
;
pParam
->
pRequest
->
code
=
code
;
tsem_post
(
&
pParam
->
sem
);
}
TAOS_RES
*
taos_query
(
TAOS
*
taos
,
const
char
*
sql
)
{
if
(
taos
==
NULL
||
sql
==
NULL
)
{
return
NULL
;
}
return
taos_query_l
(
taos
,
sql
,
(
int32_t
)
strlen
(
sql
));
STscObj
*
pTscObj
=
(
STscObj
*
)
taos
;
#if SYNC_ON_TOP_OF_ASYNC
SSyncQueryParam
*
param
=
taosMemoryCalloc
(
1
,
sizeof
(
struct
SSyncQueryParam
));
tsem_init
(
&
param
->
sem
,
0
,
0
);
taos_query_a
(
pTscObj
,
sql
,
syncQueryFn
,
param
);
tsem_wait
(
&
param
->
sem
);
return
param
->
pRequest
;
#else
size_t
sqlLen
=
strlen
(
sql
);
if
(
sqlLen
>
(
size_t
)
TSDB_MAX_ALLOWED_SQL_LEN
)
{
tscError
(
"sql string exceeds max length:%d"
,
TSDB_MAX_ALLOWED_SQL_LEN
);
terrno
=
TSDB_CODE_TSC_EXCEED_SQL_LIMIT
;
return
NULL
;
}
return
execQuery
(
pTscObj
,
sql
,
sqlLen
);
#endif
}
TAOS_ROW
taos_fetch_row
(
TAOS_RES
*
res
)
{
...
...
@@ -195,7 +222,11 @@ TAOS_ROW taos_fetch_row(TAOS_RES *res) {
return
NULL
;
}
#if SYNC_ON_TOP_OF_ASYNC
return
doAsyncFetchRow
(
pRequest
,
true
,
true
);
#else
return
doFetchRows
(
pRequest
,
true
,
true
);
#endif
}
else
if
(
TD_RES_TMQ
(
res
))
{
SMqRspObj
*
msg
=
((
SMqRspObj
*
)
res
);
...
...
@@ -205,6 +236,7 @@ TAOS_ROW taos_fetch_row(TAOS_RES *res) {
}
else
{
pResultInfo
=
tmqGetCurResInfo
(
res
);
}
if
(
pResultInfo
->
current
<
pResultInfo
->
numOfRows
)
{
doSetOneRowPtr
(
pResultInfo
);
pResultInfo
->
current
+=
1
;
...
...
@@ -563,38 +595,195 @@ const char *taos_get_server_info(TAOS *taos) {
return
pTscObj
->
ver
;
}
typedef
struct
SqlParseWrapper
{
SParseContext
*
pCtx
;
SCatalogReq
catalogReq
;
SRequestObj
*
pRequest
;
SQuery
*
pQuery
;
}
SqlParseWrapper
;
void
retrieveMetaCallback
(
SMetaData
*
pResultMeta
,
void
*
param
,
int32_t
code
)
{
SqlParseWrapper
*
pWrapper
=
(
SqlParseWrapper
*
)
param
;
SQuery
*
pQuery
=
pWrapper
->
pQuery
;
SRequestObj
*
pRequest
=
pWrapper
->
pRequest
;
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
}
code
=
qAnalyseSqlSemantic
(
pWrapper
->
pCtx
,
&
pWrapper
->
catalogReq
,
pResultMeta
,
pQuery
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
}
if
(
pQuery
->
haveResultSet
)
{
setResSchemaInfo
(
&
pRequest
->
body
.
resInfo
,
pQuery
->
pResSchema
,
(
pQuery
)
->
numOfResCols
);
setResPrecision
(
&
pRequest
->
body
.
resInfo
,
(
pQuery
)
->
precision
);
}
TSWAP
(
pRequest
->
dbList
,
(
pQuery
)
->
pDbList
);
TSWAP
(
pRequest
->
tableList
,
(
pQuery
)
->
pTableList
);
taosMemoryFree
(
pWrapper
);
launchAsyncQuery
(
pRequest
,
pQuery
);
return
;
_error:
taosMemoryFree
(
pWrapper
);
tscError
(
"0x%"
PRIx64
" error occurs, code:%s, return to user app, reqId:%"
PRIx64
,
pRequest
->
self
,
tstrerror
(
code
),
pRequest
->
requestId
);
pRequest
->
code
=
code
;
pRequest
->
body
.
queryFp
(
pRequest
->
body
.
param
,
pRequest
,
code
);
}
// todo add retry before return user's callback
void
taos_query_a
(
TAOS
*
taos
,
const
char
*
sql
,
__taos_async_fn_t
fp
,
void
*
param
)
{
ASSERT
(
fp
!=
NULL
);
if
(
taos
==
NULL
||
sql
==
NULL
)
{
fp
(
param
,
NULL
,
TSDB_CODE_INVALID_PARA
);
terrno
=
TSDB_CODE_INVALID_PARA
;
fp
(
param
,
NULL
,
terrno
);
return
;
}
SRequestObj
*
pRequest
=
NULL
;
size_t
sqlLen
=
strlen
(
sql
);
if
(
sqlLen
>
(
size_t
)
TSDB_MAX_ALLOWED_SQL_LEN
)
{
tscError
(
"sql string exceeds max length:%d"
,
TSDB_MAX_ALLOWED_SQL_LEN
);
terrno
=
TSDB_CODE_TSC_EXCEED_SQL_LIMIT
;
fp
(
param
,
NULL
,
terrno
);
return
;
}
SRequestObj
*
pRequest
=
NULL
;
int32_t
retryNum
=
0
;
int32_t
code
=
0
;
size_t
sqlLen
=
strlen
(
sql
);
// while (retryNum++ < REQUEST_MAX_TRY_TIMES) {
code
=
buildRequest
(
taos
,
sql
,
sqlLen
,
&
pRequest
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
terrno
=
code
;
fp
(
param
,
NULL
,
code
);
return
;
}
while
(
retryNum
++
<
REQUEST_MAX_TRY_TIMES
)
{
pRequest
=
launchQuery
(
taos
,
sql
,
sqlLen
);
if
(
pRequest
==
NULL
||
TSDB_CODE_SUCCESS
==
pRequest
->
code
||
!
NEED_CLIENT_HANDLE_ERROR
(
pRequest
->
code
))
{
break
;
pRequest
->
body
.
queryFp
=
fp
;
pRequest
->
body
.
param
=
param
;
STscObj
*
pTscObj
=
pRequest
->
pTscObj
;
SParseContext
*
pCxt
=
taosMemoryCalloc
(
1
,
sizeof
(
SParseContext
));
*
pCxt
=
(
SParseContext
){.
requestId
=
pRequest
->
requestId
,
.
acctId
=
pTscObj
->
acctId
,
.
db
=
pRequest
->
pDb
,
.
topicQuery
=
false
,
.
pSql
=
pRequest
->
sqlstr
,
.
sqlLen
=
pRequest
->
sqlLen
,
.
pMsg
=
pRequest
->
msgBuf
,
.
msgLen
=
ERROR_MSG_BUF_DEFAULT_SIZE
,
.
pTransporter
=
pTscObj
->
pAppInfo
->
pTransporter
,
.
pStmtCb
=
NULL
,
.
pUser
=
pTscObj
->
user
,
.
isSuperUser
=
(
0
==
strcmp
(
pTscObj
->
user
,
TSDB_DEFAULT_USER
)),
.
async
=
true
,};
pCxt
->
mgmtEpSet
=
getEpSet_s
(
&
pTscObj
->
pAppInfo
->
mgmtEp
);
code
=
catalogGetHandle
(
pTscObj
->
pAppInfo
->
clusterId
,
&
pCxt
->
pCatalog
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
}
code
=
refreshMeta
(
taos
,
pRequest
);
if
(
code
)
{
pRequest
->
code
=
code
;
break
;
SQuery
*
pQuery
=
NULL
;
SCatalogReq
catalogReq
=
{
0
};
code
=
qParseSqlSyntax
(
pCxt
,
&
pQuery
,
&
catalogReq
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
}
destroyRequest
(
pRequest
);
SqlParseWrapper
*
pWrapper
=
taosMemoryCalloc
(
1
,
sizeof
(
SqlParseWrapper
));
pWrapper
->
pCtx
=
pCxt
;
pWrapper
->
pQuery
=
pQuery
;
pWrapper
->
pRequest
=
pRequest
;
pWrapper
->
catalogReq
=
catalogReq
;
code
=
catalogAsyncGetAllMeta
(
pCxt
->
pCatalog
,
pCxt
->
pTransporter
,
&
pCxt
->
mgmtEpSet
,
pRequest
->
requestId
,
&
catalogReq
,
retrieveMetaCallback
,
pWrapper
,
&
pRequest
->
body
.
queryJob
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
}
return
;
// todo handle the retry process
// if (TSDB_CODE_SUCCESS == code || NEED_CLIENT_HANDLE_ERROR(code)) {
// TSWAP(pRequest->dbList, (pQuery)->pDbList);
// TSWAP(pRequest->tableList, (pQuery)->pTableList);
// }
_error:
terrno
=
code
;
pRequest
->
code
=
code
;
fp
(
param
,
pRequest
,
code
);
}
static
void
fetchCallback
(
void
*
pResult
,
void
*
param
,
int32_t
code
)
{
SRequestObj
*
pRequest
=
(
SRequestObj
*
)
param
;
SReqResultInfo
*
pResultInfo
=
&
pRequest
->
body
.
resInfo
;
pResultInfo
->
pData
=
pResult
;
pResultInfo
->
numOfRows
=
0
;
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
pRequest
->
code
=
code
;
pRequest
->
body
.
fetchFp
(
pRequest
->
body
.
param
,
pRequest
,
0
);
return
;
}
if
(
pRequest
->
code
!=
TSDB_CODE_SUCCESS
)
{
pRequest
->
code
=
code
;
pRequest
->
body
.
fetchFp
(
pRequest
->
body
.
param
,
pRequest
,
0
);
}
pRequest
->
code
=
setQueryResultFromRsp
(
&
pRequest
->
body
.
resInfo
,
(
SRetrieveTableRsp
*
)
pResultInfo
->
pData
,
true
,
false
);
if
(
pRequest
->
code
!=
TSDB_CODE_SUCCESS
)
{
pResultInfo
->
numOfRows
=
0
;
pRequest
->
code
=
code
;
pRequest
->
body
.
fetchFp
(
pRequest
->
body
.
param
,
pRequest
,
0
);
}
tscDebug
(
"0x%"
PRIx64
" fetch results, numOfRows:%d total Rows:%"
PRId64
", complete:%d, reqId:0x%"
PRIx64
,
pRequest
->
self
,
pResultInfo
->
numOfRows
,
pResultInfo
->
totalRows
,
pResultInfo
->
completed
,
pRequest
->
requestId
);
pRequest
->
body
.
fetchFp
(
pRequest
->
body
.
param
,
pRequest
,
pResultInfo
->
numOfRows
);
}
void
taos_fetch_rows_a
(
TAOS_RES
*
res
,
__taos_async_fn_t
fp
,
void
*
param
)
{
// TODO
ASSERT
(
res
!=
NULL
&&
fp
!=
NULL
);
SRequestObj
*
pRequest
=
res
;
pRequest
->
body
.
fetchFp
=
fp
;
SReqResultInfo
*
pResultInfo
=
&
pRequest
->
body
.
resInfo
;
if
(
taos_num_fields
(
pRequest
)
==
0
)
{
pResultInfo
->
numOfRows
=
0
;
pRequest
->
body
.
fetchFp
(
param
,
pRequest
,
pResultInfo
->
numOfRows
);
return
;
}
if
(
pResultInfo
->
pData
==
NULL
||
pResultInfo
->
current
>=
pResultInfo
->
numOfRows
)
{
// All data has returned to App already, no need to try again
if
(
pResultInfo
->
completed
)
{
pResultInfo
->
numOfRows
=
0
;
pRequest
->
body
.
fetchFp
(
param
,
pRequest
,
pResultInfo
->
numOfRows
);
return
;
}
}
schedulerAsyncFetchRows
(
pRequest
->
body
.
queryJob
,
fetchCallback
,
pRequest
);
}
TAOS_SUB
*
taos_subscribe
(
TAOS
*
taos
,
int
restart
,
const
char
*
topic
,
const
char
*
sql
,
TAOS_SUBSCRIBE_CALLBACK
fp
,
...
...
source/client/src/clientMsgHandler.c
浏览文件 @
5a9ed58b
...
...
@@ -33,7 +33,11 @@ int32_t genericRspCallback(void* param, const SDataBuf* pMsg, int32_t code) {
setErrno
(
pRequest
,
code
);
taosMemoryFree
(
pMsg
->
pData
);
if
(
pRequest
->
body
.
queryFp
!=
NULL
)
{
pRequest
->
body
.
queryFp
(
pRequest
->
body
.
param
,
pRequest
,
code
);
}
else
{
tsem_post
(
&
pRequest
->
body
.
rspSem
);
}
return
code
;
}
...
...
@@ -117,7 +121,12 @@ int32_t processCreateDbRsp(void* param, const SDataBuf* pMsg, int32_t code) {
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
setErrno
(
pRequest
,
code
);
}
if
(
pRequest
->
body
.
queryFp
)
{
pRequest
->
body
.
queryFp
(
pRequest
->
body
.
param
,
pRequest
,
code
);
}
else
{
tsem_post
(
&
pRequest
->
body
.
rspSem
);
}
return
code
;
}
...
...
@@ -146,7 +155,13 @@ int32_t processUseDbRsp(void* param, const SDataBuf* pMsg, int32_t code) {
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
taosMemoryFree
(
pMsg
->
pData
);
setErrno
(
pRequest
,
code
);
if
(
pRequest
->
body
.
queryFp
!=
NULL
)
{
pRequest
->
body
.
queryFp
(
pRequest
->
body
.
param
,
pRequest
,
pRequest
->
code
);
}
else
{
tsem_post
(
&
pRequest
->
body
.
rspSem
);
}
return
code
;
}
...
...
@@ -185,7 +200,12 @@ int32_t processUseDbRsp(void* param, const SDataBuf* pMsg, int32_t code) {
setConnectionDB
(
pRequest
->
pTscObj
,
db
);
taosMemoryFree
(
pMsg
->
pData
);
if
(
pRequest
->
body
.
queryFp
!=
NULL
)
{
pRequest
->
body
.
queryFp
(
pRequest
->
body
.
param
,
pRequest
,
pRequest
->
code
);
}
else
{
tsem_post
(
&
pRequest
->
body
.
rspSem
);
}
return
0
;
}
...
...
@@ -196,11 +216,13 @@ int32_t processCreateTableRsp(void* param, const SDataBuf* pMsg, int32_t code) {
taosMemoryFree
(
pMsg
->
pData
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
setErrno
(
pRequest
,
code
);
tsem_post
(
&
pRequest
->
body
.
rspSem
);
return
code
;
}
if
(
pRequest
->
body
.
queryFp
!=
NULL
)
{
pRequest
->
body
.
queryFp
(
pRequest
->
body
.
param
,
pRequest
,
code
);
}
else
{
tsem_post
(
&
pRequest
->
body
.
rspSem
);
}
return
code
;
}
...
...
@@ -208,18 +230,20 @@ int32_t processDropDbRsp(void* param, const SDataBuf* pMsg, int32_t code) {
SRequestObj
*
pRequest
=
param
;
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
setErrno
(
pRequest
,
code
);
tsem_post
(
&
pRequest
->
body
.
rspSem
);
return
code
;
}
}
else
{
SDropDbRsp
dropdbRsp
=
{
0
};
tDeserializeSDropDbRsp
(
pMsg
->
pData
,
pMsg
->
len
,
&
dropdbRsp
);
struct
SCatalog
*
pCatalog
=
NULL
;
catalogGetHandle
(
pRequest
->
pTscObj
->
pAppInfo
->
clusterId
,
&
pCatalog
);
catalogRemoveDB
(
pCatalog
,
dropdbRsp
.
db
,
dropdbRsp
.
uid
);
}
if
(
pRequest
->
body
.
queryFp
!=
NULL
)
{
pRequest
->
body
.
queryFp
(
pRequest
->
body
.
param
,
pRequest
,
code
);
}
else
{
tsem_post
(
&
pRequest
->
body
.
rspSem
);
}
return
code
;
}
...
...
@@ -245,6 +269,7 @@ int32_t processAlterStbRsp(void* param, const SDataBuf* pMsg, int32_t code) {
}
// todo refactor: this arraylist is too large
void
initMsgHandleFp
()
{
handleRequestRspFp
[
TMSG_INDEX
(
TDMT_MND_CONNECT
)]
=
processConnectRsp
;
handleRequestRspFp
[
TMSG_INDEX
(
TDMT_MND_CREATE_DB
)]
=
processCreateDbRsp
;
...
...
source/client/src/clientSml.c
浏览文件 @
5a9ed58b
...
...
@@ -2241,7 +2241,7 @@ static int32_t smlInsertData(SSmlHandle* info) {
}
info
->
cost
.
insertRpcTime
=
taosGetTimestampUs
();
launchQueryImpl
(
info
->
pRequest
,
info
->
pQuery
,
TSDB_CODE_SUCCESS
,
true
,
NULL
);
launchQueryImpl
(
info
->
pRequest
,
info
->
pQuery
,
true
,
NULL
);
info
->
affectedRows
=
taos_affected_rows
(
info
->
pRequest
);
return
info
->
pRequest
->
code
;
...
...
@@ -2362,7 +2362,7 @@ static int32_t isSchemalessDb(SSmlHandle* info){
*/
TAOS_RES
*
taos_schemaless_insert
(
TAOS
*
taos
,
char
*
lines
[],
int
numLines
,
int
protocol
,
int
precision
)
{
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
NULL
,
NULL
,
TSDB_SQL_INSERT
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
NULL
,
TSDB_SQL_INSERT
);
if
(
!
request
){
uError
(
"SML:taos_schemaless_insert error request is null"
);
return
NULL
;
...
...
source/client/src/clientStmt.c
浏览文件 @
5a9ed58b
...
...
@@ -771,11 +771,10 @@ int stmtExec(TAOS_STMT* stmt) {
STMT_ERR_RET
(
stmtSwitchStatus
(
pStmt
,
STMT_EXECUTE
));
if
(
STMT_TYPE_QUERY
==
pStmt
->
sql
.
type
)
{
launchQueryImpl
(
pStmt
->
exec
.
pRequest
,
pStmt
->
sql
.
pQuery
,
TSDB_CODE_SUCCESS
,
true
,
NULL
);
launchQueryImpl
(
pStmt
->
exec
.
pRequest
,
pStmt
->
sql
.
pQuery
,
true
,
NULL
);
}
else
{
STMT_ERR_RET
(
qBuildStmtOutput
(
pStmt
->
sql
.
pQuery
,
pStmt
->
exec
.
pVgHash
,
pStmt
->
exec
.
pBlockHash
));
launchQueryImpl
(
pStmt
->
exec
.
pRequest
,
pStmt
->
sql
.
pQuery
,
TSDB_CODE_SUCCESS
,
true
,
(
autoCreateTbl
?
(
void
**
)
&
pRsp
:
NULL
));
launchQueryImpl
(
pStmt
->
exec
.
pRequest
,
pStmt
->
sql
.
pQuery
,
true
,
(
autoCreateTbl
?
(
void
**
)
&
pRsp
:
NULL
));
}
if
(
pStmt
->
exec
.
pRequest
->
code
&&
NEED_CLIENT_HANDLE_ERROR
(
pStmt
->
exec
.
pRequest
->
code
))
{
...
...
source/client/test/clientTests.cpp
浏览文件 @
5a9ed58b
...
...
@@ -13,10 +13,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <gtest/gtest.h>
#include <taoserror.h>
#include <tglobal.h>
#include <iostream>
#include <gtest/gtest.h>
#include "taoserror.h"
#include "tglobal.h"
#include "thash.h"
#include "clientInt.h"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wwrite-strings"
...
...
@@ -24,7 +26,6 @@
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wsign-compare"
#include "../inc/clientInt.h"
#include "taos.h"
namespace
{
...
...
@@ -41,6 +42,47 @@ void showDB(TAOS* pConn) {
printf
(
"%s
\n
"
,
str
);
}
}
void
fetchCallback
(
void
*
param
,
void
*
res
,
int32_t
numOfRow
)
{
printf
(
"numOfRow = %d
\n
"
,
numOfRow
);
int
numFields
=
taos_num_fields
(
res
);
TAOS_FIELD
*
fields
=
taos_fetch_fields
(
res
);
TAOS
*
_taos
=
(
TAOS
*
)
param
;
if
(
numOfRow
>
0
)
{
for
(
int
i
=
0
;
i
<
numOfRow
;
++
i
)
{
TAOS_ROW
row
=
taos_fetch_row
(
res
);
char
temp
[
256
]
=
{
0
};
taos_print_row
(
temp
,
row
,
fields
,
numFields
);
printf
(
"%s
\n
"
,
temp
);
}
taos_fetch_rows_a
(
res
,
fetchCallback
,
_taos
);
}
else
{
printf
(
"no more data, close the connection.
\n
"
);
// taos_free_result(res);
// taos_close(_taos);
// taos_cleanup();
}
}
void
queryCallback
(
void
*
param
,
void
*
res
,
int32_t
code
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
printf
(
"failed to execute, reason:%s
\n
"
,
taos_errstr
(
res
));
}
printf
(
"start to fetch data
\n
"
);
taos_fetch_rows_a
(
res
,
fetchCallback
,
param
);
}
void
queryCallback1
(
void
*
param
,
void
*
res
,
int32_t
code
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
printf
(
"failed to execute, reason:%s
\n
"
,
taos_errstr
(
res
));
}
taos_free_result
(
res
);
printf
(
"exec query:
\n
"
);
taos_query_a
(
param
,
"select * from tm1"
,
queryCallback
,
param
);
}
}
// namespace
int
main
(
int
argc
,
char
**
argv
)
{
...
...
@@ -52,7 +94,7 @@ TEST(testCase, driverInit_Test) {
// taosInitGlobalCfg();
// taos_init();
}
#if 0
TEST
(
testCase
,
connect_Test
)
{
// taos_options(TSDB_OPTION_CONFIGDIR, "/home/ubuntu/first/cfg");
...
...
@@ -62,7 +104,7 @@ TEST(testCase, connect_Test) {
}
taos_close
(
pConn
);
}
#if 0
TEST(testCase, create_user_Test) {
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
assert(pConn != NULL);
...
...
@@ -432,7 +474,7 @@ TEST(testCase, create_multiple_tables) {
taos_free_result(pRes);
pRes = taos_query(pConn, "create table t_2 using st1 tags(1)");
pRes = taos_query(pConn, "create table
if not exists
t_2 using st1 tags(1)");
if (taos_errno(pRes) != 0) {
printf("failed to create multiple tables, reason:%s\n", taos_errstr(pRes));
taos_free_result(pRes);
...
...
@@ -440,7 +482,7 @@ TEST(testCase, create_multiple_tables) {
}
taos_free_result(pRes);
pRes = taos_query(pConn, "create table t_3 using st1 tags(2)");
pRes = taos_query(pConn, "create table
if not exists
t_3 using st1 tags(2)");
if (taos_errno(pRes) != 0) {
printf("failed to create multiple tables, reason:%s\n", taos_errstr(pRes));
taos_free_result(pRes);
...
...
@@ -480,9 +522,7 @@ TEST(testCase, show_table_Test) {
TAOS_RES* pRes = taos_query(pConn, "show tables");
if (taos_errno(pRes) != 0) {
printf("failed to show tables, reason:%s\n", taos_errstr(pRes));
taos_free_result(pRes);
}
taos_free_result(pRes);
taos_query(pConn, "use abc1");
...
...
@@ -550,6 +590,7 @@ TEST(testCase, generated_request_id_test) {
taosHashCleanup(phash);
}
TEST(testCase, insert_test) {
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
ASSERT_NE(pConn, nullptr);
...
...
@@ -567,7 +608,6 @@ TEST(testCase, insert_test) {
taos_free_result(pRes);
taos_close(pConn);
}
#endif
TEST(testCase, projection_query_tables) {
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
...
...
@@ -606,7 +646,7 @@ TEST(testCase, projection_query_tables) {
}
taos_free_result(pRes);
for
(
int32_t
i
=
0
;
i
<
1000
000
;
i
+=
20
)
{
for(int32_t i = 0; i < 1000; i += 20) {
char sql[1024] = {0};
sprintf(sql,
"insert into tu values(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)"
...
...
@@ -664,7 +704,7 @@ TEST(testCase, projection_query_tables) {
// taos_free_result(pRes);
taos_close(pConn);
}
#if 0
TEST(testCase, projection_query_stables) {
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
ASSERT_NE(pConn, nullptr);
...
...
@@ -705,7 +745,7 @@ TEST(testCase, agg_query_tables) {
}
taos_free_result(pRes);
pRes = taos_query(pConn, "
explain analyze select count(*) from tu interval(1s)
");
pRes = taos_query(pConn, "
show stables
");
if (taos_errno(pRes) != 0) {
printf("failed to select from table, reason:%s\n", taos_errstr(pRes));
taos_free_result(pRes);
...
...
@@ -735,4 +775,24 @@ TEST(testCase, agg_query_tables) {
}
#endif
/*
--- copy the following script in the shell to setup the environment ---
create database test;
use test;
create table m1(ts timestamp, k int) tags(a int);
create table tm0 using m1 tags(1);
create table tm1 using m1 tags(2);
insert into tm0 values('2021-1-1 1:1:1.120', 1) ('2021-1-1 1:1:2.9', 2) tm1 values('2021-1-1 1:1:1.120', 11) ('2021-1-1 1:1:2.99', 22);
*/
TEST
(
testCase
,
async_api_test
)
{
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
ASSERT_NE
(
pConn
,
nullptr
);
taos_query_a
(
pConn
,
"drop table test.tm0"
,
queryCallback
,
pConn
);
getchar
();
taos_close
(
pConn
);
}
#pragma GCC diagnostic pop
source/client/test/smlTest.cpp
浏览文件 @
5a9ed58b
...
...
@@ -486,7 +486,7 @@ TEST(testCase, smlProcess_influx_Test) {
pRes
=
taos_query
(
taos
,
"use inflx_db"
);
taos_free_result
(
pRes
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
NULL
,
NULL
,
TSDB_SQL_INSERT
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
NULL
,
TSDB_SQL_INSERT
);
ASSERT_NE
(
request
,
nullptr
);
SSmlHandle
*
info
=
smlBuildSmlInfo
(
taos
,
request
,
TSDB_SML_LINE_PROTOCOL
,
TSDB_SML_TIMESTAMP_NANO_SECONDS
);
...
...
@@ -607,7 +607,7 @@ TEST(testCase, smlParseLine_error_Test) {
pRes
=
taos_query
(
taos
,
"use sml_db"
);
taos_free_result
(
pRes
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
NULL
,
NULL
,
TSDB_SQL_INSERT
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
NULL
,
TSDB_SQL_INSERT
);
ASSERT_NE
(
request
,
nullptr
);
SSmlHandle
*
info
=
smlBuildSmlInfo
(
taos
,
request
,
TSDB_SML_LINE_PROTOCOL
,
TSDB_SML_TIMESTAMP_NANO_SECONDS
);
...
...
@@ -656,7 +656,7 @@ TEST(testCase, smlProcess_telnet_Test) {
pRes
=
taos_query
(
taos
,
"use telnet_db"
);
taos_free_result
(
pRes
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
NULL
,
NULL
,
TSDB_SQL_INSERT
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
NULL
,
TSDB_SQL_INSERT
);
ASSERT_NE
(
request
,
nullptr
);
SSmlHandle
*
info
=
smlBuildSmlInfo
(
taos
,
request
,
TSDB_SML_TELNET_PROTOCOL
,
TSDB_SML_TIMESTAMP_NANO_SECONDS
);
...
...
@@ -710,7 +710,7 @@ TEST(testCase, smlProcess_json1_Test) {
pRes
=
taos_query
(
taos
,
"use json_db"
);
taos_free_result
(
pRes
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
NULL
,
NULL
,
TSDB_SQL_INSERT
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
NULL
,
TSDB_SQL_INSERT
);
ASSERT_NE
(
request
,
nullptr
);
SSmlHandle
*
info
=
smlBuildSmlInfo
(
taos
,
request
,
TSDB_SML_JSON_PROTOCOL
,
TSDB_SML_TIMESTAMP_NANO_SECONDS
);
...
...
@@ -779,7 +779,7 @@ TEST(testCase, smlProcess_json2_Test) {
pRes
=
taos_query
(
taos
,
"use sml_db"
);
taos_free_result
(
pRes
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
NULL
,
NULL
,
TSDB_SQL_INSERT
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
NULL
,
TSDB_SQL_INSERT
);
ASSERT_NE
(
request
,
nullptr
);
SSmlHandle
*
info
=
smlBuildSmlInfo
(
taos
,
request
,
TSDB_SML_JSON_PROTOCOL
,
TSDB_SML_TIMESTAMP_NANO_SECONDS
);
...
...
@@ -823,7 +823,7 @@ TEST(testCase, smlProcess_json3_Test) {
pRes
=
taos_query
(
taos
,
"use sml_db"
);
taos_free_result
(
pRes
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
NULL
,
NULL
,
TSDB_SQL_INSERT
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
NULL
,
TSDB_SQL_INSERT
);
ASSERT_NE
(
request
,
nullptr
);
SSmlHandle
*
info
=
smlBuildSmlInfo
(
taos
,
request
,
TSDB_SML_JSON_PROTOCOL
,
TSDB_SML_TIMESTAMP_NANO_SECONDS
);
...
...
@@ -895,7 +895,7 @@ TEST(testCase, smlProcess_json4_Test) {
pRes
=
taos_query
(
taos
,
"use sml_db"
);
taos_free_result
(
pRes
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
NULL
,
NULL
,
TSDB_SQL_INSERT
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
NULL
,
TSDB_SQL_INSERT
);
ASSERT_NE
(
request
,
nullptr
);
SSmlHandle
*
info
=
smlBuildSmlInfo
(
taos
,
request
,
TSDB_SML_JSON_PROTOCOL
,
TSDB_SML_TIMESTAMP_NANO_SECONDS
);
...
...
@@ -957,7 +957,7 @@ TEST(testCase, smlParseTelnetLine_error_Test) {
pRes
=
taos_query
(
taos
,
"use sml_db"
);
taos_free_result
(
pRes
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
NULL
,
NULL
,
TSDB_SQL_INSERT
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
NULL
,
TSDB_SQL_INSERT
);
ASSERT_NE
(
request
,
nullptr
);
SSmlHandle
*
info
=
smlBuildSmlInfo
(
taos
,
request
,
TSDB_SML_TELNET_PROTOCOL
,
TSDB_SML_TIMESTAMP_NANO_SECONDS
);
...
...
@@ -1006,7 +1006,7 @@ TEST(testCase, smlParseTelnetLine_diff_type_Test) {
pRes
=
taos_query
(
taos
,
"use sml_db"
);
taos_free_result
(
pRes
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
NULL
,
NULL
,
TSDB_SQL_INSERT
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
NULL
,
TSDB_SQL_INSERT
);
ASSERT_NE
(
request
,
nullptr
);
SSmlHandle
*
info
=
smlBuildSmlInfo
(
taos
,
request
,
TSDB_SML_TELNET_PROTOCOL
,
TSDB_SML_TIMESTAMP_NANO_SECONDS
);
...
...
@@ -1033,7 +1033,7 @@ TEST(testCase, smlParseTelnetLine_json_error_Test) {
pRes
=
taos_query
(
taos
,
"use sml_db"
);
taos_free_result
(
pRes
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
NULL
,
NULL
,
TSDB_SQL_INSERT
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
NULL
,
TSDB_SQL_INSERT
);
ASSERT_NE
(
request
,
nullptr
);
SSmlHandle
*
info
=
smlBuildSmlInfo
(
taos
,
request
,
TSDB_SML_TELNET_PROTOCOL
,
TSDB_SML_TIMESTAMP_NANO_SECONDS
);
...
...
@@ -1101,7 +1101,7 @@ TEST(testCase, smlParseTelnetLine_diff_json_type1_Test) {
pRes
=
taos_query
(
taos
,
"use sml_db"
);
taos_free_result
(
pRes
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
NULL
,
NULL
,
TSDB_SQL_INSERT
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
NULL
,
TSDB_SQL_INSERT
);
ASSERT_NE
(
request
,
nullptr
);
SSmlHandle
*
info
=
smlBuildSmlInfo
(
taos
,
request
,
TSDB_SML_TELNET_PROTOCOL
,
TSDB_SML_TIMESTAMP_NANO_SECONDS
);
...
...
@@ -1146,7 +1146,7 @@ TEST(testCase, smlParseTelnetLine_diff_json_type2_Test) {
pRes
=
taos_query
(
taos
,
"use sml_db"
);
taos_free_result
(
pRes
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
NULL
,
NULL
,
TSDB_SQL_INSERT
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
NULL
,
TSDB_SQL_INSERT
);
ASSERT_NE
(
request
,
nullptr
);
SSmlHandle
*
info
=
smlBuildSmlInfo
(
taos
,
request
,
TSDB_SML_TELNET_PROTOCOL
,
TSDB_SML_TIMESTAMP_NANO_SECONDS
);
...
...
@@ -1191,7 +1191,7 @@ TEST(testCase, sml_TD15662_Test) {
pRes
=
taos_query
(
taos
,
"use db_15662"
);
taos_free_result
(
pRes
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
NULL
,
NULL
,
TSDB_SQL_INSERT
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
NULL
,
TSDB_SQL_INSERT
);
ASSERT_NE
(
request
,
nullptr
);
SSmlHandle
*
info
=
smlBuildSmlInfo
(
taos
,
request
,
TSDB_SML_LINE_PROTOCOL
,
TSDB_SML_TIMESTAMP_MILLI_SECONDS
);
...
...
@@ -1218,7 +1218,7 @@ TEST(testCase, sml_TD15735_Test) {
pRes
=
taos_query
(
taos
,
"use sml_db"
);
taos_free_result
(
pRes
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
NULL
,
NULL
,
TSDB_SQL_INSERT
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
NULL
,
TSDB_SQL_INSERT
);
ASSERT_NE
(
request
,
nullptr
);
SSmlHandle
*
info
=
smlBuildSmlInfo
(
taos
,
request
,
TSDB_SML_TELNET_PROTOCOL
,
TSDB_SML_TIMESTAMP_NANO_SECONDS
);
...
...
@@ -1244,7 +1244,7 @@ TEST(testCase, sml_TD15742_Test) {
pRes
=
taos_query
(
taos
,
"use TD15742"
);
taos_free_result
(
pRes
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
NULL
,
NULL
,
TSDB_SQL_INSERT
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
NULL
,
TSDB_SQL_INSERT
);
ASSERT_NE
(
request
,
nullptr
);
SSmlHandle
*
info
=
smlBuildSmlInfo
(
taos
,
request
,
TSDB_SML_LINE_PROTOCOL
,
TSDB_SML_TIMESTAMP_MILLI_SECONDS
);
...
...
source/common/src/systable.c
浏览文件 @
5a9ed58b
...
...
@@ -78,7 +78,7 @@ static const SSysDbTableSchema userDBSchema[] = {
{.
name
=
"replica"
,
.
bytes
=
1
,
.
type
=
TSDB_DATA_TYPE_TINYINT
},
{.
name
=
"strict"
,
.
bytes
=
9
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"duration"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
{.
name
=
"keep"
,
.
bytes
=
24
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"keep"
,
.
bytes
=
32
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"buffer"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
{.
name
=
"pagesize"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
{.
name
=
"pages"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
...
...
source/common/src/tdataformat.c
浏览文件 @
5a9ed58b
此差异已折叠。
点击以展开。
source/common/src/tmsg.c
浏览文件 @
5a9ed58b
...
...
@@ -35,6 +35,7 @@ int32_t tInitSubmitMsgIter(const SSubmitReq *pMsg, SSubmitMsgIter *pIter) {
}
pIter
->
totalLen
=
htonl
(
pMsg
->
length
);
pIter
->
numOfBlocks
=
htonl
(
pMsg
->
numOfBlocks
);
ASSERT
(
pIter
->
totalLen
>
0
);
pIter
->
len
=
0
;
pIter
->
pMsg
=
pMsg
;
...
...
source/common/src/tmsgcb.c
浏览文件 @
5a9ed58b
...
...
@@ -22,41 +22,21 @@ static SMsgCb defaultMsgCb;
void
tmsgSetDefault
(
const
SMsgCb
*
msgcb
)
{
defaultMsgCb
=
*
msgcb
;
}
int32_t
tmsgPutToQueue
(
const
SMsgCb
*
msgcb
,
EQueueType
qtype
,
SRpcMsg
*
pMsg
)
{
PutToQueueFp
fp
=
msgcb
->
queueFps
[
qtype
];
return
(
*
fp
)(
msgcb
->
mgmt
,
pMsg
);
return
(
*
msgcb
->
putToQueueFp
)(
msgcb
->
mgmt
,
qtype
,
pMsg
);
}
int32_t
tmsgGetQueueSize
(
const
SMsgCb
*
msgcb
,
int32_t
vgId
,
EQueueType
qtype
)
{
GetQueueSizeFp
fp
=
msgcb
->
qsizeFp
;
return
(
*
fp
)(
msgcb
->
mgmt
,
vgId
,
qtype
);
return
(
*
msgcb
->
qsizeFp
)(
msgcb
->
mgmt
,
vgId
,
qtype
);
}
int32_t
tmsgSendReq
(
const
SEpSet
*
epSet
,
SRpcMsg
*
pMsg
)
{
SendReqFp
fp
=
defaultMsgCb
.
sendReqFp
;
return
(
*
fp
)(
epSet
,
pMsg
);
}
int32_t
tmsgSendReq
(
const
SEpSet
*
epSet
,
SRpcMsg
*
pMsg
)
{
return
(
*
defaultMsgCb
.
sendReqFp
)(
epSet
,
pMsg
);
}
void
tmsgSendRsp
(
SRpcMsg
*
pMsg
)
{
SendRspFp
fp
=
defaultMsgCb
.
sendRspFp
;
return
(
*
fp
)(
pMsg
);
}
void
tmsgSendRsp
(
SRpcMsg
*
pMsg
)
{
return
(
*
defaultMsgCb
.
sendRspFp
)(
pMsg
);
}
void
tmsgSendRedirectRsp
(
SRpcMsg
*
pMsg
,
const
SEpSet
*
pNewEpSet
)
{
SendRedirectRspFp
fp
=
defaultMsgCb
.
sendRedirectRspFp
;
(
*
fp
)(
pMsg
,
pNewEpSet
);
}
void
tmsgSendRedirectRsp
(
SRpcMsg
*
pMsg
,
const
SEpSet
*
pNewEpSet
)
{
(
*
defaultMsgCb
.
sendRedirectRspFp
)(
pMsg
,
pNewEpSet
);
}
void
tmsgRegisterBrokenLinkArg
(
SRpcMsg
*
pMsg
)
{
RegisterBrokenLinkArgFp
fp
=
defaultMsgCb
.
registerBrokenLinkArgFp
;
(
*
fp
)(
pMsg
);
}
void
tmsgRegisterBrokenLinkArg
(
SRpcMsg
*
pMsg
)
{
(
*
defaultMsgCb
.
registerBrokenLinkArgFp
)(
pMsg
);
}
void
tmsgReleaseHandle
(
SRpcHandleInfo
*
pHandle
,
int8_t
type
)
{
ReleaseHandleFp
fp
=
defaultMsgCb
.
releaseHandleFp
;
(
*
fp
)(
pHandle
,
type
);
}
void
tmsgReleaseHandle
(
SRpcHandleInfo
*
pHandle
,
int8_t
type
)
{
(
*
defaultMsgCb
.
releaseHandleFp
)(
pHandle
,
type
);
}
void
tmsgReportStartup
(
const
char
*
name
,
const
char
*
desc
)
{
ReportStartup
fp
=
defaultMsgCb
.
reportStartupFp
;
(
*
fp
)(
name
,
desc
);
}
\ No newline at end of file
void
tmsgReportStartup
(
const
char
*
name
,
const
char
*
desc
)
{
(
*
defaultMsgCb
.
reportStartupFp
)(
name
,
desc
);
}
\ No newline at end of file
source/dnode/mgmt/mgmt_mnode/inc/mmInt.h
浏览文件 @
5a9ed58b
...
...
@@ -65,10 +65,7 @@ int32_t mmPutNodeMsgToSyncQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg);
int32_t
mmPutNodeMsgToReadQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
mmPutNodeMsgToQueryQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
mmPutNodeMsgToMonitorQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
mmPutRpcMsgToQueryQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
mmPutRpcMsgToReadQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
mmPutRpcMsgToWriteQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
mmPutRpcMsgToSyncQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
mmPutRpcMsgToQueue
(
SMnodeMgmt
*
pMgmt
,
EQueueType
qtype
,
SRpcMsg
*
pRpc
);
#ifdef __cplusplus
}
...
...
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
浏览文件 @
5a9ed58b
...
...
@@ -134,7 +134,7 @@ SArray *mmGetMsgHandles() {
// Requests handled by DNODE
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_DND_CREATE_MNODE_RSP
,
mmPutNodeMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_
D
ND_ALTER_MNODE_RSP
,
mmPutNodeMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_
M
ND_ALTER_MNODE_RSP
,
mmPutNodeMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_DND_DROP_MNODE_RSP
,
mmPutNodeMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_DND_CREATE_QNODE_RSP
,
mmPutNodeMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_DND_DROP_QNODE_RSP
,
mmPutNodeMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
...
...
@@ -190,7 +190,7 @@ SArray *mmGetMsgHandles() {
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_KILL_TRANS
,
mmPutNodeMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_GRANT
,
mmPutNodeMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_AUTH
,
mmPutNodeMsgToReadQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_
D
ND_ALTER_MNODE
,
mmPutNodeMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_
M
ND_ALTER_MNODE
,
mmPutNodeMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_CREATE_TOPIC
,
mmPutNodeMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_ALTER_TOPIC
,
mmPutNodeMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_DROP_TOPIC
,
mmPutNodeMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
...
...
source/dnode/mgmt/mgmt_mnode/src/mmInt.c
浏览文件 @
5a9ed58b
...
...
@@ -105,10 +105,7 @@ static int32_t mmOpen(SMgmtInputOpt *pInput, SMgmtOutputOpt *pOutput) {
pMgmt
->
path
=
pInput
->
path
;
pMgmt
->
name
=
pInput
->
name
;
pMgmt
->
msgCb
=
pInput
->
msgCb
;
pMgmt
->
msgCb
.
queueFps
[
QUERY_QUEUE
]
=
(
PutToQueueFp
)
mmPutRpcMsgToQueryQueue
;
pMgmt
->
msgCb
.
queueFps
[
READ_QUEUE
]
=
(
PutToQueueFp
)
mmPutRpcMsgToReadQueue
;
pMgmt
->
msgCb
.
queueFps
[
WRITE_QUEUE
]
=
(
PutToQueueFp
)
mmPutRpcMsgToWriteQueue
;
pMgmt
->
msgCb
.
queueFps
[
SYNC_QUEUE
]
=
(
PutToQueueFp
)
mmPutRpcMsgToSyncQueue
;
pMgmt
->
msgCb
.
putToQueueFp
=
(
PutToQueueFp
)
mmPutRpcMsgToQueue
;
pMgmt
->
msgCb
.
mgmt
=
pMgmt
;
taosThreadRwlockInit
(
&
pMgmt
->
lock
,
NULL
);
...
...
source/dnode/mgmt/mgmt_mnode/src/mmWorker.c
浏览文件 @
5a9ed58b
...
...
@@ -96,40 +96,38 @@ int32_t mmPutNodeMsgToMonitorQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) {
return
mmPutNodeMsgToWorker
(
&
pMgmt
->
monitorWorker
,
pMsg
);
}
static
inline
int32_t
mmPutRpcMsgToWorker
(
SSingleWorker
*
pWorker
,
SRpcMsg
*
pRpc
)
{
int32_t
mmPutRpcMsgToQueue
(
SMnodeMgmt
*
pMgmt
,
EQueueType
qtype
,
SRpcMsg
*
pRpc
)
{
SRpcMsg
*
pMsg
=
taosAllocateQitem
(
sizeof
(
SRpcMsg
),
RPC_QITEM
);
if
(
pMsg
==
NULL
)
return
-
1
;
dTrace
(
"msg:%p, create and put into worker:%s, type:%s"
,
pMsg
,
pWorker
->
name
,
TMSG_INFO
(
pRpc
->
msgType
));
memcpy
(
pMsg
,
pRpc
,
sizeof
(
SRpcMsg
));
taosWriteQitem
(
pWorker
->
queue
,
pMsg
);
return
0
;
}
int32_t
mmPutRpcMsgToQueryQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
return
mmPutRpcMsgToWorker
(
&
pMgmt
->
queryWorker
,
pMsg
);
}
int32_t
mmPutRpcMsgToWriteQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
return
mmPutRpcMsgToWorker
(
&
pMgmt
->
writeWorker
,
pMsg
);
}
int32_t
mmPutRpcMsgToReadQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
return
mmPutRpcMsgToWorker
(
&
pMgmt
->
readWorker
,
pMsg
);
}
switch
(
qtype
)
{
case
WRITE_QUEUE
:
dTrace
(
"msg:%p, is created and will put into vnode-write queue"
,
pMsg
);
taosWriteQitem
(
pMgmt
->
writeWorker
.
queue
,
pMsg
);
return
0
;
case
QUERY_QUEUE
:
dTrace
(
"msg:%p, is created and will put into vnode-query queue"
,
pMsg
);
taosWriteQitem
(
pMgmt
->
queryWorker
.
queue
,
pMsg
);
return
0
;
int32_t
mmPutRpcMsgToSyncQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
int32_t
code
=
-
1
;
case
READ_QUEUE
:
dTrace
(
"msg:%p, is created and will put into vnode-read queue"
,
pMsg
);
taosWriteQitem
(
pMgmt
->
readWorker
.
queue
,
pMsg
);
return
0
;
case
SYNC_QUEUE
:
if
(
mmAcquire
(
pMgmt
)
==
0
)
{
code
=
mmPutRpcMsgToWorker
(
&
pMgmt
->
syncWorker
,
pMsg
);
dTrace
(
"msg:%p, is created and will put into vnode-sync queue"
,
pMsg
);
taosWriteQitem
(
pMgmt
->
syncWorker
.
queue
,
pMsg
);
mmRelease
(
pMgmt
);
return
0
;
}
else
{
return
-
1
;
}
if
(
code
!=
0
)
{
rpcFreeCont
(
pMsg
->
pCont
);
pMsg
->
pCont
=
NULL
;
default:
terrno
=
TSDB_CODE_INVALID_PARA
;
return
-
1
;
}
return
code
;
}
int32_t
mmStartWorker
(
SMnodeMgmt
*
pMgmt
)
{
...
...
source/dnode/mgmt/mgmt_qnode/inc/qmInt.h
浏览文件 @
5a9ed58b
...
...
@@ -42,8 +42,7 @@ int32_t qmProcessDropReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg);
int32_t
qmProcessGetMonitorInfoReq
(
SQnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
// qmWorker.c
int32_t
qmPutRpcMsgToQueryQueue
(
SQnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
qmPutRpcMsgToFetchQueue
(
SQnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
qmPutRpcMsgToQueue
(
SQnodeMgmt
*
pMgmt
,
EQueueType
qtype
,
SRpcMsg
*
pMsg
);
int32_t
qmGetQueueSize
(
SQnodeMgmt
*
pMgmt
,
int32_t
vgId
,
EQueueType
qtype
);
int32_t
qmStartWorker
(
SQnodeMgmt
*
pMgmt
);
...
...
source/dnode/mgmt/mgmt_qnode/src/qmInt.c
浏览文件 @
5a9ed58b
...
...
@@ -43,8 +43,7 @@ static int32_t qmOpen(SMgmtInputOpt *pInput, SMgmtOutputOpt *pOutput) {
pMgmt
->
path
=
pInput
->
path
;
pMgmt
->
name
=
pInput
->
name
;
pMgmt
->
msgCb
=
pInput
->
msgCb
;
pMgmt
->
msgCb
.
queueFps
[
QUERY_QUEUE
]
=
(
PutToQueueFp
)
qmPutRpcMsgToQueryQueue
;
pMgmt
->
msgCb
.
queueFps
[
FETCH_QUEUE
]
=
(
PutToQueueFp
)
qmPutRpcMsgToFetchQueue
;
pMgmt
->
msgCb
.
putToQueueFp
=
(
PutToQueueFp
)
qmPutRpcMsgToQueue
;
pMgmt
->
msgCb
.
qsizeFp
=
(
GetQueueSizeFp
)
qmGetQueueSize
;
pMgmt
->
msgCb
.
mgmt
=
pMgmt
;
...
...
source/dnode/mgmt/mgmt_qnode/src/qmWorker.c
浏览文件 @
5a9ed58b
...
...
@@ -68,22 +68,24 @@ int32_t qmPutNodeMsgToMonitorQueue(SQnodeMgmt *pMgmt, SRpcMsg *pMsg) {
return
qmPutNodeMsgToWorker
(
&
pMgmt
->
monitorWorker
,
pMsg
);
}
static
int32_t
qmPutRpcMsgToWorker
(
SQnodeMgmt
*
pMgmt
,
SSingleWorker
*
pWorker
,
SRpcMsg
*
pRpc
)
{
int32_t
qmPutRpcMsgToQueue
(
SQnodeMgmt
*
pMgmt
,
EQueueType
qtype
,
SRpcMsg
*
pRpc
)
{
SRpcMsg
*
pMsg
=
taosAllocateQitem
(
sizeof
(
SRpcMsg
),
RPC_QITEM
);
if
(
pMsg
==
NULL
)
return
-
1
;
dTrace
(
"msg:%p, create and put into worker:%s, type:%s"
,
pMsg
,
pWorker
->
name
,
TMSG_INFO
(
pRpc
->
msgType
));
memcpy
(
pMsg
,
pRpc
,
sizeof
(
SRpcMsg
));
taosWriteQitem
(
pWorker
->
queue
,
pMsg
);
return
0
;
}
int32_t
qmPutRpcMsgToQueryQueue
(
SQnodeMgmt
*
pMgmt
,
SRpcMsg
*
pRpc
)
{
return
qmPutRpcMsgToWorker
(
pMgmt
,
&
pMgmt
->
queryWorker
,
pRpc
);
}
int32_t
qmPutRpcMsgToFetchQueue
(
SQnodeMgmt
*
pMgmt
,
SRpcMsg
*
pRpc
)
{
return
qmPutRpcMsgToWorker
(
pMgmt
,
&
pMgmt
->
fetchWorker
,
pRpc
);
switch
(
qtype
)
{
case
QUERY_QUEUE
:
dTrace
(
"msg:%p, is created and will put into qnode-query queue"
,
pMsg
);
taosWriteQitem
(
pMgmt
->
queryWorker
.
queue
,
pMsg
);
return
0
;
case
READ_QUEUE
:
dTrace
(
"msg:%p, is created and will put into qnode-fetch queue"
,
pMsg
);
taosWriteQitem
(
pMgmt
->
fetchWorker
.
queue
,
pMsg
);
return
0
;
default:
terrno
=
TSDB_CODE_INVALID_PARA
;
return
-
1
;
}
}
int32_t
qmGetQueueSize
(
SQnodeMgmt
*
pMgmt
,
int32_t
vgId
,
EQueueType
qtype
)
{
...
...
source/dnode/mgmt/mgmt_vnode/inc/vmInt.h
浏览文件 @
5a9ed58b
...
...
@@ -100,21 +100,16 @@ void vmStopWorker(SVnodeMgmt *pMgmt);
int32_t
vmAllocQueue
(
SVnodeMgmt
*
pMgmt
,
SVnodeObj
*
pVnode
);
void
vmFreeQueue
(
SVnodeMgmt
*
pMgmt
,
SVnodeObj
*
pVnode
);
int32_t
vmPutRpcMsgToWriteQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
vmPutRpcMsgToSyncQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
vmPutRpcMsgToApplyQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
vmPutRpcMsgToQueryQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
vmPutRpcMsgToFetchQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
vmPutRpcMsgToMergeQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
vmGetQueueSize
(
SVnodeMgmt
*
pMgmt
,
int32_t
vgId
,
EQueueType
qtype
);
int32_t
vmPutNodeMsgToWriteQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
vmPutNodeMsgToSyncQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
vmPutNodeMsgToQueryQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
vmPutNodeMsgToFetchQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
vmPutNodeMsgToMergeQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
vmPutNodeMsgToMgmtQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
vmPutNodeMsgToMonitorQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
vmPutRpcMsgToQueue
(
SVnodeMgmt
*
pMgmt
,
EQueueType
qtype
,
SRpcMsg
*
pRpc
);
int32_t
vmPutMsgToWriteQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
vmPutMsgToSyncQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
vmPutMsgToQueryQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
vmPutMsgToFetchQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
vmPutMsgToMergeQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
vmPutMsgToMgmtQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
vmPutMsgToMonitorQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
#ifdef __cplusplus
}
...
...
source/dnode/mgmt/mgmt_vnode/src/vmFile.c
浏览文件 @
5a9ed58b
...
...
@@ -16,6 +16,8 @@
#define _DEFAULT_SOURCE
#include "vmInt.h"
#define MAX_CONTENT_LEN 1024 * 1024
SVnodeObj
**
vmGetVnodeListFromHash
(
SVnodeMgmt
*
pMgmt
,
int32_t
*
numOfVnodes
)
{
taosThreadRwlockRdlock
(
&
pMgmt
->
lock
);
...
...
@@ -29,7 +31,7 @@ SVnodeObj **vmGetVnodeListFromHash(SVnodeMgmt *pMgmt, int32_t *numOfVnodes) {
SVnodeObj
*
pVnode
=
*
ppVnode
;
if
(
pVnode
&&
num
<
size
)
{
int32_t
refCount
=
atomic_add_fetch_32
(
&
pVnode
->
refCount
,
1
);
dTrace
(
"vgId:%d, acquire vnode, refCount:%d"
,
pVnode
->
vgId
,
refCount
);
//
dTrace("vgId:%d, acquire vnode, refCount:%d", pVnode->vgId, refCount);
pVnodes
[
num
]
=
(
*
ppVnode
);
num
++
;
pIter
=
taosHashIterate
(
pMgmt
->
hash
,
pIter
);
...
...
@@ -47,7 +49,7 @@ SVnodeObj **vmGetVnodeListFromHash(SVnodeMgmt *pMgmt, int32_t *numOfVnodes) {
int32_t
vmGetVnodeListFromFile
(
SVnodeMgmt
*
pMgmt
,
SWrapperCfg
**
ppCfgs
,
int32_t
*
numOfVnodes
)
{
int32_t
code
=
TSDB_CODE_INVALID_JSON_FORMAT
;
int32_t
len
=
0
;
int32_t
maxLen
=
1024
*
1024
;
int32_t
maxLen
=
MAX_CONTENT_LEN
;
char
*
content
=
taosMemoryCalloc
(
1
,
maxLen
+
1
);
cJSON
*
root
=
NULL
;
FILE
*
fp
=
NULL
;
...
...
@@ -128,7 +130,7 @@ int32_t vmGetVnodeListFromFile(SVnodeMgmt *pMgmt, SWrapperCfg **ppCfgs, int32_t
*
numOfVnodes
=
vnodesNum
;
code
=
0
;
dDebug
(
"succcessed to read file %s
"
,
file
);
dDebug
(
"succcessed to read file %s
, numOfVnodes:%d"
,
file
,
vnodesNum
);
_OVER:
if
(
content
!=
NULL
)
taosMemoryFree
(
content
);
...
...
@@ -156,7 +158,7 @@ int32_t vmWriteVnodeListToFile(SVnodeMgmt *pMgmt) {
SVnodeObj
**
pVnodes
=
vmGetVnodeListFromHash
(
pMgmt
,
&
numOfVnodes
);
int32_t
len
=
0
;
int32_t
maxLen
=
1024
*
1024
;
int32_t
maxLen
=
MAX_CONTENT_LEN
;
char
*
content
=
taosMemoryCalloc
(
1
,
maxLen
+
1
);
if
(
content
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
...
...
@@ -195,6 +197,6 @@ int32_t vmWriteVnodeListToFile(SVnodeMgmt *pMgmt) {
taosMemoryFree
(
pVnodes
);
}
dDebug
(
"successed to write %s
"
,
realfile
);
dDebug
(
"successed to write %s
, numOfVnodes:%d"
,
realfile
,
numOfVnodes
);
return
taosRenameFile
(
file
,
realfile
);
}
\ No newline at end of file
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
浏览文件 @
5a9ed58b
...
...
@@ -210,7 +210,7 @@ int32_t vmProcessCreateVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
return
-
1
;
}
dDebug
(
"vgId:%d,
create vnode req is received
, tsma:%d standby:%d"
,
createReq
.
vgId
,
createReq
.
isTsma
,
dDebug
(
"vgId:%d,
start to create vnode
, tsma:%d standby:%d"
,
createReq
.
vgId
,
createReq
.
isTsma
,
createReq
.
standby
);
vmGenerateVnodeCfg
(
&
createReq
,
&
vnodeCfg
);
...
...
@@ -294,7 +294,7 @@ int32_t vmProcessDropVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
}
int32_t
vgId
=
dropReq
.
vgId
;
dDebug
(
"vgId:%d,
drop vnode req is received
"
,
vgId
);
dDebug
(
"vgId:%d,
start to drop vnode
"
,
vgId
);
SVnodeObj
*
pVnode
=
vmAcquireVnode
(
pMgmt
,
vgId
);
if
(
pVnode
==
NULL
)
{
...
...
@@ -321,59 +321,59 @@ SArray *vmGetMsgHandles() {
SArray
*
pArray
=
taosArrayInit
(
32
,
sizeof
(
SMgmtHandle
));
if
(
pArray
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MON_VM_INFO
,
vmPut
Node
MsgToMonitorQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MON_VM_LOAD
,
vmPut
Node
MsgToMonitorQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MON_VM_INFO
,
vmPutMsgToMonitorQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MON_VM_LOAD
,
vmPutMsgToMonitorQueue
,
0
)
==
NULL
)
goto
_OVER
;
// Requests handled by VNODE
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_SUBMIT
,
vmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_QUERY
,
vmPut
Node
MsgToQueryQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_QUERY_CONTINUE
,
vmPut
Node
MsgToQueryQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_FETCH
,
vmPut
Node
MsgToFetchQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_ALTER_TABLE
,
vmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_UPDATE_TAG_VAL
,
vmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_TABLE_META
,
vmPut
Node
MsgToFetchQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_TABLES_META
,
vmPut
Node
MsgToFetchQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_MQ_CONSUME
,
vmPut
Node
MsgToQueryQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_MQ_QUERY
,
vmPut
Node
MsgToQueryQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_MQ_CONNECT
,
vmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_MQ_DISCONNECT
,
vmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
// if (dmSetMgmtHandle(pArray, TDMT_VND_MQ_SET_CUR, vmPut
Node
MsgToWriteQueue, 0)== NULL) goto _OVER;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_CANCEL_TASK
,
vmPut
Node
MsgToFetchQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_DROP_TASK
,
vmPut
Node
MsgToFetchQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_CREATE_STB
,
vmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_ALTER_STB
,
vmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_DROP_STB
,
vmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_CREATE_TABLE
,
vmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_DROP_TABLE
,
vmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_CREATE_SMA
,
vmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_CANCEL_SMA
,
vmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_DROP_SMA
,
vmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_SUBMIT_RSMA
,
vmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_MQ_VG_CHANGE
,
vmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_MQ_VG_DELETE
,
vmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_CONSUME
,
vmPut
Node
MsgToFetchQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_TASK_DEPLOY
,
vmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_QUERY_HEARTBEAT
,
vmPut
Node
MsgToFetchQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_STREAM_TRIGGER
,
vmPut
Node
MsgToFetchQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_TASK_RUN
,
vmPut
Node
MsgToFetchQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_TASK_DISPATCH
,
vmPut
Node
MsgToFetchQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_TASK_RECOVER
,
vmPut
Node
MsgToFetchQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_ALTER_REPLICA
,
vmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_ALTER_CONFIG
,
vmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_COMPACT
,
vmPut
Node
MsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_DND_CREATE_VNODE
,
vmPut
Node
MsgToMgmtQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_DND_DROP_VNODE
,
vmPut
Node
MsgToMgmtQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_SYNC_TIMEOUT
,
vmPut
Node
MsgToSyncQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_SYNC_PING
,
vmPut
Node
MsgToSyncQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_SYNC_PING_REPLY
,
vmPut
Node
MsgToSyncQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_SYNC_CLIENT_REQUEST
,
vmPut
Node
MsgToSyncQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_SYNC_CLIENT_REQUEST_REPLY
,
vmPut
Node
MsgToSyncQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_SYNC_REQUEST_VOTE
,
vmPut
Node
MsgToSyncQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_SYNC_REQUEST_VOTE_REPLY
,
vmPut
Node
MsgToSyncQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_SYNC_APPEND_ENTRIES
,
vmPut
Node
MsgToSyncQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_SYNC_APPEND_ENTRIES_REPLY
,
vmPut
Node
MsgToSyncQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_SUBMIT
,
vmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_QUERY
,
vmPutMsgToQueryQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_QUERY_CONTINUE
,
vmPutMsgToQueryQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_FETCH
,
vmPutMsgToFetchQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_ALTER_TABLE
,
vmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_UPDATE_TAG_VAL
,
vmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_TABLE_META
,
vmPutMsgToFetchQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_TABLES_META
,
vmPutMsgToFetchQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_MQ_CONSUME
,
vmPutMsgToQueryQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_MQ_QUERY
,
vmPutMsgToQueryQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_MQ_CONNECT
,
vmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_MQ_DISCONNECT
,
vmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
// if (dmSetMgmtHandle(pArray, TDMT_VND_MQ_SET_CUR, vmPutMsgToWriteQueue, 0)== NULL) goto _OVER;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_CANCEL_TASK
,
vmPutMsgToFetchQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_DROP_TASK
,
vmPutMsgToFetchQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_CREATE_STB
,
vmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_ALTER_STB
,
vmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_DROP_STB
,
vmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_CREATE_TABLE
,
vmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_DROP_TABLE
,
vmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_CREATE_SMA
,
vmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_CANCEL_SMA
,
vmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_DROP_SMA
,
vmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_SUBMIT_RSMA
,
vmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_MQ_VG_CHANGE
,
vmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_MQ_VG_DELETE
,
vmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_CONSUME
,
vmPutMsgToFetchQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_TASK_DEPLOY
,
vmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
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_TASK_RUN
,
vmPutMsgToFetchQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_TASK_DISPATCH
,
vmPutMsgToFetchQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_TASK_RECOVER
,
vmPutMsgToFetchQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_ALTER_REPLICA
,
vmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_ALTER_CONFIG
,
vmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_COMPACT
,
vmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_DND_CREATE_VNODE
,
vmPutMsgToMgmtQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_DND_DROP_VNODE
,
vmPutMsgToMgmtQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_SYNC_TIMEOUT
,
vmPutMsgToSyncQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_SYNC_PING
,
vmPutMsgToSyncQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_SYNC_PING_REPLY
,
vmPutMsgToSyncQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_SYNC_CLIENT_REQUEST
,
vmPutMsgToSyncQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_SYNC_CLIENT_REQUEST_REPLY
,
vmPutMsgToSyncQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_SYNC_REQUEST_VOTE
,
vmPutMsgToSyncQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_SYNC_REQUEST_VOTE_REPLY
,
vmPutMsgToSyncQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_SYNC_APPEND_ENTRIES
,
vmPutMsgToSyncQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_SYNC_APPEND_ENTRIES_REPLY
,
vmPutMsgToSyncQueue
,
0
)
==
NULL
)
goto
_OVER
;
code
=
0
;
...
...
source/dnode/mgmt/mgmt_vnode/src/vmInt.c
浏览文件 @
5a9ed58b
...
...
@@ -18,21 +18,17 @@
SVnodeObj
*
vmAcquireVnode
(
SVnodeMgmt
*
pMgmt
,
int32_t
vgId
)
{
SVnodeObj
*
pVnode
=
NULL
;
int32_t
refCount
=
0
;
taosThreadRwlockRdlock
(
&
pMgmt
->
lock
);
taosHashGetDup
(
pMgmt
->
hash
,
&
vgId
,
sizeof
(
int32_t
),
(
void
*
)
&
pVnode
);
if
(
pVnode
==
NULL
)
{
terrno
=
TSDB_CODE_VND_INVALID_VGROUP_ID
;
}
else
{
refCount
=
atomic_add_fetch_32
(
&
pVnode
->
refCount
,
1
);
int32_t
refCount
=
atomic_add_fetch_32
(
&
pVnode
->
refCount
,
1
);
// dTrace("vgId:%d, acquire vnode, ref:%d", pVnode->vgId, refCount);
}
taosThreadRwlockUnlock
(
&
pMgmt
->
lock
);
if
(
pVnode
!=
NULL
)
{
dTrace
(
"vgId:%d, acquire vnode, refCount:%d"
,
pVnode
->
vgId
,
refCount
);
}
return
pVnode
;
}
...
...
@@ -41,8 +37,8 @@ void vmReleaseVnode(SVnodeMgmt *pMgmt, SVnodeObj *pVnode) {
taosThreadRwlockRdlock
(
&
pMgmt
->
lock
);
int32_t
refCount
=
atomic_sub_fetch_32
(
&
pVnode
->
refCount
,
1
);
// dTrace("vgId:%d, release vnode, ref:%d", pVnode->vgId, refCount);
taosThreadRwlockUnlock
(
&
pMgmt
->
lock
);
dTrace
(
"vgId:%d, release vnode, refCount:%d"
,
pVnode
->
vgId
,
refCount
);
}
int32_t
vmOpenVnode
(
SVnodeMgmt
*
pMgmt
,
SWrapperCfg
*
pCfg
,
SVnode
*
pImpl
)
{
...
...
@@ -138,7 +134,7 @@ static void *vmOpenVnodeInThread(void *param) {
}
}
dDebug
(
"thread:%d,
total v
nodes:%d, opened:%d failed:%d"
,
pThread
->
threadIndex
,
pThread
->
vnodeNum
,
pThread
->
opened
,
dDebug
(
"thread:%d,
numOfV
nodes:%d, opened:%d failed:%d"
,
pThread
->
threadIndex
,
pThread
->
vnodeNum
,
pThread
->
opened
,
pThread
->
failed
);
return
NULL
;
}
...
...
@@ -160,7 +156,7 @@ static int32_t vmOpenVnodes(SVnodeMgmt *pMgmt) {
pMgmt
->
state
.
totalVnodes
=
numOfVnodes
;
int32_t
threadNum
=
1
;
// tsNumOfCores;
int32_t
threadNum
=
1
;
int32_t
vnodesPerThread
=
numOfVnodes
/
threadNum
+
1
;
SVnodeThread
*
threads
=
taosMemoryCalloc
(
threadNum
,
sizeof
(
SVnodeThread
));
...
...
@@ -253,12 +249,7 @@ static int32_t vmInit(SMgmtInputOpt *pInput, SMgmtOutputOpt *pOutput) {
pMgmt
->
path
=
pInput
->
path
;
pMgmt
->
name
=
pInput
->
name
;
pMgmt
->
msgCb
=
pInput
->
msgCb
;
pMgmt
->
msgCb
.
queueFps
[
WRITE_QUEUE
]
=
(
PutToQueueFp
)
vmPutRpcMsgToWriteQueue
;
pMgmt
->
msgCb
.
queueFps
[
SYNC_QUEUE
]
=
(
PutToQueueFp
)
vmPutRpcMsgToSyncQueue
;
pMgmt
->
msgCb
.
queueFps
[
APPLY_QUEUE
]
=
(
PutToQueueFp
)
vmPutRpcMsgToApplyQueue
;
pMgmt
->
msgCb
.
queueFps
[
QUERY_QUEUE
]
=
(
PutToQueueFp
)
vmPutRpcMsgToQueryQueue
;
pMgmt
->
msgCb
.
queueFps
[
FETCH_QUEUE
]
=
(
PutToQueueFp
)
vmPutRpcMsgToFetchQueue
;
pMgmt
->
msgCb
.
queueFps
[
MERGE_QUEUE
]
=
(
PutToQueueFp
)
vmPutRpcMsgToMergeQueue
;
pMgmt
->
msgCb
.
putToQueueFp
=
(
PutToQueueFp
)
vmPutRpcMsgToQueue
;
pMgmt
->
msgCb
.
qsizeFp
=
(
GetQueueSizeFp
)
vmGetQueueSize
;
pMgmt
->
msgCb
.
mgmt
=
pMgmt
;
taosThreadRwlockInit
(
&
pMgmt
->
lock
,
NULL
);
...
...
source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
浏览文件 @
5a9ed58b
...
...
@@ -29,11 +29,11 @@ static inline void vmSendRsp(SRpcMsg *pMsg, int32_t code) {
tmsgSendRsp
(
&
rsp
);
}
static
void
vmProcessQueue
(
SQueueInfo
*
pInfo
,
SRpcMsg
*
pMsg
)
{
static
void
vmProcess
Mgmt
Queue
(
SQueueInfo
*
pInfo
,
SRpcMsg
*
pMsg
)
{
SVnodeMgmt
*
pMgmt
=
pInfo
->
ahandle
;
int32_t
code
=
-
1
;
dTrace
(
"msg:%p, get from vnode queue, type:%s"
,
pMsg
,
TMSG_INFO
(
pMsg
->
msgType
));
dTrace
(
"msg:%p, get from vnode-mgmt queue"
,
pMsg
);
switch
(
pMsg
->
msgType
)
{
case
TDMT_MON_VM_INFO
:
code
=
vmProcessGetMonitorInfoReq
(
pMgmt
,
pMsg
);
...
...
@@ -49,11 +49,14 @@ static void vmProcessQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
break
;
default:
terrno
=
TSDB_CODE_MSG_NOT_PROCESSED
;
dError
(
"msg:%p, not processed in vnode queue"
,
pMsg
);
dError
(
"msg:%p, not processed in vnode
-mgmt
queue"
,
pMsg
);
}
if
(
IsReq
(
pMsg
))
{
if
(
code
!=
0
&&
terrno
!=
0
)
code
=
terrno
;
if
(
code
!=
0
&&
terrno
!=
0
)
{
dError
(
"msg:%p failed to process since %s"
,
pMsg
,
terrstr
());
code
=
terrno
;
}
vmSendRsp
(
pMsg
,
code
);
}
...
...
@@ -65,13 +68,15 @@ static void vmProcessQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
static
void
vmProcessQueryQueue
(
SQueueInfo
*
pInfo
,
SRpcMsg
*
pMsg
)
{
SVnodeObj
*
pVnode
=
pInfo
->
ahandle
;
dTrace
(
"
msg:%p, get from vnode-query queue"
,
pMsg
);
dTrace
(
"
vgId:%d, msg:%p get from vnode-query queue"
,
pVnode
->
vgId
,
pMsg
);
int32_t
code
=
vnodeProcessQueryMsg
(
pVnode
->
pImpl
,
pMsg
);
if
(
code
!=
0
)
{
if
(
terrno
!=
0
)
code
=
terrno
;
dError
(
"vgId:%d, msg:%p failed to query since %s"
,
pVnode
->
vgId
,
pMsg
,
terrstr
());
vmSendRsp
(
pMsg
,
code
);
}
dTrace
(
"msg:%p, is freed, code:0x%x"
,
pMsg
,
code
);
dTrace
(
"vgId:%d, msg:%p is freed, code:0x%x"
,
pVnode
->
vgId
,
pMsg
,
code
);
rpcFreeCont
(
pMsg
->
pCont
);
taosFreeQitem
(
pMsg
);
}
...
...
@@ -79,13 +84,15 @@ static void vmProcessQueryQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
static
void
vmProcessFetchQueue
(
SQueueInfo
*
pInfo
,
SRpcMsg
*
pMsg
)
{
SVnodeObj
*
pVnode
=
pInfo
->
ahandle
;
dTrace
(
"
msg:%p, get from vnode-fetch queue"
,
pMsg
);
dTrace
(
"
vgId:%d, msg:%p get from vnode-fetch queue"
,
pVnode
->
vgId
,
pMsg
);
int32_t
code
=
vnodeProcessFetchMsg
(
pVnode
->
pImpl
,
pMsg
,
pInfo
);
if
(
code
!=
0
)
{
if
(
terrno
!=
0
)
code
=
terrno
;
dError
(
"vgId:%d, msg:%p failed to fetch since %s"
,
pVnode
->
vgId
,
pMsg
,
terrstr
());
vmSendRsp
(
pMsg
,
code
);
}
dTrace
(
"msg:%p, is freed, code:0x%x"
,
pMsg
,
code
);
dTrace
(
"vgId:%d, msg:%p is freed, code:0x%x"
,
pVnode
->
vgId
,
pMsg
,
code
);
rpcFreeCont
(
pMsg
->
pCont
);
taosFreeQitem
(
pMsg
);
}
...
...
@@ -99,7 +106,7 @@ static void vmProcessWriteQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numO
for
(
int32_t
m
=
0
;
m
<
numOfMsgs
;
m
++
)
{
if
(
taosGetQitem
(
qall
,
(
void
**
)
&
pMsg
)
==
0
)
continue
;
dTrace
(
"vgId:%d,
get msg:%p from vnode-write queue, type:%s"
,
pVnode
->
vgId
,
pMsg
,
TMSG_INFO
(
pMsg
->
msgType
)
);
dTrace
(
"vgId:%d,
msg:%p get from vnode-write queue"
,
pVnode
->
vgId
,
pMsg
);
if
(
taosArrayPush
(
pArray
,
&
pMsg
)
==
NULL
)
{
dError
(
"vgId:%d, failed to push msg:%p to vnode-write array"
,
pVnode
->
vgId
,
pMsg
);
...
...
@@ -113,7 +120,7 @@ static void vmProcessWriteQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numO
if
(
code
==
TSDB_CODE_ACTION_IN_PROGRESS
)
continue
;
if
(
code
!=
0
)
{
dError
(
"vgId:%d, msg:%p failed to
process
since %s"
,
pVnode
->
vgId
,
pMsg
,
tstrerror
(
code
));
dError
(
"vgId:%d, msg:%p failed to
write
since %s"
,
pVnode
->
vgId
,
pMsg
,
tstrerror
(
code
));
vmSendRsp
(
pMsg
,
code
);
continue
;
}
...
...
@@ -129,14 +136,14 @@ static void vmProcessWriteQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numO
SRpcMsg
rsp
=
{.
code
=
TSDB_CODE_RPC_REDIRECT
,
.
info
=
pMsg
->
info
};
tmsgSendRedirectRsp
(
&
rsp
,
&
newEpSet
);
}
else
{
dError
(
"vgId:%d, msg:%p failed to
process
since %s"
,
pVnode
->
vgId
,
pMsg
,
tstrerror
(
code
));
dError
(
"vgId:%d, msg:%p failed to
write
since %s"
,
pVnode
->
vgId
,
pMsg
,
tstrerror
(
code
));
vmSendRsp
(
pMsg
,
code
);
}
}
for
(
int32_t
i
=
0
;
i
<
numOfMsgs
;
i
++
)
{
pMsg
=
*
(
SRpcMsg
**
)
taosArrayGet
(
pArray
,
i
);
dTrace
(
"vgId:%d, msg:%p
,
is freed"
,
pVnode
->
vgId
,
pMsg
);
dTrace
(
"vgId:%d, msg:%p is freed"
,
pVnode
->
vgId
,
pMsg
);
rpcFreeCont
(
pMsg
->
pCont
);
taosFreeQitem
(
pMsg
);
}
...
...
@@ -146,10 +153,11 @@ static void vmProcessWriteQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numO
static
void
vmProcessApplyQueue
(
SQueueInfo
*
pInfo
,
STaosQall
*
qall
,
int32_t
numOfMsgs
)
{
SVnodeObj
*
pVnode
=
pInfo
->
ahandle
;
SRpcMsg
*
pMsg
=
NULL
;
for
(
int32_t
i
=
0
;
i
<
numOfMsgs
;
++
i
)
{
SRpcMsg
*
pMsg
=
NULL
;
taosGetQitem
(
qall
,
(
void
**
)
&
pMsg
);
if
(
taosGetQitem
(
qall
,
(
void
**
)
&
pMsg
)
==
0
)
continue
;
dTrace
(
"vgId:%d, msg:%p get from vnode-apply queue"
,
pVnode
->
vgId
,
pMsg
);
// init response rpc msg
SRpcMsg
rsp
=
{
0
};
...
...
@@ -164,7 +172,7 @@ static void vmProcessApplyQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numO
// apply data into tsdb
if
(
vnodeProcessWriteReq
(
pVnode
->
pImpl
,
&
originalRpcMsg
,
pSyncApplyMsg
->
fsmMeta
.
index
,
&
rsp
)
<
0
)
{
rsp
.
code
=
terrno
;
d
Trace
(
"msg:%p, process write error since %s"
,
pMsg
,
terrstr
());
d
Error
(
"vgId:%d, msg:%p failed to apply since %s"
,
pVnode
->
vgId
,
pMsg
,
terrstr
());
}
syncApplyMsgDestroy
(
pSyncApplyMsg
);
...
...
@@ -176,6 +184,7 @@ static void vmProcessApplyQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numO
tmsgSendRsp
(
&
rsp
);
}
dTrace
(
"vgId:%d, msg:%p is freed, code:0x%x"
,
pVnode
->
vgId
,
pMsg
,
rsp
.
code
);
rpcFreeCont
(
pMsg
->
pCont
);
taosFreeQitem
(
pMsg
);
}
...
...
@@ -183,23 +192,22 @@ static void vmProcessApplyQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numO
static
void
vmProcessSyncQueue
(
SQueueInfo
*
pInfo
,
STaosQall
*
qall
,
int32_t
numOfMsgs
)
{
SVnodeObj
*
pVnode
=
pInfo
->
ahandle
;
SRpcMsg
*
pMsg
=
NULL
;
for
(
int32_t
i
=
0
;
i
<
numOfMsgs
;
++
i
)
{
SRpcMsg
*
pMsg
=
NULL
;
taosGetQitem
(
qall
,
(
void
**
)
&
pMsg
);
if
(
taosGetQitem
(
qall
,
(
void
**
)
&
pMsg
)
==
0
)
continue
;
dTrace
(
"vgId:%d, msg:%p get from vnode-sync queue"
,
pVnode
->
vgId
,
pMsg
);
int32_t
code
=
vnodeProcessSyncReq
(
pVnode
->
pImpl
,
pMsg
,
NULL
);
if
(
code
!=
0
)
{
dError
(
"vgId:%d, msg:%p failed to sync since %s"
,
pVnode
->
vgId
,
pMsg
,
terrstr
());
if
(
pMsg
->
info
.
handle
!=
NULL
)
{
SRpcMsg
rsp
=
{
.
code
=
(
terrno
<
0
)
?
terrno
:
code
,
.
info
=
pMsg
->
info
,
};
dTrace
(
"msg:%p, failed to process sync queue since %s"
,
pMsg
,
terrstr
());
tmsgSendRsp
(
&
rsp
);
if
(
terrno
!=
0
)
code
=
terrno
;
vmSendRsp
(
pMsg
,
code
);
}
}
dTrace
(
"vgId:%d, msg:%p is freed, code:0x%x"
,
pVnode
->
vgId
,
pMsg
,
code
);
rpcFreeCont
(
pMsg
->
pCont
);
taosFreeQitem
(
pMsg
);
}
...
...
@@ -207,24 +215,26 @@ static void vmProcessSyncQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numOf
static
void
vmProcessMergeQueue
(
SQueueInfo
*
pInfo
,
STaosQall
*
qall
,
int32_t
numOfMsgs
)
{
SVnodeObj
*
pVnode
=
pInfo
->
ahandle
;
SRpcMsg
*
pMsg
=
NULL
;
for
(
int32_t
i
=
0
;
i
<
numOfMsgs
;
++
i
)
{
SRpcMsg
*
pMsg
=
NULL
;
taosGetQitem
(
qall
,
(
void
**
)
&
pMsg
);
if
(
taosGetQitem
(
qall
,
(
void
**
)
&
pMsg
)
==
0
)
continue
;
dTrace
(
"vgId:%d, msg:%p get from vnode-merge queue"
,
pVnode
->
vgId
,
pMsg
);
dTrace
(
"msg:%p, get from vnode-merge queue"
,
pMsg
);
int32_t
code
=
vnodeProcessFetchMsg
(
pVnode
->
pImpl
,
pMsg
,
pInfo
);
if
(
code
!=
0
)
{
dError
(
"vgId:%d, msg:%p failed to merge since %s"
,
pVnode
->
vgId
,
pMsg
,
terrstr
());
if
(
terrno
!=
0
)
code
=
terrno
;
vmSendRsp
(
pMsg
,
code
);
}
dTrace
(
"msg:%p, is freed, code:0x%x"
,
pMsg
,
code
);
rpcFreeCont
(
pMsg
->
pCont
);
taosFreeQitem
(
pMsg
);
}
}
static
int32_t
vmPut
Node
MsgToQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
,
EQueueType
qtype
)
{
static
int32_t
vmPutMsgToQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
,
EQueueType
qtype
)
{
SMsgHead
*
pHead
=
pMsg
->
pCont
;
int32_t
code
=
0
;
...
...
@@ -233,31 +243,36 @@ static int32_t vmPutNodeMsgToQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg, EQueueType
SVnodeObj
*
pVnode
=
vmAcquireVnode
(
pMgmt
,
pHead
->
vgId
);
if
(
pVnode
==
NULL
)
{
dError
(
"vgId:%d, failed to put msg:%p into vnode-queue since %s"
,
pHead
->
vgId
,
pMsg
,
terrstr
());
dError
(
"vgId:%d, failed to put msg:%p into vnode queue since %s, type:%s"
,
pHead
->
vgId
,
pMsg
,
terrstr
(),
TMSG_INFO
(
pMsg
->
msgType
));
return
terrno
!=
0
?
terrno
:
-
1
;
}
switch
(
qtype
)
{
case
QUERY_QUEUE
:
dTrace
(
"
msg:%p, put into vnode-query worker, type:%s"
,
pMsg
,
TMSG_INFO
(
pMsg
->
msgType
)
);
dTrace
(
"
vgId:%d, msg:%p put into vnode-query queue"
,
pVnode
->
vgId
,
pMsg
);
taosWriteQitem
(
pVnode
->
pQueryQ
,
pMsg
);
break
;
case
FETCH_QUEUE
:
dTrace
(
"
msg:%p, put into vnode-fetch worker, type:%s"
,
pMsg
,
TMSG_INFO
(
pMsg
->
msgType
)
);
dTrace
(
"
vgId:%d, msg:%p put into vnode-fetch queue"
,
pVnode
->
vgId
,
pMsg
);
taosWriteQitem
(
pVnode
->
pFetchQ
,
pMsg
);
break
;
case
WRITE_QUEUE
:
dTrace
(
"
msg:%p, put into vnode-write worker, type:%s"
,
pMsg
,
TMSG_INFO
(
pMsg
->
msgType
)
);
dTrace
(
"
vgId:%d, msg:%p put into vnode-write queue"
,
pVnode
->
vgId
,
pMsg
);
taosWriteQitem
(
pVnode
->
pWriteQ
,
pMsg
);
break
;
case
SYNC_QUEUE
:
dTrace
(
"
msg:%p, put into vnode-sync worker, type:%s"
,
pMsg
,
TMSG_INFO
(
pMsg
->
msgType
)
);
dTrace
(
"
vgId:%d, msg:%p put into vnode-sync queue"
,
pVnode
->
vgId
,
pMsg
);
taosWriteQitem
(
pVnode
->
pSyncQ
,
pMsg
);
break
;
case
MERGE_QUEUE
:
dTrace
(
"
msg:%p, put into vnode-merge worker, type:%s"
,
pMsg
,
TMSG_INFO
(
pMsg
->
msgType
)
);
dTrace
(
"
vgId:%d, msg:%p put into vnode-merge queue"
,
pVnode
->
vgId
,
pMsg
);
taosWriteQitem
(
pVnode
->
pMergeQ
,
pMsg
);
break
;
case
APPLY_QUEUE
:
dTrace
(
"vgId:%d, msg:%p put into vnode-apply queue"
,
pVnode
->
vgId
,
pMsg
);
taosWriteQitem
(
pVnode
->
pApplyQ
,
pMsg
);
break
;
default:
code
=
-
1
;
terrno
=
TSDB_CODE_INVALID_PARA
;
...
...
@@ -268,110 +283,39 @@ static int32_t vmPutNodeMsgToQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg, EQueueType
return
code
;
}
int32_t
vmPutNodeMsgToSyncQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
return
vmPutNodeMsgToQueue
(
pMgmt
,
pMsg
,
SYNC_QUEUE
);
}
int32_t
vmPutMsgToSyncQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
return
vmPutMsgToQueue
(
pMgmt
,
pMsg
,
SYNC_QUEUE
);
}
int32_t
vmPutNodeMsgToWriteQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
return
vmPutNodeMsgToQueue
(
pMgmt
,
pMsg
,
WRITE_QUEUE
);
}
int32_t
vmPutMsgToWriteQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
return
vmPutMsgToQueue
(
pMgmt
,
pMsg
,
WRITE_QUEUE
);
}
int32_t
vmPutNodeMsgToQueryQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
return
vmPutNodeMsgToQueue
(
pMgmt
,
pMsg
,
QUERY_QUEUE
);
}
int32_t
vmPutMsgToQueryQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
return
vmPutMsgToQueue
(
pMgmt
,
pMsg
,
QUERY_QUEUE
);
}
int32_t
vmPutNodeMsgToFetchQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
return
vmPutNodeMsgToQueue
(
pMgmt
,
pMsg
,
FETCH_QUEUE
);
}
int32_t
vmPutMsgToFetchQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
return
vmPutMsgToQueue
(
pMgmt
,
pMsg
,
FETCH_QUEUE
);
}
int32_t
vmPutNodeMsgToMergeQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
return
vmPutNodeMsgToQueue
(
pMgmt
,
pMsg
,
MERGE_QUEUE
);
}
int32_t
vmPutMsgToMergeQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
return
vmPutMsgToQueue
(
pMgmt
,
pMsg
,
MERGE_QUEUE
);
}
int32_t
vmPutNodeMsgToMgmtQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
SSingleWorker
*
pWorker
=
&
pMgmt
->
mgmtWorker
;
dTrace
(
"msg:%p, put into vnode-mgmt worker, type:%s"
,
pMsg
,
TMSG_INFO
(
pMsg
->
msgType
));
taosWriteQitem
(
pWorker
->
queue
,
pMsg
);
int32_t
vmPutMsgToMgmtQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
dTrace
(
"msg:%p, put into vnode-mgmt queue"
,
pMsg
);
taosWriteQitem
(
pMgmt
->
mgmtWorker
.
queue
,
pMsg
);
return
0
;
}
int32_t
vmPutNodeMsgToMonitorQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
SSingleWorker
*
pWorker
=
&
pMgmt
->
monitorWorker
;
dTrace
(
"msg:%p, put into vnode-monitor worker, type:%s"
,
pMsg
,
TMSG_INFO
(
pMsg
->
msgType
));
taosWriteQitem
(
pWorker
->
queue
,
pMsg
);
int32_t
vmPutMsgToMonitorQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
dTrace
(
"msg:%p, put into vnode-monitor queue"
,
pMsg
);
taosWriteQitem
(
pMgmt
->
monitorWorker
.
queue
,
pMsg
);
return
0
;
}
static
int32_t
vmPutRpcMsgToQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pRpc
,
EQueueType
qtype
)
{
SMsgHead
*
pHead
=
pRpc
->
pCont
;
SVnodeObj
*
pVnode
=
vmAcquireVnode
(
pMgmt
,
pHead
->
vgId
);
if
(
pVnode
==
NULL
)
return
-
1
;
int32_t
vmPutRpcMsgToQueue
(
SVnodeMgmt
*
pMgmt
,
EQueueType
qtype
,
SRpcMsg
*
pRpc
)
{
SRpcMsg
*
pMsg
=
taosAllocateQitem
(
sizeof
(
SRpcMsg
),
RPC_QITEM
);
int32_t
code
=
0
;
if
(
pMsg
==
NULL
)
{
rpcFreeCont
(
pRpc
->
pCont
);
pRpc
->
pCont
=
NULL
;
code
=
-
1
;
}
else
{
memcpy
(
pMsg
,
pRpc
,
sizeof
(
SRpcMsg
));
switch
(
qtype
)
{
case
WRITE_QUEUE
:
dTrace
(
"msg:%p, create and put into vnode-write worker, type:%s"
,
pMsg
,
TMSG_INFO
(
pRpc
->
msgType
));
taosWriteQitem
(
pVnode
->
pWriteQ
,
pMsg
);
break
;
case
QUERY_QUEUE
:
dTrace
(
"msg:%p, create and put into vnode-query queue, type:%s"
,
pMsg
,
TMSG_INFO
(
pRpc
->
msgType
));
taosWriteQitem
(
pVnode
->
pQueryQ
,
pMsg
);
break
;
case
FETCH_QUEUE
:
dTrace
(
"msg:%p, create and put into vnode-fetch queue, type:%s"
,
pMsg
,
TMSG_INFO
(
pRpc
->
msgType
));
taosWriteQitem
(
pVnode
->
pFetchQ
,
pMsg
);
break
;
case
APPLY_QUEUE
:
dTrace
(
"msg:%p, create and put into vnode-apply queue, type:%s"
,
pMsg
,
TMSG_INFO
(
pRpc
->
msgType
));
taosWriteQitem
(
pVnode
->
pApplyQ
,
pMsg
);
break
;
case
MERGE_QUEUE
:
dTrace
(
"msg:%p, create and put into vnode-merge queue, type:%s"
,
pMsg
,
TMSG_INFO
(
pRpc
->
msgType
));
taosWriteQitem
(
pVnode
->
pMergeQ
,
pMsg
);
break
;
case
SYNC_QUEUE
:
dTrace
(
"msg:%p, create and put into vnode-sync queue, type:%s"
,
pMsg
,
TMSG_INFO
(
pRpc
->
msgType
));
taosWriteQitem
(
pVnode
->
pSyncQ
,
pMsg
);
break
;
default:
code
=
-
1
;
terrno
=
TSDB_CODE_INVALID_PARA
;
break
;
}
}
vmReleaseVnode
(
pMgmt
,
pVnode
);
return
code
;
}
int32_t
vmPutRpcMsgToWriteQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pRpc
)
{
return
vmPutRpcMsgToQueue
(
pMgmt
,
pRpc
,
WRITE_QUEUE
);
}
int32_t
vmPutRpcMsgToSyncQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pRpc
)
{
return
vmPutRpcMsgToQueue
(
pMgmt
,
pRpc
,
SYNC_QUEUE
);
}
int32_t
vmPutRpcMsgToApplyQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pRpc
)
{
return
vmPutRpcMsgToQueue
(
pMgmt
,
pRpc
,
APPLY_QUEUE
);
}
int32_t
vmPutRpcMsgToQueryQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pRpc
)
{
return
vmPutRpcMsgToQueue
(
pMgmt
,
pRpc
,
QUERY_QUEUE
);
}
if
(
pMsg
==
NULL
)
return
-
1
;
int32_t
vmPutRpcMsgToFetchQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pRpc
)
{
return
vmPutRpcMsgToQueue
(
pMgmt
,
pRpc
,
FETCH_QUEUE
);
}
SMsgHead
*
pHead
=
pRpc
->
pCont
;
dTrace
(
"vgId:%d, msg:%p is created, type:%s"
,
pHead
->
vgId
,
pMsg
,
TMSG_INFO
(
pMsg
->
msgType
));
int32_t
vmPutRpcMsgToMergeQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pRpc
)
{
return
vmPutRpcMsgToQueue
(
pMgmt
,
pRpc
,
MERGE_QUEUE
);
pHead
->
contLen
=
htonl
(
pHead
->
contLen
);
pHead
->
vgId
=
htonl
(
pHead
->
vgId
);
memcpy
(
pMsg
,
pRpc
,
sizeof
(
SRpcMsg
));
return
vmPutMsgToQueue
(
pMgmt
,
pMsg
,
qtype
);
}
int32_t
vmGetQueueSize
(
SVnodeMgmt
*
pMgmt
,
int32_t
vgId
,
EQueueType
qtype
)
{
...
...
@@ -467,29 +411,23 @@ int32_t vmStartWorker(SVnodeMgmt *pMgmt) {
pMPool
->
max
=
tsNumOfVnodeMergeThreads
;
if
(
tWWorkerInit
(
pMPool
)
!=
0
)
return
-
1
;
SSingleWorkerCfg
c
fg
=
{
SSingleWorkerCfg
mgmtC
fg
=
{
.
min
=
1
,
.
max
=
1
,
.
name
=
"vnode-mgmt"
,
.
fp
=
(
FItem
)
vmProcessQueue
,
.
fp
=
(
FItem
)
vmProcess
Mgmt
Queue
,
.
param
=
pMgmt
,
};
if
(
tSingleWorkerInit
(
&
pMgmt
->
mgmtWorker
,
&
cfg
)
!=
0
)
{
dError
(
"failed to start vnode-mgmt worker since %s"
,
terrstr
());
return
-
1
;
}
if
(
tSingleWorkerInit
(
&
pMgmt
->
mgmtWorker
,
&
mgmtCfg
)
!=
0
)
return
-
1
;
SSingleWorkerCfg
mCfg
=
{
SSingleWorkerCfg
m
onitor
Cfg
=
{
.
min
=
1
,
.
max
=
1
,
.
name
=
"vnode-monitor"
,
.
fp
=
(
FItem
)
vmProcessQueue
,
.
fp
=
(
FItem
)
vmProcess
Mgmt
Queue
,
.
param
=
pMgmt
,
};
if
(
tSingleWorkerInit
(
&
pMgmt
->
monitorWorker
,
&
mCfg
)
!=
0
)
{
dError
(
"failed to start vnode-monitor worker since %s"
,
terrstr
());
return
-
1
;
}
if
(
tSingleWorkerInit
(
&
pMgmt
->
monitorWorker
,
&
monitorCfg
)
!=
0
)
return
-
1
;
dDebug
(
"vnode workers are initialized"
);
return
0
;
...
...
source/dnode/mgmt/node_mgmt/src/dmMgmt.c
浏览文件 @
5a9ed58b
...
...
@@ -229,7 +229,7 @@ SMgmtWrapper *dmAcquireWrapper(SDnode *pDnode, EDndNodeType ntype) {
taosThreadRwlockRdlock
(
&
pWrapper
->
lock
);
if
(
pWrapper
->
deployed
)
{
int32_t
refCount
=
atomic_add_fetch_32
(
&
pWrapper
->
refCount
,
1
);
dTrace
(
"node:%s, is acquired, ref:%d"
,
pWrapper
->
name
,
refCount
);
//
dTrace("node:%s, is acquired, ref:%d", pWrapper->name, refCount);
}
else
{
terrno
=
TSDB_CODE_NODE_NOT_DEPLOYED
;
pRetWrapper
=
NULL
;
...
...
@@ -245,7 +245,7 @@ int32_t dmMarkWrapper(SMgmtWrapper *pWrapper) {
taosThreadRwlockRdlock
(
&
pWrapper
->
lock
);
if
(
pWrapper
->
deployed
||
(
InParentProc
(
pWrapper
)
&&
pWrapper
->
required
))
{
int32_t
refCount
=
atomic_add_fetch_32
(
&
pWrapper
->
refCount
,
1
);
dTrace
(
"node:%s, is marked, ref:%d"
,
pWrapper
->
name
,
refCount
);
//
dTrace("node:%s, is marked, ref:%d", pWrapper->name, refCount);
}
else
{
terrno
=
TSDB_CODE_NODE_NOT_DEPLOYED
;
code
=
-
1
;
...
...
@@ -261,7 +261,7 @@ void dmReleaseWrapper(SMgmtWrapper *pWrapper) {
taosThreadRwlockRdlock
(
&
pWrapper
->
lock
);
int32_t
refCount
=
atomic_sub_fetch_32
(
&
pWrapper
->
refCount
,
1
);
taosThreadRwlockUnlock
(
&
pWrapper
->
lock
);
dTrace
(
"node:%s, is released, ref:%d"
,
pWrapper
->
name
,
refCount
);
//
dTrace("node:%s, is released, ref:%d", pWrapper->name, refCount);
}
static
void
dmGetServerStartupStatus
(
SDnode
*
pDnode
,
SServerStatusRsp
*
pStatus
)
{
...
...
source/dnode/mgmt/node_mgmt/src/dmTransport.c
浏览文件 @
5a9ed58b
...
...
@@ -117,6 +117,7 @@ static void dmProcessRpcMsg(SDnode *pDnode, SRpcMsg *pRpc, SEpSet *pEpSet) {
if
(
pMsg
==
NULL
)
{
goto
_OVER
;
}
dTrace
(
"msg:%p, is created, type:%s"
,
pMsg
,
TMSG_INFO
(
pRpc
->
msgType
));
if
(
dmBuildNodeMsg
(
pMsg
,
pRpc
)
!=
0
)
{
goto
_OVER
;
...
...
source/dnode/mgmt/test/mnode/dmnode.cpp
浏览文件 @
5a9ed58b
...
...
@@ -94,7 +94,7 @@ TEST_F(DndTestMnode, 02_Alter_Mnode) {
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSDCreateMnodeReq
(
pReq
,
contLen
,
&
alterReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_
D
ND_ALTER_MNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_
M
ND_ALTER_MNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_INVALID_OPTION
);
}
...
...
@@ -111,7 +111,7 @@ TEST_F(DndTestMnode, 02_Alter_Mnode) {
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSDCreateMnodeReq
(
pReq
,
contLen
,
&
alterReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_
D
ND_ALTER_MNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_
M
ND_ALTER_MNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_INVALID_OPTION
);
}
...
...
@@ -128,7 +128,7 @@ TEST_F(DndTestMnode, 02_Alter_Mnode) {
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSDCreateMnodeReq
(
pReq
,
contLen
,
&
alterReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_
D
ND_ALTER_MNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_
M
ND_ALTER_MNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
...
...
@@ -186,7 +186,7 @@ TEST_F(DndTestMnode, 03_Drop_Mnode) {
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSDCreateMnodeReq
(
pReq
,
contLen
,
&
alterReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_
D
ND_ALTER_MNODE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_
M
ND_ALTER_MNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_NODE_NOT_DEPLOYED
);
}
...
...
source/dnode/mnode/impl/src/mndDb.c
浏览文件 @
5a9ed58b
...
...
@@ -1344,6 +1344,9 @@ int32_t mndValidateDbInfo(SMnode *pMnode, SDbVgVersion *pDbs, int32_t numOfDbs,
mDebug
(
"db:%s, version & numOfTable not changed"
,
pDbVgVersion
->
dbFName
);
mndReleaseDb
(
pMnode
,
pDb
);
continue
;
}
else
{
mDebug
(
"db:%s, vgroup version changed from %d to %d"
,
pDbVgVersion
->
dbFName
,
pDbVgVersion
->
vgVersion
,
pDb
->
vgVersion
);
}
usedbRsp
.
pVgroupInfos
=
taosArrayInit
(
pDb
->
cfg
.
numOfVgroups
,
sizeof
(
SVgroupInfo
));
...
...
source/dnode/mnode/impl/src/mndFunc.c
浏览文件 @
5a9ed58b
...
...
@@ -538,7 +538,7 @@ static int32_t mndRetrieveFuncs(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
isAgg
,
false
);
char
b3
[
TSDB_TYPE_STR_MAX_LEN
]
=
{
0
};
char
b3
[
TSDB_TYPE_STR_MAX_LEN
+
1
]
=
{
0
};
STR_WITH_MAXSIZE_TO_VARSTR
(
b3
,
mnodeGenTypeStr
(
buf
,
TSDB_TYPE_STR_MAX_LEN
,
pFunc
->
outputType
,
pFunc
->
outputLen
),
pShow
->
pMeta
->
pSchemas
[
cols
].
bytes
);
...
...
source/dnode/mnode/impl/src/mndMnode.c
浏览文件 @
5a9ed58b
...
...
@@ -53,10 +53,10 @@ int32_t mndInitMnode(SMnode *pMnode) {
};
mndSetMsgHandle
(
pMnode
,
TDMT_MND_CREATE_MNODE
,
mndProcessCreateMnodeReq
);
mndSetMsgHandle
(
pMnode
,
TDMT_
D
ND_ALTER_MNODE
,
mndProcessAlterMnodeReq
);
mndSetMsgHandle
(
pMnode
,
TDMT_
M
ND_ALTER_MNODE
,
mndProcessAlterMnodeReq
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_DROP_MNODE
,
mndProcessDropMnodeReq
);
mndSetMsgHandle
(
pMnode
,
TDMT_DND_CREATE_MNODE_RSP
,
mndProcessCreateMnodeRsp
);
mndSetMsgHandle
(
pMnode
,
TDMT_
D
ND_ALTER_MNODE_RSP
,
mndProcessAlterMnodeRsp
);
mndSetMsgHandle
(
pMnode
,
TDMT_
M
ND_ALTER_MNODE_RSP
,
mndProcessAlterMnodeRsp
);
mndSetMsgHandle
(
pMnode
,
TDMT_DND_DROP_MNODE_RSP
,
mndProcessDropMnodeRsp
);
mndAddShowRetrieveHandle
(
pMnode
,
TSDB_MGMT_TABLE_MNODE
,
mndRetrieveMnodes
);
...
...
@@ -338,7 +338,7 @@ static int32_t mndSetCreateMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDno
.
epSet
=
alterEpset
,
.
pCont
=
pReq
,
.
contLen
=
contLen
,
.
msgType
=
TDMT_
D
ND_ALTER_MNODE
,
.
msgType
=
TDMT_
M
ND_ALTER_MNODE
,
.
acceptableCode
=
0
,
};
...
...
@@ -506,7 +506,7 @@ static int32_t mndSetDropMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDnode
.
epSet
=
alterEpset
,
.
pCont
=
pReq
,
.
contLen
=
contLen
,
.
msgType
=
TDMT_
D
ND_ALTER_MNODE
,
.
msgType
=
TDMT_
M
ND_ALTER_MNODE
,
.
acceptableCode
=
0
,
};
...
...
source/dnode/mnode/impl/test/acct/CMakeLists.txt
浏览文件 @
5a9ed58b
...
...
@@ -5,9 +5,7 @@ target_link_libraries(
PUBLIC sut
)
if
(
NOT TD_WINDOWS
)
add_test
(
add_test
(
NAME acctTest
COMMAND acctTest
)
endif
(
NOT TD_WINDOWS
)
)
source/dnode/mnode/impl/test/func/CMakeLists.txt
浏览文件 @
5a9ed58b
...
...
@@ -5,9 +5,9 @@ target_link_libraries(
PUBLIC sut
)
if
(
NOT TD_WINDOWS
)
#
if(NOT TD_WINDOWS)
add_test
(
NAME funcTest
COMMAND funcTest
)
endif
(
NOT TD_WINDOWS
)
#
endif(NOT TD_WINDOWS)
source/dnode/mnode/impl/test/profile/CMakeLists.txt
浏览文件 @
5a9ed58b
...
...
@@ -5,9 +5,9 @@ target_link_libraries(
PUBLIC sut
)
if
(
NOT TD_WINDOWS
)
#
if(NOT TD_WINDOWS)
add_test
(
NAME profileTest
COMMAND profileTest
)
endif
(
NOT TD_WINDOWS
)
#
endif(NOT TD_WINDOWS)
source/dnode/mnode/impl/test/show/CMakeLists.txt
浏览文件 @
5a9ed58b
...
...
@@ -5,9 +5,9 @@ target_link_libraries(
PUBLIC sut
)
if
(
NOT TD_WINDOWS
)
#
if(NOT TD_WINDOWS)
add_test
(
NAME showTest
COMMAND showTest
)
endif
(
NOT TD_WINDOWS
)
#
endif(NOT TD_WINDOWS)
source/dnode/vnode/CMakeLists.txt
浏览文件 @
5a9ed58b
...
...
@@ -36,7 +36,6 @@ target_sources(
# tsdb
"src/tsdb/tsdbCommit.c"
"src/tsdb/tsdbCommit2.c"
"src/tsdb/tsdbFile.c"
"src/tsdb/tsdbFS.c"
"src/tsdb/tsdbOpen.c"
...
...
source/dnode/vnode/src/meta/metaQuery.c
浏览文件 @
5a9ed58b
...
...
@@ -576,15 +576,15 @@ SArray *metaGetSmaTbUids(SMeta *pMeta) {
const
void
*
metaGetTableTagVal
(
SMetaEntry
*
pEntry
,
int16_t
type
,
STagVal
*
val
)
{
ASSERT
(
pEntry
->
type
==
TSDB_CHILD_TABLE
);
STag
*
tag
=
(
STag
*
)
pEntry
->
ctbEntry
.
pTags
;
if
(
type
==
TSDB_DATA_TYPE_JSON
){
if
(
tag
->
nTag
==
0
)
{
if
(
type
==
TSDB_DATA_TYPE_JSON
)
{
if
(
tag
->
nTag
==
0
)
{
return
NULL
;
}
return
tag
;
}
bool
find
=
tTagGet
(
tag
,
val
);
if
(
!
find
)
{
if
(
!
find
)
{
return
NULL
;
}
return
val
;
...
...
@@ -605,8 +605,6 @@ typedef struct {
int32_t
metaFilteTableIds
(
SMeta
*
pMeta
,
SMetaFltParam
*
param
,
SArray
*
pUids
)
{
SIdxCursor
*
pCursor
=
NULL
;
char
*
tagData
=
param
->
val
;
int32_t
ret
=
0
,
valid
=
0
;
pCursor
=
(
SIdxCursor
*
)
taosMemoryCalloc
(
1
,
sizeof
(
SIdxCursor
));
pCursor
->
pMeta
=
pMeta
;
...
...
@@ -623,12 +621,16 @@ int32_t metaFilteTableIds(SMeta *pMeta, SMetaFltParam *param, SArray *pUids) {
int32_t
nKey
=
0
;
int32_t
nTagData
=
0
;
if
(
IS_VAR_DATA_TYPE
(
param
->
type
)){
nTagData
=
strlen
(
param
->
val
);
}
else
{
void
*
tagData
=
NULL
;
if
(
IS_VAR_DATA_TYPE
(
param
->
type
))
{
tagData
=
varDataVal
(
param
->
val
);
nTagData
=
varDataLen
(
param
->
val
);
}
else
{
tagData
=
param
->
val
;
nTagData
=
tDataTypes
[
param
->
type
].
bytes
;
}
ret
=
metaCreateTagIdxKey
(
pCursor
->
suid
,
pCursor
->
cid
,
param
->
val
,
nTagData
,
pCursor
->
type
,
ret
=
metaCreateTagIdxKey
(
pCursor
->
suid
,
pCursor
->
cid
,
tagData
,
nTagData
,
pCursor
->
type
,
param
->
reverse
?
INT64_MAX
:
INT64_MIN
,
&
pKey
,
&
nKey
);
if
(
ret
!=
0
)
{
goto
END
;
...
...
@@ -637,6 +639,7 @@ int32_t metaFilteTableIds(SMeta *pMeta, SMetaFltParam *param, SArray *pUids) {
if
(
tdbTbcMoveTo
(
pCursor
->
pCur
,
pKey
,
nKey
,
&
cmp
)
<
0
)
{
goto
END
;
}
void
*
entryKey
=
NULL
,
*
entryVal
=
NULL
;
int32_t
nEntryKey
,
nEntryVal
;
while
(
1
)
{
...
...
@@ -649,7 +652,12 @@ int32_t metaFilteTableIds(SMeta *pMeta, SMetaFltParam *param, SArray *pUids) {
int32_t
cmp
=
(
*
param
->
filterFunc
)(
p
->
data
,
pKey
->
data
,
pKey
->
type
);
if
(
cmp
==
0
)
{
// match
tb_uid_t
tuid
=
*
(
tb_uid_t
*
)(
p
->
data
+
tDataTypes
[
pCursor
->
type
].
bytes
);
tb_uid_t
tuid
=
0
;
if
(
IS_VAR_DATA_TYPE
(
pKey
->
type
))
{
tuid
=
*
(
tb_uid_t
*
)(
p
->
data
+
varDataTLen
(
p
->
data
));
}
else
{
tuid
=
*
(
tb_uid_t
*
)(
p
->
data
+
tDataTypes
[
pCursor
->
type
].
bytes
);
}
taosArrayPush
(
pUids
,
&
tuid
);
}
else
if
(
cmp
==
1
)
{
// not match but should continue to iter
...
...
source/dnode/vnode/src/meta/metaTable.c
浏览文件 @
5a9ed58b
...
...
@@ -49,9 +49,9 @@ int metaCreateSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
int
vLen
=
0
;
const
void
*
pKey
=
NULL
;
const
void
*
pVal
=
NULL
;
void
*
pBuf
=
NULL
;
void
*
pBuf
=
NULL
;
int32_t
szBuf
=
0
;
void
*
p
=
NULL
;
void
*
p
=
NULL
;
SMetaReader
mr
=
{
0
};
// validate req
...
...
@@ -105,7 +105,7 @@ int metaDropSTable(SMeta *pMeta, int64_t verison, SVDropStbReq *pReq) {
}
// drop all child tables
TBC
*
pCtbIdxc
=
NULL
;
TBC
*
pCtbIdxc
=
NULL
;
SArray
*
pArray
=
taosArrayInit
(
8
,
sizeof
(
tb_uid_t
));
tdbTbcOpen
(
pMeta
->
pCtbIdx
,
&
pCtbIdxc
,
&
pMeta
->
txn
);
...
...
@@ -160,8 +160,8 @@ _exit:
int
metaAlterSTable
(
SMeta
*
pMeta
,
int64_t
version
,
SVCreateStbReq
*
pReq
)
{
SMetaEntry
oStbEntry
=
{
0
};
SMetaEntry
nStbEntry
=
{
0
};
TBC
*
pUidIdxc
=
NULL
;
TBC
*
pTbDbc
=
NULL
;
TBC
*
pUidIdxc
=
NULL
;
TBC
*
pTbDbc
=
NULL
;
const
void
*
pData
;
int
nData
;
int64_t
oversion
;
...
...
@@ -280,7 +280,7 @@ _err:
}
int
metaDropTable
(
SMeta
*
pMeta
,
int64_t
version
,
SVDropTbReq
*
pReq
,
SArray
*
tbUids
)
{
void
*
pData
=
NULL
;
void
*
pData
=
NULL
;
int
nData
=
0
;
int
rc
=
0
;
tb_uid_t
uid
;
...
...
@@ -306,7 +306,7 @@ int metaDropTable(SMeta *pMeta, int64_t version, SVDropTbReq *pReq, SArray *tbUi
}
static
int
metaDropTableByUid
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int
*
type
)
{
void
*
pData
=
NULL
;
void
*
pData
=
NULL
;
int
nData
=
0
;
int
rc
=
0
;
int64_t
version
;
...
...
@@ -341,15 +341,16 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type) {
return
0
;
}
static
int
metaAlterTableColumn
(
SMeta
*
pMeta
,
int64_t
version
,
SVAlterTbReq
*
pAlterTbReq
,
STableMetaRsp
*
pMetaRsp
)
{
void
*
pVal
=
NULL
;
int
nVal
=
0
;
const
void
*
pData
=
NULL
;
const
void
*
pData
=
NULL
;
int
nData
=
0
;
int
ret
=
0
;
tb_uid_t
uid
;
int64_t
oversion
;
SSchema
*
pColumn
=
NULL
;
SSchema
*
pColumn
=
NULL
;
SMetaEntry
entry
=
{
0
};
SSchemaWrapper
*
pSchema
;
int
c
;
...
...
@@ -499,7 +500,7 @@ _err:
static
int
metaUpdateTableTagVal
(
SMeta
*
pMeta
,
int64_t
version
,
SVAlterTbReq
*
pAlterTbReq
)
{
SMetaEntry
ctbEntry
=
{
0
};
SMetaEntry
stbEntry
=
{
0
};
void
*
pVal
=
NULL
;
void
*
pVal
=
NULL
;
int
nVal
=
0
;
int
ret
;
int
c
;
...
...
@@ -530,7 +531,7 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
oversion
=
*
(
int64_t
*
)
pData
;
// search table.db
TBC
*
pTbDbc
=
NULL
;
TBC
*
pTbDbc
=
NULL
;
SDecoder
dc1
=
{
0
};
SDecoder
dc2
=
{
0
};
...
...
@@ -554,7 +555,7 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
metaDecodeEntry
(
&
dc2
,
&
stbEntry
);
SSchemaWrapper
*
pTagSchema
=
&
stbEntry
.
stbEntry
.
schemaTag
;
SSchema
*
pColumn
=
NULL
;
SSchema
*
pColumn
=
NULL
;
int32_t
iCol
=
0
;
for
(;;)
{
pColumn
=
NULL
;
...
...
@@ -584,8 +585,8 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
memcpy
((
void
*
)
ctbEntry
.
ctbEntry
.
pTags
,
pAlterTbReq
->
pTagVal
,
pAlterTbReq
->
nTagVal
);
}
else
{
const
STag
*
pOldTag
=
(
const
STag
*
)
ctbEntry
.
ctbEntry
.
pTags
;
STag
*
pNewTag
=
NULL
;
SArray
*
pTagArray
=
taosArrayInit
(
pTagSchema
->
nCols
,
sizeof
(
STagVal
));
STag
*
pNewTag
=
NULL
;
SArray
*
pTagArray
=
taosArrayInit
(
pTagSchema
->
nCols
,
sizeof
(
STagVal
));
if
(
!
pTagArray
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_err
;
...
...
@@ -669,8 +670,8 @@ int metaAlterTable(SMeta *pMeta, int64_t version, SVAlterTbReq *pReq, STableMeta
static
int
metaSaveToTbDb
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
)
{
STbDbKey
tbDbKey
;
void
*
pKey
=
NULL
;
void
*
pVal
=
NULL
;
void
*
pKey
=
NULL
;
void
*
pVal
=
NULL
;
int
kLen
=
0
;
int
vLen
=
0
;
SEncoder
coder
=
{
0
};
...
...
@@ -753,16 +754,11 @@ static int metaUpdateCtbIdx(SMeta *pMeta, const SMetaEntry *pME) {
int
metaCreateTagIdxKey
(
tb_uid_t
suid
,
int32_t
cid
,
const
void
*
pTagData
,
int32_t
nTagData
,
int8_t
type
,
tb_uid_t
uid
,
STagIdxKey
**
ppTagIdxKey
,
int32_t
*
nTagIdxKey
)
{
// int32_t nTagData = 0;
// if (pTagData) {
// if (IS_VAR_DATA_TYPE(type)) {
// nTagData = varDataTLen(pTagData);
// } else {
// nTagData = tDataTypes[type].bytes;
// }
// }
if
(
IS_VAR_DATA_TYPE
(
type
))
{
*
nTagIdxKey
=
sizeof
(
STagIdxKey
)
+
nTagData
+
VARSTR_HEADER_SIZE
+
sizeof
(
tb_uid_t
);
}
else
{
*
nTagIdxKey
=
sizeof
(
STagIdxKey
)
+
nTagData
+
sizeof
(
tb_uid_t
);
}
*
ppTagIdxKey
=
(
STagIdxKey
*
)
taosMemoryMalloc
(
*
nTagIdxKey
);
if
(
*
ppTagIdxKey
==
NULL
)
{
...
...
@@ -774,8 +770,16 @@ int metaCreateTagIdxKey(tb_uid_t suid, int32_t cid, const void *pTagData, int32_
(
*
ppTagIdxKey
)
->
cid
=
cid
;
(
*
ppTagIdxKey
)
->
isNull
=
(
pTagData
==
NULL
)
?
1
:
0
;
(
*
ppTagIdxKey
)
->
type
=
type
;
if
(
nTagData
)
memcpy
((
*
ppTagIdxKey
)
->
data
,
pTagData
,
nTagData
);
// refactor
if
(
IS_VAR_DATA_TYPE
(
type
))
{
memcpy
((
*
ppTagIdxKey
)
->
data
,
(
uint16_t
*
)
&
nTagData
,
VARSTR_HEADER_SIZE
);
memcpy
((
*
ppTagIdxKey
)
->
data
+
VARSTR_HEADER_SIZE
,
pTagData
,
nTagData
);
*
(
tb_uid_t
*
)((
*
ppTagIdxKey
)
->
data
+
VARSTR_HEADER_SIZE
+
nTagData
)
=
uid
;
}
else
{
memcpy
((
*
ppTagIdxKey
)
->
data
,
pTagData
,
nTagData
);
*
(
tb_uid_t
*
)((
*
ppTagIdxKey
)
->
data
+
nTagData
)
=
uid
;
}
return
0
;
}
...
...
@@ -785,14 +789,14 @@ static void metaDestroyTagIdxKey(STagIdxKey *pTagIdxKey) {
}
static
int
metaUpdateTagIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pCtbEntry
)
{
void
*
pData
=
NULL
;
void
*
pData
=
NULL
;
int
nData
=
0
;
STbDbKey
tbDbKey
=
{
0
};
SMetaEntry
stbEntry
=
{
0
};
STagIdxKey
*
pTagIdxKey
=
NULL
;
STagIdxKey
*
pTagIdxKey
=
NULL
;
int32_t
nTagIdxKey
;
const
SSchema
*
pTagColumn
;
// = &stbEntry.stbEntry.schema.pSchema[0];
const
void
*
pTagData
=
NULL
;
//
const
void
*
pTagData
=
NULL
;
//
int32_t
nTagData
=
0
;
SDecoder
dc
=
{
0
};
...
...
@@ -849,7 +853,7 @@ static int metaUpdateTagIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry) {
static
int
metaSaveToSkmDb
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
)
{
SEncoder
coder
=
{
0
};
void
*
pVal
=
NULL
;
void
*
pVal
=
NULL
;
int
vLen
=
0
;
int
rcode
=
0
;
SSkmDbKey
skmDbKey
=
{
0
};
...
...
source/dnode/vnode/src/tsdb/tsdbCommit.c
浏览文件 @
5a9ed58b
...
...
@@ -88,6 +88,18 @@ static void tsdbLoadAndMergeFromCache(STsdb *pTsdb, SDataCols *pDataCols, int *i
SDataCols
*
pTarget
,
TSKEY
maxKey
,
int
maxRows
,
int8_t
update
);
int
tsdbWriteBlockIdx
(
SDFile
*
pHeadf
,
SArray
*
pIdxA
,
void
**
ppBuf
);
int
tsdbBegin
(
STsdb
*
pTsdb
)
{
if
(
!
pTsdb
)
return
0
;
STsdbMemTable
*
pMem
;
if
(
tsdbMemTableCreate
(
pTsdb
,
&
pTsdb
->
mem
)
<
0
)
{
return
-
1
;
}
return
0
;
}
int
tsdbApplyRtnOnFSet
(
STsdb
*
pRepo
,
SDFileSet
*
pSet
,
SRtn
*
pRtn
)
{
SDiskID
did
;
SDFileSet
nSet
=
{
0
};
...
...
source/dnode/vnode/src/tsdb/tsdbCommit2.c
已删除
100644 → 0
浏览文件 @
6e6c9bda
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "tsdb.h"
int
tsdbBegin
(
STsdb
*
pTsdb
)
{
if
(
!
pTsdb
)
return
0
;
STsdbMemTable
*
pMem
;
if
(
tsdbMemTableCreate
(
pTsdb
,
&
pTsdb
->
mem
)
<
0
)
{
return
-
1
;
}
return
0
;
}
source/dnode/vnode/src/tsdb/tsdbMemTable2.c
浏览文件 @
5a9ed58b
...
...
@@ -52,20 +52,21 @@ struct SMemTable {
SArray
*
pArray
;
// SArray<SMemData>
};
#define SL_MAX_LEVEL 5
#define SL_NODE_SIZE(l) (sizeof(SMemSkipListNode) + sizeof(SMemSkipListNode *) * (l)*2)
#define SL_NODE_HALF_SIZE(l) (sizeof(SMemSkipListNode) + sizeof(SMemSkipListNode *) * (l))
#define SL_NODE_FORWARD(n, l) ((n)->forwards[l])
#define SL_NODE_BACKWARD(n, l) ((n)->forwards[(n)->level + (l)])
#define SL_NODE_DATA(n) (&SL_NODE_BACKWARD(n, (n)->level))
#define SL_HEAD_FORWARD(sl, l) SL_NODE_FORWARD((sl)->pHead, l)
#define SL_TAIL_BACKWARD(sl, l) SL_NODE_FORWARD((sl)->pTail, l)
static
int32_t
tsdbGetOrCreateMemData
(
SMemTable
*
pMemTable
,
tb_uid_t
suid
,
tb_uid_t
uid
,
SMemData
**
ppMemData
);
static
int
memDataPCmprFn
(
const
void
*
p1
,
const
void
*
p2
);
static
int32_t
tPutTSDBRow
(
uint8_t
*
p
,
TSDBROW
*
pRow
);
static
int32_t
tGetTSDBRow
(
uint8_t
*
p
,
TSDBROW
*
pRow
);
static
int8_t
tsdbMemSkipListRandLevel
(
SMemSkipList
*
pSl
);
static
void
memDataMovePos
(
SMemData
*
pMemData
,
TSDBROW
*
pRow
,
int8_t
isForward
,
SMemSkipListNode
**
pos
);
static
int32_t
memDataPutRow
(
SVBufPool
*
pPool
,
SMemData
*
pMemData
,
TSDBROW
*
pRow
,
int8_t
isForward
,
SMemSkipListNode
**
pos
);
// SMemTable ==============================================
int32_t
tsdbMemTableCreate2
(
STsdb
*
pTsdb
,
SMemTable
**
ppMemTable
)
{
...
...
@@ -109,6 +110,7 @@ int32_t tsdbInsertTableData2(STsdb *pTsdb, int64_t version, SVSubmitBlk *pSubmit
TSDBROW
row
=
{.
version
=
version
};
ASSERT
(
pMemTable
);
ASSERT
(
pSubmitBlk
->
nData
>
0
);
{
// check if table exists (todo)
...
...
@@ -122,38 +124,29 @@ int32_t tsdbInsertTableData2(STsdb *pTsdb, int64_t version, SVSubmitBlk *pSubmit
// do insert
int32_t
nt
;
uint8_t
*
pt
;
int32_t
n
=
0
;
uint8_t
*
p
=
pSubmitBlk
->
pData
;
SVBufPool
*
pPool
=
pTsdb
->
pVnode
->
inUse
;
int8_t
level
;
SMemSkipListNode
*
pNode
;
int32_t
nRow
=
0
;
SMemSkipListNode
*
pos
[
SL_MAX_LEVEL
]
=
{
0
};
for
(
int8_t
iLevel
=
0
;
iLevel
<
SL_MAX_LEVEL
;
iLevel
++
)
{
pos
[
iLevel
]
=
pMemData
->
sl
.
pTail
;
}
while
(
n
<
pSubmitBlk
->
nData
)
{
nt
=
tGetTSRow
(
p
+
n
,
&
row
.
tsRow
);
n
+=
nt
;
ASSERT
(
n
<=
pSubmitBlk
->
nData
);
// build the node
level
=
tsdbMemSkipListRandLevel
(
&
pMemData
->
sl
);
pNode
=
(
SMemSkipListNode
*
)
vnodeBufPoolMalloc
(
pPool
,
SL_NODE_SIZE
(
level
)
+
nt
+
sizeof
(
version
));
if
(
pNode
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
memDataMovePos
(
pMemData
,
&
row
,
nRow
?
1
:
0
,
pos
);
code
=
memDataPutRow
(
pTsdb
->
pVnode
->
inUse
,
pMemData
,
&
row
,
nRow
?
1
:
0
,
pos
);
if
(
code
)
{
goto
_err
;
}
pNode
->
level
=
level
;
tPutTSDBRow
((
uint8_t
*
)
SL_NODE_DATA
(
pNode
),
&
row
);
// put the node (todo)
// set info
if
(
tsdbKeyCmprFn
(
&
row
,
&
pMemData
->
minKey
)
<
0
)
pMemData
->
minKey
=
*
(
TSDBKEY
*
)
&
row
;
if
(
tsdbKeyCmprFn
(
&
row
,
&
pMemData
->
maxKey
)
>
0
)
pMemData
->
maxKey
=
*
(
TSDBKEY
*
)
&
row
;
nRow
++
;
}
if
(
tsdbKeyCmprFn
(
&
pMemTable
->
minKey
,
&
pMemData
->
minKey
)
<
0
)
pMemTable
->
minKey
=
pMemData
->
minKey
;
if
(
tsdbKeyCmprFn
(
&
pMemTable
->
maxKey
,
&
pMemData
->
maxKey
)
>
0
)
pMemTable
->
maxKey
=
pMemData
->
maxKey
;
return
code
;
_err:
...
...
@@ -227,7 +220,7 @@ static int32_t tsdbGetOrCreateMemData(SMemTable *pMemTable, tb_uid_t suid, tb_ui
}
// create
pMemData
=
vnodeBufPoolMalloc
(
pPool
,
sizeof
(
*
pMemData
)
+
SL_NODE_
HALF_
SIZE
(
maxLevel
)
*
2
);
pMemData
=
vnodeBufPoolMalloc
(
pPool
,
sizeof
(
*
pMemData
)
+
SL_NODE_SIZE
(
maxLevel
)
*
2
);
if
(
pMemData
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_err
;
...
...
@@ -242,11 +235,15 @@ static int32_t tsdbGetOrCreateMemData(SMemTable *pMemTable, tb_uid_t suid, tb_ui
pMemData
->
sl
.
maxLevel
=
maxLevel
;
pMemData
->
sl
.
level
=
0
;
pMemData
->
sl
.
pHead
=
(
SMemSkipListNode
*
)
&
pMemData
[
1
];
pMemData
->
sl
.
pTail
=
(
SMemSkipListNode
*
)
POINTER_SHIFT
(
pMemData
->
sl
.
pHead
,
SL_NODE_HALF_SIZE
(
maxLevel
));
pMemData
->
sl
.
pTail
=
(
SMemSkipListNode
*
)
POINTER_SHIFT
(
pMemData
->
sl
.
pHead
,
SL_NODE_SIZE
(
maxLevel
));
pMemData
->
sl
.
pHead
->
level
=
maxLevel
;
pMemData
->
sl
.
pTail
->
level
=
maxLevel
;
for
(
int8_t
iLevel
=
0
;
iLevel
<
pMemData
->
sl
.
maxLevel
;
iLevel
++
)
{
SL_HEAD_FORWARD
(
&
pMemData
->
sl
,
iLevel
)
=
pMemData
->
sl
.
pTail
;
SL_TAIL_BACKWARD
(
&
pMemData
->
sl
,
iLevel
)
=
pMemData
->
sl
.
pHead
;
SL_NODE_FORWARD
(
pMemData
->
sl
.
pHead
,
iLevel
)
=
pMemData
->
sl
.
pTail
;
SL_NODE_BACKWARD
(
pMemData
->
sl
.
pHead
,
iLevel
)
=
NULL
;
SL_NODE_BACKWARD
(
pMemData
->
sl
.
pTail
,
iLevel
)
=
pMemData
->
sl
.
pHead
;
SL_NODE_FORWARD
(
pMemData
->
sl
.
pTail
,
iLevel
)
=
NULL
;
}
if
(
idx
<
0
)
idx
=
0
;
...
...
@@ -313,264 +310,87 @@ static FORCE_INLINE int8_t tsdbMemSkipListRandLevel(SMemSkipList *pSl) {
return
level
;
}
#if 0 //====================================================================================
#define SL_MAX_LEVEL 5
struct SMemSkipListCurosr {
SMemSkipList *pSl;
SMemSkipListNode *pNodes[SL_MAX_LEVEL];
};
typedef struct {
int64_t version;
uint32_t szRow;
const STSRow *pRow;
} STsdbRow;
#define HASH_BUCKET(SUID, UID, NBUCKET) (TABS((SUID) + (UID)) % (NBUCKET))
#define SL_HEAD_NODE(sl) ((sl)->pHead)
#define SL_TAIL_NODE(sl) ((SMemSkipListNode *)&SL_NODE_FORWARD(SL_HEAD_NODE(sl), (sl)->maxLevel))
#define SL_HEAD_NODE_FORWARD(n, l) SL_NODE_FORWARD(n, l)
#define SL_TAIL_NODE_BACKWARD(n, l) SL_NODE_FORWARD(n, l)
static int8_t tsdbMemSkipListRandLevel(SMemSkipList *pSl);
static int32_t tsdbEncodeRow(SEncoder *pEncoder, const STsdbRow *pRow);
static int32_t tsdbDecodeRow(SDecoder *pDecoder, STsdbRow *pRow);
static int32_t tsdbMemSkipListCursorCreate(int8_t maxLevel, SMemSkipListCurosr **ppSlc);
static void tsdbMemSkipListCursorDestroy(SMemSkipListCurosr *pSlc);
static void tsdbMemSkipListCursorInit(SMemSkipListCurosr *pSlc, SMemSkipList *pSl);
static void tsdbMemSkipListCursorPut(SMemSkipListCurosr *pSlc, SMemSkipListNode *pNode);
static int32_t tsdbMemSkipListCursorMoveTo(SMemSkipListCurosr *pSlc, int64_t version, TSKEY ts, int32_t flags);
static void tsdbMemSkipListCursorMoveToFirst(SMemSkipListCurosr *pSlc);
static void tsdbMemSkipListCursorMoveToLast(SMemSkipListCurosr *pSlc);
static int32_t tsdbMemSkipListCursorMoveToNext(SMemSkipListCurosr *pSlc);
static int32_t tsdbMemSkipListCursorMoveToPrev(SMemSkipListCurosr *pSlc);
static SMemSkipListNode *tsdbMemSkipListNodeCreate(SVBufPool *pPool, SMemSkipList *pSl, const STsdbRow *pTRow);
// SMemTable ========================
int32_t tsdbInsertData2(SMemTable *pMemTb, int64_t version, const SVSubmitBlk *pSubmitBlk) {
SMemData *pMemData;
STsdb *pTsdb = pMemTb->pTsdb;
SVnode *pVnode = pTsdb->pVnode;
SVBufPool *pPool = pVnode->inUse;
tb_uid_t suid = pSubmitBlk->suid;
tb_uid_t uid = pSubmitBlk->uid;
int32_t iBucket;
// search SMemData by hash
iBucket = HASH_BUCKET(suid, uid, pMemTb->nBucket);
for (pMemData = pMemTb->pBuckets[iBucket]; pMemData; pMemData = pMemData->pHashNext) {
if (pMemData->suid == suid && pMemData->uid == uid) break;
}
static
void
memDataMovePos
(
SMemData
*
pMemData
,
TSDBROW
*
pRow
,
int8_t
isForward
,
SMemSkipListNode
**
pos
)
{
TSDBKEY
*
pKey
;
int
c
;
// create pMemData if need
if (pMemData == NULL) {
int8_t maxLevel = pVnode->config.tsdbCfg.slLevel;
int32_t tsize = sizeof(*pMemData) + SL_NODE_HALF_SIZE(maxLevel) * 2;
SMemSkipListNode *pHead, *pTail;
if
(
isForward
)
{
// TODO
}
else
{
SMemSkipListNode
*
px
=
pMemData
->
sl
.
pTail
;
pMemData = vnodeBufPoolMalloc(pPool, tsize);
if (pMemData == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1;
}
for
(
int8_t
iLevel
=
pMemData
->
sl
.
maxLevel
-
1
;
iLevel
>=
0
;
iLevel
--
)
{
if
(
iLevel
<
pMemData
->
sl
.
level
)
{
SMemSkipListNode
*
p
=
SL_NODE_BACKWARD
(
px
,
iLevel
);
pMemData->pHashNext = NULL;
pMemData->suid = suid;
pMemData->uid = uid;
pMemData->minKey = TSKEY_MAX;
pMemData->maxKey = TSKEY_MIN;
pMemData->minVer = -1;
pMemData->maxVer = -1;
pMemData->nRows = 0;
pMemData->sl.seed = taosRand();
pMemData->sl.maxLevel = maxLevel;
pMemData->sl.level = 0;
pMemData->sl.size = 0;
pHead = SL_HEAD_NODE(&pMemData->sl);
pTail = SL_TAIL_NODE(&pMemData->sl);
pHead->level = maxLevel;
pTail->level = maxLevel;
for (int iLevel = 0; iLevel < maxLevel; iLevel++) {
SL_HEAD_NODE_FORWARD(pHead, iLevel) = pTail;
SL_TAIL_NODE_BACKWARD(pTail, iLevel) = pHead;
}
while
(
p
!=
pMemData
->
sl
.
pHead
)
{
pKey
=
(
TSDBKEY
*
)
SL_NODE_DATA
(
p
);
// add to hash
if (pMemTb->nHash >= pMemTb->nBucket) {
// rehash (todo)
c
=
tsdbKeyCmprFn
(
pKey
,
pRow
);
if
(
c
<=
0
)
{
break
;
}
else
{
px
=
p
;
p
=
SL_NODE_BACKWARD
(
px
,
iLevel
);
}
iBucket = HASH_BUCKET(suid, uid, pMemTb->nBucket);
pMemData->pHashNext = pMemTb->pBuckets[iBucket];
pMemTb->pBuckets[iBucket] = pMemData;
pMemTb->nHash++;
// sort organize (todo)
}
// do insert data to SMemData
SMemSkipListNode *forwards[SL_MAX_LEVEL];
SMemSkipListNode *pNode;
int32_t iRow;
STsdbRow tRow = {.version = version};
SEncoder ec = {0};
SDecoder dc = {0};
tDecoderInit(&dc, pSubmitBlk->pData, pSubmitBlk->nData);
tsdbMemSkipListCursorInit(pMemTb->pSlc, &pMemData->sl);
for (iRow = 0;; iRow++) {
if (tDecodeIsEnd(&dc)) break;
// decode row
if (tDecodeBinary(&dc, (uint8_t **)&tRow.pRow, &tRow.szRow) < 0) {
terrno = TSDB_CODE_INVALID_MSG;
return -1;
pos
[
iLevel
]
=
px
;
}
// move cursor
tsdbMemSkipListCursorMoveTo(pMemTb->pSlc, version, tRow.pRow->ts, 0);
// encode row
pNode = tsdbMemSkipListNodeCreate(pPool, &pMemData->sl, &tRow);
if (pNode == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1;
}
// put the node
tsdbMemSkipListCursorPut(pMemTb->pSlc, pNode);
// update status
if (tRow.pRow->ts < pMemData->minKey) pMemData->minKey = tRow.pRow->ts;
if (tRow.pRow->ts > pMemData->maxKey) pMemData->maxKey = tRow.pRow->ts;
}
tDecoderClear(&dc);
// update status
if (pMemData->minVer == -1) pMemData->minVer = version;
if (pMemData->maxVer == -1 || pMemData->maxVer < version) pMemData->maxVer = version;
if (pMemTb->minKey < pMemData->minKey) pMemTb->minKey = pMemData->minKey;
if (pMemTb->maxKey < pMemData->maxKey) pMemTb->maxKey = pMemData->maxKey;
if (pMemTb->minVer == -1) pMemTb->minVer = version;
if (pMemTb->maxVer == -1 || pMemTb->maxVer < version) pMemTb->maxVer = version;
return 0;
}
static FORCE_INLINE int32_t tsdbEncodeRow(SEncoder *pEncoder, const STsdbRow *pRow) {
if (tEncodeI64(pEncoder, pRow->version) < 0) return -1;
if (tEncodeBinary(pEncoder, (const uint8_t *)pRow->pRow, pRow->szRow) < 0) return -1;
return 0;
}
static FORCE_INLINE int32_t tsdbDecodeRow(SDecoder *pDecoder, STsdbRow *pRow) {
if (tDecodeI64(pDecoder, &pRow->version) < 0) return -1;
if (tDecodeBinary(pDecoder, (uint8_t **)&pRow->pRow, &pRow->szRow) < 0) return -1;
return 0;
}
static int32_t tsdbMemSkipListCursorCreate(int8_t maxLevel, SMemSkipListCurosr **ppSlc) {
*ppSlc = (SMemSkipListCurosr *)taosMemoryCalloc(1, sizeof(**ppSlc) + sizeof(SMemSkipListNode *) * maxLevel);
if (*ppSlc == NULL) {
return -1;
}
return 0;
}
static void tsdbMemSkipListCursorDestroy(SMemSkipListCurosr *pSlc) { taosMemoryFree(pSlc); }
static
void
memMovePosFrom
(
SMemData
*
pMemData
,
SMemSkipListNode
*
pNode
,
TSDBROW
*
pRow
,
int8_t
isForward
,
SMemSkipListNode
**
pos
)
{
SMemSkipListNode
*
px
=
pNode
;
TSDBKEY
*
pKey
;
SMemSkipListNode
*
p
;
int
c
;
static void tsdbMemSkipListCursorInit(SMemSkipListCurosr *pSlc, SMemSkipList *pSl) {
SMemSkipListNode *pHead = SL_HEAD_NODE(pSl);
pSlc->pSl = pSl;
// for (int8_t iLevel = 0; iLevel < pSl->maxLevel; iLevel++) {
// pSlc->forwards[iLevel] = pHead;
// }
}
static void tsdbMemSkipListCursorPut(SMemSkipListCurosr *pSlc, SMemSkipListNode *pNode) {
SMemSkipList *pSl = pSlc->pSl;
SMemSkipListNode *pNodeNext;
if
(
isForward
)
{
}
else
{
ASSERT
(
pNode
!=
pMemData
->
sl
.
pHead
);
for (int8_t iLevel = 0; iLevel < pNode->level; iLevel++) {
// todo
for
(
int8_t
iLevel
=
pMemData
->
sl
.
maxLevel
-
1
;
iLevel
>=
0
;
iLevel
--
)
{
p
=
SL_NODE_BACKWARD
(
px
,
iLevel
);
while
(
p
!=
pMemData
->
sl
.
pHead
)
{
pKey
=
(
TSDBKEY
*
)
SL_NODE_DATA
(
p
);
ASSERT(0);
c
=
tsdbKeyCmprFn
(
pKey
,
pRow
);
if
(
c
<=
0
)
{
break
;
}
else
{
px
=
p
;
p
=
SL_NODE_BACKWARD
(
px
,
iLevel
);
}
if (pSl->level < pNode->level) {
pSl->level = pNode->level;
}
pSl->size += 1;
}
static int32_t tsdbMemSkipListCursorMoveTo(SMemSkipListCurosr *pSlc, int64_t version, TSKEY ts, int32_t flags) {
SMemSkipListNode **pForwards = NULL;
SMemSkipList *pSl = pSlc->pSl;
int8_t maxLevel = pSl->maxLevel;
SMemSkipListNode *pHead = SL_HEAD_NODE(pSl);
SMemSkipListNode *pTail = SL_TAIL_NODE(pSl);
if (pSl->size == 0) {
for (int8_t iLevel = 0; iLevel < pSl->maxLevel; iLevel++) {
pForwards[iLevel] = pHead;
pos
[
iLevel
]
=
px
;
}
}
return 0;
}
static void tsdbMemSkipListCursorMoveToFirst(SMemSkipListCurosr *pSlc) {
SMemSkipList *pSl = pSlc->pSl;
SMemSkipListNode *pHead = SL_HEAD_NODE(pSl);
for (int8_t iLevel = 0; iLevel < pSl->maxLevel; iLevel++) {
pSlc->pNodes[iLevel] = pHead;
}
tsdbMemSkipListCursorMoveToNext(pSlc);
}
static void tsdbMemSkipListCursorMoveToLast(SMemSkipListCurosr *pSlc) {
SMemSkipList *pSl = pSlc->pSl;
SMemSkipListNode *pTail = SL_TAIL_NODE(pSl);
static
int32_t
memDataPutRow
(
SVBufPool
*
pPool
,
SMemData
*
pMemData
,
TSDBROW
*
pRow
,
int8_t
isForward
,
SMemSkipListNode
**
pos
)
{
int32_t
code
=
0
;
int8_t
level
;
SMemSkipListNode
*
pNode
;
for (int8_t iLevel = 0; iLevel < pSl->maxLevel; iLevel++) {
pSlc->pNodes[iLevel] = pTail;
level
=
tsdbMemSkipListRandLevel
(
&
pMemData
->
sl
);
pNode
=
(
SMemSkipListNode
*
)
vnodeBufPoolMalloc
(
pPool
,
SL_NODE_SIZE
(
level
)
+
tPutTSDBRow
(
NULL
,
pRow
));
if
(
pNode
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_exit
;
}
tsdbMemSkipListCursorMoveToPrev(pSlc);
}
static int32_t tsdbMemSkipListCursorMoveToNext(SMemSkipListCurosr *pSlc) {
// do the read put
if
(
isForward
)
{
// TODO
return 0;
}
static int32_t tsdbMemSkipListCursorMoveToPrev(SMemSkipListCurosr *pSlc) {
}
else
{
// TODO
return 0;
}
static SMemSkipListNode *tsdbMemSkipListNodeCreate(SVBufPool *pPool, SMemSkipList *pSl, const STsdbRow *pTRow) {
int32_t tsize;
int32_t ret;
int8_t level = tsdbMemSkipListRandLevel(pSl);
SMemSkipListNode *pNode = NULL;
SEncoder ec = {0};
tEncodeSize(tsdbEncodeRow, pTRow, tsize, ret);
pNode = vnodeBufPoolMalloc(pPool, tsize + SL_NODE_SIZE(level));
if (pNode) {
pNode->level = level;
tEncoderInit(&ec, (uint8_t *)SL_NODE_DATA(pNode), tsize);
tsdbEncodeRow(&ec, pTRow);
tEncoderClear(&ec);
}
return pNode;
_exit:
return
code
;
}
\ No newline at end of file
#endif
\ No newline at end of file
source/dnode/vnode/src/vnd/vnodeSvr.c
浏览文件 @
5a9ed58b
...
...
@@ -715,8 +715,8 @@ static int vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq, in
goto
_exit
;
}
submitRsp
.
pArray
=
taosArrayInit
(
pSubmitReq
->
numOfBlocks
,
sizeof
(
SSubmitBlkRsp
));
newTbUids
=
taosArrayInit
(
pSubmitReq
->
numOfBlocks
,
sizeof
(
int64_t
));
submitRsp
.
pArray
=
taosArrayInit
(
msgIter
.
numOfBlocks
,
sizeof
(
SSubmitBlkRsp
));
newTbUids
=
taosArrayInit
(
msgIter
.
numOfBlocks
,
sizeof
(
int64_t
));
if
(
!
submitRsp
.
pArray
)
{
pRsp
->
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_exit
;
...
...
source/libs/catalog/inc/catalogInt.h
浏览文件 @
5a9ed58b
...
...
@@ -490,7 +490,7 @@ int32_t ctgGetTbMetaFromMnodeImpl(CTG_PARAMS, char *dbFName, char* tbName, STabl
int32_t
ctgGetTbMetaFromMnode
(
CTG_PARAMS
,
const
SName
*
pTableName
,
STableMetaOutput
*
out
,
SCtgTask
*
pTask
);
int32_t
ctgGetTbMetaFromVnode
(
CTG_PARAMS
,
const
SName
*
pTableName
,
SVgroupInfo
*
vgroupInfo
,
STableMetaOutput
*
out
,
SCtgTask
*
pTask
);
int32_t
ctgInitJob
(
CTG_PARAMS
,
SCtgJob
**
job
,
uint64_t
reqId
,
const
SCatalogReq
*
pReq
,
catalogCallback
fp
,
void
*
param
);
int32_t
ctgInitJob
(
CTG_PARAMS
,
SCtgJob
**
job
,
uint64_t
reqId
,
const
SCatalogReq
*
pReq
,
catalogCallback
fp
,
void
*
param
,
int32_t
*
taskNum
);
int32_t
ctgLaunchJob
(
SCtgJob
*
pJob
);
int32_t
ctgMakeAsyncRes
(
SCtgJob
*
pJob
);
...
...
source/libs/catalog/src/catalog.c
浏览文件 @
5a9ed58b
...
...
@@ -1028,16 +1028,21 @@ int32_t catalogAsyncGetAllMeta(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmt
CTG_API_LEAVE
(
TSDB_CODE_CTG_INVALID_INPUT
);
}
int32_t
code
=
0
;
int32_t
code
=
0
,
taskNum
=
0
;
SCtgJob
*
pJob
=
NULL
;
CTG_ERR_JRET
(
ctgInitJob
(
CTG_PARAMS_LIST
(),
&
pJob
,
reqId
,
pReq
,
fp
,
param
));
CTG_ERR_JRET
(
ctgInitJob
(
CTG_PARAMS_LIST
(),
&
pJob
,
reqId
,
pReq
,
fp
,
param
,
&
taskNum
));
if
(
taskNum
<=
0
)
{
SMetaData
*
pMetaData
=
taosMemoryCalloc
(
1
,
sizeof
(
SMetaData
));
fp
(
pMetaData
,
param
,
TSDB_CODE_SUCCESS
);
CTG_API_LEAVE
(
TSDB_CODE_SUCCESS
);
}
CTG_ERR_JRET
(
ctgLaunchJob
(
pJob
));
*
jobId
=
pJob
->
refId
;
// NOTE: here the assignment of jobId is invalid, may over-write the true scheduler created query job.
// *jobId = pJob->refId;
_return:
if
(
pJob
)
{
taosReleaseRef
(
gCtgMgmt
.
jobPool
,
pJob
->
refId
);
...
...
source/libs/catalog/src/ctgAsync.c
浏览文件 @
5a9ed58b
...
...
@@ -233,7 +233,7 @@ int32_t ctgInitGetUserTask(SCtgJob *pJob, int32_t taskIdx, SUserAuthInfo *user)
}
int32_t
ctgInitJob
(
CTG_PARAMS
,
SCtgJob
**
job
,
uint64_t
reqId
,
const
SCatalogReq
*
pReq
,
catalogCallback
fp
,
void
*
param
)
{
int32_t
ctgInitJob
(
CTG_PARAMS
,
SCtgJob
**
job
,
uint64_t
reqId
,
const
SCatalogReq
*
pReq
,
catalogCallback
fp
,
void
*
param
,
int32_t
*
taskNum
)
{
int32_t
code
=
0
;
int32_t
tbMetaNum
=
(
int32_t
)
taosArrayGetSize
(
pReq
->
pTableMeta
);
int32_t
dbVgNum
=
(
int32_t
)
taosArrayGetSize
(
pReq
->
pDbVgroup
);
...
...
@@ -245,15 +245,15 @@ int32_t ctgInitJob(CTG_PARAMS, SCtgJob** job, uint64_t reqId, const SCatalogReq*
int32_t
userNum
=
(
int32_t
)
taosArrayGetSize
(
pReq
->
pUser
);
int32_t
dbInfoNum
=
(
int32_t
)
taosArrayGetSize
(
pReq
->
pDbInfo
);
int32_t
taskNum
=
tbMetaNum
+
dbVgNum
+
udfNum
+
tbHashNum
+
qnodeNum
+
dbCfgNum
+
indexNum
+
userNum
+
dbInfoNum
;
if
(
taskNum
<=
0
)
{
ctgError
(
"
empty input for job, taskNum:%d"
,
taskNum
);
CTG_ERR_RET
(
TSDB_CODE_CTG_INVALID_INPUT
)
;
*
taskNum
=
tbMetaNum
+
dbVgNum
+
udfNum
+
tbHashNum
+
qnodeNum
+
dbCfgNum
+
indexNum
+
userNum
+
dbInfoNum
;
if
(
*
taskNum
<=
0
)
{
ctgError
(
"
Empty input for job, no need to retrieve meta, reqId:0x%"
PRIx64
,
reqId
);
return
TSDB_CODE_SUCCESS
;
}
*
job
=
taosMemoryCalloc
(
1
,
sizeof
(
SCtgJob
));
if
(
NULL
==
*
job
)
{
ctgError
(
"
calloc %d failed"
,
(
int32_t
)
sizeof
(
SCtgJob
)
);
ctgError
(
"
failed to calloc, size:%d, reqId:0x%"
PRIx64
,
(
int32_t
)
sizeof
(
SCtgJob
),
reqId
);
CTG_ERR_RET
(
TSDB_CODE_OUT_OF_MEMORY
);
}
...
...
@@ -276,51 +276,51 @@ int32_t ctgInitJob(CTG_PARAMS, SCtgJob** job, uint64_t reqId, const SCatalogReq*
pJob
->
userNum
=
userNum
;
pJob
->
dbInfoNum
=
dbInfoNum
;
pJob
->
pTasks
=
taosArrayInit
(
taskNum
,
sizeof
(
SCtgTask
));
pJob
->
pTasks
=
taosArrayInit
(
*
taskNum
,
sizeof
(
SCtgTask
));
if
(
NULL
==
pJob
->
pTasks
)
{
ctgError
(
"taosArrayInit %d tasks failed"
,
taskNum
);
ctgError
(
"taosArrayInit %d tasks failed"
,
*
taskNum
);
CTG_ERR_JRET
(
TSDB_CODE_OUT_OF_MEMORY
);
}
int32_t
taskIdx
=
0
;
for
(
int32_t
i
=
0
;
i
<
dbVgNum
;
++
i
)
{
char
*
dbFName
=
taosArrayGet
(
pReq
->
pDbVgroup
,
i
);
char
*
dbFName
=
taosArrayGet
(
pReq
->
pDbVgroup
,
i
);
CTG_ERR_JRET
(
ctgInitGetDbVgTask
(
pJob
,
taskIdx
++
,
dbFName
));
}
for
(
int32_t
i
=
0
;
i
<
dbCfgNum
;
++
i
)
{
char
*
dbFName
=
taosArrayGet
(
pReq
->
pDbCfg
,
i
);
char
*
dbFName
=
taosArrayGet
(
pReq
->
pDbCfg
,
i
);
CTG_ERR_JRET
(
ctgInitGetDbCfgTask
(
pJob
,
taskIdx
++
,
dbFName
));
}
for
(
int32_t
i
=
0
;
i
<
dbInfoNum
;
++
i
)
{
char
*
dbFName
=
taosArrayGet
(
pReq
->
pDbInfo
,
i
);
char
*
dbFName
=
taosArrayGet
(
pReq
->
pDbInfo
,
i
);
CTG_ERR_JRET
(
ctgInitGetDbInfoTask
(
pJob
,
taskIdx
++
,
dbFName
));
}
for
(
int32_t
i
=
0
;
i
<
tbMetaNum
;
++
i
)
{
SName
*
name
=
taosArrayGet
(
pReq
->
pTableMeta
,
i
);
SName
*
name
=
taosArrayGet
(
pReq
->
pTableMeta
,
i
);
CTG_ERR_JRET
(
ctgInitGetTbMetaTask
(
pJob
,
taskIdx
++
,
name
));
}
for
(
int32_t
i
=
0
;
i
<
tbHashNum
;
++
i
)
{
SName
*
name
=
taosArrayGet
(
pReq
->
pTableHash
,
i
);
SName
*
name
=
taosArrayGet
(
pReq
->
pTableHash
,
i
);
CTG_ERR_JRET
(
ctgInitGetTbHashTask
(
pJob
,
taskIdx
++
,
name
));
}
for
(
int32_t
i
=
0
;
i
<
indexNum
;
++
i
)
{
char
*
indexName
=
taosArrayGet
(
pReq
->
pIndex
,
i
);
char
*
indexName
=
taosArrayGet
(
pReq
->
pIndex
,
i
);
CTG_ERR_JRET
(
ctgInitGetIndexTask
(
pJob
,
taskIdx
++
,
indexName
));
}
for
(
int32_t
i
=
0
;
i
<
udfNum
;
++
i
)
{
char
*
udfName
=
taosArrayGet
(
pReq
->
pUdf
,
i
);
char
*
udfName
=
taosArrayGet
(
pReq
->
pUdf
,
i
);
CTG_ERR_JRET
(
ctgInitGetUdfTask
(
pJob
,
taskIdx
++
,
udfName
));
}
for
(
int32_t
i
=
0
;
i
<
userNum
;
++
i
)
{
SUserAuthInfo
*
user
=
taosArrayGet
(
pReq
->
pUser
,
i
);
SUserAuthInfo
*
user
=
taosArrayGet
(
pReq
->
pUser
,
i
);
CTG_ERR_JRET
(
ctgInitGetUserTask
(
pJob
,
taskIdx
++
,
user
));
}
...
...
@@ -328,22 +328,8 @@ int32_t ctgInitJob(CTG_PARAMS, SCtgJob** job, uint64_t reqId, const SCatalogReq*
CTG_ERR_JRET
(
ctgInitGetQnodeTask
(
pJob
,
taskIdx
++
));
}
pJob
->
refId
=
taosAddRef
(
gCtgMgmt
.
jobPool
,
pJob
);
if
(
pJob
->
refId
<
0
)
{
ctgError
(
"add job to ref failed, error: %s"
,
tstrerror
(
terrno
));
CTG_ERR_JRET
(
terrno
);
}
taosAcquireRef
(
gCtgMgmt
.
jobPool
,
pJob
->
refId
);
qDebug
(
"QID:%"
PRIx64
", job %"
PRIx64
" initialized, task num %d"
,
pJob
->
queryId
,
pJob
->
refId
,
taskNum
);
return
TSDB_CODE_SUCCESS
;
_return:
taosMemoryFreeClear
(
*
job
);
CTG_RET
(
code
);
}
...
...
source/libs/function/src/builtins.c
浏览文件 @
5a9ed58b
...
...
@@ -846,7 +846,7 @@ static int32_t translateConcatImpl(SFunctionNode* pFunc, char* pErrBuf, int32_t
for
(
int32_t
i
=
0
;
i
<
numOfParams
;
++
i
)
{
SNode
*
pPara
=
nodesListGetNode
(
pFunc
->
pParameterList
,
i
);
uint8_t
paraType
=
((
SExprNode
*
)
pPara
)
->
resType
.
type
;
if
(
!
IS_VAR_DATA_TYPE
(
paraType
)
&&
TSDB_DATA_TYPE_NULL
!=
paraType
)
{
if
(
!
IS_VAR_DATA_TYPE
(
paraType
)
&&
!
IS_NULL_TYPE
(
paraType
)
)
{
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
if
(
TSDB_DATA_TYPE_NCHAR
==
paraType
)
{
...
...
@@ -859,6 +859,12 @@ static int32_t translateConcatImpl(SFunctionNode* pFunc, char* pErrBuf, int32_t
uint8_t
paraType
=
((
SExprNode
*
)
pPara
)
->
resType
.
type
;
int32_t
paraBytes
=
((
SExprNode
*
)
pPara
)
->
resType
.
bytes
;
int32_t
factor
=
1
;
if
(
IS_NULL_TYPE
(
paraType
))
{
resultType
=
TSDB_DATA_TYPE_VARCHAR
;
resultBytes
=
0
;
sepBytes
=
0
;
break
;
}
if
(
TSDB_DATA_TYPE_NCHAR
==
resultType
&&
TSDB_DATA_TYPE_VARCHAR
==
paraType
)
{
factor
*=
TSDB_NCHAR_SIZE
;
}
...
...
source/libs/function/src/builtinsimpl.c
浏览文件 @
5a9ed58b
...
...
@@ -1324,13 +1324,11 @@ int32_t minmaxFunctionFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
SMinmaxResInfo
*
pRes
=
GET_ROWCELL_INTERBUF
(
pEntryInfo
);
int32_t
type
=
pCtx
->
input
.
pData
[
0
]
->
info
.
type
;
int32_t
slotId
=
pCtx
->
pExpr
->
base
.
resSchema
.
slotId
;
int32_t
currentRow
=
pBlock
->
info
.
rows
;
SColumnInfoData
*
pCol
=
taosArrayGet
(
pBlock
->
pDataBlock
,
slotId
);
// todo assign the tag value
int32_t
currentRow
=
pBlock
->
info
.
rows
;
pEntryInfo
->
isNullRes
=
(
pEntryInfo
->
numOfRes
==
0
);
if
(
pCol
->
info
.
type
==
TSDB_DATA_TYPE_FLOAT
)
{
float
v
=
*
(
double
*
)
&
pRes
->
v
;
...
...
@@ -1339,7 +1337,10 @@ int32_t minmaxFunctionFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
colDataAppend
(
pCol
,
currentRow
,
(
const
char
*
)
&
pRes
->
v
,
pEntryInfo
->
isNullRes
);
}
if
(
pEntryInfo
->
numOfRes
>
0
)
{
setSelectivityValue
(
pCtx
,
pBlock
,
&
pRes
->
tuplePos
,
currentRow
);
}
return
pEntryInfo
->
numOfRes
;
}
...
...
source/libs/index/src/indexFilter.c
浏览文件 @
5a9ed58b
...
...
@@ -265,23 +265,24 @@ static int32_t sifExecFunction(SFunctionNode *node, SIFCtx *ctx, SIFParam *outpu
typedef
int
(
*
Filter
)(
void
*
a
,
void
*
b
,
int16_t
dtype
);
int
sifGreaterThan
(
void
*
a
,
void
*
b
,
int16_t
dtype
)
{
__compar_fn_t
func
=
indexGetCompar
(
dtype
);
__compar_fn_t
func
=
getComparFunc
(
dtype
,
0
);
return
tDoCompare
(
func
,
QUERY_GREATER_THAN
,
a
,
b
);
}
int
sifGreaterEqual
(
void
*
a
,
void
*
b
,
int16_t
dtype
)
{
__compar_fn_t
func
=
indexGetCompar
(
dtype
);
__compar_fn_t
func
=
getComparFunc
(
dtype
,
0
);
return
tDoCompare
(
func
,
QUERY_GREATER_EQUAL
,
a
,
b
);
}
int
sifLessEqual
(
void
*
a
,
void
*
b
,
int16_t
dtype
)
{
__compar_fn_t
func
=
indexGetCompar
(
dtype
);
__compar_fn_t
func
=
getComparFunc
(
dtype
,
0
);
return
tDoCompare
(
func
,
QUERY_LESS_EQUAL
,
a
,
b
);
}
int
sifLessThan
(
void
*
a
,
void
*
b
,
int16_t
dtype
)
{
__compar_fn_t
func
=
indexGetCompar
(
dtype
);
__compar_fn_t
func
=
getComparFunc
(
dtype
,
0
);
return
(
int
)
tDoCompare
(
func
,
QUERY_LESS_THAN
,
a
,
b
);
}
int
sifEqual
(
void
*
a
,
void
*
b
,
int16_t
dtype
)
{
__compar_fn_t
func
=
indexGetCompar
(
dtype
);
__compar_fn_t
func
=
getComparFunc
(
dtype
,
0
);
//__compar_fn_t func = indexGetCompar(dtype);
return
(
int
)
tDoCompare
(
func
,
QUERY_TERM
,
a
,
b
);
}
static
Filter
sifGetFilterFunc
(
EIndexQueryType
type
,
bool
*
reverse
)
{
...
...
@@ -397,38 +398,62 @@ static int32_t sifDefaultFunc(SIFParam *left, SIFParam *right, SIFParam *output)
return
TSDB_CODE_QRY_INVALID_INPUT
;
}
static
sif_func_t
sifGetOperFn
(
int32_t
funcId
)
{
static
int32_t
sifGetOperFn
(
int32_t
funcId
,
sif_func_t
*
func
,
SIdxFltStatus
*
status
)
{
// impl later
*
status
=
SFLT_ACCURATE_INDEX
;
switch
(
funcId
)
{
case
OP_TYPE_GREATER_THAN
:
return
sifGreaterThanFunc
;
*
func
=
sifGreaterThanFunc
;
return
0
;
case
OP_TYPE_GREATER_EQUAL
:
return
sifGreaterEqualFunc
;
*
func
=
sifGreaterEqualFunc
;
return
0
;
case
OP_TYPE_LOWER_THAN
:
return
sifLessThanFunc
;
*
func
=
sifLessThanFunc
;
return
0
;
case
OP_TYPE_LOWER_EQUAL
:
return
sifLessEqualFunc
;
*
func
=
sifLessEqualFunc
;
return
0
;
case
OP_TYPE_EQUAL
:
return
sifEqualFunc
;
*
func
=
sifEqualFunc
;
return
0
;
case
OP_TYPE_NOT_EQUAL
:
return
sifNotEqualFunc
;
*
status
=
SFLT_NOT_INDEX
;
*
func
=
sifNotEqualFunc
;
return
0
;
case
OP_TYPE_IN
:
return
sifInFunc
;
*
status
=
SFLT_NOT_INDEX
;
*
func
=
sifInFunc
;
return
0
;
case
OP_TYPE_NOT_IN
:
return
sifNotInFunc
;
*
status
=
SFLT_NOT_INDEX
;
*
func
=
sifNotInFunc
;
return
0
;
case
OP_TYPE_LIKE
:
return
sifLikeFunc
;
*
status
=
SFLT_NOT_INDEX
;
*
func
=
sifLikeFunc
;
return
0
;
case
OP_TYPE_NOT_LIKE
:
return
sifNotLikeFunc
;
*
status
=
SFLT_NOT_INDEX
;
*
func
=
sifNotLikeFunc
;
return
0
;
case
OP_TYPE_MATCH
:
return
sifMatchFunc
;
*
status
=
SFLT_NOT_INDEX
;
*
func
=
sifMatchFunc
;
return
0
;
case
OP_TYPE_NMATCH
:
return
sifNotMatchFunc
;
*
status
=
SFLT_NOT_INDEX
;
*
func
=
sifNotMatchFunc
;
return
0
;
default:
return
sifNullFunc
;
*
status
=
SFLT_NOT_INDEX
;
*
func
=
sifNullFunc
;
return
0
;
}
return
sifNullFunc
;
return
0
;
}
// typedef struct filterFuncDict {
static
int32_t
sifExecOper
(
SOperatorNode
*
node
,
SIFCtx
*
ctx
,
SIFParam
*
output
)
{
int32_t
code
=
0
;
int32_t
nParam
=
sifGetOperParamNum
(
node
->
opType
);
...
...
@@ -441,18 +466,14 @@ static int32_t sifExecOper(SOperatorNode *node, SIFCtx *ctx, SIFParam *output) {
// ugly code, refactor later
output
->
arg
=
ctx
->
arg
;
sif_func_t
operFn
=
sifGetOperFn
(
node
->
opType
);
if
(
ctx
->
noExec
&&
operFn
==
NULL
)
{
output
->
status
=
SFLT_NOT_INDEX
;
}
else
{
output
->
status
=
SFLT_ACCURATE_INDEX
;
}
sif_func_t
operFn
=
sifNullFunc
;
code
=
sifGetOperFn
(
node
->
opType
,
&
operFn
,
&
output
->
status
);
if
(
ctx
->
noExec
)
{
SIF_RET
(
code
);
}
}
else
{
return
operFn
(
&
params
[
0
],
nParam
>
1
?
&
params
[
1
]
:
NULL
,
output
);
}
_return:
taosMemoryFree
(
params
);
SIF_RET
(
code
);
...
...
@@ -477,7 +498,7 @@ static int32_t sifExecLogic(SLogicConditionNode *node, SIFCtx *ctx, SIFParam *ou
}
else
if
(
node
->
condType
==
LOGIC_COND_TYPE_OR
)
{
taosArrayAddAll
(
output
->
result
,
params
[
m
].
result
);
}
else
if
(
node
->
condType
==
LOGIC_COND_TYPE_NOT
)
{
taosArrayAddAll
(
output
->
result
,
params
[
m
].
result
);
//
taosArrayAddAll(output->result, params[m].result);
}
}
}
else
{
...
...
source/libs/index/test/CMakeLists.txt
浏览文件 @
5a9ed58b
...
...
@@ -92,16 +92,14 @@ target_link_libraries (idxJsonUT
index
)
if
(
NOT TD_WINDOWS
)
add_test
(
add_test
(
NAME idxtest
COMMAND idxTest
)
add_test
(
)
add_test
(
NAME idxJsonUT
COMMAND idxJsonUT
)
endif
(
NOT TD_WINDOWS
)
)
add_test
(
NAME idxUtilUT
COMMAND idxUtilUT
...
...
source/libs/parser/src/parAstParser.c
浏览文件 @
5a9ed58b
...
...
@@ -124,6 +124,10 @@ static EDealRes collectMetaKeyFromRealTable(SCollectMetaKeyFromExprCxt* pCxt, SR
pCxt
->
errCode
=
reserveUserAuthInCache
(
pCxt
->
pComCxt
->
pParseCxt
->
acctId
,
pCxt
->
pComCxt
->
pParseCxt
->
pUser
,
pRealTable
->
table
.
dbName
,
AUTH_TYPE_READ
,
pCxt
->
pComCxt
->
pMetaCache
);
}
if
(
TSDB_CODE_SUCCESS
==
pCxt
->
errCode
)
{
pCxt
->
errCode
=
reserveDbVgInfoInCache
(
pCxt
->
pComCxt
->
pParseCxt
->
acctId
,
pRealTable
->
table
.
dbName
,
pCxt
->
pComCxt
->
pMetaCache
);
}
return
TSDB_CODE_SUCCESS
==
pCxt
->
errCode
?
DEAL_RES_CONTINUE
:
DEAL_RES_ERROR
;
}
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
5a9ed58b
...
...
@@ -2857,7 +2857,6 @@ static int32_t buildRollupAst(STranslateContext* pCxt, SCreateTableStmt* pStmt,
int32_t
code
=
getDBCfg
(
pCxt
,
pStmt
->
dbName
,
&
dbCfg
);
int32_t
num
=
taosArrayGetSize
(
dbCfg
.
pRetensions
);
if
(
TSDB_CODE_SUCCESS
!=
code
||
num
<
2
)
{
taosArrayDestroy
(
dbCfg
.
pRetensions
);
return
code
;
}
for
(
int32_t
i
=
1
;
i
<
num
;
++
i
)
{
...
...
@@ -5038,9 +5037,6 @@ int32_t translate(SParseContext* pParseCxt, SQuery* pQuery) {
STranslateContext
cxt
=
{
0
};
int32_t
code
=
initTranslateContext
(
pParseCxt
,
pQuery
->
pMetaCache
,
&
cxt
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
fmFuncMgtInit
();
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
rewriteQuery
(
&
cxt
,
pQuery
);
}
...
...
source/libs/parser/test/parSelectTest.cpp
浏览文件 @
5a9ed58b
...
...
@@ -33,6 +33,8 @@ TEST_F(ParserSelectTest, basic) {
run
(
"SELECT ts, t.c1 FROM (SELECT * FROM t1) t"
);
run
(
"SELECT * FROM t1 tt1, t1 tt2 WHERE tt1.c1 = tt2.c1"
);
run
(
"SELECT * FROM st1"
);
}
TEST_F
(
ParserSelectTest
,
constant
)
{
...
...
source/libs/parser/test/parTestMain.cpp
浏览文件 @
5a9ed58b
...
...
@@ -35,6 +35,7 @@ namespace ParserTest {
class
ParserEnv
:
public
testing
::
Environment
{
public:
virtual
void
SetUp
()
{
fmFuncMgtInit
();
initMetaDataEnv
();
generateMetaData
();
initLog
(
TD_TMP_DIR_PATH
"td"
);
...
...
source/libs/planner/test/CMakeLists.txt
浏览文件 @
5a9ed58b
...
...
@@ -32,9 +32,9 @@ if(${BUILD_WINGETOPT})
target_link_libraries
(
plannerTest PUBLIC wingetopt
)
endif
()
if
(
NOT TD_WINDOWS
)
#
if(NOT TD_WINDOWS)
add_test
(
NAME plannerTest
COMMAND plannerTest
)
endif
(
NOT TD_WINDOWS
)
#
endif(NOT TD_WINDOWS)
source/libs/planner/test/planTestMain.cpp
浏览文件 @
5a9ed58b
...
...
@@ -16,6 +16,7 @@
#include <string>
#include <gtest/gtest.h>
#include "functionMgt.h"
#include "getopt.h"
#include "mockCatalog.h"
#include "planTestUtil.h"
...
...
@@ -23,6 +24,7 @@
class
PlannerEnv
:
public
testing
::
Environment
{
public:
virtual
void
SetUp
()
{
fmFuncMgtInit
();
initMetaDataEnv
();
generateMetaData
();
initLog
(
TD_TMP_DIR_PATH
"td"
);
...
...
source/libs/qworker/test/qworkerTests.cpp
浏览文件 @
5a9ed58b
...
...
@@ -172,8 +172,7 @@ int32_t qwtPutReqToFetchQueue(void *node, struct SRpcMsg *pMsg) {
return
0
;
}
int32_t
qwtPutReqToQueue
(
void
*
node
,
struct
SRpcMsg
*
pMsg
)
{
int32_t
qwtPutReqToQueue
(
void
*
node
,
EQueueType
qtype
,
struct
SRpcMsg
*
pMsg
)
{
taosWLockLatch
(
&
qwtTestQueryQueueLock
);
struct
SRpcMsg
*
newMsg
=
(
struct
SRpcMsg
*
)
taosMemoryCalloc
(
1
,
sizeof
(
struct
SRpcMsg
));
memcpy
(
newMsg
,
pMsg
,
sizeof
(
struct
SRpcMsg
));
...
...
@@ -704,7 +703,7 @@ void *qwtclientThread(void *param) {
qwtTestCaseFinished
=
false
;
qwtBuildQueryReqMsg
(
&
queryRpc
);
qwtPutReqToQueue
((
void
*
)
0x1
,
&
queryRpc
);
qwtPutReqToQueue
((
void
*
)
0x1
,
QUERY_QUEUE
,
&
queryRpc
);
while
(
!
qwtTestCaseFinished
)
{
taosUsleep
(
1
);
...
...
@@ -874,7 +873,7 @@ TEST(seqTest, normalCase) {
SMsgCb
msgCb
=
{
0
};
msgCb
.
mgmt
=
(
void
*
)
mockPointer
;
msgCb
.
queueFps
[
QUERY_QUEUE
]
=
(
PutToQueueFp
)
qwtPutReqToQueue
;
msgCb
.
putToQueueFp
=
(
PutToQueueFp
)
qwtPutReqToQueue
;
code
=
qWorkerInit
(
NODE_TYPE_VNODE
,
1
,
NULL
,
&
mgmt
,
&
msgCb
);
ASSERT_EQ
(
code
,
0
);
...
...
@@ -910,7 +909,7 @@ TEST(seqTest, cancelFirst) {
SMsgCb
msgCb
=
{
0
};
msgCb
.
mgmt
=
(
void
*
)
mockPointer
;
msgCb
.
queueFps
[
QUERY_QUEUE
]
=
(
PutToQueueFp
)
qwtPutReqToQueue
;
msgCb
.
putToQueueFp
=
(
PutToQueueFp
)
qwtPutReqToQueue
;
code
=
qWorkerInit
(
NODE_TYPE_VNODE
,
1
,
NULL
,
&
mgmt
,
&
msgCb
);
ASSERT_EQ
(
code
,
0
);
...
...
@@ -947,7 +946,7 @@ TEST(seqTest, randCase) {
SMsgCb
msgCb
=
{
0
};
msgCb
.
mgmt
=
(
void
*
)
mockPointer
;
msgCb
.
queueFps
[
QUERY_QUEUE
]
=
(
PutToQueueFp
)
qwtPutReqToQueue
;
msgCb
.
putToQueueFp
=
(
PutToQueueFp
)
qwtPutReqToQueue
;
code
=
qWorkerInit
(
NODE_TYPE_VNODE
,
1
,
NULL
,
&
mgmt
,
&
msgCb
);
ASSERT_EQ
(
code
,
0
);
...
...
@@ -1018,7 +1017,7 @@ TEST(seqTest, multithreadRand) {
SMsgCb
msgCb
=
{
0
};
msgCb
.
mgmt
=
(
void
*
)
mockPointer
;
msgCb
.
queueFps
[
QUERY_QUEUE
]
=
(
PutToQueueFp
)
qwtPutReqToQueue
;
msgCb
.
putToQueueFp
=
(
PutToQueueFp
)
qwtPutReqToQueue
;
code
=
qWorkerInit
(
NODE_TYPE_VNODE
,
1
,
NULL
,
&
mgmt
,
&
msgCb
);
ASSERT_EQ
(
code
,
0
);
...
...
@@ -1081,7 +1080,7 @@ TEST(rcTest, shortExecshortDelay) {
SMsgCb
msgCb
=
{
0
};
msgCb
.
mgmt
=
(
void
*
)
mockPointer
;
msgCb
.
queueFps
[
QUERY_QUEUE
]
=
(
PutToQueueFp
)
qwtPutReqToQueue
;
msgCb
.
putToQueueFp
=
(
PutToQueueFp
)
qwtPutReqToQueue
;
code
=
qWorkerInit
(
NODE_TYPE_VNODE
,
1
,
NULL
,
&
mgmt
,
&
msgCb
);
ASSERT_EQ
(
code
,
0
);
...
...
@@ -1165,7 +1164,7 @@ TEST(rcTest, longExecshortDelay) {
SMsgCb
msgCb
=
{
0
};
msgCb
.
mgmt
=
(
void
*
)
mockPointer
;
msgCb
.
queueFps
[
QUERY_QUEUE
]
=
(
PutToQueueFp
)
qwtPutReqToQueue
;
msgCb
.
putToQueueFp
=
(
PutToQueueFp
)
qwtPutReqToQueue
;
code
=
qWorkerInit
(
NODE_TYPE_VNODE
,
1
,
NULL
,
&
mgmt
,
&
msgCb
);
ASSERT_EQ
(
code
,
0
);
...
...
@@ -1251,7 +1250,7 @@ TEST(rcTest, shortExeclongDelay) {
SMsgCb
msgCb
=
{
0
};
msgCb
.
mgmt
=
(
void
*
)
mockPointer
;
msgCb
.
queueFps
[
QUERY_QUEUE
]
=
(
PutToQueueFp
)
qwtPutReqToQueue
;
msgCb
.
putToQueueFp
=
(
PutToQueueFp
)
qwtPutReqToQueue
;
code
=
qWorkerInit
(
NODE_TYPE_VNODE
,
1
,
NULL
,
&
mgmt
,
&
msgCb
);
ASSERT_EQ
(
code
,
0
);
...
...
@@ -1335,7 +1334,7 @@ TEST(rcTest, dropTest) {
SMsgCb
msgCb
=
{
0
};
msgCb
.
mgmt
=
(
void
*
)
mockPointer
;
msgCb
.
queueFps
[
QUERY_QUEUE
]
=
(
PutToQueueFp
)
qwtPutReqToQueue
;
msgCb
.
putToQueueFp
=
(
PutToQueueFp
)
qwtPutReqToQueue
;
code
=
qWorkerInit
(
NODE_TYPE_VNODE
,
1
,
NULL
,
&
mgmt
,
&
msgCb
);
ASSERT_EQ
(
code
,
0
);
...
...
source/libs/scalar/src/sclfunc.c
浏览文件 @
5a9ed58b
...
...
@@ -449,7 +449,7 @@ int32_t concatFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu
bool
hasNull
=
false
;
for
(
int32_t
i
=
0
;
i
<
inputNum
;
++
i
)
{
if
(
colDataIsNull_s
(
pInputData
[
i
],
k
)
||
GET_PARAM_TYPE
(
&
pInput
[
i
])
==
TSDB_DATA_TYPE_NULL
)
{
IS_NULL_TYPE
(
GET_PARAM_TYPE
(
&
pInput
[
i
]))
)
{
colDataAppendNULL
(
pOutputData
,
k
);
hasNull
=
true
;
break
;
...
...
@@ -526,7 +526,7 @@ int32_t concatWsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p
for
(
int32_t
k
=
0
;
k
<
numOfRows
;
++
k
)
{
if
(
colDataIsNull_s
(
pInputData
[
0
],
k
)
||
GET_PARAM_TYPE
(
&
pInput
[
0
])
==
TSDB_DATA_TYPE_NULL
)
{
IS_NULL_TYPE
(
GET_PARAM_TYPE
(
&
pInput
[
0
]))
)
{
colDataAppendNULL
(
pOutputData
,
k
);
continue
;
}
...
...
@@ -535,7 +535,7 @@ int32_t concatWsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p
bool
hasNull
=
false
;
for
(
int32_t
i
=
1
;
i
<
inputNum
;
++
i
)
{
if
(
colDataIsNull_s
(
pInputData
[
i
],
k
)
||
GET_PARAM_TYPE
(
&
pInput
[
i
])
==
TSDB_DATA_TYPE_NULL
)
{
IS_NULL_TYPE
(
GET_PARAM_TYPE
(
&
pInput
[
i
]))
)
{
hasNull
=
true
;
break
;
}
...
...
@@ -718,7 +718,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp
int16_t
outputType
=
GET_PARAM_TYPE
(
&
pOutput
[
0
]);
int64_t
outputLen
=
GET_PARAM_BYTES
(
&
pOutput
[
0
]);
char
*
outputBuf
=
taosMemoryCalloc
(
outputLen
*
pInput
[
0
].
numOfRows
,
1
);
char
*
outputBuf
=
taosMemoryCalloc
(
outputLen
*
pInput
[
0
].
numOfRows
+
1
,
1
);
char
*
output
=
outputBuf
;
for
(
int32_t
i
=
0
;
i
<
pInput
[
0
].
numOfRows
;
++
i
)
{
...
...
@@ -1221,8 +1221,8 @@ int32_t timeDiffFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p
if
(
IS_VAR_DATA_TYPE
(
type
))
{
/* datetime format strings */
int32_t
ret
=
convertStringToTimestamp
(
type
,
input
[
k
],
TSDB_TIME_PRECISION_NANO
,
&
timeVal
[
k
]);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
colDataAppendNULL
(
pOutput
->
columnData
,
i
)
;
continue
;
hasNull
=
true
;
break
;
}
}
else
if
(
type
==
TSDB_DATA_TYPE_BIGINT
||
type
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
/* unix timestamp or ts column*/
GET_TYPED_DATA
(
timeVal
[
k
],
int64_t
,
type
,
input
[
k
]);
...
...
@@ -1247,8 +1247,8 @@ int32_t timeDiffFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p
}
else
if
(
tsDigits
==
TSDB_TIME_PRECISION_NANO_DIGITS
)
{
timeVal
[
k
]
=
timeVal
[
k
];
}
else
{
colDataAppendNULL
(
pOutput
->
columnData
,
i
)
;
continue
;
hasNull
=
true
;
break
;
}
}
}
...
...
source/libs/scheduler/src/schDbg.c
浏览文件 @
5a9ed58b
...
...
@@ -30,13 +30,4 @@ void schdExecCallback(SQueryResult* pResult, void* param, int32_t code) {
tsem_post
(
&
schdRspSem
);
}
void
schdFetchCallback
(
void
*
pResult
,
void
*
param
,
int32_t
code
)
{
SSchdFetchParam
*
fParam
=
(
SSchdFetchParam
*
)
param
;
*
fParam
->
pData
=
pResult
;
*
fParam
->
code
=
code
;
tsem_post
(
&
schdRspSem
);
}
source/libs/scheduler/src/schJob.c
浏览文件 @
5a9ed58b
...
...
@@ -21,9 +21,9 @@
#include "tref.h"
#include "trpc.h"
FORCE_INLINE
SSchJob
*
schAcquireJob
(
int64_t
refId
)
{
return
(
SSchJob
*
)
taosAcquireRef
(
schMgmt
.
jobRef
,
refId
);
}
FORCE_INLINE
SSchJob
*
schAcquireJob
(
int64_t
refId
)
{
qDebug
(
"acquire jobId:0x%"
PRIx64
,
refId
);
return
(
SSchJob
*
)
taosAcquireRef
(
schMgmt
.
jobRef
,
refId
);
}
FORCE_INLINE
int32_t
schReleaseJob
(
int64_t
refId
)
{
return
taosReleaseRef
(
schMgmt
.
jobRef
,
refId
);
}
FORCE_INLINE
int32_t
schReleaseJob
(
int64_t
refId
)
{
qDebug
(
"release jobId:0x%"
PRIx64
,
refId
);
return
taosReleaseRef
(
schMgmt
.
jobRef
,
refId
);
}
int32_t
schInitTask
(
SSchJob
*
pJob
,
SSchTask
*
pTask
,
SSubplan
*
pPlan
,
SSchLevel
*
pLevel
)
{
pTask
->
plan
=
pPlan
;
...
...
@@ -1365,8 +1365,6 @@ void schFreeJobImpl(void *job) {
int32_t
schExecJobImpl
(
void
*
pTrans
,
SArray
*
pNodeList
,
SQueryPlan
*
pDag
,
int64_t
*
job
,
const
char
*
sql
,
SSchResInfo
*
pRes
,
int64_t
startTs
,
bool
sync
)
{
qDebug
(
"QID:0x%"
PRIx64
" job started"
,
pDag
->
queryId
);
if
(
pNodeList
==
NULL
||
taosArrayGetSize
(
pNodeList
)
<=
0
)
{
qDebug
(
"QID:0x%"
PRIx64
" input exec nodeList is empty"
,
pDag
->
queryId
);
}
...
...
@@ -1375,6 +1373,7 @@ int32_t schExecJobImpl(void *pTrans, SArray *pNodeList, SQueryPlan *pDag, int64_
SSchJob
*
pJob
=
NULL
;
SCH_ERR_RET
(
schInitJob
(
&
pJob
,
pDag
,
pTrans
,
pNodeList
,
sql
,
pRes
,
startTs
,
sync
));
qDebug
(
"QID:0x%"
PRIx64
" jobId:0x%"
PRIx64
" started"
,
pDag
->
queryId
,
pJob
->
refId
);
*
job
=
pJob
->
refId
;
SCH_ERR_JRET
(
schLaunchJob
(
pJob
));
...
...
@@ -1386,7 +1385,7 @@ int32_t schExecJobImpl(void *pTrans, SArray *pNodeList, SQueryPlan *pDag, int64_
pJob
->
userCb
=
SCH_EXEC_CB
;
}
SCH_JOB_DLOG
(
"job exec done, job status:%s
"
,
SCH_GET_JOB_STATUS_STR
(
pJob
)
);
SCH_JOB_DLOG
(
"job exec done, job status:%s
, jobId:0x%"
PRIx64
,
SCH_GET_JOB_STATUS_STR
(
pJob
),
pJob
->
refId
);
_return:
...
...
source/libs/scheduler/src/scheduler.c
浏览文件 @
5a9ed58b
...
...
@@ -79,12 +79,19 @@ int32_t schedulerExecJob(void *pTrans, SArray *pNodeList, SQueryPlan *pDag, int6
int32_t
schedulerAsyncExecJob
(
void
*
pTrans
,
SArray
*
pNodeList
,
SQueryPlan
*
pDag
,
int64_t
*
pJob
,
const
char
*
sql
,
int64_t
startTs
,
schedulerExecCallback
fp
,
void
*
param
)
{
if
(
NULL
==
pTrans
||
NULL
==
pDag
||
NULL
==
pDag
->
pSubplans
||
NULL
==
pJob
||
NULL
==
fp
||
NULL
==
param
)
{
SCH_ERR_RET
(
TSDB_CODE_QRY_INVALID_INPUT
);
int32_t
code
=
0
;
if
(
NULL
==
pTrans
||
NULL
==
pDag
||
NULL
==
pDag
->
pSubplans
||
NULL
==
pJob
||
NULL
==
fp
)
{
code
=
TSDB_CODE_QRY_INVALID_INPUT
;
}
else
{
SSchResInfo
resInfo
=
{.
execFp
=
fp
,
.
userParam
=
param
};
code
=
schAsyncExecJob
(
pTrans
,
pNodeList
,
pDag
,
pJob
,
sql
,
startTs
,
&
resInfo
);
}
SSchResInfo
resInfo
=
{.
execFp
=
fp
,
.
userParam
=
param
};
SCH_RET
(
schAsyncExecJob
(
pTrans
,
pNodeList
,
pDag
,
pJob
,
sql
,
startTs
,
&
resInfo
));
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
fp
(
NULL
,
param
,
code
);
}
return
code
;
}
int32_t
schedulerFetchRows
(
int64_t
job
,
void
**
pData
)
{
...
...
@@ -95,7 +102,7 @@ int32_t schedulerFetchRows(int64_t job, void **pData) {
int32_t
code
=
0
;
SSchJob
*
pJob
=
schAcquireJob
(
job
);
if
(
NULL
==
pJob
)
{
qError
(
"acquire job from jobRef list failed, may be dropped,
refId:
%"
PRIx64
,
job
);
qError
(
"acquire job from jobRef list failed, may be dropped,
jobId:0x
%"
PRIx64
,
job
);
SCH_ERR_RET
(
TSDB_CODE_SCH_STATUS_ERROR
);
}
...
...
@@ -108,27 +115,26 @@ int32_t schedulerFetchRows(int64_t job, void **pData) {
SCH_RET
(
code
);
}
int32_t
schedulerAsyncFetchRows
(
int64_t
job
,
schedulerFetchCallback
fp
,
void
*
param
)
{
void
schedulerAsyncFetchRows
(
int64_t
job
,
schedulerFetchCallback
fp
,
void
*
param
)
{
if
(
NULL
==
fp
||
NULL
==
param
)
{
SCH_ERR_RET
(
TSDB_CODE_QRY_INVALID_INPUT
);
fp
(
NULL
,
param
,
TSDB_CODE_QRY_INVALID_INPUT
);
return
;
}
int32_t
code
=
0
;
SSchJob
*
pJob
=
schAcquireJob
(
job
);
if
(
NULL
==
pJob
)
{
qError
(
"acquire job from jobRef list failed, may be dropped, refId:%"
PRIx64
,
job
);
SCH_ERR_RET
(
TSDB_CODE_SCH_STATUS_ERROR
);
qError
(
"acquire job from jobRef list failed, may be dropped, jobId:0x%"
PRIx64
,
job
);
fp
(
NULL
,
param
,
TSDB_CODE_SCH_STATUS_ERROR
);
return
;
}
pJob
->
attr
.
syncSchedule
=
false
;
pJob
->
userRes
.
fetchFp
=
fp
;
pJob
->
userRes
.
userParam
=
param
;
code
=
schAsyncFetchRows
(
pJob
);
/*code = */
schAsyncFetchRows
(
pJob
);
schReleaseJob
(
job
);
SCH_RET
(
code
);
}
int32_t
schedulerGetTasksStatus
(
int64_t
job
,
SArray
*
pSub
)
{
...
...
@@ -165,7 +171,7 @@ _return:
int32_t
scheduleCancelJob
(
int64_t
job
)
{
SSchJob
*
pJob
=
schAcquireJob
(
job
);
if
(
NULL
==
pJob
)
{
qError
(
"acquire job from jobRef list failed, may be dropped,
refId:
%"
PRIx64
,
job
);
qError
(
"acquire job from jobRef list failed, may be dropped,
jobId:0x
%"
PRIx64
,
job
);
SCH_ERR_RET
(
TSDB_CODE_SCH_STATUS_ERROR
);
}
...
...
@@ -179,7 +185,7 @@ int32_t scheduleCancelJob(int64_t job) {
void
schedulerFreeJob
(
int64_t
job
)
{
SSchJob
*
pJob
=
schAcquireJob
(
job
);
if
(
NULL
==
pJob
)
{
q
Debug
(
"acquire job from jobRef list failed, may be dropped, refId:
%"
PRIx64
,
job
);
q
Error
(
"acquire job from jobRef list failed, may be dropped, jobId:0x
%"
PRIx64
,
job
);
return
;
}
...
...
source/libs/transport/src/transCli.c
浏览文件 @
5a9ed58b
...
...
@@ -1151,7 +1151,6 @@ void transSetDefaultAddr(void* ahandle, const char* ip, const char* fqdn) {
SCliThrdObj
*
thrd
=
((
SCliObj
*
)
pTransInst
->
tcphandle
)
->
pThreadObj
[
i
];
tDebug
(
"update epset at thread:%d, threadID:%"
PRId64
""
,
i
,
thrd
->
thread
);
tsem_t
*
pSem
=
pCtx
->
pSem
;
transSendAsync
(
thrd
->
asyncPool
,
&
(
cliMsg
->
q
));
}
}
...
...
tests/pytest/util/dnodes.py
浏览文件 @
5a9ed58b
...
...
@@ -247,7 +247,7 @@ class TDDnode:
if
bool
(
updatecfgDict
)
and
updatecfgDict
[
0
]
and
updatecfgDict
[
0
][
0
]:
print
(
updatecfgDict
[
0
][
0
])
for
key
,
value
in
updatecfgDict
[
0
][
0
].
items
():
if
key
==
"clientCfg"
:
if
key
==
"clientCfg"
and
self
.
remoteIP
==
""
and
not
platform
.
system
().
lower
()
==
'windows'
:
continue
if
value
==
'dataDir'
:
if
isFirstDir
:
...
...
tests/script/jenkins/basic.txt
浏览文件 @
5a9ed58b
...
...
@@ -58,7 +58,7 @@
./test.sh -f tsim/mnode/basic1.sim
./test.sh -f tsim/mnode/basic2.sim
./test.sh -f tsim/mnode/basic3.sim
#
./test.sh -f tsim/mnode/basic4.sim
./test.sh -f tsim/mnode/basic4.sim
# ---- show
./test.sh -f tsim/show/basic.sim
...
...
@@ -135,6 +135,7 @@
./test.sh -f tsim/sync/3Replica5VgElect.sim
./test.sh -f tsim/sync/oneReplica1VgElect.sim
./test.sh -f tsim/sync/oneReplica5VgElect.sim
# ./test.sh -f tsim/sync/3Replica5VgElect3mnode.sim
# --- catalog
./test.sh -f tsim/catalog/alterInCurrent.sim
...
...
tests/script/tsim/db/alter_replica_13.sim
浏览文件 @
5a9ed58b
...
...
@@ -128,7 +128,6 @@ if $data[0][8] != follower then
endi
print ============= step5: stop dnode 2
return
sql select * from db.stb
if $rows != 1 then
...
...
tests/script/tsim/db/alter_replica_31.sim
0 → 100644
浏览文件 @
5a9ed58b
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/deploy.sh -n dnode2 -i 2
system sh/deploy.sh -n dnode3 -i 3
system sh/deploy.sh -n dnode4 -i 4
system sh/exec.sh -n dnode1 -s start
system sh/exec.sh -n dnode2 -s start
system sh/exec.sh -n dnode3 -s start
system sh/exec.sh -n dnode4 -s start
sql connect
print =============== step1: create dnodes
sql create dnode $hostname port 7200
sql create dnode $hostname port 7300
sql create dnode $hostname port 7400
$x = 0
step1:
$x = $x + 1
sleep 1000
if $x == 10 then
print ====> dnode not ready!
return -1
endi
sql show dnodes
print ===> rows: $rows
print ===> $data00 $data01 $data02 $data03 $data04 $data05
print ===> $data10 $data11 $data12 $data13 $data14 $data15
print ===> $data20 $data21 $data22 $data23 $data24 $data25
print ===> $data30 $data31 $data32 $data33 $data24 $data35
if $rows != 4 then
return -1
endi
if $data(1)[4] != ready then
goto step1
endi
if $data(2)[4] != ready then
goto step1
endi
if $data(3)[4] != ready then
goto step1
endi
if $data(4)[4] != ready then
goto step1
endi
print =============== step2: create database
sql create database db vgroups 1 replica 3
sql show databases
if $rows != 3 then
return -1
endi
if $data(db)[4] != 3 then
return -1
endi
sql show dnodes
if $data(2)[2] != 1 then
return -1
endi
if $data(3)[2] != 1 then
return -1
endi
if $data(4)[2] != 1 then
return -1
endi
# vnodes
sql show dnodes
if $data(2)[2] != 1 then
return -1
endi
if $data(3)[2] != 1 then
return -1
endi
if $data(4)[2] != 1 then
return -1
endi
# v1_dnode
sql show db.vgroups
print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08
if $data(2)[3] != 4 then
return -1
endi
if $data(2)[5] != 3 then
return -1
endi
if $data(2)[7] != 2 then
return -1
endi
sql create table db.stb (ts timestamp, c1 int, c2 binary(4)) tags(t1 int, t2 binary(16)) comment "abd"
sql create table db.ctb using db.stb tags(101, "102")
sql insert into db.ctb values(now, 1, "2")
sql show db.vgroups
print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08
sleep 1000
sql select * from db.ctb
print ===> $data00 $data01 $data02 $data03 $data04 $data05
if $rows != 1 then
return -1
endi
sleep 3000
print ============= step3: alter database
sql alter database db replica 1
$x = 0
step3:
$x = $x + 1
sleep 1000
if $x == 10 then
print ====> dnode not ready!
return -1
endi
sql show db.vgroups
print ===> rows: $rows
if $rows != 1 then
goto step3
endi
if $data(2)[3] != 4 then
goto step3
endi
if $data(2)[5] != NULL then
goto step3
endi
if $data(2)[7] != NULL then
goto step3
endi
print ============= step5: stop dnode 2
return
sql select * from db.stb
if $rows != 1 then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode2 -s stop -x SIGINT
system sh/exec.sh -n dnode3 -s stop -x SIGINT
system sh/exec.sh -n dnode4 -s stop -x SIGINT
\ No newline at end of file
tests/script/tsim/sync/3Replica5VgElect.sim
浏览文件 @
5a9ed58b
...
...
@@ -751,5 +751,6 @@ system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode2 -s stop -x SIGINT
system sh/exec.sh -n dnode3 -s stop -x SIGINT
system sh/exec.sh -n dnode4 -s stop -x SIGINT
system sh/exec.sh -n dnode5 -s stop -x SIGINT
tests/script/tsim/sync/3Replica5VgElect3mnode.sim
0 → 100644
浏览文件 @
5a9ed58b
此差异已折叠。
点击以展开。
tests/script/tsim/sync/3Replica5VgElect3mnodedrop.sim
0 → 100644
浏览文件 @
5a9ed58b
此差异已折叠。
点击以展开。
tests/script/tsim/testsuit.sim
浏览文件 @
5a9ed58b
#run user/pass_alter.sim
#run user/basic1.sim
#run user/privilege2.sim
#run user/user_len.sim
#run user/privilege1.sim
#run user/pass_len.sim
#run tstream/basic1.sim
#run tstream/basic0.sim
#run table/basic1.sim
#run trans/create_db.sim
#run stable/alter1.sim
#run stable/vnode3.sim
#run stable/metrics.sim
#run stable/show.sim
#run stable/values.sim
#run stable/dnode3.sim
#run stable/refcount.sim
#run stable/disk.sim
#run db/basic1.sim
#run db/basic3.sim
#run db/basic7.sim
#run db/basic6.sim
#run db/create_all_options.sim
#run db/basic2.sim
#run db/error1.sim
#run db/taosdlog.sim
#run db/alter_option.sim
#run mnode/basic1.sim
#run parser/fourArithmetic-basic.sim
#run parser/groupby-basic.sim
#run snode/basic1.sim
#run query/time_process.sim
#run query/stddev.sim
#run query/interval-offset.sim
#run query/charScalarFunction.sim
#run query/complex_select.sim
#run query/explain.sim
#run query/crash_sql.sim
#run query/diff.sim
#run query/complex_limit.sim
#run query/complex_having.sim
#run query/udf.sim
#run query/complex_group.sim
#run query/interval.sim
#run query/session.sim
print ========> dead lock failed when 2 rows in outputCapacity
run query/scalarFunction.sim
run query/scalarNull.sim
run query/complex_where.sim
run tmq/basic1.sim
run tmq/basic4.sim
run tmq/basic1Of2Cons.sim
run tmq/prepareBasicEnv-1vgrp.sim
run tmq/topic.sim
run tmq/basic4Of2Cons.sim
run tmq/prepareBasicEnv-4vgrp.sim
run tmq/basic3.sim
run tmq/basic2Of2Cons.sim
run tmq/basic2.sim
run tmq/basic3Of2Cons.sim
run tmq/basic2Of2ConsOverlap.sim
run tmq/clearConsume.sim
run qnode/basic1.sim
run dnode/basic1.sim
run show/basic.sim
run insert/basic1.sim
run insert/basic0.sim
run insert/backquote.sim
run insert/null.sim
run sync/oneReplica1VgElectWithInsert.sim
run sync/threeReplica1VgElect.sim
run sync/oneReplica1VgElect.sim
run sync/insertDataByRunBack.sim
run sync/threeReplica1VgElectWihtInsert.sim
run sma/tsmaCreateInsertData.sim
run sma/rsmaCreateInsertQuery.sim
run valgrind/checkError.sim
run bnode/basic1.sim
run tsim/user/pass_alter.sim
run tsim/user/basic1.sim
run tsim/user/privilege2.sim
run tsim/user/user_len.sim
run tsim/user/privilege1.sim
run tsim/user/pass_len.sim
run tsim/table/basic1.sim
run tsim/trans/lossdata1.sim
run tsim/trans/create_db.sim
run tsim/stable/alter_metrics.sim
run tsim/stable/tag_modify.sim
run tsim/stable/alter_comment.sim
run tsim/stable/column_drop.sim
run tsim/stable/column_modify.sim
run tsim/stable/tag_rename.sim
run tsim/stable/vnode3.sim
run tsim/stable/metrics.sim
run tsim/stable/alter_insert2.sim
run tsim/stable/show.sim
run tsim/stable/alter_import.sim
run tsim/stable/tag_add.sim
run tsim/stable/tag_drop.sim
run tsim/stable/column_add.sim
run tsim/stable/alter_count.sim
run tsim/stable/values.sim
run tsim/stable/dnode3.sim
run tsim/stable/alter_insert1.sim
run tsim/stable/refcount.sim
run tsim/stable/disk.sim
run tsim/db/basic1.sim
run tsim/db/basic3.sim
run tsim/db/basic7.sim
run tsim/db/basic6.sim
run tsim/db/create_all_options.sim
run tsim/db/basic2.sim
run tsim/db/error1.sim
run tsim/db/taosdlog.sim
run tsim/db/alter_option.sim
run tsim/mnode/basic1.sim
run tsim/mnode/basic3.sim
run tsim/mnode/basic2.sim
run tsim/parser/fourArithmetic-basic.sim
run tsim/parser/groupby-basic.sim
run tsim/snode/basic1.sim
run tsim/query/time_process.sim
run tsim/query/stddev.sim
run tsim/query/interval-offset.sim
run tsim/query/charScalarFunction.sim
run tsim/query/complex_select.sim
run tsim/query/explain.sim
run tsim/query/crash_sql.sim
run tsim/query/diff.sim
run tsim/query/complex_limit.sim
run tsim/query/complex_having.sim
run tsim/query/udf.sim
run tsim/query/complex_group.sim
run tsim/query/interval.sim
run tsim/query/session.sim
run tsim/query/scalarFunction.sim
run tsim/query/scalarNull.sim
run tsim/query/complex_where.sim
run tsim/tmq/basic1.sim
run tsim/tmq/basic4.sim
run tsim/tmq/basic1Of2Cons.sim
run tsim/tmq/prepareBasicEnv-1vgrp.sim
run tsim/tmq/topic.sim
run tsim/tmq/basic4Of2Cons.sim
run tsim/tmq/prepareBasicEnv-4vgrp.sim
run tsim/tmq/basic3.sim
run tsim/tmq/basic2Of2Cons.sim
run tsim/tmq/basic2.sim
run tsim/tmq/basic3Of2Cons.sim
run tsim/tmq/basic2Of2ConsOverlap.sim
run tsim/tmq/clearConsume.sim
run tsim/qnode/basic1.sim
run tsim/dnode/basic1.sim
run tsim/show/basic.sim
run tsim/stream/basic1.sim
run tsim/stream/triggerInterval0.sim
run tsim/stream/triggerSession0.sim
run tsim/stream/basic0.sim
run tsim/stream/session0.sim
run tsim/stream/session1.sim
run tsim/stream/basic2.sim
run tsim/insert/basic1.sim
run tsim/insert/commit-merge0.sim
run tsim/insert/basic0.sim
run tsim/insert/update0.sim
run tsim/insert/backquote.sim
run tsim/insert/null.sim
run tsim/sync/oneReplica1VgElectWithInsert.sim
run tsim/sync/threeReplica1VgElect.sim
run tsim/sync/oneReplica1VgElect.sim
run tsim/sync/3Replica5VgElect.sim
run tsim/sync/insertDataByRunBack.sim
run tsim/sync/oneReplica5VgElect.sim
run tsim/sync/3Replica1VgElect.sim
run tsim/sync/threeReplica1VgElectWihtInsert.sim
run tsim/sma/tsmaCreateInsertData.sim
run tsim/sma/rsmaCreateInsertQuery.sim
run tsim/valgrind/basic.sim
run tsim/valgrind/checkError.sim
run tsim/bnode/basic1.sim
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录