Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
e9d7a099
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
e9d7a099
编写于
4月 04, 2023
作者:
X
Xiaoyu Wang
浏览文件
操作
浏览文件
下载
差异文件
merge main
上级
8eb6cff7
0e53e578
变更
153
展开全部
隐藏空白更改
内联
并排
Showing
153 changed file
with
5033 addition
and
3105 deletion
+5033
-3105
CMakeLists.txt
CMakeLists.txt
+2
-0
cmake/cmake.version
cmake/cmake.version
+18
-1
docs/en/07-develop/07-tmq.mdx
docs/en/07-develop/07-tmq.mdx
+0
-1
docs/examples/go/sub/main.go
docs/examples/go/sub/main.go
+0
-1
docs/zh/07-develop/07-tmq.mdx
docs/zh/07-develop/07-tmq.mdx
+0
-2
examples/JDBC/taosdemo/pom.xml
examples/JDBC/taosdemo/pom.xml
+1
-1
include/common/tcommon.h
include/common/tcommon.h
+1
-1
include/common/tdatablock.h
include/common/tdatablock.h
+1
-1
include/common/tmsgcb.h
include/common/tmsgcb.h
+1
-1
include/common/tmsgdef.h
include/common/tmsgdef.h
+1
-1
include/libs/executor/executor.h
include/libs/executor/executor.h
+4
-10
include/libs/function/function.h
include/libs/function/function.h
+1
-1
include/libs/function/functionMgt.h
include/libs/function/functionMgt.h
+1
-0
include/libs/qcom/query.h
include/libs/qcom/query.h
+1
-0
include/libs/stream/streamState.h
include/libs/stream/streamState.h
+11
-12
include/libs/stream/tstream.h
include/libs/stream/tstream.h
+3
-4
include/libs/sync/sync.h
include/libs/sync/sync.h
+1
-1
include/util/tarray.h
include/util/tarray.h
+2
-16
include/util/tsimplehash.h
include/util/tsimplehash.h
+7
-0
include/util/version.h
include/util/version.h
+1
-0
packaging/rpm/tdengine.spec
packaging/rpm/tdengine.spec
+14
-26
packaging/tools/makepkg.sh
packaging/tools/makepkg.sh
+2
-0
packaging/tools/post.sh
packaging/tools/post.sh
+54
-0
source/client/src/clientMsgHandler.c
source/client/src/clientMsgHandler.c
+2
-2
source/client/src/clientRawBlockWrite.c
source/client/src/clientRawBlockWrite.c
+34
-26
source/client/src/clientSml.c
source/client/src/clientSml.c
+86
-78
source/client/src/clientTmq.c
source/client/src/clientTmq.c
+355
-347
source/client/test/clientTests.cpp
source/client/test/clientTests.cpp
+71
-71
source/common/src/tdatablock.c
source/common/src/tdatablock.c
+27
-52
source/common/src/tdataformat.c
source/common/src/tdataformat.c
+11
-0
source/dnode/mgmt/exe/dmMain.c
source/dnode/mgmt/exe/dmMain.c
+13
-9
source/dnode/mgmt/mgmt_mnode/inc/mmInt.h
source/dnode/mgmt/mgmt_mnode/inc/mmInt.h
+2
-2
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
+8
-5
source/dnode/mgmt/mgmt_mnode/src/mmWorker.c
source/dnode/mgmt/mgmt_mnode/src/mmWorker.c
+8
-8
source/dnode/mgmt/mgmt_vnode/inc/vmInt.h
source/dnode/mgmt/mgmt_vnode/inc/vmInt.h
+2
-2
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
+8
-7
source/dnode/mgmt/mgmt_vnode/src/vmInt.c
source/dnode/mgmt/mgmt_vnode/src/vmInt.c
+3
-3
source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
+9
-11
source/dnode/mnode/impl/inc/mndDef.h
source/dnode/mnode/impl/inc/mndDef.h
+1
-1
source/dnode/mnode/impl/src/mndConsumer.c
source/dnode/mnode/impl/src/mndConsumer.c
+111
-82
source/dnode/mnode/impl/src/mndIndex.c
source/dnode/mnode/impl/src/mndIndex.c
+2
-2
source/dnode/mnode/impl/src/mndProfile.c
source/dnode/mnode/impl/src/mndProfile.c
+1
-1
source/dnode/mnode/impl/src/mndSubscribe.c
source/dnode/mnode/impl/src/mndSubscribe.c
+122
-73
source/dnode/mnode/impl/src/mndSync.c
source/dnode/mnode/impl/src/mndSync.c
+1
-1
source/dnode/mnode/impl/src/mndTrans.c
source/dnode/mnode/impl/src/mndTrans.c
+5
-2
source/dnode/vnode/CMakeLists.txt
source/dnode/vnode/CMakeLists.txt
+1
-1
source/dnode/vnode/inc/vnode.h
source/dnode/vnode/inc/vnode.h
+2
-2
source/dnode/vnode/src/inc/tq.h
source/dnode/vnode/src/inc/tq.h
+13
-19
source/dnode/vnode/src/inc/tsdb.h
source/dnode/vnode/src/inc/tsdb.h
+4
-0
source/dnode/vnode/src/inc/vnodeInt.h
source/dnode/vnode/src/inc/vnodeInt.h
+8
-7
source/dnode/vnode/src/sma/smaRollup.c
source/dnode/vnode/src/sma/smaRollup.c
+1
-1
source/dnode/vnode/src/tq/tq.c
source/dnode/vnode/src/tq/tq.c
+142
-159
source/dnode/vnode/src/tq/tqMeta.c
source/dnode/vnode/src/tq/tqMeta.c
+6
-6
source/dnode/vnode/src/tq/tqPush.c
source/dnode/vnode/src/tq/tqPush.c
+115
-92
source/dnode/vnode/src/tq/tqRead.c
source/dnode/vnode/src/tq/tqRead.c
+1
-1
source/dnode/vnode/src/tq/tqScan.c
source/dnode/vnode/src/tq/tqScan.c
+53
-56
source/dnode/vnode/src/tsdb/tsdbCache.c
source/dnode/vnode/src/tsdb/tsdbCache.c
+30
-69
source/dnode/vnode/src/tsdb/tsdbMemTable.c
source/dnode/vnode/src/tsdb/tsdbMemTable.c
+35
-1
source/dnode/vnode/src/tsdb/tsdbMergeTree.c
source/dnode/vnode/src/tsdb/tsdbMergeTree.c
+26
-1
source/dnode/vnode/src/tsdb/tsdbRead.c
source/dnode/vnode/src/tsdb/tsdbRead.c
+443
-123
source/dnode/vnode/src/vnd/vnodeCommit.c
source/dnode/vnode/src/vnd/vnodeCommit.c
+3
-6
source/dnode/vnode/src/vnd/vnodeSnapshot.c
source/dnode/vnode/src/vnd/vnodeSnapshot.c
+1
-0
source/dnode/vnode/src/vnd/vnodeSync.c
source/dnode/vnode/src/vnd/vnodeSync.c
+1
-1
source/libs/catalog/src/ctgUtil.c
source/libs/catalog/src/ctgUtil.c
+59
-61
source/libs/executor/inc/executil.h
source/libs/executor/inc/executil.h
+1
-0
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+57
-43
source/libs/executor/inc/tfill.h
source/libs/executor/inc/tfill.h
+2
-2
source/libs/executor/src/aggregateoperator.c
source/libs/executor/src/aggregateoperator.c
+563
-0
source/libs/executor/src/cachescanoperator.c
source/libs/executor/src/cachescanoperator.c
+10
-8
source/libs/executor/src/exchangeoperator.c
source/libs/executor/src/exchangeoperator.c
+13
-3
source/libs/executor/src/executil.c
source/libs/executor/src/executil.c
+21
-2
source/libs/executor/src/executor.c
source/libs/executor/src/executor.c
+154
-132
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+80
-873
source/libs/executor/src/filloperator.c
source/libs/executor/src/filloperator.c
+45
-46
source/libs/executor/src/projectoperator.c
source/libs/executor/src/projectoperator.c
+24
-15
source/libs/executor/src/scanoperator.c
source/libs/executor/src/scanoperator.c
+192
-100
source/libs/executor/src/sortoperator.c
source/libs/executor/src/sortoperator.c
+1
-1
source/libs/executor/src/sysscanoperator.c
source/libs/executor/src/sysscanoperator.c
+12
-10
source/libs/executor/src/timewindowoperator.c
source/libs/executor/src/timewindowoperator.c
+14
-12
source/libs/function/inc/builtinsimpl.h
source/libs/function/inc/builtinsimpl.h
+1
-0
source/libs/function/src/builtins.c
source/libs/function/src/builtins.c
+15
-13
source/libs/function/src/builtinsimpl.c
source/libs/function/src/builtinsimpl.c
+50
-5
source/libs/function/src/functionMgt.c
source/libs/function/src/functionMgt.c
+7
-0
source/libs/index/src/indexFstFile.c
source/libs/index/src/indexFstFile.c
+0
-2
source/libs/parser/src/parCalcConst.c
source/libs/parser/src/parCalcConst.c
+37
-10
source/libs/parser/src/parInsertSml.c
source/libs/parser/src/parInsertSml.c
+2
-0
source/libs/parser/src/parInsertUtil.c
source/libs/parser/src/parInsertUtil.c
+78
-69
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+35
-7
source/libs/parser/src/parUtil.c
source/libs/parser/src/parUtil.c
+1
-1
source/libs/planner/src/planOptimizer.c
source/libs/planner/src/planOptimizer.c
+1
-1
source/libs/planner/src/planPhysiCreater.c
source/libs/planner/src/planPhysiCreater.c
+11
-2
source/libs/planner/src/planSpliter.c
source/libs/planner/src/planSpliter.c
+2
-1
source/libs/qcom/src/queryUtil.c
source/libs/qcom/src/queryUtil.c
+2
-0
source/libs/qworker/src/qwDbg.c
source/libs/qworker/src/qwDbg.c
+14
-3
source/libs/qworker/src/qworker.c
source/libs/qworker/src/qworker.c
+1
-1
source/libs/scalar/src/sclfunc.c
source/libs/scalar/src/sclfunc.c
+5
-1
source/libs/scheduler/inc/schInt.h
source/libs/scheduler/inc/schInt.h
+33
-11
source/libs/scheduler/src/schFlowCtrl.c
source/libs/scheduler/src/schFlowCtrl.c
+0
-1
source/libs/scheduler/src/schJob.c
source/libs/scheduler/src/schJob.c
+91
-5
source/libs/scheduler/src/schRemote.c
source/libs/scheduler/src/schRemote.c
+34
-15
source/libs/scheduler/src/schStatus.c
source/libs/scheduler/src/schStatus.c
+3
-0
source/libs/scheduler/src/schTask.c
source/libs/scheduler/src/schTask.c
+45
-37
source/libs/scheduler/src/scheduler.c
source/libs/scheduler/src/scheduler.c
+1
-1
source/libs/stream/src/stream.c
source/libs/stream/src/stream.c
+4
-4
source/libs/stream/src/streamExec.c
source/libs/stream/src/streamExec.c
+8
-2
source/libs/sync/src/syncAppendEntries.c
source/libs/sync/src/syncAppendEntries.c
+3
-3
source/libs/sync/src/syncElection.c
source/libs/sync/src/syncElection.c
+0
-1
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+11
-14
source/libs/sync/src/syncMessage.c
source/libs/sync/src/syncMessage.c
+2
-2
source/libs/sync/src/syncRequestVote.c
source/libs/sync/src/syncRequestVote.c
+4
-1
source/libs/sync/src/syncSnapshot.c
source/libs/sync/src/syncSnapshot.c
+1
-1
source/libs/sync/src/syncTimeout.c
source/libs/sync/src/syncTimeout.c
+0
-5
source/libs/tdb/src/db/tdbPager.c
source/libs/tdb/src/db/tdbPager.c
+27
-11
source/util/src/tarray.c
source/util/src/tarray.c
+3
-56
source/util/src/tconfig.c
source/util/src/tconfig.c
+2
-0
source/util/src/tsimplehash.c
source/util/src/tsimplehash.c
+23
-16
source/util/src/tversion.c
source/util/src/tversion.c
+12
-7
source/util/src/version.c.in
source/util/src/version.c.in
+1
-0
tests/parallel_test/cases.task
tests/parallel_test/cases.task
+16
-4
tests/parallel_test/run.sh
tests/parallel_test/run.sh
+6
-4
tests/script/coverage_test.sh
tests/script/coverage_test.sh
+23
-1
tests/script/tsim/parser/limit1_stb.sim
tests/script/tsim/parser/limit1_stb.sim
+1
-0
tests/script/tsim/parser/slimit1_query.sim
tests/script/tsim/parser/slimit1_query.sim
+1
-1
tests/script/tsim/query/interval-offset.sim
tests/script/tsim/query/interval-offset.sim
+2
-2
tests/script/tsim/query/join_interval.sim
tests/script/tsim/query/join_interval.sim
+42
-0
tests/script/tsim/query/nullColSma.sim
tests/script/tsim/query/nullColSma.sim
+139
-0
tests/script/tsim/query/sys_tbname.sim
tests/script/tsim/query/sys_tbname.sim
+5
-0
tests/script/tsim/query/unionall_as_table.sim
tests/script/tsim/query/unionall_as_table.sim
+28
-0
tests/script/tsim/stream/distributeInterval0.sim
tests/script/tsim/stream/distributeInterval0.sim
+118
-0
tests/script/tsim/stream/distributeIntervalRetrive0.sim
tests/script/tsim/stream/distributeIntervalRetrive0.sim
+26
-5
tests/script/tsim/stream/state1.sim
tests/script/tsim/stream/state1.sim
+61
-5
tests/system-test/0-others/check_assert.py
tests/system-test/0-others/check_assert.py
+2
-2
tests/system-test/0-others/tmqBasic.json
tests/system-test/0-others/tmqBasic.json
+0
-1
tests/system-test/2-query/columnLenUpdated.py
tests/system-test/2-query/columnLenUpdated.py
+215
-0
tests/system-test/2-query/nestedQuery.py
tests/system-test/2-query/nestedQuery.py
+4
-4
tests/system-test/2-query/nestedQuery_26.py
tests/system-test/2-query/nestedQuery_26.py
+76
-0
tests/system-test/2-query/nestedQuery_math.py
tests/system-test/2-query/nestedQuery_math.py
+3
-3
tests/system-test/2-query/out_of_order.py
tests/system-test/2-query/out_of_order.py
+9
-10
tests/system-test/7-tmq/raw_block_interface_test.py
tests/system-test/7-tmq/raw_block_interface_test.py
+54
-0
tests/system-test/7-tmq/subscribeDb.py
tests/system-test/7-tmq/subscribeDb.py
+2
-2
tests/system-test/7-tmq/subscribeStb1.py
tests/system-test/7-tmq/subscribeStb1.py
+4
-4
tests/system-test/7-tmq/tmq3mnodeSwitch.py
tests/system-test/7-tmq/tmq3mnodeSwitch.py
+5
-4
tests/system-test/7-tmq/tmqConsFromTsdb-mutilVg.py
tests/system-test/7-tmq/tmqConsFromTsdb-mutilVg.py
+2
-0
tests/system-test/7-tmq/tmqDelete-1ctb.py
tests/system-test/7-tmq/tmqDelete-1ctb.py
+124
-2
tests/system-test/7-tmq/tmqDnodeRestart.py
tests/system-test/7-tmq/tmqDnodeRestart.py
+2
-2
tests/system-test/7-tmq/tmqDropNtb-snapshot0.py
tests/system-test/7-tmq/tmqDropNtb-snapshot0.py
+3
-3
tests/system-test/7-tmq/tmqMultiConsumer.py
tests/system-test/7-tmq/tmqMultiConsumer.py
+174
-0
tools/shell/src/shellArguments.c
tools/shell/src/shellArguments.c
+31
-15
tools/shell/src/shellEngine.c
tools/shell/src/shellEngine.c
+1
-1
utils/test/c/CMakeLists.txt
utils/test/c/CMakeLists.txt
+9
-0
utils/test/c/sml_test.c
utils/test/c/sml_test.c
+5
-2
utils/test/c/tmq_taosx_ci.c
utils/test/c/tmq_taosx_ci.c
+0
-1
utils/test/c/write_raw_block_test.c
utils/test/c/write_raw_block_test.c
+128
-0
未找到文件。
CMakeLists.txt
浏览文件 @
e9d7a099
...
...
@@ -10,6 +10,8 @@ if (NOT DEFINED TD_SOURCE_DIR)
set
(
TD_SOURCE_DIR
${
PROJECT_SOURCE_DIR
}
)
endif
()
SET
(
TD_COMMUNITY_DIR
${
PROJECT_SOURCE_DIR
}
)
set
(
TD_SUPPORT_DIR
"
${
TD_SOURCE_DIR
}
/cmake"
)
set
(
TD_CONTRIB_DIR
"
${
TD_SOURCE_DIR
}
/contrib"
)
...
...
cmake/cmake.version
浏览文件 @
e9d7a099
...
...
@@ -16,7 +16,7 @@ find_program(HAVE_GIT NAMES git)
IF (DEFINED GITINFO)
SET(TD_VER_GIT ${GITINFO})
ELSEIF (HAVE_GIT)
execute_process(COMMAND git log -1 --format=%H WORKING_DIRECTORY ${
CMAKE_CURRENT_SOURCE
_DIR} OUTPUT_VARIABLE GIT_COMMITID)
execute_process(COMMAND git log -1 --format=%H WORKING_DIRECTORY ${
TD_COMMUNITY
_DIR} OUTPUT_VARIABLE GIT_COMMITID)
#message(STATUS "git log result:${GIT_COMMITID}")
IF (GIT_COMMITID)
string (REGEX REPLACE "[\n\t\r]" "" GIT_COMMITID ${GIT_COMMITID})
...
...
@@ -30,6 +30,23 @@ ELSE ()
SET(TD_VER_GIT "no git commit id")
ENDIF ()
IF (DEFINED GITINFOI)
SET(TD_VER_GIT_INTERNAL ${GITINFOI})
ELSEIF (HAVE_GIT)
execute_process(COMMAND git log -1 --format=%H WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE GIT_COMMITID)
message(STATUS "git log result:${GIT_COMMITID}")
IF (GIT_COMMITID)
string (REGEX REPLACE "[\n\t\r]" "" GIT_COMMITID ${GIT_COMMITID})
SET(TD_VER_GIT_INTERNAL ${GIT_COMMITID})
ELSE ()
message(STATUS "not a git repository")
SET(TD_VER_GIT "no git commit id")
ENDIF ()
ELSE ()
message(STATUS "no git cmd")
SET(TD_VER_GIT_INTERNAL "no git commit id")
ENDIF ()
IF (DEFINED VERDATE)
SET(TD_VER_DATE ${VERDATE})
ELSE ()
...
...
docs/en/07-develop/07-tmq.mdx
浏览文件 @
e9d7a099
...
...
@@ -368,7 +368,6 @@ conf := &tmq.ConfigMap{
"td.connect.port": "6030",
"client.id": "test_tmq_c",
"enable.auto.commit": "false",
"enable.heartbeat.background": "true",
"experimental.snapshot.enable": "true",
"msg.with.table.name": "true",
}
...
...
docs/examples/go/sub/main.go
浏览文件 @
e9d7a099
...
...
@@ -35,7 +35,6 @@ func main() {
"td.connect.port"
:
"6030"
,
"client.id"
:
"test_tmq_client"
,
"enable.auto.commit"
:
"false"
,
"enable.heartbeat.background"
:
"true"
,
"experimental.snapshot.enable"
:
"true"
,
"msg.with.table.name"
:
"true"
,
})
...
...
docs/zh/07-develop/07-tmq.mdx
浏览文件 @
e9d7a099
...
...
@@ -367,7 +367,6 @@ conf := &tmq.ConfigMap{
"td.connect.port": "6030",
"client.id": "test_tmq_c",
"enable.auto.commit": "false",
"enable.heartbeat.background": "true",
"experimental.snapshot.enable": "true",
"msg.with.table.name": "true",
}
...
...
@@ -419,7 +418,6 @@ consumer = Consumer({"group.id": "local", "td.connect.ip": "127.0.0.1"})
| `auto.commit.interval.ms` | string | 以毫秒为单位的自动提交时间间隔 | 默认值:5000 ms |
| `auto.offset.reset` | string | 消费组订阅的初始位置 | 可选:`earliest`(default), `latest`, `none` |
| `experimental.snapshot.enable` | string | 是否允许从 TSDB 消费数据 | 合法值:`true`, `false` |
| `enable.heartbeat.background` | string | 启用后台心跳,启用后即使长时间不 poll 消息也不会造成离线 | 合法值:`true`, `false` |
</TabItem>
...
...
examples/JDBC/taosdemo/pom.xml
浏览文件 @
e9d7a099
...
...
@@ -10,7 +10,7 @@
<description>
Demo project for TDengine
</description>
<properties>
<spring.version>
5.3.2
0
</spring.version>
<spring.version>
5.3.2
6
</spring.version>
</properties>
<dependencies>
...
...
include/common/tcommon.h
浏览文件 @
e9d7a099
...
...
@@ -185,7 +185,7 @@ typedef struct SBlockID {
typedef
struct
SDataBlockInfo
{
STimeWindow
window
;
int32_t
rowSize
;
int
32
_t
rows
;
// todo hide this attribute
int
64
_t
rows
;
// todo hide this attribute
uint32_t
capacity
;
SBlockID
id
;
int16_t
hasVarCol
;
...
...
include/common/tdatablock.h
浏览文件 @
e9d7a099
...
...
@@ -178,7 +178,7 @@ int32_t getJsonValueLen(const char* data);
int32_t
colDataSetVal
(
SColumnInfoData
*
pColumnInfoData
,
uint32_t
rowIndex
,
const
char
*
pData
,
bool
isNull
);
int32_t
colDataAppend
(
SColumnInfoData
*
pColumnInfoData
,
uint32_t
rowIndex
,
const
char
*
pData
,
bool
isNull
);
int32_t
colDataSetNItems
(
SColumnInfoData
*
pColumnInfoData
,
uint32_t
rowIndex
,
const
char
*
pData
,
uint32_t
numOfRows
);
int32_t
colDataSetNItems
(
SColumnInfoData
*
pColumnInfoData
,
uint32_t
rowIndex
,
const
char
*
pData
,
uint32_t
numOfRows
,
bool
trimValue
);
int32_t
colDataMergeCol
(
SColumnInfoData
*
pColumnInfoData
,
int32_t
numOfRow1
,
int32_t
*
capacity
,
const
SColumnInfoData
*
pSource
,
int32_t
numOfRow2
);
int32_t
colDataAssign
(
SColumnInfoData
*
pColumnInfoData
,
const
SColumnInfoData
*
pSource
,
int32_t
numOfRows
,
...
...
include/common/tmsgcb.h
浏览文件 @
e9d7a099
...
...
@@ -34,7 +34,7 @@ typedef enum {
WRITE_QUEUE
,
APPLY_QUEUE
,
SYNC_QUEUE
,
SYNC_
CTRL
_QUEUE
,
SYNC_
RD
_QUEUE
,
STREAM_QUEUE
,
QUEUE_MAX
,
}
EQueueType
;
...
...
include/common/tmsgdef.h
浏览文件 @
e9d7a099
...
...
@@ -260,7 +260,7 @@ enum {
TD_NEW_MSG_SEG
(
TDMT_SYNC_MSG
)
TD_DEF_MSG_TYPE
(
TDMT_SYNC_TIMEOUT
,
"sync-timer"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_SYNC_
PING
,
"sync-ping"
,
NULL
,
NULL
)
// no longer used
TD_DEF_MSG_TYPE
(
TDMT_SYNC_
TIMEOUT_ELECTION
,
"sync-elect"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_SYNC_PING_REPLY
,
"sync-ping-reply"
,
NULL
,
NULL
)
// no longer used
TD_DEF_MSG_TYPE
(
TDMT_SYNC_CLIENT_REQUEST
,
"sync-client-request"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_SYNC_CLIENT_REQUEST_BATCH
,
"sync-client-request-batch"
,
NULL
,
NULL
)
...
...
include/libs/executor/executor.h
浏览文件 @
e9d7a099
...
...
@@ -78,7 +78,8 @@ qTaskInfo_t qCreateStreamExecTaskInfo(void* msg, SReadHandle* readers, int32_t v
* @param SReadHandle
* @return
*/
qTaskInfo_t
qCreateQueueExecTaskInfo
(
void
*
msg
,
SReadHandle
*
pReaderHandle
,
int32_t
vgId
,
int32_t
*
numOfCols
,
SSchemaWrapper
**
pSchema
);
qTaskInfo_t
qCreateQueueExecTaskInfo
(
void
*
msg
,
SReadHandle
*
pReaderHandle
,
int32_t
vgId
,
int32_t
*
numOfCols
,
uint64_t
id
);
/**
* set the task Id, usually used by message queue process
...
...
@@ -89,6 +90,7 @@ qTaskInfo_t qCreateQueueExecTaskInfo(void* msg, SReadHandle* pReaderHandle, int3
void
qSetTaskId
(
qTaskInfo_t
tinfo
,
uint64_t
taskId
,
uint64_t
queryId
);
int32_t
qSetStreamOpOpen
(
qTaskInfo_t
tinfo
);
/**
* Set multiple input data blocks for the stream scan.
* @param tinfo
...
...
@@ -149,7 +151,6 @@ int32_t qGetQueryTableSchemaVersion(qTaskInfo_t tinfo, char* dbName, char* table
* @param handle
* @return
*/
int32_t
qExecTaskOpt
(
qTaskInfo_t
tinfo
,
SArray
*
pResList
,
uint64_t
*
useconds
,
bool
*
hasMore
,
SLocalFetch
*
pLocal
);
int32_t
qExecTask
(
qTaskInfo_t
tinfo
,
SSDataBlock
**
pBlock
,
uint64_t
*
useconds
);
...
...
@@ -162,6 +163,7 @@ void qCleanExecTaskBlockBuf(qTaskInfo_t tinfo);
* @return
*/
int32_t
qAsyncKillTask
(
qTaskInfo_t
tinfo
,
int32_t
rspCode
);
int32_t
qKillTask
(
qTaskInfo_t
tinfo
,
int32_t
rspCode
);
bool
qTaskIsExecuting
(
qTaskInfo_t
qinfo
);
...
...
@@ -171,14 +173,6 @@ bool qTaskIsExecuting(qTaskInfo_t qinfo);
*/
void
qDestroyTask
(
qTaskInfo_t
tinfo
);
/**
* Extract the qualified table id list, and than pass them to the TSDB driver to load the required table data blocks.
*
* @param iter the table iterator to traverse all tables belongs to a super table, or an invert index
* @return
*/
int32_t
qGetQualifiedTableIdList
(
void
*
pTableList
,
const
char
*
tagCond
,
int32_t
tagCondLen
,
SArray
*
pTableIdList
);
void
qProcessRspMsg
(
void
*
parent
,
struct
SRpcMsg
*
pMsg
,
struct
SEpSet
*
pEpSet
);
int32_t
qGetExplainExecInfo
(
qTaskInfo_t
tinfo
,
SArray
*
pExecInfoList
/*,int32_t* resNum, SExplainExecInfo** pRes*/
);
...
...
include/libs/function/function.h
浏览文件 @
e9d7a099
...
...
@@ -112,7 +112,7 @@ typedef struct SResultDataInfo {
typedef
struct
SInputColumnInfoData
{
int32_t
totalRows
;
// total rows in current columnar data
int32_t
startRowIndex
;
// handle started row index
int
32
_t
numOfRows
;
// the number of rows needs to be handled
int
64
_t
numOfRows
;
// the number of rows needs to be handled
int32_t
numOfInputCols
;
// PTS is not included
bool
colDataSMAIsSet
;
// if agg is set or not
SColumnInfoData
*
pPTS
;
// primary timestamp column
...
...
include/libs/function/functionMgt.h
浏览文件 @
e9d7a099
...
...
@@ -241,6 +241,7 @@ int32_t fmGetUdafExecFuncs(int32_t funcId, SFuncExecFuncs* pFpSet);
int32_t
fmSetInvertFunc
(
int32_t
funcId
,
SFuncExecFuncs
*
pFpSet
);
int32_t
fmSetNormalFunc
(
int32_t
funcId
,
SFuncExecFuncs
*
pFpSet
);
bool
fmIsInvertible
(
int32_t
funcId
);
char
*
fmGetFuncName
(
int32_t
funcId
);
#ifdef __cplusplus
}
...
...
include/libs/qcom/query.h
浏览文件 @
e9d7a099
...
...
@@ -33,6 +33,7 @@ typedef enum {
JOB_TASK_STATUS_INIT
,
JOB_TASK_STATUS_EXEC
,
JOB_TASK_STATUS_PART_SUCC
,
JOB_TASK_STATUS_FETCH
,
JOB_TASK_STATUS_SUCC
,
JOB_TASK_STATUS_FAIL
,
JOB_TASK_STATUS_DROP
,
...
...
include/libs/stream/streamState.h
浏览文件 @
e9d7a099
...
...
@@ -23,20 +23,19 @@ extern "C" {
#ifndef _STREAM_STATE_H_
#define _STREAM_STATE_H_
typedef
struct
SStreamTask
SStreamTask
;
typedef
bool
(
*
state_key_cmpr_fn
)(
void
*
pKey1
,
void
*
pKey2
);
typedef
struct
STdbState
{
SStreamTask
*
pOwner
;
TDB
*
db
;
TTB
*
pStateDb
;
TTB
*
pFuncStateDb
;
TTB
*
pFillStateDb
;
// todo refactor
TTB
*
pSessionStateDb
;
TTB
*
pParNameDb
;
TTB
*
pParTagDb
;
TXN
*
txn
;
struct
SStreamTask
*
pOwner
;
TDB
*
db
;
TTB
*
pStateDb
;
TTB
*
pFuncStateDb
;
TTB
*
pFillStateDb
;
// todo refactor
TTB
*
pSessionStateDb
;
TTB
*
pParNameDb
;
TTB
*
pParTagDb
;
TXN
*
txn
;
}
STdbState
;
// incremental state storage
...
...
@@ -45,7 +44,7 @@ typedef struct {
int32_t
number
;
}
SStreamState
;
SStreamState
*
streamStateOpen
(
char
*
path
,
SStreamTask
*
pTask
,
bool
specPath
,
int32_t
szPage
,
int32_t
pages
);
SStreamState
*
streamStateOpen
(
char
*
path
,
struct
SStreamTask
*
pTask
,
bool
specPath
,
int32_t
szPage
,
int32_t
pages
);
void
streamStateClose
(
SStreamState
*
pState
);
int32_t
streamStateBegin
(
SStreamState
*
pState
);
int32_t
streamStateCommit
(
SStreamState
*
pState
);
...
...
include/libs/stream/tstream.h
浏览文件 @
e9d7a099
...
...
@@ -295,7 +295,7 @@ typedef struct {
SEpSet
epSet
;
}
SStreamChildEpInfo
;
typedef
struct
SStreamTask
{
struct
SStreamTask
{
int64_t
streamId
;
int32_t
taskId
;
int32_t
totalLevel
;
...
...
@@ -362,8 +362,7 @@ typedef struct SStreamTask {
int64_t
checkpointingId
;
int32_t
checkpointAlignCnt
;
}
SStreamTask
;
};
int32_t
tEncodeStreamEpInfo
(
SEncoder
*
pEncoder
,
const
SStreamChildEpInfo
*
pInfo
);
int32_t
tDecodeStreamEpInfo
(
SDecoder
*
pDecoder
,
SStreamChildEpInfo
*
pInfo
);
...
...
@@ -587,7 +586,7 @@ int32_t streamProcessDispatchReq(SStreamTask* pTask, SStreamDispatchReq* pReq, S
int32_t
streamProcessDispatchRsp
(
SStreamTask
*
pTask
,
SStreamDispatchRsp
*
pRsp
,
int32_t
code
);
int32_t
streamProcessRetrieveReq
(
SStreamTask
*
pTask
,
SStreamRetrieveReq
*
pReq
,
SRpcMsg
*
pMsg
);
int32_t
streamProcessRetrieveRsp
(
SStreamTask
*
pTask
,
SStreamRetrieveRsp
*
pRsp
);
//
int32_t streamProcessRetrieveRsp(SStreamTask* pTask, SStreamRetrieveRsp* pRsp);
int32_t
streamTryExec
(
SStreamTask
*
pTask
);
int32_t
streamSchedExec
(
SStreamTask
*
pTask
);
...
...
include/libs/sync/sync.h
浏览文件 @
e9d7a099
...
...
@@ -48,7 +48,7 @@ extern "C" {
#define SYNC_HEARTBEAT_REPLY_SLOW_MS 1500
#define SYNC_SNAP_RESEND_MS 1000 * 60
#define SYNC_VND_COMMIT_MIN_MS
1
000
#define SYNC_VND_COMMIT_MIN_MS
3
000
#define SYNC_MAX_BATCH_SIZE 1
#define SYNC_INDEX_BEGIN 0
...
...
include/util/tarray.h
浏览文件 @
e9d7a099
...
...
@@ -69,14 +69,6 @@ void* taosArrayAddBatch(SArray* pArray, const void* pData, int32_t nEles);
*/
void
taosArrayRemoveDuplicate
(
SArray
*
pArray
,
__compar_fn_t
comparFn
,
void
(
*
fp
)(
void
*
));
/**
*
* @param pArray
* @param comparFn
* @param fp
*/
void
taosArrayRemoveDuplicateP
(
SArray
*
pArray
,
__compar_fn_t
comparFn
,
void
(
*
fp
)(
void
*
));
/**
* add all element from the source array list into the destination
* @param pArray
...
...
@@ -216,6 +208,8 @@ void taosArrayDestroyP(SArray* pArray, FDelete fp);
void
taosArrayDestroyEx
(
SArray
*
pArray
,
FDelete
fp
);
void
taosArraySwap
(
SArray
*
a
,
SArray
*
b
);
/**
* sort the array
* @param pArray
...
...
@@ -252,14 +246,6 @@ void taosArraySortPWithExt(SArray* pArray, __ext_compar_fn_t fn, const void* par
int32_t
taosEncodeArray
(
void
**
buf
,
const
SArray
*
pArray
,
FEncode
encode
);
void
*
taosDecodeArray
(
const
void
*
buf
,
SArray
**
pArray
,
FDecode
decode
,
int32_t
dataSz
);
/**
* swap array
* @param a
* @param b
* @return
*/
void
taosArraySwap
(
SArray
*
a
,
SArray
*
b
);
#ifdef __cplusplus
}
#endif
...
...
include/util/tsimplehash.h
浏览文件 @
e9d7a099
...
...
@@ -48,6 +48,13 @@ SSHashObj *tSimpleHashInit(size_t capacity, _hash_fn_t fn);
*/
int32_t
tSimpleHashGetSize
(
const
SSHashObj
*
pHashObj
);
/**
* set the free function pointer
* @param pHashObj
* @param freeFp
*/
void
tSimpleHashSetFreeFp
(
SSHashObj
*
pHashObj
,
_hash_free_fn_t
freeFp
);
int32_t
tSimpleHashPrint
(
const
SSHashObj
*
pHashObj
);
/**
...
...
include/util/version.h
浏览文件 @
e9d7a099
...
...
@@ -23,6 +23,7 @@ extern "C" {
extern
char
version
[];
extern
char
compatible_version
[];
extern
char
gitinfo
[];
extern
char
gitinfoOfInternal
[];
extern
char
buildinfo
[];
#ifdef __cplusplus
...
...
packaging/rpm/tdengine.spec
浏览文件 @
e9d7a099
...
...
@@ -90,45 +90,33 @@ cp %{_compiledir}/../include/libs/function/taosudf.h %{buildroot}%{homepat
cp -r %{_compiledir}/../examples/* %{buildroot}%{homepath}/examples
if [ -f %{_compiledir}/build/bin/jemalloc-config ]; then
mkdir -p %{buildroot}%{userlocalpath}/bin
mkdir -p %{buildroot}%{userlocalpath}/lib
mkdir -p %{buildroot}%{userlocalpath}/lib/pkgconfig
mkdir -p %{buildroot}%{userlocalpath}/include
mkdir -p %{buildroot}%{userlocalpath}/include/jemalloc
mkdir -p %{buildroot}%{userlocalpath}/share
mkdir -p %{buildroot}%{userlocalpath}/share/doc
mkdir -p %{buildroot}%{userlocalpath}/share/doc/jemalloc
mkdir -p %{buildroot}%{userlocalpath}/share/man
mkdir -p %{buildroot}%{userlocalpath}/share/man/man3
cp %{_compiledir}/build/bin/jemalloc-config %{buildroot}%{userlocalpath}/bin/
mkdir -p %{buildroot}%{homepath}/jemalloc/ ||:
mkdir -p %{buildroot}%{homepath}/jemalloc/include/jemalloc/ ||:
mkdir -p %{buildroot}%{homepath}/jemalloc/lib/ ||:
mkdir -p %{buildroot}%{homepath}/jemalloc/lib/pkgconfig ||:
cp %{_compiledir}/build/bin/jemalloc-config %{buildroot}%{homepath}/jemalloc/bin
if [ -f %{_compiledir}/build/bin/jemalloc.sh ]; then
cp %{_compiledir}/build/bin/jemalloc.sh %{buildroot}%{
userlocalpath}/bin/
cp %{_compiledir}/build/bin/jemalloc.sh %{buildroot}%{
homepath}/jemalloc/bin
fi
if [ -f %{_compiledir}/build/bin/jeprof ]; then
cp %{_compiledir}/build/bin/jeprof %{buildroot}%{
userlocalpath}/bin/
cp %{_compiledir}/build/bin/jeprof %{buildroot}%{
homepath}/jemalloc/bin
fi
if [ -f %{_compiledir}/build/include/jemalloc/jemalloc.h ]; then
cp %{_compiledir}/build/include/jemalloc/jemalloc.h %{buildroot}%{
userlocalpath}
/include/jemalloc/
cp %{_compiledir}/build/include/jemalloc/jemalloc.h %{buildroot}%{
homepath}/jemalloc
/include/jemalloc/
fi
if [ -f %{_compiledir}/build/lib/libjemalloc.so.2 ]; then
cp %{_compiledir}/build/lib/libjemalloc.so.2 %{buildroot}%{
userlocalpath}/lib/
ln -sf libjemalloc.so.2 %{buildroot}%{
userlocalpath}
/lib/libjemalloc.so
cp %{_compiledir}/build/lib/libjemalloc.so.2 %{buildroot}%{
homepath}/jemalloc/lib
ln -sf libjemalloc.so.2 %{buildroot}%{
homepath}/jemalloc
/lib/libjemalloc.so
fi
if [ -f %{_compiledir}/build/lib/libjemalloc.a ]; then
cp %{_compiledir}/build/lib/libjemalloc.a %{buildroot}%{
userlocalpath}/lib/
cp %{_compiledir}/build/lib/libjemalloc.a %{buildroot}%{
homepath}/jemalloc/lib
fi
if [ -f %{_compiledir}/build/lib/libjemalloc_pic.a ]; then
cp %{_compiledir}/build/lib/libjemalloc_pic.a %{buildroot}%{
userlocalpath}/lib/
cp %{_compiledir}/build/lib/libjemalloc_pic.a %{buildroot}%{
homepath}/jemalloc/lib
fi
if [ -f %{_compiledir}/build/lib/pkgconfig/jemalloc.pc ]; then
cp %{_compiledir}/build/lib/pkgconfig/jemalloc.pc %{buildroot}%{userlocalpath}/lib/pkgconfig/
fi
if [ -f %{_compiledir}/build/share/doc/jemalloc/jemalloc.html ]; then
cp %{_compiledir}/build/share/doc/jemalloc/jemalloc.html %{buildroot}%{userlocalpath}/share/doc/jemalloc/
fi
if [ -f %{_compiledir}/build/share/man/man3/jemalloc.3 ]; then
cp %{_compiledir}/build/share/man/man3/jemalloc.3 %{buildroot}%{userlocalpath}/share/man/man3/
cp %{_compiledir}/build/lib/pkgconfig/jemalloc.pc %{buildroot}%{homepath}/jemalloc/lib/pkgconfig
fi
fi
...
...
packaging/tools/makepkg.sh
浏览文件 @
e9d7a099
...
...
@@ -51,6 +51,8 @@ fi
if
[
-d
${
top_dir
}
/tools/taos-tools/packaging/deb
]
;
then
cd
${
top_dir
}
/tools/taos-tools/packaging/deb
taostools_ver
=
$(
git
for
-each-ref
--sort
=
taggerdate
--format
'%(tag)'
refs/tags|grep
-v
taos |
tail
-1
)
[
-z
"
$taos_tools_ver
"
]
&&
taos_tools_ver
=
"0.1.0"
taostools_ver
=
$(
git
for
-each-ref
--sort
=
taggerdate
--format
'%(tag)'
refs/tags|grep
-v
taos |
tail
-1
)
...
...
packaging/tools/post.sh
浏览文件 @
e9d7a099
...
...
@@ -145,6 +145,59 @@ function install_include() {
log_print
"install include success"
}
function
install_jemalloc
()
{
jemalloc_dir
=
${
script_dir
}
/../jemalloc
if
[
-d
${
jemalloc_dir
}
]
;
then
${
csudo
}
/usr/bin/install
-c
-d
/usr/local/bin
if
[
-f
${
jemalloc_dir
}
/bin/jemalloc-config
]
;
then
${
csudo
}
/usr/bin/install
-c
-m
755
${
jemalloc_dir
}
/bin/jemalloc-config /usr/local/bin
fi
if
[
-f
${
jemalloc_dir
}
/bin/jemalloc.sh
]
;
then
${
csudo
}
/usr/bin/install
-c
-m
755
${
jemalloc_dir
}
/bin/jemalloc.sh /usr/local/bin
fi
if
[
-f
${
jemalloc_dir
}
/bin/jeprof
]
;
then
${
csudo
}
/usr/bin/install
-c
-m
755
${
jemalloc_dir
}
/bin/jeprof /usr/local/bin
fi
if
[
-f
${
jemalloc_dir
}
/include/jemalloc/jemalloc.h
]
;
then
${
csudo
}
/usr/bin/install
-c
-d
/usr/local/include/jemalloc
${
csudo
}
/usr/bin/install
-c
-m
644
${
jemalloc_dir
}
/include/jemalloc/jemalloc.h /usr/local/include/jemalloc
fi
if
[
-f
${
jemalloc_dir
}
/lib/libjemalloc.so.2
]
;
then
${
csudo
}
/usr/bin/install
-c
-d
/usr/local/lib
${
csudo
}
/usr/bin/install
-c
-m
755
${
jemalloc_dir
}
/lib/libjemalloc.so.2 /usr/local/lib
${
csudo
}
ln
-sf
libjemalloc.so.2 /usr/local/lib/libjemalloc.so
${
csudo
}
/usr/bin/install
-c
-d
/usr/local/lib
if
[
-f
${
jemalloc_dir
}
/lib/libjemalloc.a
]
;
then
${
csudo
}
/usr/bin/install
-c
-m
755
${
jemalloc_dir
}
/lib/libjemalloc.a /usr/local/lib
fi
if
[
-f
${
jemalloc_dir
}
/lib/libjemalloc_pic.a
]
;
then
${
csudo
}
/usr/bin/install
-c
-m
755
${
jemalloc_dir
}
/lib/libjemalloc_pic.a /usr/local/lib
fi
if
[
-f
${
jemalloc_dir
}
/lib/libjemalloc_pic.a
]
;
then
${
csudo
}
/usr/bin/install
-c
-d
/usr/local/lib/pkgconfig
${
csudo
}
/usr/bin/install
-c
-m
644
${
jemalloc_dir
}
/lib/pkgconfig/jemalloc.pc /usr/local/lib/pkgconfig
fi
fi
if
[
-f
${
jemalloc_dir
}
/share/doc/jemalloc/jemalloc.html
]
;
then
${
csudo
}
/usr/bin/install
-c
-d
/usr/local/share/doc/jemalloc
${
csudo
}
/usr/bin/install
-c
-m
644
${
jemalloc_dir
}
/share/doc/jemalloc/jemalloc.html /usr/local/share/doc/jemalloc
fi
if
[
-f
${
jemalloc_dir
}
/share/man/man3/jemalloc.3
]
;
then
${
csudo
}
/usr/bin/install
-c
-d
/usr/local/share/man/man3
${
csudo
}
/usr/bin/install
-c
-m
644
${
jemalloc_dir
}
/share/man/man3/jemalloc.3 /usr/local/share/man/man3
fi
if
[
-d
/etc/ld.so.conf.d
]
;
then
echo
"/usr/local/lib"
|
${
csudo
}
tee
/etc/ld.so.conf.d/jemalloc.conf
>
/dev/null
||
echo
-e
"failed to write /etc/ld.so.conf.d/jemalloc.conf"
${
csudo
}
ldconfig
else
echo
"/etc/ld.so.conf.d not found!"
fi
fi
}
function
install_lib
()
{
log_print
"start install lib from
${
lib_dir
}
to
${
lib_link_dir
}
"
${
csudo
}
rm
-f
${
lib_link_dir
}
/libtaos
*
||
:
...
...
@@ -667,6 +720,7 @@ function install_TDengine() {
# Install include, lib, binary and service
install_include
&&
install_lib
&&
install_jemalloc
install_bin
if
[[
"
$?
"
!=
0
]]
;
then
...
...
source/client/src/clientMsgHandler.c
浏览文件 @
e9d7a099
...
...
@@ -76,7 +76,7 @@ int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) {
goto
End
;
}
if
((
code
=
taosCheckVersionCompatibleFromStr
(
version
,
connectRsp
.
sVer
,
2
))
!=
0
)
{
if
((
code
=
taosCheckVersionCompatibleFromStr
(
version
,
connectRsp
.
sVer
,
3
))
!=
0
)
{
setErrno
(
pRequest
,
code
);
tsem_post
(
&
pRequest
->
body
.
rspSem
);
goto
End
;
...
...
@@ -506,7 +506,7 @@ int32_t processShowVariablesRsp(void* param, SDataBuf* pMsg, int32_t code) {
code
=
setQueryResultFromRsp
(
&
pRequest
->
body
.
resInfo
,
pRes
,
false
,
true
);
}
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
taosMemoryFree
(
pRes
);
}
tFreeSShowVariablesRsp
(
&
rsp
);
...
...
source/client/src/clientRawBlockWrite.c
浏览文件 @
e9d7a099
...
...
@@ -25,9 +25,7 @@
#include "tref.h"
#include "ttimer.h"
static
tb_uid_t
processSuid
(
tb_uid_t
suid
,
char
*
db
){
return
suid
+
MurmurHash3_32
(
db
,
strlen
(
db
));
}
static
tb_uid_t
processSuid
(
tb_uid_t
suid
,
char
*
db
)
{
return
suid
+
MurmurHash3_32
(
db
,
strlen
(
db
));
}
static
char
*
buildCreateTableJson
(
SSchemaWrapper
*
schemaRow
,
SSchemaWrapper
*
schemaTag
,
char
*
name
,
int64_t
id
,
int8_t
t
)
{
...
...
@@ -363,7 +361,8 @@ static char* processCreateTable(SMqMetaRsp* metaRsp) {
if
(
pCreateReq
->
type
==
TSDB_CHILD_TABLE
)
{
string
=
buildCreateCTableJson
(
req
.
pReqs
,
req
.
nReqs
);
}
else
if
(
pCreateReq
->
type
==
TSDB_NORMAL_TABLE
)
{
string
=
buildCreateTableJson
(
&
pCreateReq
->
ntb
.
schemaRow
,
NULL
,
pCreateReq
->
name
,
pCreateReq
->
uid
,
TSDB_NORMAL_TABLE
);
string
=
buildCreateTableJson
(
&
pCreateReq
->
ntb
.
schemaRow
,
NULL
,
pCreateReq
->
name
,
pCreateReq
->
uid
,
TSDB_NORMAL_TABLE
);
}
uDebug
(
"processCreateTable :%s"
,
string
);
}
...
...
@@ -709,7 +708,7 @@ static int32_t taosCreateStb(TAOS* taos, void* meta, int32_t metaLen) {
pReq
.
source
=
TD_REQ_FROM_TAOX
;
pReq
.
igExists
=
true
;
uDebug
(
"taosCreateStb name:%s suid:%"
PRId64
" processSuid:%"
PRId64
,
req
.
name
,
req
.
suid
,
pReq
.
suid
);
uDebug
(
"taosCreateStb name:%s suid:%"
PRId64
" processSuid:%"
PRId64
,
req
.
name
,
req
.
suid
,
pReq
.
suid
);
STscObj
*
pTscObj
=
pRequest
->
pTscObj
;
SName
tableName
;
tNameExtractFullName
(
toName
(
pTscObj
->
acctId
,
pRequest
->
pDb
,
req
.
name
,
&
tableName
),
pReq
.
name
);
...
...
@@ -776,20 +775,20 @@ static int32_t taosDropStb(TAOS* taos, void* meta, int32_t metaLen) {
goto
end
;
}
SCatalog
*
pCatalog
=
NULL
;
SCatalog
*
pCatalog
=
NULL
;
code
=
catalogGetHandle
(
pRequest
->
pTscObj
->
pAppInfo
->
clusterId
,
&
pCatalog
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
end
;
}
SRequestConnInfo
conn
=
{.
pTrans
=
pRequest
->
pTscObj
->
pAppInfo
->
pTransporter
,
.
requestId
=
pRequest
->
requestId
,
.
requestObjRefId
=
pRequest
->
self
,
.
mgmtEps
=
getEpSet_s
(
&
pRequest
->
pTscObj
->
pAppInfo
->
mgmtEp
)};
SName
pName
=
{
0
};
.
requestId
=
pRequest
->
requestId
,
.
requestObjRefId
=
pRequest
->
self
,
.
mgmtEps
=
getEpSet_s
(
&
pRequest
->
pTscObj
->
pAppInfo
->
mgmtEp
)};
SName
pName
=
{
0
};
toName
(
pRequest
->
pTscObj
->
acctId
,
pRequest
->
pDb
,
req
.
name
,
&
pName
);
STableMeta
*
pTableMeta
=
NULL
;
STableMeta
*
pTableMeta
=
NULL
;
code
=
catalogGetTableMeta
(
pCatalog
,
&
conn
,
&
pName
,
&
pTableMeta
);
if
(
code
==
TSDB_CODE_PAR_TABLE_NOT_EXIST
){
if
(
code
==
TSDB_CODE_PAR_TABLE_NOT_EXIST
)
{
code
=
TSDB_CODE_SUCCESS
;
taosMemoryFreeClear
(
pTableMeta
);
goto
end
;
...
...
@@ -804,9 +803,9 @@ static int32_t taosDropStb(TAOS* taos, void* meta, int32_t metaLen) {
// build drop stable
pReq
.
igNotExists
=
true
;
pReq
.
source
=
TD_REQ_FROM_TAOX
;
// pReq.suid = processSuid(req.suid, pRequest->pDb);
// pReq.suid = processSuid(req.suid, pRequest->pDb);
uDebug
(
"taosDropStb name:%s suid:%"
PRId64
" new suid:%"
PRId64
,
req
.
name
,
req
.
suid
,
pReq
.
suid
);
uDebug
(
"taosDropStb name:%s suid:%"
PRId64
" new suid:%"
PRId64
,
req
.
name
,
req
.
suid
,
pReq
.
suid
);
STscObj
*
pTscObj
=
pRequest
->
pTscObj
;
SName
tableName
=
{
0
};
tNameExtractFullName
(
toName
(
pTscObj
->
acctId
,
pRequest
->
pDb
,
req
.
name
,
&
tableName
),
pReq
.
name
);
...
...
@@ -831,7 +830,7 @@ static int32_t taosDropStb(TAOS* taos, void* meta, int32_t metaLen) {
launchQueryImpl
(
pRequest
,
&
pQuery
,
true
,
NULL
);
if
(
pRequest
->
code
==
TSDB_CODE_SUCCESS
)
{
// SCatalog* pCatalog = NULL;
// SCatalog* pCatalog = NULL;
catalogGetHandle
(
pTscObj
->
pAppInfo
->
clusterId
,
&
pCatalog
);
catalogRemoveTableMeta
(
pCatalog
,
&
tableName
);
}
...
...
@@ -924,8 +923,8 @@ static int32_t taosCreateTable(TAOS* taos, void* meta, int32_t metaLen) {
if
(
pCreateReq
->
type
==
TSDB_CHILD_TABLE
)
{
STableMeta
*
pTableMeta
=
NULL
;
SName
sName
=
{
0
};
tb_uid_t
oldSuid
=
pCreateReq
->
ctb
.
suid
;
// pCreateReq->ctb.suid = processSuid(pCreateReq->ctb.suid, pRequest->pDb);
tb_uid_t
oldSuid
=
pCreateReq
->
ctb
.
suid
;
// pCreateReq->ctb.suid = processSuid(pCreateReq->ctb.suid, pRequest->pDb);
toName
(
pTscObj
->
acctId
,
pRequest
->
pDb
,
pCreateReq
->
ctb
.
stbName
,
&
sName
);
code
=
catalogGetTableMeta
(
pCatalog
,
&
conn
,
&
sName
,
&
pTableMeta
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
...
...
@@ -933,7 +932,8 @@ static int32_t taosCreateTable(TAOS* taos, void* meta, int32_t metaLen) {
goto
end
;
}
pCreateReq
->
ctb
.
suid
=
pTableMeta
->
uid
;
uDebug
(
"taosCreateTable name:%s sname:%s suid:%"
PRId64
" new suid:%"
PRId64
,
pCreateReq
->
name
,
pCreateReq
->
ctb
.
stbName
,
oldSuid
,
pCreateReq
->
ctb
.
suid
);
uDebug
(
"taosCreateTable name:%s sname:%s suid:%"
PRId64
" new suid:%"
PRId64
,
pCreateReq
->
name
,
pCreateReq
->
ctb
.
stbName
,
oldSuid
,
pCreateReq
->
ctb
.
suid
);
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pCreateReq
->
ctb
.
tagName
);
i
++
)
{
char
*
tName
=
taosArrayGet
(
pCreateReq
->
ctb
.
tagName
,
i
);
...
...
@@ -1066,7 +1066,7 @@ static int32_t taosDropTable(TAOS* taos, void* meta, int32_t metaLen) {
for
(
int32_t
iReq
=
0
;
iReq
<
req
.
nReqs
;
iReq
++
)
{
pDropReq
=
req
.
pReqs
+
iReq
;
pDropReq
->
igNotExists
=
true
;
// pDropReq->suid = processSuid(pDropReq->suid, pRequest->pDb);
// pDropReq->suid = processSuid(pDropReq->suid, pRequest->pDb);
SVgroupInfo
pInfo
=
{
0
};
SName
pName
=
{
0
};
...
...
@@ -1076,9 +1076,9 @@ static int32_t taosDropTable(TAOS* taos, void* meta, int32_t metaLen) {
goto
end
;
}
STableMeta
*
pTableMeta
=
NULL
;
STableMeta
*
pTableMeta
=
NULL
;
code
=
catalogGetTableMeta
(
pCatalog
,
&
conn
,
&
pName
,
&
pTableMeta
);
if
(
code
==
TSDB_CODE_PAR_TABLE_NOT_EXIST
){
if
(
code
==
TSDB_CODE_PAR_TABLE_NOT_EXIST
)
{
code
=
TSDB_CODE_SUCCESS
;
taosMemoryFreeClear
(
pTableMeta
);
continue
;
...
...
@@ -1090,7 +1090,7 @@ static int32_t taosDropTable(TAOS* taos, void* meta, int32_t metaLen) {
tb_uid_t
oldSuid
=
pDropReq
->
suid
;
pDropReq
->
suid
=
pTableMeta
->
suid
;
taosMemoryFreeClear
(
pTableMeta
);
uDebug
(
"taosDropTable name:%s suid:%"
PRId64
" new suid:%"
PRId64
,
pDropReq
->
name
,
oldSuid
,
pDropReq
->
suid
);
uDebug
(
"taosDropTable name:%s suid:%"
PRId64
" new suid:%"
PRId64
,
pDropReq
->
name
,
oldSuid
,
pDropReq
->
suid
);
taosArrayPush
(
pRequest
->
tableList
,
&
pName
);
SVgroupDropTableBatch
*
pTableBatch
=
taosHashGet
(
pVgroupHashmap
,
&
pInfo
.
vgId
,
sizeof
(
pInfo
.
vgId
));
...
...
@@ -1106,7 +1106,7 @@ static int32_t taosDropTable(TAOS* taos, void* meta, int32_t metaLen) {
}
}
if
(
taosHashGetSize
(
pVgroupHashmap
)
==
0
){
if
(
taosHashGetSize
(
pVgroupHashmap
)
==
0
)
{
goto
end
;
}
SArray
*
pBufArray
=
serializeVgroupsDropTableBatch
(
pVgroupHashmap
);
...
...
@@ -1373,7 +1373,7 @@ int taos_write_raw_block_with_fields(TAOS* taos, int rows, char* pData, const ch
uError
(
"WriteRaw:catalogGetTableMeta failed. table name: %s"
,
tbname
);
goto
end
;
}
// uError("td23101 0vgId:%d, vgId:%d, name:%s, uid:%"PRIu64, vgData.vgId, pTableMeta->vgId, tbname, pTableMeta->uid);
// uError("td23101 0vgId:%d, vgId:%d, name:%s, uid:%"PRIu64, vgData.vgId, pTableMeta->vgId, tbname, pTableMeta->uid);
pQuery
=
smlInitHandle
();
if
(
pQuery
==
NULL
)
{
...
...
@@ -1382,7 +1382,8 @@ int taos_write_raw_block_with_fields(TAOS* taos, int rows, char* pData, const ch
}
pVgHash
=
taosHashInit
(
16
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_INT
),
true
,
HASH_NO_LOCK
);
taosHashPut
(
pVgHash
,
(
const
char
*
)
&
vgData
.
vgId
,
sizeof
(
vgData
.
vgId
),
(
char
*
)
&
vgData
,
sizeof
(
vgData
));
// uError("td23101 1vgId:%d, numEps:%d, name:%s, uid:%"PRIu64, vgData.vgId, vgData.epSet.numOfEps, tbname, pTableMeta->uid);
// uError("td23101 1vgId:%d, numEps:%d, name:%s, uid:%"PRIu64, vgData.vgId, vgData.epSet.numOfEps, tbname,
// pTableMeta->uid);
code
=
rawBlockBindData
(
pQuery
,
pTableMeta
,
pData
,
NULL
,
fields
,
numFields
,
false
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
...
...
@@ -1601,6 +1602,7 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) {
uError
(
"WriteRaw:rawBlockBindData failed"
);
goto
end
;
}
taosMemoryFreeClear
(
pTableMeta
);
}
code
=
smlBuildOutput
(
pQuery
,
pVgHash
);
...
...
@@ -1707,6 +1709,7 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen)
tDecoderInit
(
&
decoderTmp
,
*
dataTmp
,
*
lenTmp
);
if
(
tDecodeSVCreateTbReq
(
&
decoderTmp
,
&
pCreateReq
)
<
0
)
{
tDecoderClear
(
&
decoderTmp
);
tDestroySVCreateTbReq
(
&
pCreateReq
,
TSDB_MSG_FLG_DECODE
);
uError
(
"WriteRaw: tDecodeSVCreateTbReq error"
);
code
=
TSDB_CODE_TMQ_INVALID_MSG
;
goto
end
;
...
...
@@ -1715,15 +1718,19 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen)
if
(
pCreateReq
.
type
!=
TSDB_CHILD_TABLE
)
{
uError
(
"WriteRaw:pCreateReq.type != TSDB_CHILD_TABLE. table name: %s"
,
tbName
);
code
=
TSDB_CODE_TSC_INVALID_VALUE
;
tDecoderClear
(
&
decoderTmp
);
tDestroySVCreateTbReq
(
&
pCreateReq
,
TSDB_MSG_FLG_DECODE
);
goto
end
;
}
if
(
strcmp
(
tbName
,
pCreateReq
.
name
)
==
0
)
{
cloneSVreateTbReq
(
&
pCreateReq
,
&
pCreateReqDst
);
// pCreateReqDst->ctb.suid = processSuid(pCreateReqDst->ctb.suid, pRequest->pDb);
// pCreateReqDst->ctb.suid = processSuid(pCreateReqDst->ctb.suid, pRequest->pDb);
tDecoderClear
(
&
decoderTmp
);
tDestroySVCreateTbReq
(
&
pCreateReq
,
TSDB_MSG_FLG_DECODE
);
break
;
}
tDecoderClear
(
&
decoderTmp
);
tDestroySVCreateTbReq
(
&
pCreateReq
,
TSDB_MSG_FLG_DECODE
);
}
SVgroupInfo
vg
;
...
...
@@ -1774,6 +1781,7 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen)
goto
end
;
}
pCreateReqDst
=
NULL
;
taosMemoryFreeClear
(
pTableMeta
);
}
code
=
smlBuildOutput
(
pQuery
,
pVgHash
);
...
...
source/client/src/clientSml.c
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/client/src/clientTmq.c
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/client/test/clientTests.cpp
浏览文件 @
e9d7a099
...
...
@@ -52,15 +52,15 @@ void printResult(TAOS_RES* pRes) {
int32_t
n
=
0
;
char
str
[
512
]
=
{
0
};
while
((
pRow
=
taos_fetch_row
(
pRes
))
!=
NULL
)
{
// int32_t* length = taos_fetch_lengths(pRes);
// for(int32_t i = 0; i < numOfFields; ++i) {
// printf("(%d):%d " , i, length[i]);
// }
// printf("\n");
//
// int32_t code = taos_print_row(str, pRow, pFields, numOfFields);
// printf("%s\n", str);
// memset(str, 0, sizeof(str));
// int32_t* length = taos_fetch_lengths(pRes);
// for(int32_t i = 0; i < numOfFields; ++i) {
// printf("(%d):%d " , i, length[i]);
// }
// printf("\n");
//
// int32_t code = taos_print_row(str, pRow, pFields, numOfFields);
// printf("%s\n", str);
// memset(str, 0, sizeof(str));
}
}
...
...
@@ -112,7 +112,7 @@ void createNewTable(TAOS* pConn, int32_t index) {
}
taos_free_result
(
pRes
);
for
(
int32_t
i
=
0
;
i
<
100
;
i
+=
20
)
{
for
(
int32_t
i
=
0
;
i
<
100
;
i
+=
20
)
{
char
sql
[
1024
]
=
{
0
};
sprintf
(
sql
,
"insert into tu%d values(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)"
...
...
@@ -131,7 +131,7 @@ void createNewTable(TAOS* pConn, int32_t index) {
}
}
void
*
queryThread
(
void
*
arg
)
{
void
*
queryThread
(
void
*
arg
)
{
TAOS
*
pConn
=
taos_connect
(
"192.168.0.209"
,
"root"
,
"taosdata"
,
NULL
,
0
);
if
(
pConn
==
NULL
)
{
printf
(
"failed to connect to db, reason:%s"
,
taos_errstr
(
pConn
));
...
...
@@ -141,9 +141,10 @@ void *queryThread(void *arg) {
int64_t
el
=
0
;
for
(
int32_t
i
=
0
;
i
<
5000000
;
++
i
)
{
int64_t
st
=
taosGetTimestampUs
();
int64_t
st
=
taosGetTimestampUs
();
TAOS_RES
*
pRes
=
taos_query
(
pConn
,
"SELECT _wstart as ts,max(usage_user) FROM benchmarkcpu.host_49 WHERE ts >= 1451618560000 AND ts < 1451622160000 INTERVAL(1m) ;"
);
"SELECT _wstart as ts,max(usage_user) FROM benchmarkcpu.host_49 WHERE ts >= "
"1451618560000 AND ts < 1451622160000 INTERVAL(1m) ;"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed, reason:%s
\n
"
,
taos_errstr
(
pRes
));
}
else
{
...
...
@@ -153,7 +154,7 @@ void *queryThread(void *arg) {
taos_free_result
(
pRes
);
el
+=
(
taosGetTimestampUs
()
-
st
);
if
(
i
%
1000
==
0
&&
i
!=
0
)
{
printf
(
"total:%d, avg time:%.2fms
\n
"
,
i
,
el
/
(
double
)(
i
*
1000
));
printf
(
"total:%d, avg time:%.2fms
\n
"
,
i
,
el
/
(
double
)(
i
*
1000
));
}
}
...
...
@@ -163,9 +164,7 @@ void *queryThread(void *arg) {
static
int32_t
numOfThreads
=
1
;
void
tmq_commit_cb_print
(
tmq_t
*
pTmq
,
int32_t
code
,
void
*
param
)
{
printf
(
"success, code:%d
\n
"
,
code
);
}
void
tmq_commit_cb_print
(
tmq_t
*
pTmq
,
int32_t
code
,
void
*
param
)
{
printf
(
"success, code:%d
\n
"
,
code
);
}
void
*
doConsumeData
(
void
*
param
)
{
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
...
...
@@ -205,7 +204,7 @@ void* doConsumeData(void* param) {
while
(
1
)
{
TAOS_RES
*
pRes
=
tmq_consumer_poll
(
tmq
,
timeout
);
if
(
pRes
)
{
char
buf
[
1024
];
char
buf
[
1024
];
const
char
*
topicName
=
tmq_get_topic_name
(
pRes
);
const
char
*
dbName
=
tmq_get_db_name
(
pRes
);
...
...
@@ -226,7 +225,7 @@ void* doConsumeData(void* param) {
precision
=
taos_result_precision
(
pRes
);
taos_print_row
(
buf
,
row
,
fields
,
numOfFields
);
totalRows
+=
1
;
// printf("precision: %d, row content: %s\n", precision, buf);
// printf("precision: %d, row content: %s\n", precision, buf);
}
taos_free_result
(
pRes
);
...
...
@@ -491,17 +490,17 @@ TEST(clientCase, create_stable_Test) {
ASSERT_EQ
(
numOfFields
,
0
);
taos_free_result
(
pRes
);
// pRes = taos_query(pConn, "create stable if not exists abc1.`123_$^)` (ts timestamp, `abc` int) tags(a int)");
// if (taos_errno(pRes) != 0) {
// printf("failed to create super table 123_$^), reason:%s\n", taos_errstr(pRes));
// }
//
// pRes = taos_query(pConn, "use abc1");
// taos_free_result(pRes);
// pRes = taos_query(pConn, "drop stable `123_$^)`");
// if (taos_errno(pRes) != 0) {
// printf("failed to drop super table 123_$^), reason:%s\n", taos_errstr(pRes));
// }
// pRes = taos_query(pConn, "create stable if not exists abc1.`123_$^)` (ts timestamp, `abc` int) tags(a int)");
// if (taos_errno(pRes) != 0) {
// printf("failed to create super table 123_$^), reason:%s\n", taos_errstr(pRes));
// }
//
// pRes = taos_query(pConn, "use abc1");
// taos_free_result(pRes);
// pRes = taos_query(pConn, "drop stable `123_$^)`");
// if (taos_errno(pRes) != 0) {
// printf("failed to drop super table 123_$^), reason:%s\n", taos_errstr(pRes));
// }
taos_close
(
pConn
);
}
...
...
@@ -666,8 +665,7 @@ TEST(clientCase, create_multiple_tables) {
for
(
int32_t
i
=
0
;
i
<
500
;
i
+=
2
)
{
char
sql
[
512
]
=
{
0
};
snprintf
(
sql
,
tListLen
(
sql
),
"create table t_x_%d using st1 tags(2) t_x_%d using st1 tags(5)"
,
i
,
i
+
1
);
snprintf
(
sql
,
tListLen
(
sql
),
"create table t_x_%d using st1 tags(2) t_x_%d using st1 tags(5)"
,
i
,
i
+
1
);
TAOS_RES
*
pres
=
taos_query
(
pConn
,
sql
);
if
(
taos_errno
(
pres
)
!=
0
)
{
printf
(
"failed to create table %d
\n
, reason:%s"
,
i
,
taos_errstr
(
pres
));
...
...
@@ -701,7 +699,7 @@ TEST(clientCase, show_table_Test) {
int32_t
numOfFields
=
taos_num_fields
(
pRes
);
int32_t
count
=
0
;
char
str
[
512
]
=
{
0
};
char
str
[
512
]
=
{
0
};
while
((
pRow
=
taos_fetch_row
(
pRes
))
!=
NULL
)
{
int32_t
code
=
taos_print_row
(
str
,
pRow
,
pFields
,
numOfFields
);
...
...
@@ -712,30 +710,30 @@ TEST(clientCase, show_table_Test) {
taos_close
(
pConn
);
}
//TEST(clientCase, drop_stable_Test) {
// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
// assert(pConn != nullptr);
//
TEST(clientCase, drop_stable_Test) {
//
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
//
assert(pConn != nullptr);
//
// TAOS_RES* pRes = taos_query(pConn, "create database if not exists abc1");
// if (taos_errno(pRes) != 0) {
// printf("error in creating db, reason:%s\n", taos_errstr(pRes));
// }
// taos_free_result(pRes);
//
TAOS_RES* pRes = taos_query(pConn, "create database if not exists abc1");
//
if (taos_errno(pRes) != 0) {
//
printf("error in creating db, reason:%s\n", taos_errstr(pRes));
//
}
//
taos_free_result(pRes);
//
// pRes = taos_query(pConn, "use abc1");
// if (taos_errno(pRes) != 0) {
// printf("error in using db, reason:%s\n", taos_errstr(pRes));
// }
// taos_free_result(pRes);
//
pRes = taos_query(pConn, "use abc1");
//
if (taos_errno(pRes) != 0) {
//
printf("error in using db, reason:%s\n", taos_errstr(pRes));
//
}
//
taos_free_result(pRes);
//
// pRes = taos_query(pConn, "drop stable st1");
// if (taos_errno(pRes) != 0) {
// printf("failed to drop stable, reason:%s\n", taos_errstr(pRes));
// }
//
pRes = taos_query(pConn, "drop stable st1");
//
if (taos_errno(pRes) != 0) {
//
printf("failed to drop stable, reason:%s\n", taos_errstr(pRes));
//
}
//
// taos_free_result(pRes);
// taos_close(pConn);
//}
//
taos_free_result(pRes);
//
taos_close(pConn);
//
}
TEST
(
clientCase
,
generated_request_id_test
)
{
SHashObj
*
phash
=
taosHashInit
(
10000
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
false
,
HASH_ENTRY_LOCK
);
...
...
@@ -744,7 +742,7 @@ TEST(clientCase, generated_request_id_test) {
uint64_t
v
=
generateRequestId
();
void
*
result
=
taosHashGet
(
phash
,
&
v
,
sizeof
(
v
));
if
(
result
!=
nullptr
)
{
// printf("0x%llx, index:%d\n", v, i);
// printf("0x%llx, index:%d\n", v, i);
}
assert
(
result
==
nullptr
);
taosHashPut
(
phash
,
&
v
,
sizeof
(
v
),
NULL
,
0
);
...
...
@@ -832,7 +830,7 @@ TEST(clientCase, projection_query_tables) {
TEST
(
clientCase
,
tsbs_perf_test
)
{
TdThread
qid
[
20
]
=
{
0
};
for
(
int32_t
i
=
0
;
i
<
numOfThreads
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfThreads
;
++
i
)
{
taosThreadCreate
(
&
qid
[
i
],
NULL
,
queryThread
,
NULL
);
}
getchar
();
...
...
@@ -858,8 +856,8 @@ TEST(clientCase, projection_query_stables) {
char
str
[
512
]
=
{
0
};
while
((
pRow
=
taos_fetch_row
(
pRes
))
!=
NULL
)
{
// int32_t code = taos_print_row(str, pRow, pFields, numOfFields);
// printf("%s\n", str);
// int32_t code = taos_print_row(str, pRow, pFields, numOfFields);
// printf("%s\n", str);
}
taos_free_result
(
pRes
);
...
...
@@ -898,7 +896,8 @@ 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);
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
(
clientCase
,
async_api_test
)
{
...
...
@@ -912,7 +911,7 @@ TEST(clientCase, async_api_test) {
printf
(
"failed, reason:%s
\n
"
,
taos_errstr
(
pRes
));
}
int32_t
n
=
0
;
int32_t
n
=
0
;
TAOS_ROW
pRow
=
NULL
;
TAOS_FIELD
*
pFields
=
taos_fetch_fields
(
pRes
);
int32_t
numOfFields
=
taos_num_fields
(
pRes
);
...
...
@@ -920,8 +919,8 @@ TEST(clientCase, async_api_test) {
char
str
[
512
]
=
{
0
};
while
((
pRow
=
taos_fetch_row
(
pRes
))
!=
NULL
)
{
int32_t
*
length
=
taos_fetch_lengths
(
pRes
);
for
(
int32_t
i
=
0
;
i
<
numOfFields
;
++
i
)
{
printf
(
"(%d):%d "
,
i
,
length
[
i
]);
for
(
int32_t
i
=
0
;
i
<
numOfFields
;
++
i
)
{
printf
(
"(%d):%d "
,
i
,
length
[
i
]);
}
printf
(
"
\n
"
);
...
...
@@ -963,8 +962,8 @@ TEST(clientCase, update_test) {
taos_free_result
(
pRes
);
char
s
[
256
]
=
{
0
};
for
(
int32_t
i
=
0
;
i
<
17000
;
++
i
)
{
char
s
[
256
]
=
{
0
};
for
(
int32_t
i
=
0
;
i
<
17000
;
++
i
)
{
sprintf
(
s
,
"insert into tup values(now+%da, %d)"
,
i
,
i
);
pRes
=
taos_query
(
pConn
,
s
);
taos_free_result
(
pRes
);
...
...
@@ -998,7 +997,8 @@ TEST(clientCase, sub_db_test) {
// 创建订阅 topics 列表
tmq_list_t
*
topicList
=
tmq_list_new
();
tmq_list_append
(
topicList
,
"topic_db1"
);
tmq_list_append
(
topicList
,
"topic_t1"
);
tmq_list_append
(
topicList
,
"topic_s2"
);
// 启动订阅
tmq_subscribe
(
tmq
,
topicList
);
...
...
@@ -1027,7 +1027,7 @@ TEST(clientCase, sub_db_test) {
printf
(
"db: %s
\n
"
,
dbName
);
printf
(
"vgroup id: %d
\n
"
,
vgroupId
);
if
(
count
++
>
200
)
{
if
(
count
++
>
200
)
{
tmq_unsubscribe
(
tmq
);
break
;
}
...
...
@@ -1091,7 +1091,7 @@ TEST(clientCase, sub_tb_test) {
while
(
1
)
{
TAOS_RES
*
pRes
=
tmq_consumer_poll
(
tmq
,
timeout
);
if
(
pRes
)
{
char
buf
[
1024
];
char
buf
[
1024
];
const
char
*
topicName
=
tmq_get_topic_name
(
pRes
);
const
char
*
dbName
=
tmq_get_db_name
(
pRes
);
...
...
@@ -1116,9 +1116,9 @@ TEST(clientCase, sub_tb_test) {
}
taos_free_result
(
pRes
);
// if ((++count) > 1) {
// break;
// }
// if ((++count) > 1) {
// break;
// }
}
else
{
break
;
}
...
...
@@ -1133,11 +1133,11 @@ TEST(clientCase, sub_tb_mt_test) {
taos_options
(
TSDB_OPTION_CONFIGDIR
,
"~/first/cfg"
);
TdThread
qid
[
20
]
=
{
0
};
for
(
int32_t
i
=
0
;
i
<
1
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
1
;
++
i
)
{
taosThreadCreate
(
&
qid
[
i
],
NULL
,
doConsumeData
,
NULL
);
}
for
(
int32_t
i
=
0
;
i
<
4
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
4
;
++
i
)
{
taosThreadJoin
(
qid
[
i
],
NULL
);
}
}
...
...
source/common/src/tdatablock.c
浏览文件 @
e9d7a099
...
...
@@ -147,9 +147,17 @@ int32_t colDataReserve(SColumnInfoData* pColumnInfoData, size_t newSize) {
return
TSDB_CODE_SUCCESS
;
}
static
void
doCopyNItems
(
struct
SColumnInfoData
*
pColumnInfoData
,
int32_t
currentRow
,
const
char
*
pData
,
int32_t
itemLen
,
int32_t
numOfRows
)
{
ASSERT
(
pColumnInfoData
->
info
.
bytes
>=
itemLen
);
static
int32_t
doCopyNItems
(
struct
SColumnInfoData
*
pColumnInfoData
,
int32_t
currentRow
,
const
char
*
pData
,
int32_t
itemLen
,
int32_t
numOfRows
,
bool
trimValue
)
{
if
(
pColumnInfoData
->
info
.
bytes
<
itemLen
)
{
uWarn
(
"column/tag actual data len %d is bigger than schema len %d, trim it:%d"
,
itemLen
,
pColumnInfoData
->
info
.
bytes
,
trimValue
);
if
(
trimValue
)
{
itemLen
=
pColumnInfoData
->
info
.
bytes
;
}
else
{
return
TSDB_CODE_TDB_INVALID_TABLE_SCHEMA_VER
;
}
}
size_t
start
=
1
;
// the first item
...
...
@@ -178,10 +186,12 @@ static void doCopyNItems(struct SColumnInfoData* pColumnInfoData, int32_t curren
pColumnInfoData
->
varmeta
.
length
+=
numOfRows
*
itemLen
;
}
return
TSDB_CODE_SUCCESS
;
}
int32_t
colDataSetNItems
(
SColumnInfoData
*
pColumnInfoData
,
uint32_t
currentRow
,
const
char
*
pData
,
uint32_t
numOfRows
)
{
uint32_t
numOfRows
,
bool
trimValue
)
{
int32_t
len
=
pColumnInfoData
->
info
.
bytes
;
if
(
IS_VAR_DATA_TYPE
(
pColumnInfoData
->
info
.
type
))
{
len
=
varDataTLen
(
pData
);
...
...
@@ -193,8 +203,7 @@ int32_t colDataSetNItems(SColumnInfoData* pColumnInfoData, uint32_t currentRow,
}
}
doCopyNItems
(
pColumnInfoData
,
currentRow
,
pData
,
len
,
numOfRows
);
return
TSDB_CODE_SUCCESS
;
return
doCopyNItems
(
pColumnInfoData
,
currentRow
,
pData
,
len
,
numOfRows
,
trimValue
);
}
static
void
doBitmapMerge
(
SColumnInfoData
*
pColumnInfoData
,
int32_t
numOfRow1
,
const
SColumnInfoData
*
pSource
,
...
...
@@ -973,7 +982,7 @@ int32_t blockDataSort(SSDataBlock* pDataBlock, SArray* pOrderInfo) {
taosSort
(
pColInfoData
->
pData
,
pDataBlock
->
info
.
rows
,
pColInfoData
->
info
.
bytes
,
fn
);
int64_t
p1
=
taosGetTimestampUs
();
uDebug
(
"blockDataSort easy cost:%"
PRId64
", rows:%
d
\n
"
,
p1
-
p0
,
pDataBlock
->
info
.
rows
);
uDebug
(
"blockDataSort easy cost:%"
PRId64
", rows:%
"
PRId64
"
\n
"
,
p1
-
p0
,
pDataBlock
->
info
.
rows
);
return
TSDB_CODE_SUCCESS
;
}
else
{
// var data type
...
...
@@ -1026,6 +1035,7 @@ int32_t blockDataSort(SSDataBlock* pDataBlock, SArray* pOrderInfo) {
return
TSDB_CODE_SUCCESS
;
}
#if 0
typedef struct SHelper {
int32_t index;
union {
...
...
@@ -1074,59 +1084,20 @@ SHelper* createTupleIndex_rv(int32_t numOfRows, SArray* pOrderInfo, SSDataBlock*
int32_t dataBlockCompar_rv(const void* p1, const void* p2, const void* param) {
const SSDataBlockSortHelper* pHelper = (const SSDataBlockSortHelper*)param;
// SSDataBlock* pDataBlock = pHelper->pDataBlock;
SHelper* left = (SHelper*)p1;
SHelper* right = (SHelper*)p2;
SArray* pInfo = pHelper->orderInfo;
int32_t offset = 0;
// for(int32_t i = 0; i < pInfo->size; ++i) {
// SBlockOrderInfo* pOrder = TARRAY_GET_ELEM(pInfo, 0);
// SColumnInfoData* pColInfoData = pOrder->pColData;//TARRAY_GET_ELEM(pDataBlock->pDataBlock, pOrder->colIndex);
// if (pColInfoData->hasNull) {
// bool leftNull = colDataIsNull(pColInfoData, pDataBlock->info.rows, left, pDataBlock->pBlockAgg);
// bool rightNull = colDataIsNull(pColInfoData, pDataBlock->info.rows, right, pDataBlock->pBlockAgg);
// if (leftNull && rightNull) {
// continue; // continue to next slot
// }
//
// if (rightNull) {
// return pHelper->nullFirst? 1:-1;
// }
//
// if (leftNull) {
// return pHelper->nullFirst? -1:1;
// }
// }
// void* left1 = colDataGetData(pColInfoData, left);
// void* right1 = colDataGetData(pColInfoData, right);
// switch(pColInfoData->info.type) {
// case TSDB_DATA_TYPE_INT: {
int32_t leftx = *(int32_t*)left->pData; //*(int32_t*)(left->pData + offset);
int32_t rightx = *(int32_t*)right->pData; //*(int32_t*)(right->pData + offset);
// offset += pColInfoData->info.bytes;
if (leftx == rightx) {
// break;
return 0;
} else {
// if (pOrder->order == TSDB_ORDER_ASC) {
return (leftx < rightx) ? -1 : 1;
// } else {
// return (leftx < rightx)? 1:-1;
// }
}
// }
// default:
// assert(0);
// }
// }
}
return 0;
}
...
...
@@ -1170,6 +1141,7 @@ int32_t blockDataSort_rv(SSDataBlock* pDataBlock, SArray* pOrderInfo, bool nullF
// destroyTupleIndex(index);
return 0;
}
#endif
void
blockDataCleanup
(
SSDataBlock
*
pDataBlock
)
{
blockDataEmpty
(
pDataBlock
);
...
...
@@ -1180,7 +1152,7 @@ void blockDataCleanup(SSDataBlock* pDataBlock) {
void
blockDataEmpty
(
SSDataBlock
*
pDataBlock
)
{
SDataBlockInfo
*
pInfo
=
&
pDataBlock
->
info
;
if
(
pInfo
->
capacity
==
0
||
pInfo
->
rows
>
pDataBlock
->
info
.
capacity
)
{
if
(
pInfo
->
capacity
==
0
)
{
return
;
}
...
...
@@ -1739,14 +1711,14 @@ int32_t tEncodeDataBlock(void** buf, const SSDataBlock* pBlock) {
int64_t
tbUid
=
pBlock
->
info
.
id
.
uid
;
int16_t
numOfCols
=
taosArrayGetSize
(
pBlock
->
pDataBlock
);
int16_t
hasVarCol
=
pBlock
->
info
.
hasVarCol
;
int
32
_t
rows
=
pBlock
->
info
.
rows
;
int
64
_t
rows
=
pBlock
->
info
.
rows
;
int32_t
sz
=
taosArrayGetSize
(
pBlock
->
pDataBlock
);
int32_t
tlen
=
0
;
tlen
+=
taosEncodeFixedI64
(
buf
,
tbUid
);
tlen
+=
taosEncodeFixedI16
(
buf
,
numOfCols
);
tlen
+=
taosEncodeFixedI16
(
buf
,
hasVarCol
);
tlen
+=
taosEncodeFixedI
32
(
buf
,
rows
);
tlen
+=
taosEncodeFixedI
64
(
buf
,
rows
);
tlen
+=
taosEncodeFixedI32
(
buf
,
sz
);
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
SColumnInfoData
*
pColData
=
(
SColumnInfoData
*
)
taosArrayGet
(
pBlock
->
pDataBlock
,
i
);
...
...
@@ -1777,7 +1749,7 @@ void* tDecodeDataBlock(const void* buf, SSDataBlock* pBlock) {
buf
=
taosDecodeFixedU64
(
buf
,
&
pBlock
->
info
.
id
.
uid
);
buf
=
taosDecodeFixedI16
(
buf
,
&
numOfCols
);
buf
=
taosDecodeFixedI16
(
buf
,
&
pBlock
->
info
.
hasVarCol
);
buf
=
taosDecodeFixedI
32
(
buf
,
&
pBlock
->
info
.
rows
);
buf
=
taosDecodeFixedI
64
(
buf
,
&
pBlock
->
info
.
rows
);
buf
=
taosDecodeFixedI32
(
buf
,
&
sz
);
pBlock
->
pDataBlock
=
taosArrayInit
(
sz
,
sizeof
(
SColumnInfoData
));
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
...
...
@@ -1878,6 +1850,7 @@ static char* formatTimestamp(char* buf, int64_t val, int precision) {
return
buf
;
}
#if 0
void blockDebugShowDataBlock(SSDataBlock* pBlock, const char* flag) {
SArray* dataBlocks = taosArrayInit(1, sizeof(SSDataBlock*));
taosArrayPush(dataBlocks, &pBlock);
...
...
@@ -1970,6 +1943,8 @@ void blockDebugShowDataBlocks(const SArray* dataBlocks, const char* flag) {
}
}
#endif
// for debug
char
*
dumpBlockData
(
SSDataBlock
*
pDataBlock
,
const
char
*
flag
,
char
**
pDataBuf
)
{
int32_t
size
=
2048
;
...
...
@@ -1981,7 +1956,7 @@ char* dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf)
int32_t
len
=
0
;
len
+=
snprintf
(
dumpBuf
+
len
,
size
-
len
,
"===stream===%s|block type %d|child id %d|group id:%"
PRIu64
"|uid:%"
PRId64
"|rows:%
d
|version:%"
PRIu64
"|cal start:%"
PRIu64
"|cal end:%"
PRIu64
"|tbl:%s
\n
"
,
"|rows:%
"
PRId64
"
|version:%"
PRIu64
"|cal start:%"
PRIu64
"|cal end:%"
PRIu64
"|tbl:%s
\n
"
,
flag
,
(
int32_t
)
pDataBlock
->
info
.
type
,
pDataBlock
->
info
.
childId
,
pDataBlock
->
info
.
id
.
groupId
,
pDataBlock
->
info
.
id
.
uid
,
pDataBlock
->
info
.
rows
,
pDataBlock
->
info
.
version
,
pDataBlock
->
info
.
calWin
.
skey
,
pDataBlock
->
info
.
calWin
.
ekey
,
pDataBlock
->
info
.
parTbName
);
...
...
source/common/src/tdataformat.c
浏览文件 @
e9d7a099
...
...
@@ -2439,6 +2439,12 @@ _exit:
int32_t
tColDataAddValueByDataBlock
(
SColData
*
pColData
,
int8_t
type
,
int32_t
bytes
,
int32_t
nRows
,
char
*
lengthOrbitmap
,
char
*
data
)
{
int32_t
code
=
0
;
if
(
data
==
NULL
){
for
(
int32_t
i
=
0
;
i
<
nRows
;
++
i
)
{
code
=
tColDataAppendValueImpl
[
pColData
->
flag
][
CV_FLAG_NONE
](
pColData
,
NULL
,
0
);
}
goto
_exit
;
}
if
(
IS_VAR_DATA_TYPE
(
type
))
{
// var-length data type
for
(
int32_t
i
=
0
;
i
<
nRows
;
++
i
)
{
...
...
@@ -2447,6 +2453,11 @@ int32_t tColDataAddValueByDataBlock(SColData *pColData, int8_t type, int32_t byt
code
=
tColDataAppendValueImpl
[
pColData
->
flag
][
CV_FLAG_NULL
](
pColData
,
NULL
,
0
);
if
(
code
)
goto
_exit
;
}
else
{
if
(
ASSERT
(
varDataTLen
(
data
+
offset
)
<=
bytes
)){
uError
(
"var data length invalid, varDataTLen(data + offset):%d <= bytes:%d"
,
(
int
)
varDataTLen
(
data
+
offset
),
bytes
);
code
=
TSDB_CODE_INVALID_PARA
;
goto
_exit
;
}
code
=
tColDataAppendValueImpl
[
pColData
->
flag
][
CV_FLAG_VALUE
](
pColData
,
(
uint8_t
*
)
varDataVal
(
data
+
offset
),
varDataLen
(
data
+
offset
));
}
...
...
source/dnode/mgmt/exe/dmMain.c
浏览文件 @
e9d7a099
...
...
@@ -18,6 +18,7 @@
#include "mnode.h"
#include "tconfig.h"
#include "tglobal.h"
#include "version.h"
// clang-format off
#define DM_APOLLO_URL "The apollo string to use when configuring the server, such as: -a 'jsonFile:./tests/cfg.json', cfg.json text can be '{\"fqdn\":\"td1\"}'."
...
...
@@ -76,28 +77,28 @@ void dmLogCrash(int signum, void *sigInfo, void *context) {
taosIgnSignal
(
SIGINT
);
taosIgnSignal
(
SIGBREAK
);
#ifndef WINDOWS
#ifndef WINDOWS
taosIgnSignal
(
SIGBUS
);
#endif
taosIgnSignal
(
SIGABRT
);
taosIgnSignal
(
SIGFPE
);
taosIgnSignal
(
SIGSEGV
);
char
*
pMsg
=
NULL
;
char
*
pMsg
=
NULL
;
const
char
*
flags
=
"UTL FATAL "
;
ELogLevel
level
=
DEBUG_FATAL
;
int32_t
dflag
=
255
;
int64_t
msgLen
=
-
1
;
int64_t
msgLen
=
-
1
;
if
(
tsEnableCrashReport
)
{
if
(
taosGenCrashJsonMsg
(
signum
,
&
pMsg
,
dmGetClusterId
(),
global
.
startTime
))
{
taosPrintLog
(
flags
,
level
,
dflag
,
"failed to generate crash json msg"
);
goto
_return
;
}
else
{
msgLen
=
strlen
(
pMsg
);
msgLen
=
strlen
(
pMsg
);
}
}
_return:
taosLogCrashInfo
(
"taosd"
,
pMsg
,
msgLen
,
signum
,
sigInfo
);
...
...
@@ -123,7 +124,7 @@ static void dmSetSignalHandle() {
#ifndef WINDOWS
taosSetSignal
(
SIGBUS
,
dmLogCrash
);
#endif
#endif
taosSetSignal
(
SIGABRT
,
dmLogCrash
);
taosSetSignal
(
SIGFPE
,
dmLogCrash
);
taosSetSignal
(
SIGSEGV
,
dmLogCrash
);
...
...
@@ -134,7 +135,7 @@ static int32_t dmParseArgs(int32_t argc, char const *argv[]) {
int32_t
cmdEnvIndex
=
0
;
if
(
argc
<
2
)
return
0
;
global
.
envCmd
=
taosMemoryMalloc
((
argc
-
1
)
*
sizeof
(
char
*
));
memset
(
global
.
envCmd
,
0
,
(
argc
-
1
)
*
sizeof
(
char
*
));
for
(
int32_t
i
=
1
;
i
<
argc
;
++
i
)
{
...
...
@@ -203,6 +204,9 @@ static void dmPrintVersion() {
#endif
printf
(
"%s version: %s compatible_version: %s
\n
"
,
releaseName
,
version
,
compatible_version
);
printf
(
"gitinfo: %s
\n
"
,
gitinfo
);
#ifdef TD_ENTERPRISE
printf
(
"gitinfoOfInternal: %s
\n
"
,
gitinfoOfInternal
);
#endif
printf
(
"buildInfo: %s
\n
"
,
buildinfo
);
}
...
...
@@ -284,7 +288,7 @@ int mainWindows(int argc, char **argv) {
printf
(
"failed to init memory dbg, error:%s
\n
"
,
tstrerror
(
code
));
return
code
;
}
tsAsyncLog
=
false
;
tsAsyncLog
=
false
;
printf
(
"memory dbg enabled
\n
"
);
}
#endif
...
...
source/dnode/mgmt/mgmt_mnode/inc/mmInt.h
浏览文件 @
e9d7a099
...
...
@@ -34,7 +34,7 @@ typedef struct SMnodeMgmt {
SSingleWorker
readWorker
;
SSingleWorker
writeWorker
;
SSingleWorker
syncWorker
;
SSingleWorker
sync
Ctrl
Worker
;
SSingleWorker
sync
Rd
Worker
;
bool
stopped
;
int32_t
refCount
;
TdThreadRwlock
lock
;
...
...
@@ -54,7 +54,7 @@ int32_t mmStartWorker(SMnodeMgmt *pMgmt);
void
mmStopWorker
(
SMnodeMgmt
*
pMgmt
);
int32_t
mmPutMsgToWriteQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
mmPutMsgToSyncQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
mmPutMsgToSync
Ctrl
Queue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
mmPutMsgToSync
Rd
Queue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
mmPutMsgToReadQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
mmPutMsgToQueryQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
mmPutMsgToFetchQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
...
...
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
浏览文件 @
e9d7a099
...
...
@@ -189,7 +189,7 @@ SArray *mmGetMsgHandles() {
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_DROP_INDEX_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_DISABLE_WRITE_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_TIMEOUT
,
mmPutMsgToSyncQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_TIMEOUT
_ELECTION
,
mmPutMsgToSyncQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_CLIENT_REQUEST
,
mmPutMsgToSyncQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_CLIENT_REQUEST_BATCH
,
mmPutMsgToSyncQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_CLIENT_REQUEST_REPLY
,
mmPutMsgToSyncQueue
,
1
)
==
NULL
)
goto
_OVER
;
...
...
@@ -199,13 +199,16 @@ SArray *mmGetMsgHandles() {
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_APPEND_ENTRIES_BATCH
,
mmPutMsgToSyncQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_APPEND_ENTRIES_REPLY
,
mmPutMsgToSyncQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_SNAPSHOT_SEND
,
mmPutMsgToSyncQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_SNAPSHOT_RSP
,
mmPutMsgToSyncQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_PRE_SNAPSHOT
,
mmPutMsgToSyncQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_PRE_SNAPSHOT_REPLY
,
mmPutMsgToSyncQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_HEARTBEAT
,
mmPutMsgToSyncCtrlQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_HEARTBEAT_REPLY
,
mmPutMsgToSyncCtrlQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_FORCE_FOLLOWER_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_TIMEOUT
,
mmPutMsgToSyncRdQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_HEARTBEAT
,
mmPutMsgToSyncRdQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_HEARTBEAT_REPLY
,
mmPutMsgToSyncRdQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_SNAPSHOT_RSP
,
mmPutMsgToSyncRdQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_PRE_SNAPSHOT_REPLY
,
mmPutMsgToSyncRdQueue
,
1
)
==
NULL
)
goto
_OVER
;
code
=
0
;
_OVER:
...
...
source/dnode/mgmt/mgmt_mnode/src/mmWorker.c
浏览文件 @
e9d7a099
...
...
@@ -111,8 +111,8 @@ int32_t mmPutMsgToSyncQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) {
return
mmPutMsgToWorker
(
pMgmt
,
&
pMgmt
->
syncWorker
,
pMsg
);
}
int32_t
mmPutMsgToSync
Ctrl
Queue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
return
mmPutMsgToWorker
(
pMgmt
,
&
pMgmt
->
sync
Ctrl
Worker
,
pMsg
);
int32_t
mmPutMsgToSync
Rd
Queue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
return
mmPutMsgToWorker
(
pMgmt
,
&
pMgmt
->
sync
Rd
Worker
,
pMsg
);
}
int32_t
mmPutMsgToReadQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
...
...
@@ -151,8 +151,8 @@ int32_t mmPutMsgToQueue(SMnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc) {
case
SYNC_QUEUE
:
pWorker
=
&
pMgmt
->
syncWorker
;
break
;
case
SYNC_
CTRL
_QUEUE
:
pWorker
=
&
pMgmt
->
sync
Ctrl
Worker
;
case
SYNC_
RD
_QUEUE
:
pWorker
=
&
pMgmt
->
sync
Rd
Worker
;
break
;
default:
terrno
=
TSDB_CODE_INVALID_PARA
;
...
...
@@ -238,12 +238,12 @@ int32_t mmStartWorker(SMnodeMgmt *pMgmt) {
SSingleWorkerCfg
scCfg
=
{
.
min
=
1
,
.
max
=
1
,
.
name
=
"mnode-sync-
ctrl
"
,
.
name
=
"mnode-sync-
rd
"
,
.
fp
=
(
FItem
)
mmProcessSyncMsg
,
.
param
=
pMgmt
,
};
if
(
tSingleWorkerInit
(
&
pMgmt
->
sync
Ctrl
Worker
,
&
scCfg
)
!=
0
)
{
dError
(
"failed to start mnode mnode-sync-
ctrl
worker since %s"
,
terrstr
());
if
(
tSingleWorkerInit
(
&
pMgmt
->
sync
Rd
Worker
,
&
scCfg
)
!=
0
)
{
dError
(
"failed to start mnode mnode-sync-
rd
worker since %s"
,
terrstr
());
return
-
1
;
}
...
...
@@ -259,6 +259,6 @@ void mmStopWorker(SMnodeMgmt *pMgmt) {
tSingleWorkerCleanup
(
&
pMgmt
->
readWorker
);
tSingleWorkerCleanup
(
&
pMgmt
->
writeWorker
);
tSingleWorkerCleanup
(
&
pMgmt
->
syncWorker
);
tSingleWorkerCleanup
(
&
pMgmt
->
sync
Ctrl
Worker
);
tSingleWorkerCleanup
(
&
pMgmt
->
sync
Rd
Worker
);
dDebug
(
"mnode workers are closed"
);
}
source/dnode/mgmt/mgmt_vnode/inc/vmInt.h
浏览文件 @
e9d7a099
...
...
@@ -59,7 +59,7 @@ typedef struct {
SVnode
*
pImpl
;
SMultiWorker
pWriteW
;
SMultiWorker
pSyncW
;
SMultiWorker
pSync
Ctrl
W
;
SMultiWorker
pSync
Rd
W
;
SMultiWorker
pApplyW
;
STaosQueue
*
pQueryQ
;
STaosQueue
*
pStreamQ
;
...
...
@@ -107,7 +107,7 @@ 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
vmPutMsgToSync
Ctrl
Queue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
vmPutMsgToSync
Rd
Queue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
vmPutMsgToQueryQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
vmPutMsgToFetchQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
vmPutMsgToStreamQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
...
...
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
浏览文件 @
e9d7a099
...
...
@@ -21,7 +21,7 @@ void vmGetVnodeLoads(SVnodeMgmt *pMgmt, SMonVloadInfo *pInfo, bool isReset) {
if
(
pInfo
->
pVloads
==
NULL
)
return
;
tfsUpdateSize
(
pMgmt
->
pTfs
);
taosThreadRwlockRdlock
(
&
pMgmt
->
lock
);
void
*
pIter
=
taosHashIterate
(
pMgmt
->
hash
,
NULL
);
...
...
@@ -549,7 +549,7 @@ SArray *vmGetMsgHandles() {
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_SYNC_TIMEOUT
,
vmPutMsgToSyncQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_TIMEOUT
_ELECTION
,
vmPutMsgToSyncQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_CLIENT_REQUEST
,
vmPutMsgToSyncQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_CLIENT_REQUEST_BATCH
,
vmPutMsgToSyncQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_CLIENT_REQUEST_REPLY
,
vmPutMsgToSyncQueue
,
0
)
==
NULL
)
goto
_OVER
;
...
...
@@ -559,14 +559,15 @@ SArray *vmGetMsgHandles() {
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_APPEND_ENTRIES_BATCH
,
vmPutMsgToSyncQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_APPEND_ENTRIES_REPLY
,
vmPutMsgToSyncQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_SNAPSHOT_SEND
,
vmPutMsgToSyncQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_SNAPSHOT_RSP
,
vmPutMsgToSyncQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_PRE_SNAPSHOT
,
vmPutMsgToSyncQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_PRE_SNAPSHOT_REPLY
,
vmPutMsgToSyncQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_HEARTBEAT
,
vmPutMsgToSyncCtrlQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_HEARTBEAT_REPLY
,
vmPutMsgToSyncCtrlQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_FORCE_FOLLOWER
,
vmPutMsgToSyncQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_TIMEOUT
,
vmPutMsgToSyncRdQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_HEARTBEAT
,
vmPutMsgToSyncRdQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_HEARTBEAT_REPLY
,
vmPutMsgToSyncRdQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_SNAPSHOT_RSP
,
vmPutMsgToSyncRdQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_PRE_SNAPSHOT_REPLY
,
vmPutMsgToSyncRdQueue
,
0
)
==
NULL
)
goto
_OVER
;
code
=
0
;
_OVER:
...
...
source/dnode/mgmt/mgmt_vnode/src/vmInt.c
浏览文件 @
e9d7a099
...
...
@@ -98,9 +98,9 @@ void vmCloseVnode(SVnodeMgmt *pMgmt, SVnodeObj *pVnode, bool commitAndRemoveWal)
pVnode
->
pSyncW
.
queue
->
threadId
);
tMultiWorkerCleanup
(
&
pVnode
->
pSyncW
);
dInfo
(
"vgId:%d, wait for vnode sync
ctrl queue:%p is empty, thread:%08"
PRId64
,
pVnode
->
vgId
,
pVnode
->
pSync
CtrlW
.
queue
,
pVnode
->
pSyncCtrl
W
.
queue
->
threadId
);
tMultiWorkerCleanup
(
&
pVnode
->
pSync
Ctrl
W
);
dInfo
(
"vgId:%d, wait for vnode sync
rd queue:%p is empty, thread:%08"
PRId64
,
pVnode
->
vgId
,
pVnode
->
pSyncRdW
.
queue
,
pVnode
->
pSync
Rd
W
.
queue
->
threadId
);
tMultiWorkerCleanup
(
&
pVnode
->
pSync
Rd
W
);
dInfo
(
"vgId:%d, wait for vnode apply queue:%p is empty, thread:%08"
PRId64
,
pVnode
->
vgId
,
pVnode
->
pApplyW
.
queue
,
pVnode
->
pApplyW
.
queue
->
threadId
);
...
...
source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
浏览文件 @
e9d7a099
...
...
@@ -216,9 +216,9 @@ static int32_t vmPutMsgToQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg, EQueueType qtyp
dGTrace
(
"vgId:%d, msg:%p put into vnode-sync queue"
,
pVnode
->
vgId
,
pMsg
);
taosWriteQitem
(
pVnode
->
pSyncW
.
queue
,
pMsg
);
break
;
case
SYNC_
CTRL
_QUEUE
:
dGTrace
(
"vgId:%d, msg:%p put into vnode-sync-
ctrl
queue"
,
pVnode
->
vgId
,
pMsg
);
taosWriteQitem
(
pVnode
->
pSync
Ctrl
W
.
queue
,
pMsg
);
case
SYNC_
RD
_QUEUE
:
dGTrace
(
"vgId:%d, msg:%p put into vnode-sync-
rd
queue"
,
pVnode
->
vgId
,
pMsg
);
taosWriteQitem
(
pVnode
->
pSync
Rd
W
.
queue
,
pMsg
);
break
;
case
APPLY_QUEUE
:
dGTrace
(
"vgId:%d, msg:%p put into vnode-apply queue"
,
pVnode
->
vgId
,
pMsg
);
...
...
@@ -234,9 +234,7 @@ static int32_t vmPutMsgToQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg, EQueueType qtyp
return
code
;
}
int32_t
vmPutMsgToSyncCtrlQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
return
vmPutMsgToQueue
(
pMgmt
,
pMsg
,
SYNC_CTRL_QUEUE
);
}
int32_t
vmPutMsgToSyncRdQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
return
vmPutMsgToQueue
(
pMgmt
,
pMsg
,
SYNC_RD_QUEUE
);
}
int32_t
vmPutMsgToSyncQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
return
vmPutMsgToQueue
(
pMgmt
,
pMsg
,
SYNC_QUEUE
);
}
...
...
@@ -327,18 +325,18 @@ int32_t vmGetQueueSize(SVnodeMgmt *pMgmt, int32_t vgId, EQueueType qtype) {
int32_t
vmAllocQueue
(
SVnodeMgmt
*
pMgmt
,
SVnodeObj
*
pVnode
)
{
SMultiWorkerCfg
wcfg
=
{.
max
=
1
,
.
name
=
"vnode-write"
,
.
fp
=
(
FItems
)
vnodeProposeWriteMsg
,
.
param
=
pVnode
->
pImpl
};
SMultiWorkerCfg
scfg
=
{.
max
=
1
,
.
name
=
"vnode-sync"
,
.
fp
=
(
FItems
)
vmProcessSyncQueue
,
.
param
=
pVnode
};
SMultiWorkerCfg
sccfg
=
{.
max
=
1
,
.
name
=
"vnode-sync-
ctrl
"
,
.
fp
=
(
FItems
)
vmProcessSyncQueue
,
.
param
=
pVnode
};
SMultiWorkerCfg
sccfg
=
{.
max
=
1
,
.
name
=
"vnode-sync-
rd
"
,
.
fp
=
(
FItems
)
vmProcessSyncQueue
,
.
param
=
pVnode
};
SMultiWorkerCfg
acfg
=
{.
max
=
1
,
.
name
=
"vnode-apply"
,
.
fp
=
(
FItems
)
vnodeApplyWriteMsg
,
.
param
=
pVnode
->
pImpl
};
(
void
)
tMultiWorkerInit
(
&
pVnode
->
pWriteW
,
&
wcfg
);
(
void
)
tMultiWorkerInit
(
&
pVnode
->
pSyncW
,
&
scfg
);
(
void
)
tMultiWorkerInit
(
&
pVnode
->
pSync
Ctrl
W
,
&
sccfg
);
(
void
)
tMultiWorkerInit
(
&
pVnode
->
pSync
Rd
W
,
&
sccfg
);
(
void
)
tMultiWorkerInit
(
&
pVnode
->
pApplyW
,
&
acfg
);
pVnode
->
pQueryQ
=
tQWorkerAllocQueue
(
&
pMgmt
->
queryPool
,
pVnode
,
(
FItem
)
vmProcessQueryQueue
);
pVnode
->
pStreamQ
=
tAutoQWorkerAllocQueue
(
&
pMgmt
->
streamPool
,
pVnode
,
(
FItem
)
vmProcessStreamQueue
);
pVnode
->
pFetchQ
=
tWWorkerAllocQueue
(
&
pMgmt
->
fetchPool
,
pVnode
,
(
FItems
)
vmProcessFetchQueue
);
if
(
pVnode
->
pWriteW
.
queue
==
NULL
||
pVnode
->
pSyncW
.
queue
==
NULL
||
pVnode
->
pSync
Ctrl
W
.
queue
==
NULL
||
if
(
pVnode
->
pWriteW
.
queue
==
NULL
||
pVnode
->
pSyncW
.
queue
==
NULL
||
pVnode
->
pSync
Rd
W
.
queue
==
NULL
||
pVnode
->
pApplyW
.
queue
==
NULL
||
pVnode
->
pQueryQ
==
NULL
||
pVnode
->
pStreamQ
==
NULL
||
pVnode
->
pFetchQ
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
...
...
@@ -348,8 +346,8 @@ int32_t vmAllocQueue(SVnodeMgmt *pMgmt, SVnodeObj *pVnode) {
pVnode
->
pWriteW
.
queue
->
threadId
);
dInfo
(
"vgId:%d, sync-queue:%p is alloced, thread:%08"
PRId64
,
pVnode
->
vgId
,
pVnode
->
pSyncW
.
queue
,
pVnode
->
pSyncW
.
queue
->
threadId
);
dInfo
(
"vgId:%d, sync-
ctrl-queue:%p is alloced, thread:%08"
PRId64
,
pVnode
->
vgId
,
pVnode
->
pSyncCtrl
W
.
queue
,
pVnode
->
pSync
Ctrl
W
.
queue
->
threadId
);
dInfo
(
"vgId:%d, sync-
rd-queue:%p is alloced, thread:%08"
PRId64
,
pVnode
->
vgId
,
pVnode
->
pSyncRd
W
.
queue
,
pVnode
->
pSync
Rd
W
.
queue
->
threadId
);
dInfo
(
"vgId:%d, apply-queue:%p is alloced, thread:%08"
PRId64
,
pVnode
->
vgId
,
pVnode
->
pApplyW
.
queue
,
pVnode
->
pApplyW
.
queue
->
threadId
);
dInfo
(
"vgId:%d, query-queue:%p is alloced"
,
pVnode
->
vgId
,
pVnode
->
pQueryQ
);
...
...
source/dnode/mnode/impl/inc/mndDef.h
浏览文件 @
e9d7a099
...
...
@@ -393,7 +393,7 @@ typedef struct {
}
SSmaObj
;
typedef
struct
{
char
name
[
TSDB_
TABLE
_FNAME_LEN
];
char
name
[
TSDB_
INDEX
_FNAME_LEN
];
char
stb
[
TSDB_TABLE_FNAME_LEN
];
char
db
[
TSDB_DB_FNAME_LEN
];
char
dstTbName
[
TSDB_TABLE_FNAME_LEN
];
...
...
source/dnode/mnode/impl/src/mndConsumer.c
浏览文件 @
e9d7a099
...
...
@@ -81,9 +81,7 @@ bool mndRebTryStart() {
return
old
==
0
;
}
void
mndRebEnd
()
{
mndRebCntDec
();
}
void
mndRebEnd
()
{
mndRebCntDec
();
}
void
mndRebCntInc
()
{
int32_t
val
=
atomic_add_fetch_32
(
&
mqRebInExecCnt
,
1
);
...
...
@@ -247,6 +245,13 @@ static SMqRebInfo *mndGetOrCreateRebSub(SHashObj *pHash, const char *key) {
return
pRebInfo
;
}
static
void
freeRebalanceItem
(
void
*
param
)
{
SMqRebInfo
*
pInfo
=
param
;
taosArrayDestroy
(
pInfo
->
lostConsumers
);
taosArrayDestroy
(
pInfo
->
newConsumers
);
taosArrayDestroy
(
pInfo
->
removedConsumers
);
}
static
int32_t
mndProcessMqTimerMsg
(
SRpcMsg
*
pMsg
)
{
SMnode
*
pMnode
=
pMsg
->
info
.
node
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
...
...
@@ -262,8 +267,21 @@ static int32_t mndProcessMqTimerMsg(SRpcMsg *pMsg) {
}
SMqDoRebalanceMsg
*
pRebMsg
=
rpcMallocCont
(
sizeof
(
SMqDoRebalanceMsg
));
if
(
pRebMsg
==
NULL
)
{
mError
(
"failed to create the rebalance msg, size:%d, quit mq timer"
,
(
int32_t
)
sizeof
(
SMqDoRebalanceMsg
));
mndRebEnd
();
return
TSDB_CODE_OUT_OF_MEMORY
;
}
pRebMsg
->
rebSubHash
=
taosHashInit
(
64
,
MurmurHash3_32
,
true
,
HASH_NO_LOCK
);
// TODO set cleanfp
if
(
pRebMsg
->
rebSubHash
==
NULL
)
{
mError
(
"failed to create rebalance hashmap"
);
rpcFreeCont
(
pRebMsg
);
mndRebEnd
();
return
TSDB_CODE_OUT_OF_MEMORY
;
}
taosHashSetFreeFp
(
pRebMsg
->
rebSubHash
,
freeRebalanceItem
);
// iterate all consumers, find all modification
while
(
1
)
{
...
...
@@ -356,7 +374,7 @@ static int32_t mndProcessMqTimerMsg(SRpcMsg *pMsg) {
}
else
{
taosHashCleanup
(
pRebMsg
->
rebSubHash
);
rpcFreeCont
(
pRebMsg
);
mDebug
(
"mq
rebalance finished, no modification
"
);
mDebug
(
"mq
timer finished, no need to re-balance
"
);
mndRebEnd
();
}
return
0
;
...
...
@@ -576,7 +594,7 @@ int32_t mndSetConsumerCommitLogs(SMnode *pMnode, STrans *pTrans, SMqConsumerObj
return
0
;
}
static
int32_t
validateTopics
(
const
SArray
*
pTopicList
,
SMnode
*
pMnode
,
const
char
*
pUser
)
{
static
int32_t
validateTopics
(
const
SArray
*
pTopicList
,
SMnode
*
pMnode
,
const
char
*
pUser
)
{
int32_t
numOfTopics
=
taosArrayGetSize
(
pTopicList
);
for
(
int32_t
i
=
0
;
i
<
numOfTopics
;
i
++
)
{
...
...
@@ -597,8 +615,13 @@ static int32_t validateTopics(const SArray* pTopicList, SMnode* pMnode, const ch
return
0
;
}
static
void
*
topicNameDup
(
void
*
p
){
return
taosStrdup
((
char
*
)
p
);
static
void
*
topicNameDup
(
void
*
p
)
{
return
taosStrdup
((
char
*
)
p
);
}
static
void
freeItem
(
void
*
param
)
{
void
*
pItem
=
*
(
void
**
)
param
;
if
(
pItem
!=
NULL
)
{
taosMemoryFree
(
pItem
);
}
}
int32_t
mndProcessSubscribeReq
(
SRpcMsg
*
pMsg
)
{
...
...
@@ -616,7 +639,7 @@ int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) {
int32_t
code
=
-
1
;
SArray
*
pTopicList
=
subscribe
.
topicNames
;
taosArraySort
(
pTopicList
,
taosArrayCompareString
);
taosArrayRemoveDuplicate
P
(
pTopicList
,
taosArrayCompareString
,
taosMemoryFree
);
taosArrayRemoveDuplicate
(
pTopicList
,
taosArrayCompareString
,
freeItem
);
int32_t
newTopicNum
=
taosArrayGetSize
(
pTopicList
);
...
...
@@ -633,8 +656,8 @@ int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) {
pExistedConsumer
=
mndAcquireConsumer
(
pMnode
,
consumerId
);
if
(
pExistedConsumer
==
NULL
)
{
mInfo
(
"receive subscribe request from new consumer:0x%"
PRIx64
" cgroup:%s, numOfTopics:%d"
,
consumerId
,
subscribe
.
cgroup
,
(
int32_t
)
taosArrayGetSize
(
pTopicList
));
mInfo
(
"receive subscribe request from new consumer:0x%"
PRIx64
" cgroup:%s, numOfTopics:%d"
,
consumerId
,
subscribe
.
cgroup
,
(
int32_t
)
taosArrayGetSize
(
pTopicList
));
pConsumerNew
=
tNewSMqConsumerObj
(
consumerId
,
cgroup
);
tstrncpy
(
pConsumerNew
->
clientId
,
subscribe
.
clientId
,
tListLen
(
pConsumerNew
->
clientId
));
...
...
@@ -656,8 +679,9 @@ int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) {
/*taosRLockLatch(&pExistedConsumer->lock);*/
int32_t
status
=
atomic_load_32
(
&
pExistedConsumer
->
status
);
mInfo
(
"receive subscribe request from existed consumer:0x%"
PRIx64
" cgroup:%s, current status:%d(%s), subscribe topic num: %d"
,
consumerId
,
subscribe
.
cgroup
,
status
,
mndConsumerStatusName
(
status
),
newTopicNum
);
mInfo
(
"receive subscribe request from existed consumer:0x%"
PRIx64
" cgroup:%s, current status:%d(%s), subscribe topic num: %d"
,
consumerId
,
subscribe
.
cgroup
,
status
,
mndConsumerStatusName
(
status
),
newTopicNum
);
if
(
status
!=
MQ_CONSUMER_STATUS__READY
)
{
terrno
=
TSDB_CODE_MND_CONSUMER_NOT_READY
;
...
...
@@ -674,7 +698,7 @@ int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) {
taosArrayDestroy
(
pConsumerNew
->
assignedTopics
);
pConsumerNew
->
assignedTopics
=
taosArrayDup
(
pTopicList
,
topicNameDup
);
int32_t
oldTopicNum
=
(
pExistedConsumer
->
currentTopics
)
?
taosArrayGetSize
(
pExistedConsumer
->
currentTopics
)
:
0
;
int32_t
oldTopicNum
=
(
pExistedConsumer
->
currentTopics
)
?
taosArrayGetSize
(
pExistedConsumer
->
currentTopics
)
:
0
;
int32_t
i
=
0
,
j
=
0
;
while
(
i
<
oldTopicNum
||
j
<
newTopicNum
)
{
...
...
@@ -839,12 +863,59 @@ static int32_t mndConsumerActionInsert(SSdb *pSdb, SMqConsumerObj *pConsumer) {
}
static
int32_t
mndConsumerActionDelete
(
SSdb
*
pSdb
,
SMqConsumerObj
*
pConsumer
)
{
mDebug
(
"consumer:0x%"
PRIx64
" perform delete action, status:(%d)%s"
,
pConsumer
->
consumerId
,
pConsumer
->
status
,
mndConsumerStatusName
(
pConsumer
->
status
));
mDebug
(
"consumer:0x%"
PRIx64
" perform delete action, status:(%d)%s"
,
pConsumer
->
consumerId
,
pConsumer
->
status
,
mndConsumerStatusName
(
pConsumer
->
status
));
tDeleteSMqConsumerObj
(
pConsumer
);
return
0
;
}
static
void
updateConsumerStatus
(
SMqConsumerObj
*
pConsumer
)
{
int32_t
status
=
pConsumer
->
status
;
if
(
taosArrayGetSize
(
pConsumer
->
rebNewTopics
)
==
0
&&
taosArrayGetSize
(
pConsumer
->
rebRemovedTopics
)
==
0
)
{
if
(
status
==
MQ_CONSUMER_STATUS__MODIFY
||
status
==
MQ_CONSUMER_STATUS__MODIFY_IN_REB
)
{
pConsumer
->
status
=
MQ_CONSUMER_STATUS__READY
;
}
else
if
(
status
==
MQ_CONSUMER_STATUS__LOST_IN_REB
||
status
==
MQ_CONSUMER_STATUS__LOST
)
{
pConsumer
->
status
=
MQ_CONSUMER_STATUS__LOST_REBD
;
}
}
else
{
if
(
status
==
MQ_CONSUMER_STATUS__MODIFY
||
status
==
MQ_CONSUMER_STATUS__MODIFY_IN_REB
)
{
pConsumer
->
status
=
MQ_CONSUMER_STATUS__MODIFY
;
}
else
if
(
status
==
MQ_CONSUMER_STATUS__LOST
||
status
==
MQ_CONSUMER_STATUS__LOST_IN_REB
)
{
pConsumer
->
status
=
MQ_CONSUMER_STATUS__LOST
;
}
}
}
// remove from new topic
static
void
removeFromNewTopicList
(
SMqConsumerObj
*
pConsumer
,
const
char
*
pTopic
)
{
int32_t
size
=
taosArrayGetSize
(
pConsumer
->
rebNewTopics
);
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pConsumer
->
rebNewTopics
);
i
++
)
{
char
*
p
=
taosArrayGetP
(
pConsumer
->
rebNewTopics
,
i
);
if
(
strcmp
(
pTopic
,
p
)
==
0
)
{
taosArrayRemove
(
pConsumer
->
rebNewTopics
,
i
);
taosMemoryFree
(
p
);
mDebug
(
"consumer:0x%"
PRIx64
" remove new topic:%s in the topic list, remain newTopics:%d"
,
pConsumer
->
consumerId
,
pTopic
,
(
int
)
taosArrayGetSize
(
pConsumer
->
rebNewTopics
));
break
;
}
}
}
// remove from removed topic
static
void
removeFromRemoveTopicList
(
SMqConsumerObj
*
pConsumer
,
const
char
*
pTopic
)
{
int32_t
size
=
taosArrayGetSize
(
pConsumer
->
rebRemovedTopics
);
for
(
int32_t
i
=
0
;
i
<
size
;
i
++
)
{
char
*
p
=
taosArrayGetP
(
pConsumer
->
rebRemovedTopics
,
i
);
if
(
strcmp
(
pTopic
,
p
)
==
0
)
{
taosArrayRemove
(
pConsumer
->
rebRemovedTopics
,
i
);
taosMemoryFree
(
p
);
break
;
}
}
}
static
int32_t
mndConsumerActionUpdate
(
SSdb
*
pSdb
,
SMqConsumerObj
*
pOldConsumer
,
SMqConsumerObj
*
pNewConsumer
)
{
mDebug
(
"consumer:0x%"
PRIx64
" perform update action, update type:%d, subscribe-time:%"
PRId64
", uptime:%"
PRId64
,
pOldConsumer
->
consumerId
,
pNewConsumer
->
updateType
,
pOldConsumer
->
subscribeTime
,
pOldConsumer
->
upTime
);
...
...
@@ -855,6 +926,7 @@ static int32_t mndConsumerActionUpdate(SSdb *pSdb, SMqConsumerObj *pOldConsumer,
/*A(taosArrayGetSize(pOldConsumer->rebNewTopics) == 0);*/
/*A(taosArrayGetSize(pOldConsumer->rebRemovedTopics) == 0);*/
// this new consumer has identical topics with one existed consumers.
if
(
taosArrayGetSize
(
pNewConsumer
->
rebNewTopics
)
==
0
&&
taosArrayGetSize
(
pNewConsumer
->
rebRemovedTopics
)
==
0
)
{
pOldConsumer
->
status
=
MQ_CONSUMER_STATUS__READY
;
}
else
{
...
...
@@ -871,7 +943,6 @@ static int32_t mndConsumerActionUpdate(SSdb *pSdb, SMqConsumerObj *pOldConsumer,
pNewConsumer
->
assignedTopics
=
tmp
;
pOldConsumer
->
subscribeTime
=
pNewConsumer
->
upTime
;
pOldConsumer
->
status
=
MQ_CONSUMER_STATUS__MODIFY
;
}
}
else
if
(
pNewConsumer
->
updateType
==
CONSUMER_UPDATE__LOST
)
{
...
...
@@ -911,71 +982,48 @@ static int32_t mndConsumerActionUpdate(SSdb *pSdb, SMqConsumerObj *pOldConsumer,
pOldConsumer
->
rebalanceTime
=
pNewConsumer
->
upTime
;
}
else
if
(
pNewConsumer
->
updateType
==
CONSUMER_UPDATE__ADD
)
{
/*A(taosArrayGetSize(pNewConsumer->rebNewTopics) == 1);*/
/*A(taosArrayGetSize(pNewConsumer->rebRemovedTopics) == 0);*/
ASSERT
(
taosArrayGetSize
(
pNewConsumer
->
rebNewTopics
)
==
1
&&
taosArrayGetSize
(
pNewConsumer
->
rebRemovedTopics
)
==
0
);
char
*
pNewTopic
=
taosStrdup
(
taosArrayGetP
(
pNewConsumer
->
rebNewTopics
,
0
));
char
*
addedTopic
=
taosStrdup
(
taosArrayGetP
(
pNewConsumer
->
rebNewTopics
,
0
));
// not exist in current topic
bool
existing
=
false
;
#if 1
bool
existing
=
false
;
int32_t
numOfExistedTopics
=
taosArrayGetSize
(
pOldConsumer
->
currentTopics
);
for
(
int32_t
i
=
0
;
i
<
numOfExistedTopics
;
i
++
)
{
char
*
topic
=
taosArrayGetP
(
pOldConsumer
->
currentTopics
,
i
);
if
(
strcmp
(
topic
,
added
Topic
)
==
0
)
{
if
(
strcmp
(
topic
,
pNew
Topic
)
==
0
)
{
existing
=
true
;
}
}
#endif
// remove from new topic
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pOldConsumer
->
rebNewTopics
);
i
++
)
{
char
*
topic
=
taosArrayGetP
(
pOldConsumer
->
rebNewTopics
,
i
);
if
(
strcmp
(
addedTopic
,
topic
)
==
0
)
{
taosArrayRemove
(
pOldConsumer
->
rebNewTopics
,
i
);
taosMemoryFree
(
topic
);
break
;
}
}
removeFromNewTopicList
(
pOldConsumer
,
pNewTopic
);
// add to current topic
if
(
!
existing
)
{
taosArrayPush
(
pOldConsumer
->
currentTopics
,
&
added
Topic
);
taosArrayPush
(
pOldConsumer
->
currentTopics
,
&
pNew
Topic
);
taosArraySort
(
pOldConsumer
->
currentTopics
,
taosArrayCompareString
);
}
else
{
taosMemoryFree
(
added
Topic
);
taosMemoryFree
(
pNew
Topic
);
}
// set status
int32_t
status
=
pOldConsumer
->
status
;
if
(
taosArrayGetSize
(
pOldConsumer
->
rebNewTopics
)
==
0
&&
taosArrayGetSize
(
pOldConsumer
->
rebRemovedTopics
)
==
0
)
{
if
(
status
==
MQ_CONSUMER_STATUS__MODIFY
||
status
==
MQ_CONSUMER_STATUS__MODIFY_IN_REB
)
{
pOldConsumer
->
status
=
MQ_CONSUMER_STATUS__READY
;
}
else
if
(
status
==
MQ_CONSUMER_STATUS__LOST_IN_REB
||
status
==
MQ_CONSUMER_STATUS__LOST
)
{
pOldConsumer
->
status
=
MQ_CONSUMER_STATUS__LOST_REBD
;
}
}
else
{
if
(
status
==
MQ_CONSUMER_STATUS__MODIFY
||
status
==
MQ_CONSUMER_STATUS__MODIFY_IN_REB
)
{
pOldConsumer
->
status
=
MQ_CONSUMER_STATUS__MODIFY_IN_REB
;
}
else
if
(
status
==
MQ_CONSUMER_STATUS__LOST
||
status
==
MQ_CONSUMER_STATUS__LOST_IN_REB
)
{
pOldConsumer
->
status
=
MQ_CONSUMER_STATUS__LOST_IN_REB
;
}
}
updateConsumerStatus
(
pOldConsumer
);
// the re-balance is triggered when the new consumer is launched.
pOldConsumer
->
rebalanceTime
=
pNewConsumer
->
upTime
;
atomic_add_fetch_32
(
&
pOldConsumer
->
epoch
,
1
);
mDebug
(
"consumer:0x%"
PRIx64
" state (%d)%s -> (%d)%s, new epoch:%d, reb-time:%"
PRId64
", current topics:%d"
,
mDebug
(
"consumer:0x%"
PRIx64
" state (%d)%s -> (%d)%s, new epoch:%d, reb-time:%"
PRId64
", current topics:%d, newTopics:%d, removeTopics:%d"
,
pOldConsumer
->
consumerId
,
status
,
mndConsumerStatusName
(
status
),
pOldConsumer
->
status
,
mndConsumerStatusName
(
pOldConsumer
->
status
),
pOldConsumer
->
epoch
,
pOldConsumer
->
rebalanceTime
,
(
int
)
taosArrayGetSize
(
pOldConsumer
->
currentTopics
));
mndConsumerStatusName
(
pOldConsumer
->
status
),
pOldConsumer
->
epoch
,
pOldConsumer
->
rebalanceTime
,
(
int
)
taosArrayGetSize
(
pOldConsumer
->
currentTopics
),
(
int
)
taosArrayGetSize
(
pOldConsumer
->
rebNewTopics
),
(
int
)
taosArrayGetSize
(
pOldConsumer
->
rebRemovedTopics
));
}
else
if
(
pNewConsumer
->
updateType
==
CONSUMER_UPDATE__REMOVE
)
{
/*A(taosArrayGetSize(pNewConsumer->rebNewTopics) == 0);*/
/*A(taosArrayGetSize(pNewConsumer->rebRemovedTopics) == 1);*/
char
*
removedTopic
=
taosArrayGetP
(
pNewConsumer
->
rebRemovedTopics
,
0
);
// not exist in new topic
#if 0
for (int32_t i = 0; i < taosArrayGetSize(pOldConsumer->rebNewTopics); i++) {
char *topic = taosArrayGetP(pOldConsumer->rebNewTopics, i);
...
...
@@ -984,14 +1032,7 @@ static int32_t mndConsumerActionUpdate(SSdb *pSdb, SMqConsumerObj *pOldConsumer,
#endif
// remove from removed topic
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pOldConsumer
->
rebRemovedTopics
);
i
++
)
{
char
*
topic
=
taosArrayGetP
(
pOldConsumer
->
rebRemovedTopics
,
i
);
if
(
strcmp
(
removedTopic
,
topic
)
==
0
)
{
taosArrayRemove
(
pOldConsumer
->
rebRemovedTopics
,
i
);
taosMemoryFree
(
topic
);
break
;
}
}
removeFromRemoveTopicList
(
pOldConsumer
,
removedTopic
);
// remove from current topic
int32_t
i
=
0
;
...
...
@@ -1004,32 +1045,20 @@ static int32_t mndConsumerActionUpdate(SSdb *pSdb, SMqConsumerObj *pOldConsumer,
break
;
}
}
// must find the topic
/*A(i < sz);*/
// set status
int32_t
status
=
pOldConsumer
->
status
;
if
(
taosArrayGetSize
(
pOldConsumer
->
rebNewTopics
)
==
0
&&
taosArrayGetSize
(
pOldConsumer
->
rebRemovedTopics
)
==
0
)
{
if
(
status
==
MQ_CONSUMER_STATUS__MODIFY
||
status
==
MQ_CONSUMER_STATUS__MODIFY_IN_REB
)
{
pOldConsumer
->
status
=
MQ_CONSUMER_STATUS__READY
;
}
else
if
(
status
==
MQ_CONSUMER_STATUS__LOST_IN_REB
||
status
==
MQ_CONSUMER_STATUS__LOST
)
{
pOldConsumer
->
status
=
MQ_CONSUMER_STATUS__LOST_REBD
;
}
}
else
{
if
(
status
==
MQ_CONSUMER_STATUS__MODIFY
||
status
==
MQ_CONSUMER_STATUS__MODIFY_IN_REB
)
{
pOldConsumer
->
status
=
MQ_CONSUMER_STATUS__MODIFY_IN_REB
;
}
else
if
(
status
==
MQ_CONSUMER_STATUS__LOST
||
status
==
MQ_CONSUMER_STATUS__LOST_IN_REB
)
{
pOldConsumer
->
status
=
MQ_CONSUMER_STATUS__LOST_IN_REB
;
}
}
updateConsumerStatus
(
pOldConsumer
);
pOldConsumer
->
rebalanceTime
=
pNewConsumer
->
upTime
;
atomic_add_fetch_32
(
&
pOldConsumer
->
epoch
,
1
);
mDebug
(
"consumer:0x%"
PRIx64
" state %d(%s) -> %d(%s), new epoch:%d, reb-time:%"
PRId64
", current topics:%d"
,
mDebug
(
"consumer:0x%"
PRIx64
" state (%d)%s -> (%d)%s, new epoch:%d, reb-time:%"
PRId64
", current topics:%d, newTopics:%d, removeTopics:%d"
,
pOldConsumer
->
consumerId
,
status
,
mndConsumerStatusName
(
status
),
pOldConsumer
->
status
,
mndConsumerStatusName
(
pOldConsumer
->
status
),
pOldConsumer
->
epoch
,
pOldConsumer
->
rebalanceTime
,
(
int
)
taosArrayGetSize
(
pOldConsumer
->
currentTopics
));
mndConsumerStatusName
(
pOldConsumer
->
status
),
pOldConsumer
->
epoch
,
pOldConsumer
->
rebalanceTime
,
(
int
)
taosArrayGetSize
(
pOldConsumer
->
currentTopics
),
(
int
)
taosArrayGetSize
(
pOldConsumer
->
rebNewTopics
),
(
int
)
taosArrayGetSize
(
pOldConsumer
->
rebRemovedTopics
));
}
taosWUnLockLatch
(
&
pOldConsumer
->
lock
);
...
...
@@ -1105,8 +1134,8 @@ static int32_t mndRetrieveConsumer(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *
colDataSetVal
(
pColInfo
,
numOfRows
,
(
const
char
*
)
clientId
,
false
);
// status
char
status
[
20
+
VARSTR_HEADER_SIZE
]
=
{
0
};
const
char
*
pStatusName
=
mndConsumerStatusName
(
pConsumer
->
status
);
char
status
[
20
+
VARSTR_HEADER_SIZE
]
=
{
0
};
const
char
*
pStatusName
=
mndConsumerStatusName
(
pConsumer
->
status
);
STR_TO_VARSTR
(
status
,
pStatusName
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
...
...
source/dnode/mnode/impl/src/mndIndex.c
浏览文件 @
e9d7a099
...
...
@@ -138,7 +138,7 @@ static void *mndBuildDropIdxReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pStbOb
mInfo
(
"idx: %s start to build drop index req"
,
pIdx
->
name
);
len
=
tSerializeSDropIdxReq
(
NULL
,
0
,
&
req
);
if
(
ret
<
0
)
{
if
(
len
<
0
)
{
goto
_err
;
}
...
...
@@ -672,7 +672,7 @@ _OVER:
static
int32_t
mndAddIndex
(
SMnode
*
pMnode
,
SRpcMsg
*
pReq
,
SCreateTagIndexReq
*
req
,
SDbObj
*
pDb
,
SStbObj
*
pStb
)
{
int32_t
code
=
-
1
;
SIdxObj
idxObj
=
{
0
};
memcpy
(
idxObj
.
name
,
req
->
idxName
,
TSDB_
TABLE
_FNAME_LEN
);
memcpy
(
idxObj
.
name
,
req
->
idxName
,
TSDB_
INDEX
_FNAME_LEN
);
memcpy
(
idxObj
.
stb
,
pStb
->
name
,
TSDB_TABLE_FNAME_LEN
);
memcpy
(
idxObj
.
db
,
pDb
->
name
,
TSDB_DB_FNAME_LEN
);
memcpy
(
idxObj
.
colName
,
req
->
colName
,
TSDB_COL_NAME_LEN
);
...
...
source/dnode/mnode/impl/src/mndProfile.c
浏览文件 @
e9d7a099
...
...
@@ -226,7 +226,7 @@ static int32_t mndProcessConnectReq(SRpcMsg *pReq) {
goto
_OVER
;
}
if
((
code
=
taosCheckVersionCompatibleFromStr
(
connReq
.
sVer
,
version
,
2
))
!=
0
)
{
if
((
code
=
taosCheckVersionCompatibleFromStr
(
connReq
.
sVer
,
version
,
3
))
!=
0
)
{
terrno
=
code
;
goto
_OVER
;
}
...
...
source/dnode/mnode/impl/src/mndSubscribe.c
浏览文件 @
e9d7a099
...
...
@@ -197,24 +197,20 @@ static SMqRebInfo *mndGetOrCreateRebSub(SHashObj *pHash, const char *key) {
return
pRebSub
;
}
static
int32_t
mndDoRebalance
(
SMnode
*
pMnode
,
const
SMqRebInputObj
*
pInput
,
SMqRebOutputObj
*
pOutput
)
{
int32_t
totalVgNum
=
pOutput
->
pSub
->
vgNum
;
const
char
*
sub
=
pOutput
->
pSub
->
key
;
mInfo
(
"sub:%s mq re-balance %d vgroups"
,
sub
,
pOutput
->
pSub
->
vgNum
);
// 1. build temporary hash(vgId -> SMqRebOutputVg) to store modified vg
SHashObj
*
pHash
=
taosHashInit
(
64
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_INT
),
false
,
HASH_NO_LOCK
);
static
void
doRemoveExistedConsumers
(
SMqRebOutputObj
*
pOutput
,
SHashObj
*
pHash
,
const
SMqRebInputObj
*
pInput
)
{
int32_t
numOfRemoved
=
taosArrayGetSize
(
pInput
->
pRebInfo
->
removedConsumers
);
const
char
*
pSubKey
=
pOutput
->
pSub
->
key
;
// 2. check and get actual removed consumers, put their vg into hash
int32_t
removedNum
=
taosArrayGetSize
(
pInput
->
pRebInfo
->
removedConsumers
);
int32_t
actualRemoved
=
0
;
for
(
int32_t
i
=
0
;
i
<
removedNum
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
numOfRemoved
;
i
++
)
{
uint64_t
consumerId
=
*
(
uint64_t
*
)
taosArrayGet
(
pInput
->
pRebInfo
->
removedConsumers
,
i
);
SMqConsumerEp
*
pConsumerEp
=
taosHashGet
(
pOutput
->
pSub
->
consumerHash
,
&
consumerId
,
sizeof
(
int64_t
));
// consumer exists till now
if
(
pConsumerEp
)
{
actualRemoved
++
;
int32_t
consumerVgNum
=
taosArrayGetSize
(
pConsumerEp
->
vgs
);
for
(
int32_t
j
=
0
;
j
<
consumerVgNum
;
j
++
)
{
SMqVgEp
*
pVgEp
=
taosArrayGetP
(
pConsumerEp
->
vgs
,
j
);
...
...
@@ -223,52 +219,67 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
.
newConsumerId
=
-
1
,
.
pVgEp
=
pVgEp
,
};
taosHashPut
(
pHash
,
&
pVgEp
->
vgId
,
sizeof
(
int32_t
),
&
outputVg
,
sizeof
(
SMqRebOutputVg
));
mInfo
(
"sub:%s mq re-balance remove vgId:%d from consumer:
0x%"
PRIx64
,
sub
,
pVgEp
->
vgId
,
consumerId
);
mInfo
(
"sub:%s mq re-balance remove vgId:%d from consumer:
%"
PRIx64
,
pSubKey
,
pVgEp
->
vgId
,
consumerId
);
}
taosArrayDestroy
(
pConsumerEp
->
vgs
);
taosHashRemove
(
pOutput
->
pSub
->
consumerHash
,
&
consumerId
,
sizeof
(
int64_t
));
// put into removed
taosArrayPush
(
pOutput
->
removedConsumers
,
&
consumerId
);
}
}
if
(
removedNum
!=
actualRemoved
)
{
mError
(
"sub:%s mq re-balance removedNum:%d not matched with actual:%d"
,
sub
,
removedNum
,
actualRemoved
);
if
(
numOfRemoved
!=
actualRemoved
)
{
mError
(
"sub:%s mq re-balance removedNum:%d not matched with actual:%d"
,
pSubKey
,
numOfRemoved
,
actualRemoved
);
}
else
{
mInfo
(
"sub:%s removed %d consumers"
,
pSubKey
,
numOfRemoved
);
}
}
// if previously no consumer, there are vgs not assigned
{
int32_t
consumerVgNum
=
taosArrayGetSize
(
pOutput
->
pSub
->
unassignedVgs
);
for
(
int32_t
i
=
0
;
i
<
consumerVgNum
;
i
++
)
{
SMqVgEp
*
pVgEp
=
*
(
SMqVgEp
**
)
taosArrayPop
(
pOutput
->
pSub
->
unassignedVgs
);
SMqRebOutputVg
rebOutput
=
{
.
oldConsumerId
=
-
1
,
.
newConsumerId
=
-
1
,
.
pVgEp
=
pVgEp
,
};
taosHashPut
(
pHash
,
&
pVgEp
->
vgId
,
sizeof
(
int32_t
),
&
rebOutput
,
sizeof
(
SMqRebOutputVg
));
mInfo
(
"sub:%s mq re-balance remove vgId:%d from unassigned"
,
sub
,
pVgEp
->
vgId
);
}
static
void
doAddNewConsumers
(
SMqRebOutputObj
*
pOutput
,
const
SMqRebInputObj
*
pInput
)
{
int32_t
numOfNewConsumers
=
taosArrayGetSize
(
pInput
->
pRebInfo
->
newConsumers
);
const
char
*
pSubKey
=
pOutput
->
pSub
->
key
;
for
(
int32_t
i
=
0
;
i
<
numOfNewConsumers
;
i
++
)
{
int64_t
consumerId
=
*
(
int64_t
*
)
taosArrayGet
(
pInput
->
pRebInfo
->
newConsumers
,
i
);
SMqConsumerEp
newConsumerEp
;
newConsumerEp
.
consumerId
=
consumerId
;
newConsumerEp
.
vgs
=
taosArrayInit
(
0
,
sizeof
(
void
*
));
taosHashPut
(
pOutput
->
pSub
->
consumerHash
,
&
consumerId
,
sizeof
(
int64_t
),
&
newConsumerEp
,
sizeof
(
SMqConsumerEp
));
taosArrayPush
(
pOutput
->
newConsumers
,
&
consumerId
);
mInfo
(
"sub:%s mq rebalance add new consumer:%"
PRIx64
,
pSubKey
,
consumerId
);
}
}
// 3. calc vg number of each consumer
int32_t
afterRebConsumerNum
=
pInput
->
oldConsumerNum
+
taosArrayGetSize
(
pInput
->
pRebInfo
->
newConsumers
)
-
taosArrayGetSize
(
pInput
->
pRebInfo
->
removedConsumers
);
int32_t
minVgCnt
=
0
;
int32_t
imbConsumerNum
=
0
;
// calc num
if
(
afterRebConsumerNum
)
{
minVgCnt
=
totalVgNum
/
afterRebConsumerNum
;
imbConsumerNum
=
totalVgNum
%
afterRebConsumerNum
;
static
void
addUnassignedVgroups
(
SMqRebOutputObj
*
pOutput
,
SHashObj
*
pHash
)
{
const
char
*
pSubKey
=
pOutput
->
pSub
->
key
;
int32_t
numOfVgroups
=
taosArrayGetSize
(
pOutput
->
pSub
->
unassignedVgs
);
for
(
int32_t
i
=
0
;
i
<
numOfVgroups
;
i
++
)
{
SMqVgEp
*
pVgEp
=
*
(
SMqVgEp
**
)
taosArrayPop
(
pOutput
->
pSub
->
unassignedVgs
);
SMqRebOutputVg
rebOutput
=
{
.
oldConsumerId
=
-
1
,
.
newConsumerId
=
-
1
,
.
pVgEp
=
pVgEp
,
};
taosHashPut
(
pHash
,
&
pVgEp
->
vgId
,
sizeof
(
int32_t
),
&
rebOutput
,
sizeof
(
SMqRebOutputVg
));
mInfo
(
"sub:%s mq re-balance remove vgId:%d from unassigned"
,
pSubKey
,
pVgEp
->
vgId
);
}
}
mInfo
(
"sub:%s mq re-balance %d consumers: at least %d vgs each, %d consumers has more vgs"
,
sub
,
afterRebConsumerNum
,
minVgCnt
,
imbConsumerNum
);
static
void
transferVgroupsForConsumers
(
SMqRebOutputObj
*
pOutput
,
SHashObj
*
pHash
,
int32_t
minVgCnt
,
int32_t
imbConsumerNum
)
{
const
char
*
pSubKey
=
pOutput
->
pSub
->
key
;
// 4. first scan: remove consumer more than wanted, put to remove hash
int32_t
imbCnt
=
0
;
void
*
pIter
=
NULL
;
while
(
1
)
{
pIter
=
taosHashIterate
(
pOutput
->
pSub
->
consumerHash
,
pIter
);
if
(
pIter
==
NULL
)
{
...
...
@@ -276,8 +287,8 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
}
SMqConsumerEp
*
pConsumerEp
=
(
SMqConsumerEp
*
)
pIter
;
int32_t
consumerVgNum
=
taosArrayGetSize
(
pConsumerEp
->
vgs
);
int32_t
consumerVgNum
=
taosArrayGetSize
(
pConsumerEp
->
vgs
);
// all old consumers still existing are touched
// TODO optimize: touch only consumer whose vgs changed
taosArrayPush
(
pOutput
->
touchedConsumers
,
&
pConsumerEp
->
consumerId
);
...
...
@@ -296,13 +307,13 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
.
pVgEp
=
pVgEp
,
};
taosHashPut
(
pHash
,
&
pVgEp
->
vgId
,
sizeof
(
int32_t
),
&
outputVg
,
sizeof
(
SMqRebOutputVg
));
mInfo
(
"sub:%s mq rebalance remove vgId:%d from consumer:0x%"
PRIx64
",(first scan)"
,
sub
,
pVgEp
->
vgId
,
mInfo
(
"sub:%s mq rebalance remove vgId:%d from consumer:0x%"
PRIx64
",(first scan)"
,
pSubKey
,
pVgEp
->
vgId
,
pConsumerEp
->
consumerId
);
}
imbCnt
++
;
}
}
else
{
//
pop until equal
minVg
//
all the remain consumers should only have the number of vgroups, which is equalled to the value of
minVg
while
(
taosArrayGetSize
(
pConsumerEp
->
vgs
)
>
minVgCnt
)
{
SMqVgEp
*
pVgEp
=
*
(
SMqVgEp
**
)
taosArrayPop
(
pConsumerEp
->
vgs
);
SMqRebOutputVg
outputVg
=
{
...
...
@@ -311,36 +322,67 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
.
pVgEp
=
pVgEp
,
};
taosHashPut
(
pHash
,
&
pVgEp
->
vgId
,
sizeof
(
int32_t
),
&
outputVg
,
sizeof
(
SMqRebOutputVg
));
mInfo
(
"sub:%s mq rebalance remove vgId:%d from consumer:0x%"
PRIx64
",(first scan)"
,
sub
,
pVgEp
->
vgId
,
mInfo
(
"sub:%s mq rebalance remove vgId:%d from consumer:0x%"
PRIx64
",(first scan)"
,
pSubKey
,
pVgEp
->
vgId
,
pConsumerEp
->
consumerId
);
}
}
}
}
}
// 5. add new consumer into sub
{
int32_t
consumerNum
=
taosArrayGetSize
(
pInput
->
pRebInfo
->
newConsumers
);
for
(
int32_t
i
=
0
;
i
<
consumerNum
;
i
++
)
{
int64_t
consumerId
=
*
(
int64_t
*
)
taosArrayGet
(
pInput
->
pRebInfo
->
newConsumers
,
i
);
SMqConsumerEp
newConsumerEp
;
newConsumerEp
.
consumerId
=
consumerId
;
newConsumerEp
.
vgs
=
taosArrayInit
(
0
,
sizeof
(
void
*
));
taosHashPut
(
pOutput
->
pSub
->
consumerHash
,
&
consumerId
,
sizeof
(
int64_t
),
&
newConsumerEp
,
sizeof
(
SMqConsumerEp
));
taosArrayPush
(
pOutput
->
newConsumers
,
&
consumerId
);
mInfo
(
"sub:%s mq rebalance add new consumer:0x%"
PRIx64
,
sub
,
consumerId
);
}
static
int32_t
mndDoRebalance
(
SMnode
*
pMnode
,
const
SMqRebInputObj
*
pInput
,
SMqRebOutputObj
*
pOutput
)
{
int32_t
totalVgNum
=
pOutput
->
pSub
->
vgNum
;
const
char
*
pSubKey
=
pOutput
->
pSub
->
key
;
int32_t
numOfRemoved
=
taosArrayGetSize
(
pInput
->
pRebInfo
->
removedConsumers
);
int32_t
numOfAdded
=
taosArrayGetSize
(
pInput
->
pRebInfo
->
newConsumers
);
mInfo
(
"sub:%s mq re-balance %d vgroups, existed consumers:%d, added:%d, removed:%d"
,
pSubKey
,
totalVgNum
,
pInput
->
oldConsumerNum
,
numOfAdded
,
numOfRemoved
);
// 1. build temporary hash(vgId -> SMqRebOutputVg) to store modified vg
SHashObj
*
pHash
=
taosHashInit
(
64
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_INT
),
false
,
HASH_NO_LOCK
);
// 2. check and get actual removed consumers, put their vg into hash
doRemoveExistedConsumers
(
pOutput
,
pHash
,
pInput
);
// 3. if previously no consumer, there are vgs not assigned
addUnassignedVgroups
(
pOutput
,
pHash
);
// 4. calc vg number of each consumer
int32_t
numOfFinal
=
pInput
->
oldConsumerNum
+
numOfAdded
-
numOfRemoved
;
int32_t
minVgCnt
=
0
;
int32_t
imbConsumerNum
=
0
;
// calc num
if
(
numOfFinal
)
{
minVgCnt
=
totalVgNum
/
numOfFinal
;
imbConsumerNum
=
totalVgNum
%
numOfFinal
;
mInfo
(
"sub:%s mq re-balance %d consumers: at least %d vgs each, %d consumers has 1 more vgroups than avg value"
,
pSubKey
,
numOfFinal
,
minVgCnt
,
imbConsumerNum
);
}
else
{
mInfo
(
"sub:%s no consumer subscribe this topic"
,
pSubKey
);
}
// 6. second scan: find consumer do not have enough vg, extract from temporary hash and assign to new consumer.
// 5. first scan: remove vgroups from te consumers, who have more vgroups than the threashold value that is
// minVgCnt, and then put them into the recycled hash list
transferVgroupsForConsumers
(
pOutput
,
pHash
,
minVgCnt
,
imbConsumerNum
);
// 6. add new consumer into sub
doAddNewConsumers
(
pOutput
,
pInput
);
// 7. second scan: find consumer do not have enough vgroups, extract from temporary hash and assign to them
// All related vg should be put into rebVgs
SMqRebOutputVg
*
pRebVg
=
NULL
;
void
*
pRemovedIter
=
NULL
;
pIter
=
NULL
;
void
*
pIter
=
NULL
;
while
(
1
)
{
pIter
=
taosHashIterate
(
pOutput
->
pSub
->
consumerHash
,
pIter
);
if
(
pIter
==
NULL
)
break
;
if
(
pIter
==
NULL
)
{
break
;
}
SMqConsumerEp
*
pConsumerEp
=
(
SMqConsumerEp
*
)
pIter
;
// push until equal minVg
...
...
@@ -348,8 +390,8 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
// iter hash and find one vg
pRemovedIter
=
taosHashIterate
(
pHash
,
pRemovedIter
);
if
(
pRemovedIter
==
NULL
)
{
mError
(
"sub:%s removed iter is null"
,
sub
);
continue
;
mError
(
"sub:%s removed iter is null"
,
pSubKey
);
break
;
}
pRebVg
=
(
SMqRebOutputVg
*
)
pRemovedIter
;
...
...
@@ -409,15 +451,15 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
taosArrayPush
(
pOutput
->
pSub
->
unassignedVgs
,
&
pRebOutput
->
pVgEp
);
taosArrayPush
(
pOutput
->
rebVgs
,
pRebOutput
);
mInfo
(
"sub:%s mq re-balance unassign vgId:%d (second scan)"
,
sub
,
pRebOutput
->
pVgEp
->
vgId
);
mInfo
(
"sub:%s mq re-balance unassign vgId:%d (second scan)"
,
pSubKey
,
pRebOutput
->
pVgEp
->
vgId
);
}
}
// 8. generate logs
mInfo
(
"sub:%s mq re-balance calculation completed, re-balanced vg"
,
sub
);
mInfo
(
"sub:%s mq re-balance calculation completed, re-balanced vg"
,
pSubKey
);
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pOutput
->
rebVgs
);
i
++
)
{
SMqRebOutputVg
*
pOutputRebVg
=
taosArrayGet
(
pOutput
->
rebVgs
,
i
);
mInfo
(
"sub:%s mq re-balance vgId:%d, moved from consumer:0x%"
PRIx64
", to consumer:0x%"
PRIx64
,
sub
,
mInfo
(
"sub:%s mq re-balance vgId:%d, moved from consumer:0x%"
PRIx64
", to consumer:0x%"
PRIx64
,
pSubKey
,
pOutputRebVg
->
pVgEp
->
vgId
,
pOutputRebVg
->
oldConsumerId
,
pOutputRebVg
->
newConsumerId
);
}
{
...
...
@@ -427,10 +469,10 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
if
(
pIter
==
NULL
)
break
;
SMqConsumerEp
*
pConsumerEp
=
(
SMqConsumerEp
*
)
pIter
;
int32_t
sz
=
taosArrayGetSize
(
pConsumerEp
->
vgs
);
mInfo
(
"sub:%s mq re-balance final cfg: consumer:0x%"
PRIx64
" has %d vg"
,
sub
,
pConsumerEp
->
consumerId
,
sz
);
mInfo
(
"sub:%s mq re-balance final cfg: consumer:0x%"
PRIx64
" has %d vg"
,
pSubKey
,
pConsumerEp
->
consumerId
,
sz
);
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
SMqVgEp
*
pVgEp
=
taosArrayGetP
(
pConsumerEp
->
vgs
,
i
);
mInfo
(
"sub:%s mq re-balance final cfg: vg %d to consumer:0x%"
PRIx64
,
sub
,
pVgEp
->
vgId
,
mInfo
(
"sub:%s mq re-balance final cfg: vg %d to consumer:0x%"
PRIx64
,
pSubKey
,
pVgEp
->
vgId
,
pConsumerEp
->
consumerId
);
}
}
...
...
@@ -555,17 +597,23 @@ static int32_t mndProcessRebalanceReq(SRpcMsg *pMsg) {
SMnode
*
pMnode
=
pMsg
->
info
.
node
;
SMqDoRebalanceMsg
*
pReq
=
pMsg
->
pCont
;
void
*
pIter
=
NULL
;
bool
rebalanceOnce
=
false
;
// to ensure only once.
mInfo
(
"mq re-balance start
"
);
mInfo
(
"mq re-balance start
, total required re-balanced trans:%d"
,
taosHashGetSize
(
pReq
->
rebSubHash
)
);
// here we only handle one topic rebalance requirement to ensure the atomic execution of this transaction.
while
(
1
)
{
if
(
rebalanceOnce
)
{
break
;
}
pIter
=
taosHashIterate
(
pReq
->
rebSubHash
,
pIter
);
if
(
pIter
==
NULL
)
{
break
;
}
SMqRebInputObj
rebInput
=
{
0
};
// todo handle the malloc failure
SMqRebInputObj
rebInput
=
{
0
};
SMqRebOutputObj
rebOutput
=
{
0
};
rebOutput
.
newConsumers
=
taosArrayInit
(
0
,
sizeof
(
int64_t
));
rebOutput
.
removedConsumers
=
taosArrayInit
(
0
,
sizeof
(
int64_t
));
...
...
@@ -582,9 +630,10 @@ static int32_t mndProcessRebalanceReq(SRpcMsg *pMsg) {
char
topic
[
TSDB_TOPIC_FNAME_LEN
];
char
cgroup
[
TSDB_CGROUP_LEN
];
mndSplitSubscribeKey
(
pRebInfo
->
key
,
topic
,
cgroup
,
true
);
SMqTopicObj
*
pTopic
=
mndAcquireTopic
(
pMnode
,
topic
);
if
(
pTopic
==
NULL
)
{
mError
(
"mq re-balance %s ignored since topic %s
no
t exist"
,
pRebInfo
->
key
,
topic
);
mError
(
"mq re-balance %s ignored since topic %s
doesn'
t exist"
,
pRebInfo
->
key
,
topic
);
continue
;
}
...
...
@@ -604,11 +653,13 @@ static int32_t mndProcessRebalanceReq(SRpcMsg *pMsg) {
mndReleaseTopic
(
pMnode
,
pTopic
);
rebInput
.
oldConsumerNum
=
0
;
mInfo
(
"topic:%s has no consumers sub yet"
,
topic
);
}
else
{
taosRLockLatch
(
&
pSub
->
lock
);
rebInput
.
oldConsumerNum
=
taosHashGetSize
(
pSub
->
consumerHash
);
rebOutput
.
pSub
=
tCloneSubscribeObj
(
pSub
);
taosRUnLockLatch
(
&
pSub
->
lock
);
mInfo
(
"topic:%s has %d consumers sub till now"
,
pRebInfo
->
key
,
rebInput
.
oldConsumerNum
);
mndReleaseSubscribe
(
pMnode
,
pSub
);
}
...
...
@@ -623,16 +674,14 @@ static int32_t mndProcessRebalanceReq(SRpcMsg *pMsg) {
mError
(
"mq re-balance persist output error, possibly vnode splitted or dropped"
);
}
taosArrayDestroy
(
pRebInfo
->
lostConsumers
);
taosArrayDestroy
(
pRebInfo
->
newConsumers
);
taosArrayDestroy
(
pRebInfo
->
removedConsumers
);
taosArrayDestroy
(
rebOutput
.
newConsumers
);
taosArrayDestroy
(
rebOutput
.
touchedConsumers
);
taosArrayDestroy
(
rebOutput
.
removedConsumers
);
taosArrayDestroy
(
rebOutput
.
rebVgs
);
tDeleteSubscribeObj
(
rebOutput
.
pSub
);
taosMemoryFree
(
rebOutput
.
pSub
);
rebalanceOnce
=
true
;
}
// reset flag
...
...
source/dnode/mnode/impl/src/mndSync.c
浏览文件 @
e9d7a099
...
...
@@ -33,7 +33,7 @@ static int32_t mndSyncEqCtrlMsg(const SMsgCb *msgcb, SRpcMsg *pMsg) {
return
-
1
;
}
int32_t
code
=
tmsgPutToQueue
(
msgcb
,
SYNC_
CTRL
_QUEUE
,
pMsg
);
int32_t
code
=
tmsgPutToQueue
(
msgcb
,
SYNC_
RD
_QUEUE
,
pMsg
);
if
(
code
!=
0
)
{
rpcFreeCont
(
pMsg
->
pCont
);
pMsg
->
pCont
=
NULL
;
...
...
source/dnode/mnode/impl/src/mndTrans.c
浏览文件 @
e9d7a099
...
...
@@ -1093,10 +1093,13 @@ int32_t mndTransProcessRsp(SRpcMsg *pRsp) {
pAction
->
msgReceived
=
1
;
pAction
->
errCode
=
pRsp
->
code
;
pTrans
->
lastErrorNo
=
pRsp
->
code
;
mInfo
(
"trans:%d, %s:%d response is received, code:0x%x, accept:0x%x retry:0x%x"
,
transId
,
mndTransStr
(
pAction
->
stage
),
action
,
pRsp
->
code
,
pAction
->
acceptableCode
,
pAction
->
retryCode
);
}
else
{
mInfo
(
"trans:%d, invalid action, index:%d, code:0x%x"
,
transId
,
action
,
pRsp
->
code
);
}
mInfo
(
"trans:%d, %s:%d response is received, code:0x%x, accept:0x%x retry:0x%x"
,
transId
,
mndTransStr
(
pAction
->
stage
),
action
,
pRsp
->
code
,
pAction
->
acceptableCode
,
pAction
->
retryCode
);
mndTransExecute
(
pMnode
,
pTrans
,
true
);
_OVER:
...
...
source/dnode/vnode/CMakeLists.txt
浏览文件 @
e9d7a099
...
...
@@ -57,7 +57,7 @@ target_sources(
# tq
"src/tq/tq.c"
"src/tq/tq
Exec
.c"
"src/tq/tq
Scan
.c"
"src/tq/tqMeta.c"
"src/tq/tqRead.c"
"src/tq/tqOffset.c"
...
...
source/dnode/vnode/inc/vnode.h
浏览文件 @
e9d7a099
...
...
@@ -178,11 +178,11 @@ typedef struct STsdbReader STsdbReader;
int32_t
tsdbSetTableList
(
STsdbReader
*
pReader
,
const
void
*
pTableList
,
int32_t
num
);
int32_t
tsdbReaderOpen
(
SVnode
*
pVnode
,
SQueryTableDataCond
*
pCond
,
void
*
pTableList
,
int32_t
numOfTables
,
SSDataBlock
*
pResBlock
,
STsdbReader
**
ppReader
,
const
char
*
idstr
);
SSDataBlock
*
pResBlock
,
STsdbReader
**
ppReader
,
const
char
*
idstr
,
bool
countOnly
);
void
tsdbReaderSetId
(
STsdbReader
*
pReader
,
const
char
*
idstr
);
void
tsdbReaderClose
(
STsdbReader
*
pReader
);
bool
tsdbNextDataBlock
(
STsdbReader
*
pReader
);
int32_t
tsdbNextDataBlock
(
STsdbReader
*
pReader
,
bool
*
hasNext
);
int32_t
tsdbRetrieveDatablockSMA
(
STsdbReader
*
pReader
,
SSDataBlock
*
pDataBlock
,
bool
*
allHave
);
void
tsdbReleaseDataBlock
(
STsdbReader
*
pReader
);
SSDataBlock
*
tsdbRetrieveDataBlock
(
STsdbReader
*
pTsdbReadHandle
,
SArray
*
pColumnIdList
);
...
...
source/dnode/vnode/src/inc/tq.h
浏览文件 @
e9d7a099
...
...
@@ -109,23 +109,18 @@ typedef struct {
}
STqPushEntry
;
struct
STQ
{
SVnode
*
pVnode
;
char
*
path
;
int64_t
walLogLastVer
;
SRWLatch
pushLock
;
SHashObj
*
pPushMgr
;
// consumerId -> STqPushEntry
SHashObj
*
pHandle
;
// subKey -> STqHandle
SHashObj
*
pCheckInfo
;
// topic -> SAlterCheckInfo
SVnode
*
pVnode
;
char
*
path
;
int64_t
walLogLastVer
;
SRWLatch
lock
;
SHashObj
*
pPushMgr
;
// consumerId -> STqPushEntry
SHashObj
*
pHandle
;
// subKey -> STqHandle
SHashObj
*
pCheckInfo
;
// topic -> SAlterCheckInfo
STqOffsetStore
*
pOffsetStore
;
TDB
*
pMetaDB
;
TTB
*
pExecStore
;
TTB
*
pCheckStore
;
SStreamMeta
*
pStreamMeta
;
TDB
*
pMetaDB
;
TTB
*
pExecStore
;
TTB
*
pCheckStore
;
SStreamMeta
*
pStreamMeta
;
};
typedef
struct
{
...
...
@@ -144,8 +139,7 @@ int32_t tqScanData(STQ* pTq, const STqHandle* pHandle, SMqDataRsp* pRsp, STqOffs
int32_t
tqFetchLog
(
STQ
*
pTq
,
STqHandle
*
pHandle
,
int64_t
*
fetchOffset
,
SWalCkHead
**
pHeadWithCkSum
,
uint64_t
reqId
);
// tqExec
int32_t
tqTaosxScanLog
(
STQ
*
pTq
,
STqHandle
*
pHandle
,
SPackedData
submit
,
STaosxRsp
*
pRsp
);
// int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SSubmitReq* pReq, STaosxRsp* pRsp);
int32_t
tqTaosxScanLog
(
STQ
*
pTq
,
STqHandle
*
pHandle
,
SPackedData
submit
,
STaosxRsp
*
pRsp
,
int32_t
*
totalRows
);
int32_t
tqAddBlockDataToRsp
(
const
SSDataBlock
*
pBlock
,
SMqDataRsp
*
pRsp
,
int32_t
numOfCols
,
int8_t
precision
);
int32_t
tqSendDataRsp
(
STQ
*
pTq
,
const
SRpcMsg
*
pMsg
,
const
SMqPollReq
*
pReq
,
const
SMqDataRsp
*
pRsp
,
int32_t
type
);
int32_t
tqPushDataRsp
(
STQ
*
pTq
,
STqPushEntry
*
pPushEntry
);
...
...
@@ -164,7 +158,7 @@ typedef struct {
int32_t
size
;
}
STqOffsetHead
;
STqOffsetStore
*
tqOffsetOpen
();
STqOffsetStore
*
tqOffsetOpen
(
STQ
*
pTq
);
void
tqOffsetClose
(
STqOffsetStore
*
);
STqOffset
*
tqOffsetRead
(
STqOffsetStore
*
pStore
,
const
char
*
subscribeKey
);
int32_t
tqOffsetWrite
(
STqOffsetStore
*
pStore
,
const
STqOffset
*
pOffset
);
...
...
source/dnode/vnode/src/inc/tsdb.h
浏览文件 @
e9d7a099
...
...
@@ -224,6 +224,8 @@ int32_t tsdbTbDataIterCreate(STbData *pTbData, TSDBKEY *pFrom, int8_t backward,
void
*
tsdbTbDataIterDestroy
(
STbDataIter
*
pIter
);
void
tsdbTbDataIterOpen
(
STbData
*
pTbData
,
TSDBKEY
*
pFrom
,
int8_t
backward
,
STbDataIter
*
pIter
);
bool
tsdbTbDataIterNext
(
STbDataIter
*
pIter
);
void
tsdbMemTableCountRows
(
SMemTable
*
pMemTable
,
SHashObj
*
pTableMap
,
int64_t
*
rowsNum
);
// STbData
int32_t
tsdbGetNRowsInTbData
(
STbData
*
pTbData
);
// tsdbFile.c ==============================================================================================
...
...
@@ -687,6 +689,8 @@ typedef struct SSttBlockLoadInfo {
STSchema
*
pSchema
;
int16_t
*
colIds
;
int32_t
numOfCols
;
bool
checkRemainingRow
;
bool
isLast
;
bool
sttBlockLoaded
;
int32_t
numOfStt
;
...
...
source/dnode/vnode/src/inc/vnodeInt.h
浏览文件 @
e9d7a099
...
...
@@ -187,13 +187,14 @@ int32_t tsdbDeleteTableData(STsdb* pTsdb, int64_t version, tb_uid_t suid, tb_uid
int32_t
tsdbSetKeepCfg
(
STsdb
*
pTsdb
,
STsdbCfg
*
pCfg
);
// tq
int
tqInit
();
void
tqCleanUp
();
STQ
*
tqOpen
(
const
char
*
path
,
SVnode
*
pVnode
);
void
tqClose
(
STQ
*
);
int
tqPushMsg
(
STQ
*
,
void
*
msg
,
int32_t
msgLen
,
tmsg_t
msgType
,
int64_t
ver
);
int
tqRegisterPushEntry
(
STQ
*
pTq
,
void
*
pHandle
,
const
SMqPollReq
*
pRequest
,
SRpcMsg
*
pRpcMsg
,
SMqDataRsp
*
pDataRsp
,
int32_t
type
);
int
tqRemovePushEntry
(
STQ
*
pTq
,
const
char
*
pKey
,
int32_t
keyLen
,
uint64_t
consumerId
,
bool
rspConsumer
);
int
tqInit
();
void
tqCleanUp
();
STQ
*
tqOpen
(
const
char
*
path
,
SVnode
*
pVnode
);
void
tqClose
(
STQ
*
);
int
tqPushMsg
(
STQ
*
,
void
*
msg
,
int32_t
msgLen
,
tmsg_t
msgType
,
int64_t
ver
);
int
tqRegisterPushEntry
(
STQ
*
pTq
,
void
*
pHandle
,
const
SMqPollReq
*
pRequest
,
SRpcMsg
*
pRpcMsg
,
SMqDataRsp
*
pDataRsp
,
int32_t
type
);
int
tqUnregisterPushEntry
(
STQ
*
pTq
,
const
char
*
pKey
,
int32_t
keyLen
,
uint64_t
consumerId
,
bool
rspConsumer
);
int
tqCommit
(
STQ
*
);
int32_t
tqUpdateTbUidList
(
STQ
*
pTq
,
const
SArray
*
tbUidList
,
bool
isAdd
);
...
...
source/dnode/vnode/src/sma/smaRollup.c
浏览文件 @
e9d7a099
...
...
@@ -669,7 +669,7 @@ static int32_t tdRSmaExecAndSubmitResult(SSma *pSma, qTaskInfo_t taskInfo, SRSma
#endif
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pResList
);
++
i
)
{
SSDataBlock
*
output
=
taosArrayGetP
(
pResList
,
i
);
smaDebug
(
"result block, uid:%"
PRIu64
", groupid:%"
PRIu64
", rows:%
d"
,
output
->
info
.
id
.
uid
,
smaDebug
(
"result block, uid:%"
PRIu64
", groupid:%"
PRIu64
", rows:%
"
PRId64
,
output
->
info
.
id
.
uid
,
output
->
info
.
id
.
groupId
,
output
->
info
.
rows
);
STsdb
*
sinkTsdb
=
(
pItem
->
level
==
TSDB_RETENTION_L1
?
pSma
->
pRSmaTsdb
[
0
]
:
pSma
->
pRSmaTsdb
[
1
]);
...
...
source/dnode/vnode/src/tq/tq.c
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/dnode/vnode/src/tq/tqMeta.c
浏览文件 @
e9d7a099
...
...
@@ -269,7 +269,7 @@ int32_t tqMetaDeleteHandle(STQ* pTq, const char* key) {
}
int32_t
tqMetaRestoreHandle
(
STQ
*
pTq
)
{
int
code
=
0
;
int
code
=
0
;
TBC
*
pCur
=
NULL
;
if
(
tdbTbcOpen
(
pTq
->
pExecStore
,
&
pCur
,
NULL
)
<
0
)
{
return
-
1
;
...
...
@@ -307,7 +307,7 @@ int32_t tqMetaRestoreHandle(STQ* pTq) {
if
(
handle
.
execHandle
.
subType
==
TOPIC_SUB_TYPE__COLUMN
)
{
handle
.
execHandle
.
task
=
qCreateQueueExecTaskInfo
(
handle
.
execHandle
.
execCol
.
qmsg
,
&
reader
,
vgId
,
&
handle
.
execHandle
.
numOfCols
,
NULL
);
qCreateQueueExecTaskInfo
(
handle
.
execHandle
.
execCol
.
qmsg
,
&
reader
,
vgId
,
&
handle
.
execHandle
.
numOfCols
,
0
);
if
(
handle
.
execHandle
.
task
==
NULL
)
{
tqError
(
"cannot create exec task for %s"
,
handle
.
subKey
);
code
=
-
1
;
...
...
@@ -332,7 +332,7 @@ int32_t tqMetaRestoreHandle(STQ* pTq) {
buildSnapContext
(
reader
.
meta
,
reader
.
version
,
0
,
handle
.
execHandle
.
subType
,
handle
.
fetchMeta
,
(
SSnapContext
**
)(
&
reader
.
sContext
));
handle
.
execHandle
.
task
=
qCreateQueueExecTaskInfo
(
NULL
,
&
reader
,
vgId
,
NULL
,
NULL
);
handle
.
execHandle
.
task
=
qCreateQueueExecTaskInfo
(
NULL
,
&
reader
,
vgId
,
NULL
,
0
);
}
else
if
(
handle
.
execHandle
.
subType
==
TOPIC_SUB_TYPE__TABLE
)
{
handle
.
pWalReader
=
walOpenReader
(
pTq
->
pVnode
->
pWal
,
NULL
);
...
...
@@ -341,7 +341,7 @@ int32_t tqMetaRestoreHandle(STQ* pTq) {
tqDebug
(
"vgId:%d, tq try to get all ctb, suid:%"
PRId64
,
pTq
->
pVnode
->
config
.
vgId
,
handle
.
execHandle
.
execTb
.
suid
);
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
tbUidList
);
i
++
)
{
int64_t
tbUid
=
*
(
int64_t
*
)
taosArrayGet
(
tbUidList
,
i
);
tqDebug
(
"vgId:%d, idx %d, uid:%"
PRId64
,
TD_VID
(
pTq
->
pVnode
)
,
i
,
tbUid
);
tqDebug
(
"vgId:%d, idx %d, uid:%"
PRId64
,
vgId
,
i
,
tbUid
);
}
handle
.
execHandle
.
pExecReader
=
tqOpenReader
(
pTq
->
pVnode
);
tqReaderSetTbUidList
(
handle
.
execHandle
.
pExecReader
,
tbUidList
);
...
...
@@ -349,9 +349,9 @@ int32_t tqMetaRestoreHandle(STQ* pTq) {
buildSnapContext
(
reader
.
meta
,
reader
.
version
,
handle
.
execHandle
.
execTb
.
suid
,
handle
.
execHandle
.
subType
,
handle
.
fetchMeta
,
(
SSnapContext
**
)(
&
reader
.
sContext
));
handle
.
execHandle
.
task
=
qCreateQueueExecTaskInfo
(
NULL
,
&
reader
,
vgId
,
NULL
,
NULL
);
handle
.
execHandle
.
task
=
qCreateQueueExecTaskInfo
(
NULL
,
&
reader
,
vgId
,
NULL
,
0
);
}
tqDebug
(
"tq restore %s consumer %"
PRId64
" vgId:%d"
,
handle
.
subKey
,
handle
.
consumerId
,
TD_VID
(
pTq
->
pVnode
)
);
tqDebug
(
"tq restore %s consumer %"
PRId64
" vgId:%d"
,
handle
.
subKey
,
handle
.
consumerId
,
vgId
);
taosHashPut
(
pTq
->
pHandle
,
pKey
,
kLen
,
&
handle
,
sizeof
(
STqHandle
));
}
...
...
source/dnode/vnode/src/tq/tqPush.c
浏览文件 @
e9d7a099
...
...
@@ -206,38 +206,110 @@ int32_t tqPushMsgNew(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_
}
#endif
int
tqPushMsg
(
STQ
*
pTq
,
void
*
msg
,
int32_t
msgLen
,
tmsg_t
msgType
,
int64_t
ver
)
{
typedef
struct
{
void
*
pKey
;
int64_t
keyLen
;
}
SItem
;
static
void
recordPushedEntry
(
SArray
*
cachedKey
,
void
*
pIter
);
static
void
freeItem
(
void
*
param
)
{
SItem
*
p
=
(
SItem
*
)
param
;
taosMemoryFree
(
p
->
pKey
);
}
static
void
doRemovePushedEntry
(
SArray
*
pCachedKeys
,
STQ
*
pTq
)
{
int32_t
vgId
=
TD_VID
(
pTq
->
pVnode
);
int32_t
numOfKeys
=
(
int32_t
)
taosArrayGetSize
(
pCachedKeys
);
for
(
int32_t
i
=
0
;
i
<
numOfKeys
;
i
++
)
{
SItem
*
pItem
=
taosArrayGet
(
pCachedKeys
,
i
);
if
(
taosHashRemove
(
pTq
->
pPushMgr
,
pItem
->
pKey
,
pItem
->
keyLen
)
!=
0
)
{
tqError
(
"vgId:%d, tq push hash remove key error, key: %s"
,
vgId
,
(
char
*
)
pItem
->
pKey
);
}
}
if
(
numOfKeys
>
0
)
{
tqDebug
(
"vgId:%d, pushed %d items and remain:%d"
,
vgId
,
numOfKeys
,
(
int32_t
)
taosHashGetSize
(
pTq
->
pPushMgr
));
}
}
static
void
doPushDataForEntry
(
void
*
pIter
,
STqExecHandle
*
pExec
,
STQ
*
pTq
,
int64_t
ver
,
int32_t
vgId
,
char
*
pData
,
int32_t
dataLen
,
SArray
*
pCachedKey
)
{
STqPushEntry
*
pPushEntry
=
*
(
STqPushEntry
**
)
pIter
;
SMqDataRsp
*
pRsp
=
pPushEntry
->
pDataRsp
;
if
(
pRsp
->
reqOffset
.
version
>=
ver
)
{
tqDebug
(
"vgId:%d, push entry req version %"
PRId64
", while push version %"
PRId64
", skip"
,
vgId
,
pRsp
->
reqOffset
.
version
,
ver
);
return
;
}
qTaskInfo_t
pTaskInfo
=
pExec
->
task
;
// prepare scan mem data
SPackedData
submit
=
{.
msgStr
=
pData
,
.
msgLen
=
dataLen
,
.
ver
=
ver
};
if
(
qStreamSetScanMemData
(
pTaskInfo
,
submit
)
!=
0
)
{
return
;
}
// here start to scan submit block to extract the subscribed data
int32_t
totalRows
=
0
;
while
(
1
)
{
SSDataBlock
*
pDataBlock
=
NULL
;
uint64_t
ts
=
0
;
if
(
qExecTask
(
pTaskInfo
,
&
pDataBlock
,
&
ts
)
<
0
)
{
tqDebug
(
"vgId:%d, tq exec error since %s"
,
vgId
,
terrstr
());
}
if
(
pDataBlock
==
NULL
)
{
break
;
}
tqAddBlockDataToRsp
(
pDataBlock
,
pRsp
,
pExec
->
numOfCols
,
pTq
->
pVnode
->
config
.
tsdbCfg
.
precision
);
pRsp
->
blockNum
++
;
totalRows
+=
pDataBlock
->
info
.
rows
;
}
tqDebug
(
"vgId:%d, tq handle push, subkey:%s, block num:%d, rows:%d"
,
vgId
,
pPushEntry
->
subKey
,
pRsp
->
blockNum
,
totalRows
);
if
(
pRsp
->
blockNum
>
0
)
{
tqOffsetResetToLog
(
&
pRsp
->
rspOffset
,
ver
);
tqPushDataRsp
(
pTq
,
pPushEntry
);
recordPushedEntry
(
pCachedKey
,
pIter
);
}
}
int32_t
tqPushMsg
(
STQ
*
pTq
,
void
*
msg
,
int32_t
msgLen
,
tmsg_t
msgType
,
int64_t
ver
)
{
void
*
pReq
=
POINTER_SHIFT
(
msg
,
sizeof
(
SSubmitReq2Msg
));
int32_t
len
=
msgLen
-
sizeof
(
SSubmitReq2Msg
);
int32_t
vgId
=
TD_VID
(
pTq
->
pVnode
);
if
(
msgType
==
TDMT_VND_SUBMIT
)
{
// lock push mgr to avoid potential msg lost
taosWLockLatch
(
&
pTq
->
pushL
ock
);
taosWLockLatch
(
&
pTq
->
l
ock
);
int32_t
numOfRegisteredPush
=
taosHashGetSize
(
pTq
->
pPushMgr
);
if
(
numOfRegisteredPush
>
0
)
{
tqDebug
(
"vgId:%d tq push msg version:%"
PRId64
" type:%s, head:%p, body:%p len:%d, numOfPushed consumers:%d"
,
vgId
,
ver
,
TMSG_INFO
(
msgType
),
msg
,
pReq
,
len
,
numOfRegisteredPush
);
SArray
*
cachedKeys
=
taosArrayInit
(
0
,
sizeof
(
void
*
));
SArray
*
cachedKeyLens
=
taosArrayInit
(
0
,
sizeof
(
size_t
));
vgId
,
ver
,
TMSG_INFO
(
msgType
),
msg
,
pReq
,
len
,
numOfRegisteredPush
);
void
*
data
=
taosMemoryMalloc
(
len
);
void
*
data
=
taosMemoryMalloc
(
len
);
if
(
data
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
tqError
(
"failed to copy data for stream since out of memory"
);
taosArrayDestroyP
(
cachedKeys
,
(
FDelete
)
taosMemoryFree
);
taosArrayDestroy
(
cachedKeyLens
);
// unlock
taosWUnLockLatch
(
&
pTq
->
pushLock
);
tqError
(
"failed to copy data for stream since out of memory, vgId:%d"
,
vgId
);
taosWUnLockLatch
(
&
pTq
->
lock
);
return
-
1
;
}
memcpy
(
data
,
pReq
,
len
);
void
*
pIter
=
NULL
;
SArray
*
cachedKey
=
taosArrayInit
(
0
,
sizeof
(
SItem
));
void
*
pIter
=
NULL
;
while
(
1
)
{
pIter
=
taosHashIterate
(
pTq
->
pPushMgr
,
pIter
);
if
(
pIter
==
NULL
)
{
...
...
@@ -248,83 +320,30 @@ int tqPushMsg(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t ver)
STqHandle
*
pHandle
=
taosHashGet
(
pTq
->
pHandle
,
pPushEntry
->
subKey
,
strlen
(
pPushEntry
->
subKey
));
if
(
pHandle
==
NULL
)
{
tqDebug
(
"vgId:%d, cannot find handle %s"
,
pTq
->
pVnode
->
config
.
vgId
,
pPushEntry
->
subKey
);
continue
;
}
SMqDataRsp
*
pRsp
=
pPushEntry
->
pDataRsp
;
if
(
pRsp
->
reqOffset
.
version
>=
ver
)
{
tqDebug
(
"vgId:%d, push entry req version %"
PRId64
", while push version %"
PRId64
", skip"
,
vgId
,
pRsp
->
reqOffset
.
version
,
ver
);
tqDebug
(
"vgId:%d, failed to find handle %s in pushing data to consumer, ignore"
,
pTq
->
pVnode
->
config
.
vgId
,
pPushEntry
->
subKey
);
continue
;
}
STqExecHandle
*
pExec
=
&
pHandle
->
execHandle
;
qTaskInfo_t
task
=
pExec
->
task
;
// prepare scan mem data
SPackedData
submit
=
{
.
msgStr
=
data
,
.
msgLen
=
len
,
.
ver
=
ver
,
};
if
(
qStreamSetScanMemData
(
task
,
submit
)
!=
0
){
continue
;
}
// here start to scan submit block to extract the subscribed data
while
(
1
)
{
SSDataBlock
*
pDataBlock
=
NULL
;
uint64_t
ts
=
0
;
if
(
qExecTask
(
task
,
&
pDataBlock
,
&
ts
)
<
0
)
{
tqDebug
(
"vgId:%d, tq exec error since %s"
,
vgId
,
terrstr
());
}
if
(
pDataBlock
==
NULL
)
{
break
;
}
tqAddBlockDataToRsp
(
pDataBlock
,
pRsp
,
pExec
->
numOfCols
,
pTq
->
pVnode
->
config
.
tsdbCfg
.
precision
);
pRsp
->
blockNum
++
;
}
tqDebug
(
"vgId:%d, tq handle push, subkey:%s, block num:%d"
,
vgId
,
pPushEntry
->
subKey
,
pRsp
->
blockNum
);
if
(
pRsp
->
blockNum
>
0
)
{
// set offset
tqOffsetResetToLog
(
&
pRsp
->
rspOffset
,
ver
);
// remove from hash
size_t
kLen
;
void
*
key
=
taosHashGetKey
(
pIter
,
&
kLen
);
void
*
keyCopy
=
taosMemoryCalloc
(
1
,
kLen
+
1
);
memcpy
(
keyCopy
,
key
,
kLen
);
taosArrayPush
(
cachedKeys
,
&
keyCopy
);
taosArrayPush
(
cachedKeyLens
,
&
kLen
);
tqPushDataRsp
(
pTq
,
pPushEntry
);
}
}
// delete entry
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
cachedKeys
);
i
++
)
{
void
*
key
=
taosArrayGetP
(
cachedKeys
,
i
);
size_t
kLen
=
*
(
size_t
*
)
taosArrayGet
(
cachedKeyLens
,
i
);
if
(
taosHashRemove
(
pTq
->
pPushMgr
,
key
,
kLen
)
!=
0
)
{
tqError
(
"vgId:%d, tq push hash remove key error, key: %s"
,
pTq
->
pVnode
->
config
.
vgId
,
(
char
*
)
key
);
}
doPushDataForEntry
(
pIter
,
pExec
,
pTq
,
ver
,
vgId
,
data
,
len
,
cachedKey
);
}
taosArrayDestroyP
(
cachedKeys
,
(
FDelete
)
taosMemoryFree
);
taosArrayDestroy
(
cachedKeyLens
);
doRemovePushedEntry
(
cachedKey
,
pTq
);
taosArrayDestroy
Ex
(
cachedKey
,
freeItem
);
taosMemoryFree
(
data
);
}
// unlock
taosWUnLockLatch
(
&
pTq
->
pushL
ock
);
taosWUnLockLatch
(
&
pTq
->
l
ock
);
}
// push data for stream processing
if
(
!
tsDisableStream
&&
vnodeIsRoleLeader
(
pTq
->
pVnode
))
{
if
(
taosHashGetSize
(
pTq
->
pStreamMeta
->
pTasks
)
==
0
)
return
0
;
if
(
taosHashGetSize
(
pTq
->
pStreamMeta
->
pTasks
)
==
0
)
{
return
0
;
}
if
(
msgType
==
TDMT_VND_SUBMIT
)
{
void
*
data
=
taosMemoryMalloc
(
len
);
if
(
data
==
NULL
)
{
...
...
@@ -332,12 +351,9 @@ int tqPushMsg(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t ver)
tqError
(
"failed to copy data for stream since out of memory"
);
return
-
1
;
}
memcpy
(
data
,
pReq
,
len
);
SPackedData
submit
=
{
.
msgStr
=
data
,
.
msgLen
=
len
,
.
ver
=
ver
,
};
SPackedData
submit
=
{.
msgStr
=
data
,
.
msgLen
=
len
,
.
ver
=
ver
};
tqDebug
(
"tq copy write msg %p %d %"
PRId64
" from %p"
,
data
,
len
,
ver
,
pReq
);
tqProcessSubmitReq
(
pTq
,
submit
);
...
...
@@ -351,8 +367,15 @@ int tqPushMsg(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t ver)
return
0
;
}
int32_t
tqRegisterPushEntry
(
STQ
*
pTq
,
void
*
pHandle
,
const
SMqPollReq
*
pRequest
,
SRpcMsg
*
pRpcMsg
,
SMqDataRsp
*
pDataRsp
,
int32_t
type
)
{
void
recordPushedEntry
(
SArray
*
cachedKey
,
void
*
pIter
)
{
size_t
kLen
=
0
;
void
*
key
=
taosHashGetKey
(
pIter
,
&
kLen
);
SItem
item
=
{.
pKey
=
strndup
(
key
,
kLen
),
.
keyLen
=
kLen
};
taosArrayPush
(
cachedKey
,
&
item
);
}
int32_t
tqRegisterPushEntry
(
STQ
*
pTq
,
void
*
pHandle
,
const
SMqPollReq
*
pRequest
,
SRpcMsg
*
pRpcMsg
,
SMqDataRsp
*
pDataRsp
,
int32_t
type
)
{
uint64_t
consumerId
=
pRequest
->
consumerId
;
int32_t
vgId
=
TD_VID
(
pTq
->
pVnode
);
STqHandle
*
pTqHandle
=
pHandle
;
...
...
@@ -369,7 +392,7 @@ int32_t tqRegisterPushEntry(STQ* pTq, void* pHandle, const SMqPollReq* pRequest,
memcpy
(
pPushEntry
->
subKey
,
pTqHandle
->
subKey
,
TSDB_SUBSCRIBE_KEY_LEN
);
if
(
type
==
TMQ_MSG_TYPE__TAOSX_RSP
)
{
pPushEntry
->
pDataRsp
=
taosMemoryCalloc
(
1
,
sizeof
(
STaosxRsp
));
pPushEntry
->
pDataRsp
=
taosMemoryCalloc
(
1
,
sizeof
(
STaosxRsp
));
memcpy
(
pPushEntry
->
pDataRsp
,
pDataRsp
,
sizeof
(
STaosxRsp
));
}
else
if
(
type
==
TMQ_MSG_TYPE__POLL_RSP
)
{
pPushEntry
->
pDataRsp
=
taosMemoryCalloc
(
1
,
sizeof
(
SMqDataRsp
));
...
...
@@ -383,13 +406,13 @@ int32_t tqRegisterPushEntry(STQ* pTq, void* pHandle, const SMqPollReq* pRequest,
taosHashPut
(
pTq
->
pPushMgr
,
pTqHandle
->
subKey
,
strlen
(
pTqHandle
->
subKey
),
&
pPushEntry
,
sizeof
(
void
*
));
tqDebug
(
"tmq poll: consumer:0x%"
PRIx64
", subkey %s offset:%"
PRId64
", vgId:%d save handle to push mgr, total:%d"
,
consumerId
,
pTqHandle
->
subKey
,
pDataRsp
->
reqOffset
.
version
,
vgId
,
taosHashGetSize
(
pTq
->
pPushMgr
));
tqDebug
(
"tmq poll: consumer:0x%"
PRIx64
", subkey %s offset:%"
PRId64
", vgId:%d save handle to push mgr, total:%d"
,
consumerId
,
pTqHandle
->
subKey
,
pDataRsp
->
reqOffset
.
version
,
vgId
,
taosHashGetSize
(
pTq
->
pPushMgr
));
return
0
;
}
int32_t
tq
Remove
PushEntry
(
STQ
*
pTq
,
const
char
*
pKey
,
int32_t
keyLen
,
uint64_t
consumerId
,
bool
rspConsumer
)
{
int32_t
vgId
=
TD_VID
(
pTq
->
pVnode
);
int32_t
tq
Unregister
PushEntry
(
STQ
*
pTq
,
const
char
*
pKey
,
int32_t
keyLen
,
uint64_t
consumerId
,
bool
rspConsumer
)
{
int32_t
vgId
=
TD_VID
(
pTq
->
pVnode
);
STqPushEntry
**
pEntry
=
taosHashGet
(
pTq
->
pPushMgr
,
pKey
,
keyLen
);
if
(
pEntry
!=
NULL
)
{
...
...
@@ -399,7 +422,7 @@ int32_t tqRemovePushEntry(STQ* pTq, const char* pKey, int32_t keyLen, uint64_t c
tqDebug
(
"tmq poll: consumer:0x%"
PRIx64
", subkey %s vgId:%d remove from push mgr, remains:%d"
,
consumerId
,
(
*
pEntry
)
->
subKey
,
vgId
,
taosHashGetSize
(
pTq
->
pPushMgr
)
-
1
);
if
(
rspConsumer
)
{
// rsp the old consumer with empty block.
if
(
rspConsumer
)
{
// rsp the old consumer with empty block.
tqPushDataRsp
(
pTq
,
*
pEntry
);
}
...
...
source/dnode/vnode/src/tq/tqRead.c
浏览文件 @
e9d7a099
...
...
@@ -340,7 +340,7 @@ int32_t tqNextBlock(STqReader* pReader, SFetchRet* ret) {
continue
;
}
ret
->
fetchType
=
FETCH_TYPE__DATA
;
tqDebug
(
"return data rows %
d"
,
ret
->
data
.
info
.
rows
);
tqDebug
(
"return data rows %
"
PRId64
,
ret
->
data
.
info
.
rows
);
return
0
;
}
...
...
source/dnode/vnode/src/tq/tq
Exec
.c
→
source/dnode/vnode/src/tq/tq
Scan
.c
浏览文件 @
e9d7a099
...
...
@@ -18,7 +18,9 @@
int32_t
tqAddBlockDataToRsp
(
const
SSDataBlock
*
pBlock
,
SMqDataRsp
*
pRsp
,
int32_t
numOfCols
,
int8_t
precision
)
{
int32_t
dataStrLen
=
sizeof
(
SRetrieveTableRsp
)
+
blockGetEncodeSize
(
pBlock
);
void
*
buf
=
taosMemoryCalloc
(
1
,
dataStrLen
);
if
(
buf
==
NULL
)
return
-
1
;
if
(
buf
==
NULL
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
SRetrieveTableRsp
*
pRetrieve
=
(
SRetrieveTableRsp
*
)
buf
;
pRetrieve
->
useconds
=
0
;
...
...
@@ -31,7 +33,8 @@ int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, SMqDataRsp* pRsp, int32_t
actualLen
+=
sizeof
(
SRetrieveTableRsp
);
taosArrayPush
(
pRsp
->
blockDataLen
,
&
actualLen
);
taosArrayPush
(
pRsp
->
blockData
,
&
buf
);
return
0
;
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
tqAddBlockSchemaToRsp
(
const
STqExecHandle
*
pExec
,
STaosxRsp
*
pRsp
)
{
...
...
@@ -62,69 +65,84 @@ static int32_t tqAddTbNameToRsp(const STQ* pTq, int64_t uid, STaosxRsp* pRsp, in
}
int32_t
tqScanData
(
STQ
*
pTq
,
const
STqHandle
*
pHandle
,
SMqDataRsp
*
pRsp
,
STqOffsetVal
*
pOffset
)
{
const
STqExecHandle
*
pExec
=
&
pHandle
->
execHandle
;
const
int32_t
MAX_ROWS_TO_RETURN
=
4096
;
int32_t
vgId
=
TD_VID
(
pTq
->
pVnode
);
int32_t
code
=
0
;
int32_t
totalRows
=
0
;
qTaskInfo_t
task
=
pExec
->
task
;
const
STqExecHandle
*
pExec
=
&
pHandle
->
execHandle
;
qTaskInfo_t
task
=
pExec
->
task
;
if
(
qStreamPrepareScan
(
task
,
pOffset
,
pHandle
->
execHandle
.
subType
)
<
0
)
{
tqDebug
(
"prepare scan failed,
return"
);
tqDebug
(
"prepare scan failed,
vgId:%d, consumer:0x%"
PRIx64
,
vgId
,
pHandle
->
consumerId
);
if
(
pOffset
->
type
==
TMQ_OFFSET__LOG
)
{
pRsp
->
rspOffset
=
*
pOffset
;
return
0
;
return
code
;
}
else
{
tqOffsetResetToLog
(
pOffset
,
pHandle
->
snapshotVer
);
if
(
qStreamPrepareScan
(
task
,
pOffset
,
pHandle
->
execHandle
.
subType
)
<
0
)
{
tqDebug
(
"prepare scan failed,
return"
);
tqDebug
(
"prepare scan failed,
vgId:%d, consumer:0x%"
PRIx64
,
vgId
,
pHandle
->
consumerId
);
pRsp
->
rspOffset
=
*
pOffset
;
return
0
;
return
code
;
}
}
}
int32_t
rowCnt
=
0
;
while
(
1
)
{
SSDataBlock
*
pDataBlock
=
NULL
;
uint64_t
ts
=
0
;
tqDebug
(
"vgId:%d, tmq task start to execute"
,
pTq
->
pVnode
->
config
.
vgId
);
if
(
qExecTask
(
task
,
&
pDataBlock
,
&
ts
)
<
0
)
{
tqError
(
"vgId:%d, task exec error since %s"
,
pTq
->
pVnode
->
config
.
vgId
,
terrstr
());
return
-
1
;
}
tqDebug
(
"vgId:%d, tmq task start to execute, consumer:0x%"
PRIx64
,
vgId
,
pHandle
->
consumerId
);
tqDebug
(
"consumer:0x%"
PRIx64
" vgId:%d, tmq task executed, get %p"
,
pHandle
->
consumerId
,
pTq
->
pVnode
->
config
.
vgId
,
pDataBlock
);
code
=
qExecTask
(
task
,
&
pDataBlock
,
&
ts
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
tqError
(
"vgId:%d, task exec error since %s, consumer:0x%"
PRIx64
,
vgId
,
terrstr
(),
pHandle
->
consumerId
);
return
code
;
}
// current scan should be stopped
asap, since the re
balance occurs.
// current scan should be stopped
ASAP, since the re-
balance occurs.
if
(
pDataBlock
==
NULL
)
{
break
;
}
tqAddBlockDataToRsp
(
pDataBlock
,
pRsp
,
pExec
->
numOfCols
,
pTq
->
pVnode
->
config
.
tsdbCfg
.
precision
);
code
=
tqAddBlockDataToRsp
(
pDataBlock
,
pRsp
,
pExec
->
numOfCols
,
pTq
->
pVnode
->
config
.
tsdbCfg
.
precision
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
tqError
(
"vgId:%d, failed to add block to rsp msg"
,
vgId
);
return
code
;
}
pRsp
->
blockNum
++
;
tqDebug
(
"vgId:%d, consumer:0x%"
PRIx64
" tmq task executed, rows:%"
PRId64
", total blocks:%d"
,
vgId
,
pHandle
->
consumerId
,
pDataBlock
->
info
.
rows
,
pRsp
->
blockNum
);
if
(
pOffset
->
type
==
TMQ_OFFSET__SNAPSHOT_DATA
)
{
rowCnt
+=
pDataBlock
->
info
.
rows
;
if
(
rowCnt
>=
4096
)
{
totalRows
+=
pDataBlock
->
info
.
rows
;
if
(
totalRows
>=
MAX_ROWS_TO_RETURN
)
{
break
;
}
}
}
if
(
qStreamExtractOffset
(
task
,
&
pRsp
->
rspOffset
)
<
0
)
{
return
-
1
;
}
qStreamExtractOffset
(
task
,
&
pRsp
->
rspOffset
);
if
(
pRsp
->
rspOffset
.
type
==
0
)
{
tqError
(
"expected rsp offset: type %d %"
PRId64
" %"
PRId64
" %"
PRId64
,
pRsp
->
rspOffset
.
type
,
pRsp
->
rspOffset
.
ts
,
pRsp
->
rspOffset
.
uid
,
pRsp
->
rspOffset
.
version
);
return
-
1
;
code
=
TSDB_CODE_INVALID_PARA
;
tqError
(
"vgId:%d, expected rsp offset: type %d %"
PRId64
" %"
PRId64
" %"
PRId64
,
vgId
,
pRsp
->
rspOffset
.
type
,
pRsp
->
rspOffset
.
ts
,
pRsp
->
rspOffset
.
uid
,
pRsp
->
rspOffset
.
version
);
return
code
;
}
if
(
pRsp
->
withTbName
||
pRsp
->
withSchema
)
{
tqError
(
"get column should not with meta:%d,%d"
,
pRsp
->
withTbName
,
pRsp
->
withSchema
);
return
-
1
;
code
=
TSDB_CODE_INVALID_PARA
;
tqError
(
"vgId:%d, get column should not with meta:%d,%d"
,
vgId
,
pRsp
->
withTbName
,
pRsp
->
withSchema
);
return
code
;
}
return
0
;
tqDebug
(
"vgId:%d, consumer:0x%"
PRIx64
" tmq task executed, total blocks:%d, rows:%d"
,
vgId
,
pHandle
->
consumerId
,
pRsp
->
blockNum
,
totalRows
);
return
code
;
}
int32_t
tqScanTaosx
(
STQ
*
pTq
,
const
STqHandle
*
pHandle
,
STaosxRsp
*
pRsp
,
SMqMetaRsp
*
pMetaRsp
,
STqOffsetVal
*
pOffset
)
{
...
...
@@ -230,23 +248,15 @@ int32_t tqScanTaosx(STQ* pTq, const STqHandle* pHandle, STaosxRsp* pRsp, SMqMeta
return
0
;
}
int32_t
tqTaosxScanLog
(
STQ
*
pTq
,
STqHandle
*
pHandle
,
SPackedData
submit
,
STaosxRsp
*
pRsp
)
{
int32_t
tqTaosxScanLog
(
STQ
*
pTq
,
STqHandle
*
pHandle
,
SPackedData
submit
,
STaosxRsp
*
pRsp
,
int32_t
*
totalRows
)
{
STqExecHandle
*
pExec
=
&
pHandle
->
execHandle
;
/*A(pExec->subType != TOPIC_SUB_TYPE__COLUMN);*/
SArray
*
pBlocks
=
taosArrayInit
(
0
,
sizeof
(
SSDataBlock
));
SArray
*
pSchemas
=
taosArrayInit
(
0
,
sizeof
(
void
*
));
SArray
*
pBlocks
=
taosArrayInit
(
0
,
sizeof
(
SSDataBlock
));
SArray
*
pSchemas
=
taosArrayInit
(
0
,
sizeof
(
void
*
));
if
(
pExec
->
subType
==
TOPIC_SUB_TYPE__TABLE
)
{
STqReader
*
pReader
=
pExec
->
pExecReader
;
/*tqReaderSetDataMsg(pReader, pReq, 0);*/
tqReaderSetSubmitReq2
(
pReader
,
submit
.
msgStr
,
submit
.
msgLen
,
submit
.
ver
);
while
(
tqNextDataBlock2
(
pReader
))
{
/*SSDataBlock block = {0};*/
/*if (tqRetrieveDataBlock(&block, pReader) < 0) {*/
/*if (terrno == TSDB_CODE_TQ_TABLE_SCHEMA_NOT_FOUND) continue;*/
/*}*/
taosArrayClear
(
pBlocks
);
taosArrayClear
(
pSchemas
);
SSubmitTbData
*
pSubmitTbDataRet
=
NULL
;
...
...
@@ -254,7 +264,6 @@ int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SPackedData submit, STaosxR
if
(
terrno
==
TSDB_CODE_TQ_TABLE_SCHEMA_NOT_FOUND
)
continue
;
}
if
(
pRsp
->
withTbName
)
{
/*int64_t uid = pExec->pExecReader->msgIter.uid;*/
int64_t
uid
=
pExec
->
pExecReader
->
lastBlkUid
;
if
(
tqAddTbNameToRsp
(
pTq
,
uid
,
pRsp
,
taosArrayGetSize
(
pBlocks
))
<
0
)
{
taosArrayDestroyEx
(
pBlocks
,
(
FDelete
)
blockDataFreeRes
);
...
...
@@ -276,7 +285,7 @@ int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SPackedData submit, STaosxR
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
continue
;
}
void
*
createReq
=
taosMemoryCalloc
(
1
,
len
);
void
*
createReq
=
taosMemoryCalloc
(
1
,
len
);
SEncoder
encoder
=
{
0
};
tEncoderInit
(
&
encoder
,
createReq
,
len
);
code
=
tEncodeSVCreateTbReq
(
&
encoder
,
pSubmitTbDataRet
->
pCreateTbReq
);
...
...
@@ -296,6 +305,7 @@ int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SPackedData submit, STaosxR
SSDataBlock
*
pBlock
=
taosArrayGet
(
pBlocks
,
i
);
tqAddBlockDataToRsp
(
pBlock
,
(
SMqDataRsp
*
)
pRsp
,
taosArrayGetSize
(
pBlock
->
pDataBlock
),
pTq
->
pVnode
->
config
.
tsdbCfg
.
precision
);
totalRows
+=
pBlock
->
info
.
rows
;
blockDataFreeRes
(
pBlock
);
SSchemaWrapper
*
pSW
=
taosArrayGetP
(
pSchemas
,
i
);
taosArrayPush
(
pRsp
->
blockSchema
,
&
pSW
);
...
...
@@ -304,13 +314,8 @@ int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SPackedData submit, STaosxR
}
}
else
if
(
pExec
->
subType
==
TOPIC_SUB_TYPE__DB
)
{
STqReader
*
pReader
=
pExec
->
pExecReader
;
/*tqReaderSetDataMsg(pReader, pReq, 0);*/
tqReaderSetSubmitReq2
(
pReader
,
submit
.
msgStr
,
submit
.
msgLen
,
submit
.
ver
);
while
(
tqNextDataBlockFilterOut2
(
pReader
,
pExec
->
execDb
.
pFilterOutTbUid
))
{
/*SSDataBlock block = {0};*/
/*if (tqRetrieveDataBlock(&block, pReader) < 0) {*/
/*if (terrno == TSDB_CODE_TQ_TABLE_SCHEMA_NOT_FOUND) continue;*/
/*}*/
taosArrayClear
(
pBlocks
);
taosArrayClear
(
pSchemas
);
SSubmitTbData
*
pSubmitTbDataRet
=
NULL
;
...
...
@@ -339,7 +344,7 @@ int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SPackedData submit, STaosxR
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
continue
;
}
void
*
createReq
=
taosMemoryCalloc
(
1
,
len
);
void
*
createReq
=
taosMemoryCalloc
(
1
,
len
);
SEncoder
encoder
=
{
0
};
tEncoderInit
(
&
encoder
,
createReq
,
len
);
code
=
tEncodeSVCreateTbReq
(
&
encoder
,
pSubmitTbDataRet
->
pCreateTbReq
);
...
...
@@ -355,15 +360,11 @@ int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SPackedData submit, STaosxR
tEncoderClear
(
&
encoder
);
}
/*tqAddBlockDataToRsp(&block, (SMqDataRsp*)pRsp, taosArrayGetSize(block.pDataBlock),*/
/*pTq->pVnode->config.tsdbCfg.precision);*/
/*blockDataFreeRes(&block);*/
/*tqAddBlockSchemaToRsp(pExec, (SMqDataRsp*)pRsp);*/
/*pRsp->blockNum++;*/
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pBlocks
);
i
++
)
{
SSDataBlock
*
pBlock
=
taosArrayGet
(
pBlocks
,
i
);
tqAddBlockDataToRsp
(
pBlock
,
(
SMqDataRsp
*
)
pRsp
,
taosArrayGetSize
(
pBlock
->
pDataBlock
),
pTq
->
pVnode
->
config
.
tsdbCfg
.
precision
);
*
totalRows
+=
pBlock
->
info
.
rows
;
blockDataFreeRes
(
pBlock
);
SSchemaWrapper
*
pSW
=
taosArrayGetP
(
pSchemas
,
i
);
taosArrayPush
(
pRsp
->
blockSchema
,
&
pSW
);
...
...
@@ -373,9 +374,5 @@ int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SPackedData submit, STaosxR
}
taosArrayDestroy
(
pBlocks
);
taosArrayDestroy
(
pSchemas
);
// if (pRsp->blockNum == 0) {
// return -1;
// }
return
0
;
}
source/dnode/vnode/src/tsdb/tsdbCache.c
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/dnode/vnode/src/tsdb/tsdbMemTable.c
浏览文件 @
e9d7a099
...
...
@@ -282,6 +282,40 @@ bool tsdbTbDataIterNext(STbDataIter *pIter) {
return
true
;
}
int64_t
tsdbCountTbDataRows
(
STbData
*
pTbData
)
{
SMemSkipListNode
*
pNode
=
pTbData
->
sl
.
pHead
;
int64_t
rowsNum
=
0
;
while
(
NULL
!=
pNode
)
{
pNode
=
SL_GET_NODE_FORWARD
(
pNode
,
0
);
if
(
pNode
==
pTbData
->
sl
.
pTail
)
{
return
rowsNum
;
}
rowsNum
++
;
}
return
rowsNum
;
}
void
tsdbMemTableCountRows
(
SMemTable
*
pMemTable
,
SHashObj
*
pTableMap
,
int64_t
*
rowsNum
)
{
taosRLockLatch
(
&
pMemTable
->
latch
);
for
(
int32_t
i
=
0
;
i
<
pMemTable
->
nBucket
;
++
i
)
{
STbData
*
pTbData
=
pMemTable
->
aBucket
[
i
];
while
(
pTbData
)
{
void
*
p
=
taosHashGet
(
pTableMap
,
&
pTbData
->
uid
,
sizeof
(
pTbData
->
uid
));
if
(
p
==
NULL
)
{
pTbData
=
pTbData
->
next
;
continue
;
}
*
rowsNum
+=
tsdbCountTbDataRows
(
pTbData
);
pTbData
=
pTbData
->
next
;
}
}
taosRUnLockLatch
(
&
pMemTable
->
latch
);
}
static
int32_t
tsdbMemTableRehash
(
SMemTable
*
pMemTable
)
{
int32_t
code
=
0
;
...
...
@@ -787,4 +821,4 @@ SArray *tsdbMemTableGetTbDataArray(SMemTable *pMemTable) {
_exit:
return
aTbDataP
;
}
\ No newline at end of file
}
source/dnode/vnode/src/tsdb/tsdbMergeTree.c
浏览文件 @
e9d7a099
...
...
@@ -504,9 +504,34 @@ bool tLDataIterNextRow(SLDataIter *pIter, const char *idStr) {
pIter
->
iRow
+=
step
;
while
(
1
)
{
bool
skipBlock
=
false
;
findNextValidRow
(
pIter
,
idStr
);
if
(
pIter
->
iRow
>=
pBlockData
->
nRow
||
pIter
->
iRow
<
0
)
{
if
(
pIter
->
pBlockLoadInfo
->
checkRemainingRow
)
{
skipBlock
=
true
;
int16_t
*
aCols
=
pIter
->
pBlockLoadInfo
->
colIds
;
int
nCols
=
pIter
->
pBlockLoadInfo
->
numOfCols
;
bool
isLast
=
pIter
->
pBlockLoadInfo
->
isLast
;
for
(
int
inputColIndex
=
0
;
inputColIndex
<
nCols
;
++
inputColIndex
)
{
for
(
int
colIndex
=
0
;
colIndex
<
pBlockData
->
nColData
;
++
colIndex
)
{
SColData
*
pColData
=
&
pBlockData
->
aColData
[
colIndex
];
int16_t
cid
=
pColData
->
cid
;
if
(
cid
==
aCols
[
inputColIndex
])
{
if
(
isLast
&&
(
pColData
->
flag
&
HAS_VALUE
))
{
skipBlock
=
false
;
break
;
}
else
if
(
pColData
->
flag
&
(
HAS_VALUE
|
HAS_NULL
))
{
skipBlock
=
false
;
break
;
}
}
}
}
}
if
(
skipBlock
||
pIter
->
iRow
>=
pBlockData
->
nRow
||
pIter
->
iRow
<
0
)
{
tLDataIterNextBlock
(
pIter
,
idStr
);
if
(
pIter
->
pSttBlk
==
NULL
)
{
// no more data
goto
_exit
;
...
...
source/dnode/vnode/src/tsdb/tsdbRead.c
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/dnode/vnode/src/vnd/vnodeCommit.c
浏览文件 @
e9d7a099
...
...
@@ -156,13 +156,10 @@ int vnodeShouldCommit(SVnode *pVnode) {
bool
needCommit
=
false
;
taosThreadMutexLock
(
&
pVnode
->
mutex
);
if
(
!
pVnode
->
inUse
||
!
diskAvail
)
{
goto
_out
;
if
(
pVnode
->
inUse
&&
diskAvail
)
{
needCommit
=
((
pVnode
->
inUse
->
size
>
pVnode
->
inUse
->
node
.
size
)
&&
(
pSched
->
commitMs
+
SYNC_VND_COMMIT_MIN_MS
<
nowMs
));
}
needCommit
=
(((
pVnode
->
inUse
->
size
>
pVnode
->
inUse
->
node
.
size
)
&&
(
pSched
->
commitMs
+
SYNC_VND_COMMIT_MIN_MS
<
nowMs
))
||
(
pVnode
->
inUse
->
size
>
0
&&
pSched
->
commitMs
+
pSched
->
maxWaitMs
<
nowMs
));
_out:
taosThreadMutexUnlock
(
&
pVnode
->
mutex
);
return
needCommit
;
}
...
...
source/dnode/vnode/src/vnd/vnodeSnapshot.c
浏览文件 @
e9d7a099
...
...
@@ -335,6 +335,7 @@ int32_t vnodeSnapWriterClose(SVSnapWriter *pWriter, int8_t rollback, SSnapshot *
// commit json
if
(
!
rollback
)
{
pWriter
->
info
.
state
.
committed
=
pWriter
->
ever
;
pVnode
->
config
=
pWriter
->
info
.
config
;
pVnode
->
state
=
(
SVState
){.
committed
=
pWriter
->
info
.
state
.
committed
,
.
applied
=
pWriter
->
info
.
state
.
committed
,
...
...
source/dnode/vnode/src/vnd/vnodeSync.c
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/libs/catalog/src/ctgUtil.c
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/libs/executor/inc/executil.h
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/libs/executor/inc/executorimpl.h
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/libs/executor/inc/tfill.h
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/libs/executor/src/aggregateoperator.c
0 → 100644
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/libs/executor/src/cachescanoperator.c
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/libs/executor/src/exchangeoperator.c
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/libs/executor/src/executil.c
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/libs/executor/src/executor.c
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/libs/executor/src/executorimpl.c
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/libs/executor/src/filloperator.c
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/libs/executor/src/projectoperator.c
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/libs/executor/src/scanoperator.c
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/libs/executor/src/sortoperator.c
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/libs/executor/src/sysscanoperator.c
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/libs/executor/src/timewindowoperator.c
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/libs/function/inc/builtinsimpl.h
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/libs/function/src/builtins.c
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/libs/function/src/builtinsimpl.c
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/libs/function/src/functionMgt.c
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/libs/index/src/indexFstFile.c
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/libs/parser/src/parCalcConst.c
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/libs/parser/src/parInsertSml.c
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/libs/parser/src/parInsertUtil.c
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/libs/parser/src/parTranslater.c
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/libs/parser/src/parUtil.c
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/libs/planner/src/planOptimizer.c
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/libs/planner/src/planPhysiCreater.c
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/libs/planner/src/planSpliter.c
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/libs/qcom/src/queryUtil.c
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/libs/qworker/src/qwDbg.c
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/libs/qworker/src/qworker.c
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/libs/scalar/src/sclfunc.c
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/libs/scheduler/inc/schInt.h
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/libs/scheduler/src/schFlowCtrl.c
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/libs/scheduler/src/schJob.c
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/libs/scheduler/src/schRemote.c
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/libs/scheduler/src/schStatus.c
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/libs/scheduler/src/schTask.c
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/libs/scheduler/src/scheduler.c
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/libs/stream/src/stream.c
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/libs/stream/src/streamExec.c
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/libs/sync/src/syncAppendEntries.c
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/libs/sync/src/syncElection.c
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/libs/sync/src/syncMain.c
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/libs/sync/src/syncMessage.c
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/libs/sync/src/syncRequestVote.c
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/libs/sync/src/syncSnapshot.c
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/libs/sync/src/syncTimeout.c
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/libs/tdb/src/db/tdbPager.c
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/util/src/tarray.c
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/util/src/tconfig.c
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/util/src/tsimplehash.c
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/util/src/tversion.c
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
source/util/src/version.c.in
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
tests/parallel_test/cases.task
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
tests/parallel_test/run.sh
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
tests/script/coverage_test.sh
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
tests/script/tsim/parser/limit1_stb.sim
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
tests/script/tsim/parser/slimit1_query.sim
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
tests/script/tsim/query/interval-offset.sim
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
tests/script/tsim/query/join_interval.sim
0 → 100644
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
tests/script/tsim/query/nullColSma.sim
0 → 100644
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
tests/script/tsim/query/sys_tbname.sim
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
tests/script/tsim/query/unionall_as_table.sim
0 → 100644
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
tests/script/tsim/stream/distributeInterval0.sim
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
tests/script/tsim/stream/distributeIntervalRetrive0.sim
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
tests/script/tsim/stream/state1.sim
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
tests/system-test/0-others/check_assert.py
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
tests/system-test/0-others/tmqBasic.json
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
tests/system-test/2-query/columnLenUpdated.py
0 → 100644
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
tests/system-test/2-query/nestedQuery.py
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
tests/system-test/2-query/nestedQuery_26.py
0 → 100755
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
tests/system-test/2-query/nestedQuery_math.py
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
tests/system-test/2-query/out_of_order.py
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
tests/system-test/7-tmq/raw_block_interface_test.py
0 → 100644
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
tests/system-test/7-tmq/subscribeDb.py
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
tests/system-test/7-tmq/subscribeStb1.py
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
tests/system-test/7-tmq/tmq3mnodeSwitch.py
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
tests/system-test/7-tmq/tmqConsFromTsdb-mutilVg.py
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
tests/system-test/7-tmq/tmqDelete-1ctb.py
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
tests/system-test/7-tmq/tmqDnodeRestart.py
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
tests/system-test/7-tmq/tmqDropNtb-snapshot0.py
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
tests/system-test/7-tmq/tmqMultiConsumer.py
0 → 100644
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
tools/shell/src/shellArguments.c
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
tools/shell/src/shellEngine.c
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
utils/test/c/CMakeLists.txt
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
utils/test/c/sml_test.c
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
utils/test/c/tmq_taosx_ci.c
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
utils/test/c/write_raw_block_test.c
0 → 100644
浏览文件 @
e9d7a099
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录