Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
e77931f1
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1193
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
e77931f1
编写于
7月 10, 2022
作者:
dengyihao
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'dev' into index
上级
06fe7f6a
60135336
变更
146
展开全部
隐藏空白更改
内联
并排
Showing
146 changed file
with
4389 addition
and
2116 deletion
+4389
-2116
examples/c/tmq.c
examples/c/tmq.c
+12
-4
include/client/taos.h
include/client/taos.h
+10
-9
include/common/tcommon.h
include/common/tcommon.h
+4
-2
include/common/tdatablock.h
include/common/tdatablock.h
+1
-1
include/common/tmsg.h
include/common/tmsg.h
+32
-23
include/common/tname.h
include/common/tname.h
+2
-0
include/libs/executor/executor.h
include/libs/executor/executor.h
+7
-1
include/libs/function/function.h
include/libs/function/function.h
+6
-0
include/libs/parser/parser.h
include/libs/parser/parser.h
+3
-0
include/libs/transport/trpc.h
include/libs/transport/trpc.h
+1
-1
include/libs/wal/wal.h
include/libs/wal/wal.h
+10
-36
include/util/taoserror.h
include/util/taoserror.h
+3
-1
include/util/tlog.h
include/util/tlog.h
+1
-1
packaging/tools/install.sh
packaging/tools/install.sh
+2
-0
packaging/tools/makepkg.sh
packaging/tools/makepkg.sh
+2
-1
source/client/src/clientHb.c
source/client/src/clientHb.c
+8
-7
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+2
-0
source/client/src/clientSml.c
source/client/src/clientSml.c
+13
-12
source/client/src/tmq.c
source/client/src/tmq.c
+668
-140
source/client/test/smlTest.cpp
source/client/test/smlTest.cpp
+207
-1
source/common/src/tdatablock.c
source/common/src/tdatablock.c
+3
-3
source/common/src/tmsg.c
source/common/src/tmsg.c
+33
-10
source/common/src/tname.c
source/common/src/tname.c
+8
-0
source/dnode/mgmt/mgmt_dnode/src/dmHandle.c
source/dnode/mgmt/mgmt_dnode/src/dmHandle.c
+1
-1
source/dnode/mgmt/mgmt_mnode/src/mmWorker.c
source/dnode/mgmt/mgmt_mnode/src/mmWorker.c
+1
-1
source/dnode/mgmt/node_mgmt/src/dmNodes.c
source/dnode/mgmt/node_mgmt/src/dmNodes.c
+1
-1
source/dnode/mnode/impl/inc/mndInt.h
source/dnode/mnode/impl/inc/mndInt.h
+0
-3
source/dnode/mnode/impl/src/mndConsumer.c
source/dnode/mnode/impl/src/mndConsumer.c
+6
-6
source/dnode/mnode/impl/src/mndDnode.c
source/dnode/mnode/impl/src/mndDnode.c
+1
-1
source/dnode/mnode/impl/src/mndOffset.c
source/dnode/mnode/impl/src/mndOffset.c
+1
-1
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+79
-41
source/dnode/mnode/impl/src/mndSubscribe.c
source/dnode/mnode/impl/src/mndSubscribe.c
+14
-10
source/dnode/mnode/impl/src/mndTopic.c
source/dnode/mnode/impl/src/mndTopic.c
+1
-1
source/dnode/mnode/impl/test/stb/stb.cpp
source/dnode/mnode/impl/test/stb/stb.cpp
+1
-3
source/dnode/snode/src/snode.c
source/dnode/snode/src/snode.c
+1
-1
source/dnode/vnode/CMakeLists.txt
source/dnode/vnode/CMakeLists.txt
+9
-9
source/dnode/vnode/inc/vnode.h
source/dnode/vnode/inc/vnode.h
+16
-9
source/dnode/vnode/src/inc/meta.h
source/dnode/vnode/src/inc/meta.h
+3
-0
source/dnode/vnode/src/inc/sma.h
source/dnode/vnode/src/inc/sma.h
+9
-4
source/dnode/vnode/src/inc/tq.h
source/dnode/vnode/src/inc/tq.h
+1
-0
source/dnode/vnode/src/inc/tsdb.h
source/dnode/vnode/src/inc/tsdb.h
+1
-0
source/dnode/vnode/src/inc/vnodeInt.h
source/dnode/vnode/src/inc/vnodeInt.h
+43
-21
source/dnode/vnode/src/meta/metaSnapshot.c
source/dnode/vnode/src/meta/metaSnapshot.c
+115
-24
source/dnode/vnode/src/meta/metaTable.c
source/dnode/vnode/src/meta/metaTable.c
+29
-30
source/dnode/vnode/src/sma/sma.c
source/dnode/vnode/src/sma/sma.c
+0
-257
source/dnode/vnode/src/sma/smaCommit.c
source/dnode/vnode/src/sma/smaCommit.c
+2
-1
source/dnode/vnode/src/sma/smaEnv.c
source/dnode/vnode/src/sma/smaEnv.c
+83
-27
source/dnode/vnode/src/sma/smaRollup.c
source/dnode/vnode/src/sma/smaRollup.c
+161
-138
source/dnode/vnode/src/sma/smaTimeRange.c
source/dnode/vnode/src/sma/smaTimeRange.c
+30
-0
source/dnode/vnode/src/sma/smaUtil.c
source/dnode/vnode/src/sma/smaUtil.c
+19
-0
source/dnode/vnode/src/tq/tq.c
source/dnode/vnode/src/tq/tq.c
+64
-31
source/dnode/vnode/src/tq/tqExec.c
source/dnode/vnode/src/tq/tqExec.c
+66
-10
source/dnode/vnode/src/tq/tqOffset.c
source/dnode/vnode/src/tq/tqOffset.c
+1
-1
source/dnode/vnode/src/tq/tqPush.c
source/dnode/vnode/src/tq/tqPush.c
+1
-1
source/dnode/vnode/src/tq/tqRead.c
source/dnode/vnode/src/tq/tqRead.c
+30
-20
source/dnode/vnode/src/tsdb/tsdbRead.c
source/dnode/vnode/src/tsdb/tsdbRead.c
+12
-3
source/dnode/vnode/src/tsdb/tsdbRetention.c
source/dnode/vnode/src/tsdb/tsdbRetention.c
+19
-22
source/dnode/vnode/src/tsdb/tsdbSnapshot.c
source/dnode/vnode/src/tsdb/tsdbSnapshot.c
+673
-9
source/dnode/vnode/src/tsdb/tsdbUtil.c
source/dnode/vnode/src/tsdb/tsdbUtil.c
+6
-1
source/dnode/vnode/src/vnd/vnodeCommit.c
source/dnode/vnode/src/vnd/vnodeCommit.c
+5
-1
source/dnode/vnode/src/vnd/vnodeModule.c
source/dnode/vnode/src/vnd/vnodeModule.c
+1
-0
source/dnode/vnode/src/vnd/vnodeOpen.c
source/dnode/vnode/src/vnd/vnodeOpen.c
+8
-1
source/dnode/vnode/src/vnd/vnodeSnapshot.c
source/dnode/vnode/src/vnd/vnodeSnapshot.c
+150
-50
source/dnode/vnode/src/vnd/vnodeSvr.c
source/dnode/vnode/src/vnd/vnodeSvr.c
+1
-0
source/dnode/vnode/src/vnd/vnodeSync.c
source/dnode/vnode/src/vnd/vnodeSync.c
+22
-10
source/libs/catalog/inc/catalogInt.h
source/libs/catalog/inc/catalogInt.h
+1
-1
source/libs/catalog/src/ctgDbg.c
source/libs/catalog/src/ctgDbg.c
+1
-1
source/libs/catalog/src/ctgUtil.c
source/libs/catalog/src/ctgUtil.c
+1
-1
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+106
-94
source/libs/executor/src/executil.c
source/libs/executor/src/executil.c
+11
-8
source/libs/executor/src/executor.c
source/libs/executor/src/executor.c
+3
-3
source/libs/executor/src/executorMain.c
source/libs/executor/src/executorMain.c
+87
-1
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+25
-19
source/libs/executor/src/scanoperator.c
source/libs/executor/src/scanoperator.c
+198
-93
source/libs/executor/src/timewindowoperator.c
source/libs/executor/src/timewindowoperator.c
+101
-42
source/libs/executor/test/executorTests.cpp
source/libs/executor/test/executorTests.cpp
+8
-8
source/libs/executor/test/sortTests.cpp
source/libs/executor/test/sortTests.cpp
+2
-2
source/libs/function/inc/fnLog.h
source/libs/function/inc/fnLog.h
+1
-1
source/libs/function/src/builtinsimpl.c
source/libs/function/src/builtinsimpl.c
+7
-0
source/libs/function/src/tudf.c
source/libs/function/src/tudf.c
+6
-6
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+17
-21
source/libs/qcom/src/querymsg.c
source/libs/qcom/src/querymsg.c
+5
-5
source/libs/qworker/src/qwDbg.c
source/libs/qworker/src/qwDbg.c
+1
-1
source/libs/qworker/src/qworker.c
source/libs/qworker/src/qworker.c
+1
-1
source/libs/scalar/inc/sclInt.h
source/libs/scalar/inc/sclInt.h
+1
-1
source/libs/scalar/src/filter.c
source/libs/scalar/src/filter.c
+9
-2
source/libs/scalar/src/scalar.c
source/libs/scalar/src/scalar.c
+64
-33
source/libs/scalar/src/sclvector.c
source/libs/scalar/src/sclvector.c
+6
-8
source/libs/scalar/test/filter/filterTests.cpp
source/libs/scalar/test/filter/filterTests.cpp
+41
-18
source/libs/scalar/test/scalar/scalarTests.cpp
source/libs/scalar/test/scalar/scalarTests.cpp
+1
-1
source/libs/scheduler/inc/schInt.h
source/libs/scheduler/inc/schInt.h
+39
-37
source/libs/scheduler/src/schJob.c
source/libs/scheduler/src/schJob.c
+1
-1
source/libs/scheduler/src/schRemote.c
source/libs/scheduler/src/schRemote.c
+1
-1
source/libs/scheduler/src/schTask.c
source/libs/scheduler/src/schTask.c
+32
-10
source/libs/sync/src/syncAppendEntries.c
source/libs/sync/src/syncAppendEntries.c
+58
-58
source/libs/sync/src/syncAppendEntriesReply.c
source/libs/sync/src/syncAppendEntriesReply.c
+16
-13
source/libs/sync/src/syncCommit.c
source/libs/sync/src/syncCommit.c
+9
-9
source/libs/sync/src/syncElection.c
source/libs/sync/src/syncElection.c
+3
-2
source/libs/sync/src/syncIndexMgr.c
source/libs/sync/src/syncIndexMgr.c
+5
-5
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+46
-46
source/libs/sync/src/syncMessage.c
source/libs/sync/src/syncMessage.c
+112
-112
source/libs/sync/src/syncRaftCfg.c
source/libs/sync/src/syncRaftCfg.c
+11
-11
source/libs/sync/src/syncRaftEntry.c
source/libs/sync/src/syncRaftEntry.c
+11
-11
source/libs/sync/src/syncRaftLog.c
source/libs/sync/src/syncRaftLog.c
+31
-31
source/libs/sync/src/syncReplication.c
source/libs/sync/src/syncReplication.c
+7
-9
source/libs/sync/src/syncRequestVote.c
source/libs/sync/src/syncRequestVote.c
+5
-5
source/libs/sync/src/syncRequestVoteReply.c
source/libs/sync/src/syncRequestVoteReply.c
+8
-8
source/libs/sync/src/syncRespMgr.c
source/libs/sync/src/syncRespMgr.c
+3
-3
source/libs/sync/src/syncSnapshot.c
source/libs/sync/src/syncSnapshot.c
+15
-15
source/libs/sync/src/syncVoteMgr.c
source/libs/sync/src/syncVoteMgr.c
+10
-10
source/libs/sync/test/syncConfigChangeSnapshotTest.cpp
source/libs/sync/test/syncConfigChangeSnapshotTest.cpp
+6
-6
source/libs/sync/test/syncConfigChangeTest.cpp
source/libs/sync/test/syncConfigChangeTest.cpp
+6
-6
source/libs/sync/test/syncIndexMgrTest.cpp
source/libs/sync/test/syncIndexMgrTest.cpp
+1
-1
source/libs/sync/test/syncIndexTest.cpp
source/libs/sync/test/syncIndexTest.cpp
+1
-1
source/libs/sync/test/syncRaftIdCheck.cpp
source/libs/sync/test/syncRaftIdCheck.cpp
+2
-2
source/libs/sync/test/syncRaftLogTest.cpp
source/libs/sync/test/syncRaftLogTest.cpp
+5
-5
source/libs/sync/test/syncRaftLogTest2.cpp
source/libs/sync/test/syncRaftLogTest2.cpp
+2
-2
source/libs/sync/test/syncRaftLogTest3.cpp
source/libs/sync/test/syncRaftLogTest3.cpp
+30
-30
source/libs/sync/test/syncRefTest.cpp
source/libs/sync/test/syncRefTest.cpp
+4
-4
source/libs/sync/test/syncReplicateTest.cpp
source/libs/sync/test/syncReplicateTest.cpp
+5
-5
source/libs/sync/test/syncRespMgrTest.cpp
source/libs/sync/test/syncRespMgrTest.cpp
+6
-6
source/libs/sync/test/syncSnapshotTest.cpp
source/libs/sync/test/syncSnapshotTest.cpp
+5
-5
source/libs/sync/test/syncTestTool.cpp
source/libs/sync/test/syncTestTool.cpp
+12
-12
source/libs/sync/test/syncWriteTest.cpp
source/libs/sync/test/syncWriteTest.cpp
+3
-3
source/libs/tdb/src/db/tdbPager.c
source/libs/tdb/src/db/tdbPager.c
+1
-1
source/libs/transport/inc/transComm.h
source/libs/transport/inc/transComm.h
+24
-24
source/libs/transport/src/trans.c
source/libs/transport/src/trans.c
+3
-3
source/libs/transport/src/transCli.c
source/libs/transport/src/transCli.c
+26
-26
source/libs/transport/src/transComm.c
source/libs/transport/src/transComm.c
+3
-3
source/libs/transport/src/transSvr.c
source/libs/transport/src/transSvr.c
+20
-21
source/libs/transport/test/pushServer.c
source/libs/transport/test/pushServer.c
+1
-1
source/libs/wal/src/walRead.c
source/libs/wal/src/walRead.c
+65
-59
source/libs/wal/src/walWrite.c
source/libs/wal/src/walWrite.c
+2
-1
source/os/src/osSemaphore.c
source/os/src/osSemaphore.c
+2
-2
source/util/src/terror.c
source/util/src/terror.c
+2
-0
source/util/src/tjson.c
source/util/src/tjson.c
+2
-4
tests/script/jenkins/basic.txt
tests/script/jenkins/basic.txt
+1
-1
tests/script/tsim/valgrind/basic1.sim
tests/script/tsim/valgrind/basic1.sim
+27
-4
tests/script/tsim/valgrind/basic2.sim
tests/script/tsim/valgrind/basic2.sim
+21
-61
tests/script/tsim/valgrind/basic3.sim
tests/script/tsim/valgrind/basic3.sim
+152
-0
tests/script/tsim/valgrind/checkError1.sim
tests/script/tsim/valgrind/checkError1.sim
+54
-0
tests/script/tsim/valgrind/checkError3.sim
tests/script/tsim/valgrind/checkError3.sim
+23
-34
tests/system-test/0-others/taosShellError.py
tests/system-test/0-others/taosShellError.py
+11
-11
tests/system-test/failed.txt
tests/system-test/failed.txt
+1
-0
tests/system-test/fulltest.sh
tests/system-test/fulltest.sh
+1
-1
tests/test/c/sdbDump.c
tests/test/c/sdbDump.c
+7
-0
未找到文件。
examples/c/tmq.c
浏览文件 @
e77931f1
...
@@ -28,15 +28,23 @@ static void msg_process(TAOS_RES* msg) {
...
@@ -28,15 +28,23 @@ static void msg_process(TAOS_RES* msg) {
printf
(
"db: %s
\n
"
,
tmq_get_db_name
(
msg
));
printf
(
"db: %s
\n
"
,
tmq_get_db_name
(
msg
));
printf
(
"vg: %d
\n
"
,
tmq_get_vgroup_id
(
msg
));
printf
(
"vg: %d
\n
"
,
tmq_get_vgroup_id
(
msg
));
if
(
tmq_get_res_type
(
msg
)
==
TMQ_RES_TABLE_META
)
{
if
(
tmq_get_res_type
(
msg
)
==
TMQ_RES_TABLE_META
)
{
void
*
meta
;
tmq_raw_data
*
raw
=
tmq_get_raw_meta
(
msg
);
int32_t
metaLen
;
if
(
raw
){
tmq_get_raw_meta
(
msg
,
&
meta
,
&
metaLen
);
TAOS
*
pConn
=
taos_connect
(
"192.168.1.86"
,
"root"
,
"taosdata"
,
"abc1"
,
0
);
if
(
pConn
==
NULL
)
{
return
;
}
int32_t
ret
=
taos_write_raw_meta
(
pConn
,
raw
);
printf
(
"write raw data: %s
\n
"
,
tmq_err2str
(
ret
));
free
(
raw
);
taos_close
(
pConn
);
}
char
*
result
=
tmq_get_json_meta
(
msg
);
char
*
result
=
tmq_get_json_meta
(
msg
);
if
(
result
){
if
(
result
){
printf
(
"meta result: %s
\n
"
,
result
);
printf
(
"meta result: %s
\n
"
,
result
);
free
(
result
);
free
(
result
);
}
}
printf
(
"meta
, len is %d
\n
"
,
metaLen
);
printf
(
"meta
:%p
\n
"
,
raw
);
return
;
return
;
}
}
while
(
1
)
{
while
(
1
)
{
...
...
include/client/taos.h
浏览文件 @
e77931f1
...
@@ -260,15 +260,16 @@ enum tmq_res_t {
...
@@ -260,15 +260,16 @@ enum tmq_res_t {
};
};
typedef
enum
tmq_res_t
tmq_res_t
;
typedef
enum
tmq_res_t
tmq_res_t
;
typedef
struct
tmq_raw_data
tmq_raw_data
;
DLL_EXPORT
tmq_res_t
tmq_get_res_type
(
TAOS_RES
*
res
);
DLL_EXPORT
int32_t
tmq_get_raw_meta
(
TAOS_RES
*
res
,
void
**
raw_meta
,
int32_t
*
raw_meta_len
);
DLL_EXPORT
tmq_res_t
tmq_get_res_type
(
TAOS_RES
*
res
);
DLL_EXPORT
int32_t
taos_write_raw_meta
(
TAOS
*
res
,
void
*
raw_meta
,
int32_t
raw_meta_len
);
DLL_EXPORT
tmq_raw_data
*
tmq_get_raw_meta
(
TAOS_RES
*
res
);
DLL_EXPORT
char
*
tmq_get_json_meta
(
TAOS_RES
*
res
);
// Returning null means error. Returned result need to be freed.
DLL_EXPORT
int32_t
taos_write_raw_meta
(
TAOS
*
taos
,
tmq_raw_data
*
raw_meta
);
DLL_EXPORT
const
char
*
tmq_get_topic_name
(
TAOS_RES
*
res
);
DLL_EXPORT
char
*
tmq_get_json_meta
(
TAOS_RES
*
res
);
// Returning null means error. Returned result need to be freed.
DLL_EXPORT
const
char
*
tmq_get_db_name
(
TAOS_RES
*
res
);
DLL_EXPORT
const
char
*
tmq_get_topic_name
(
TAOS_RES
*
res
);
DLL_EXPORT
int32_t
tmq_get_vgroup_id
(
TAOS_RES
*
res
);
DLL_EXPORT
const
char
*
tmq_get_db_name
(
TAOS_RES
*
res
);
DLL_EXPORT
const
char
*
tmq_get_table_name
(
TAOS_RES
*
res
);
DLL_EXPORT
int32_t
tmq_get_vgroup_id
(
TAOS_RES
*
res
);
DLL_EXPORT
const
char
*
tmq_get_table_name
(
TAOS_RES
*
res
);
/* ------------------------------ TMQ END -------------------------------- */
/* ------------------------------ TMQ END -------------------------------- */
...
...
include/common/tcommon.h
浏览文件 @
e77931f1
...
@@ -55,7 +55,8 @@ enum {
...
@@ -55,7 +55,8 @@ enum {
enum
{
enum
{
STREAM_INPUT__DATA_SUBMIT
=
1
,
STREAM_INPUT__DATA_SUBMIT
=
1
,
STREAM_INPUT__DATA_BLOCK
,
STREAM_INPUT__DATA_BLOCK
,
STREAM_INPUT__DATA_SCAN
,
STREAM_INPUT__TABLE_SCAN
,
STREAM_INPUT__TQ_SCAN
,
STREAM_INPUT__DATA_RETRIEVE
,
STREAM_INPUT__DATA_RETRIEVE
,
STREAM_INPUT__TRIGGER
,
STREAM_INPUT__TRIGGER
,
STREAM_INPUT__CHECKPOINT
,
STREAM_INPUT__CHECKPOINT
,
...
@@ -122,7 +123,8 @@ enum {
...
@@ -122,7 +123,8 @@ enum {
};
};
typedef
struct
{
typedef
struct
{
int8_t
fetchType
;
int8_t
fetchType
;
STqOffsetVal
offset
;
union
{
union
{
SSDataBlock
data
;
SSDataBlock
data
;
void
*
meta
;
void
*
meta
;
...
...
include/common/tdatablock.h
浏览文件 @
e77931f1
...
@@ -231,7 +231,7 @@ SSDataBlock* createDataBlock();
...
@@ -231,7 +231,7 @@ SSDataBlock* createDataBlock();
int32_t
blockDataAppendColInfo
(
SSDataBlock
*
pBlock
,
SColumnInfoData
*
pColInfoData
);
int32_t
blockDataAppendColInfo
(
SSDataBlock
*
pBlock
,
SColumnInfoData
*
pColInfoData
);
SColumnInfoData
createColumnInfoData
(
int16_t
type
,
int32_t
bytes
,
int16_t
colId
);
SColumnInfoData
createColumnInfoData
(
int16_t
type
,
int32_t
bytes
,
int16_t
colId
);
SColumnInfoData
*
bdGetColumnInfoData
(
SSDataBlock
*
pBlock
,
int32_t
index
);
SColumnInfoData
*
bdGetColumnInfoData
(
const
SSDataBlock
*
pBlock
,
int32_t
index
);
void
blockEncode
(
const
SSDataBlock
*
pBlock
,
char
*
data
,
int32_t
*
dataLen
,
int32_t
numOfCols
,
int8_t
needCompress
);
void
blockEncode
(
const
SSDataBlock
*
pBlock
,
char
*
data
,
int32_t
*
dataLen
,
int32_t
numOfCols
,
int8_t
needCompress
);
const
char
*
blockDecode
(
SSDataBlock
*
pBlock
,
int32_t
numOfCols
,
int32_t
numOfRows
,
const
char
*
pData
);
const
char
*
blockDecode
(
SSDataBlock
*
pBlock
,
int32_t
numOfCols
,
int32_t
numOfRows
,
const
char
*
pData
);
...
...
include/common/tmsg.h
浏览文件 @
e77931f1
...
@@ -169,6 +169,9 @@ typedef enum _mgmt_table {
...
@@ -169,6 +169,9 @@ typedef enum _mgmt_table {
#define TD_CHILD_TABLE TSDB_CHILD_TABLE
#define TD_CHILD_TABLE TSDB_CHILD_TABLE
#define TD_NORMAL_TABLE TSDB_NORMAL_TABLE
#define TD_NORMAL_TABLE TSDB_NORMAL_TABLE
#define TD_REQ_FROM_APP 0
#define TD_REQ_FROM_TAOX 1
typedef
struct
{
typedef
struct
{
int32_t
vgId
;
int32_t
vgId
;
char
*
dbFName
;
char
*
dbFName
;
...
@@ -432,25 +435,30 @@ static FORCE_INLINE int32_t tDecodeSSchemaWrapperEx(SDecoder* pDecoder, SSchemaW
...
@@ -432,25 +435,30 @@ static FORCE_INLINE int32_t tDecodeSSchemaWrapperEx(SDecoder* pDecoder, SSchemaW
STSchema
*
tdGetSTSChemaFromSSChema
(
SSchema
**
pSchema
,
int32_t
nCols
);
STSchema
*
tdGetSTSChemaFromSSChema
(
SSchema
**
pSchema
,
int32_t
nCols
);
typedef
struct
{
typedef
struct
{
char
name
[
TSDB_TABLE_FNAME_LEN
];
char
name
[
TSDB_TABLE_FNAME_LEN
];
int8_t
igExists
;
int8_t
igExists
;
int64_t
delay1
;
int8_t
source
;
// 1-taosX or 0-taosClient
int64_t
delay2
;
int8_t
reserved
[
6
];
int64_t
watermark1
;
tb_uid_t
suid
;
int64_t
watermark2
;
int64_t
delay1
;
int32_t
ttl
;
int64_t
delay2
;
int32_t
numOfColumns
;
int64_t
watermark1
;
int32_t
numOfTags
;
int64_t
watermark2
;
int32_t
numOfFuncs
;
int32_t
ttl
;
int32_t
commentLen
;
int32_t
colVer
;
int32_t
ast1Len
;
int32_t
tagVer
;
int32_t
ast2Len
;
int32_t
numOfColumns
;
SArray
*
pColumns
;
// array of SField
int32_t
numOfTags
;
SArray
*
pTags
;
// array of SField
int32_t
numOfFuncs
;
SArray
*
pFuncs
;
int32_t
commentLen
;
char
*
pComment
;
int32_t
ast1Len
;
char
*
pAst1
;
int32_t
ast2Len
;
char
*
pAst2
;
SArray
*
pColumns
;
// array of SField
SArray
*
pTags
;
// array of SField
SArray
*
pFuncs
;
char
*
pComment
;
char
*
pAst1
;
char
*
pAst2
;
}
SMCreateStbReq
;
}
SMCreateStbReq
;
int32_t
tSerializeSMCreateStbReq
(
void
*
buf
,
int32_t
bufLen
,
SMCreateStbReq
*
pReq
);
int32_t
tSerializeSMCreateStbReq
(
void
*
buf
,
int32_t
bufLen
,
SMCreateStbReq
*
pReq
);
...
@@ -458,8 +466,11 @@ int32_t tDeserializeSMCreateStbReq(void* buf, int32_t bufLen, SMCreateStbReq* pR
...
@@ -458,8 +466,11 @@ int32_t tDeserializeSMCreateStbReq(void* buf, int32_t bufLen, SMCreateStbReq* pR
void
tFreeSMCreateStbReq
(
SMCreateStbReq
*
pReq
);
void
tFreeSMCreateStbReq
(
SMCreateStbReq
*
pReq
);
typedef
struct
{
typedef
struct
{
char
name
[
TSDB_TABLE_FNAME_LEN
];
char
name
[
TSDB_TABLE_FNAME_LEN
];
int8_t
igNotExists
;
int8_t
igNotExists
;
int8_t
source
;
// 1-taosX or 0-taosClient
int8_t
reserved
[
6
];
tb_uid_t
suid
;
}
SMDropStbReq
;
}
SMDropStbReq
;
int32_t
tSerializeSMDropStbReq
(
void
*
buf
,
int32_t
bufLen
,
SMDropStbReq
*
pReq
);
int32_t
tSerializeSMDropStbReq
(
void
*
buf
,
int32_t
bufLen
,
SMDropStbReq
*
pReq
);
...
@@ -468,8 +479,6 @@ int32_t tDeserializeSMDropStbReq(void* buf, int32_t bufLen, SMDropStbReq* pReq);
...
@@ -468,8 +479,6 @@ int32_t tDeserializeSMDropStbReq(void* buf, int32_t bufLen, SMDropStbReq* pReq);
typedef
struct
{
typedef
struct
{
char
name
[
TSDB_TABLE_FNAME_LEN
];
char
name
[
TSDB_TABLE_FNAME_LEN
];
int8_t
alterType
;
int8_t
alterType
;
int32_t
tagVer
;
int32_t
colVer
;
int32_t
numOfFields
;
int32_t
numOfFields
;
SArray
*
pFields
;
SArray
*
pFields
;
int32_t
ttl
;
int32_t
ttl
;
...
...
include/common/tname.h
浏览文件 @
e77931f1
...
@@ -37,6 +37,8 @@ typedef struct SName {
...
@@ -37,6 +37,8 @@ typedef struct SName {
char
tname
[
TSDB_TABLE_NAME_LEN
];
char
tname
[
TSDB_TABLE_NAME_LEN
];
}
SName
;
}
SName
;
SName
*
toName
(
int32_t
acctId
,
const
char
*
pDbName
,
const
char
*
pTableName
,
SName
*
pName
);
int32_t
tNameExtractFullName
(
const
SName
*
name
,
char
*
dst
);
int32_t
tNameExtractFullName
(
const
SName
*
name
,
char
*
dst
);
int32_t
tNameLen
(
const
SName
*
name
);
int32_t
tNameLen
(
const
SName
*
name
);
...
...
include/libs/executor/executor.h
浏览文件 @
e77931f1
...
@@ -174,7 +174,13 @@ int32_t qDeserializeTaskStatus(qTaskInfo_t tinfo, const char* pInput, int32_t le
...
@@ -174,7 +174,13 @@ int32_t qDeserializeTaskStatus(qTaskInfo_t tinfo, const char* pInput, int32_t le
*/
*/
int32_t
qGetStreamScanStatus
(
qTaskInfo_t
tinfo
,
uint64_t
*
uid
,
int64_t
*
ts
);
int32_t
qGetStreamScanStatus
(
qTaskInfo_t
tinfo
,
uint64_t
*
uid
,
int64_t
*
ts
);
int32_t
qStreamPrepareScan
(
qTaskInfo_t
tinfo
,
uint64_t
uid
,
int64_t
ts
);
int32_t
qStreamPrepareTsdbScan
(
qTaskInfo_t
tinfo
,
uint64_t
uid
,
int64_t
ts
);
int32_t
qStreamPrepareScan
(
qTaskInfo_t
tinfo
,
const
STqOffsetVal
*
pOffset
);
int32_t
qStreamExtractOffset
(
qTaskInfo_t
tinfo
,
STqOffsetVal
*
pOffset
);
void
*
qStreamExtractMetaMsg
(
qTaskInfo_t
tinfo
);
void
*
qExtractReaderFromStreamScanner
(
void
*
scanner
);
void
*
qExtractReaderFromStreamScanner
(
void
*
scanner
);
int32_t
qExtractStreamScanner
(
qTaskInfo_t
tinfo
,
void
**
scanner
);
int32_t
qExtractStreamScanner
(
qTaskInfo_t
tinfo
,
void
**
scanner
);
...
...
include/libs/function/function.h
浏览文件 @
e77931f1
...
@@ -172,7 +172,13 @@ typedef struct tExprNode {
...
@@ -172,7 +172,13 @@ typedef struct tExprNode {
void
tExprTreeDestroy
(
tExprNode
*
pNode
,
void
(
*
fp
)(
void
*
));
void
tExprTreeDestroy
(
tExprNode
*
pNode
,
void
(
*
fp
)(
void
*
));
typedef
enum
{
SHOULD_FREE_COLDATA
=
0x1
,
// the newly created column data needs to be destroyed.
DELEGATED_MGMT_COLDATA
=
0x2
,
// input column data should not be released.
}
ECOLDATA_MGMT_TYPE_E
;
struct
SScalarParam
{
struct
SScalarParam
{
ECOLDATA_MGMT_TYPE_E
type
;
SColumnInfoData
*
columnData
;
SColumnInfoData
*
columnData
;
SHashObj
*
pHashFilter
;
SHashObj
*
pHashFilter
;
int32_t
hashValueType
;
int32_t
hashValueType
;
...
...
include/libs/parser/parser.h
浏览文件 @
e77931f1
...
@@ -96,6 +96,9 @@ int32_t smlBindData(void* handle, SArray* tags, SArray* colsSchema, SArray* cols
...
@@ -96,6 +96,9 @@ int32_t smlBindData(void* handle, SArray* tags, SArray* colsSchema, SArray* cols
char
*
tableName
,
char
*
msgBuf
,
int16_t
msgBufLen
);
char
*
tableName
,
char
*
msgBuf
,
int16_t
msgBufLen
);
int32_t
smlBuildOutput
(
void
*
handle
,
SHashObj
*
pVgHash
);
int32_t
smlBuildOutput
(
void
*
handle
,
SHashObj
*
pVgHash
);
int32_t
rewriteToVnodeModifyOpStmt
(
SQuery
*
pQuery
,
SArray
*
pBufArray
);
SArray
*
serializeVgroupsCreateTableBatch
(
SHashObj
*
pVgroupHashmap
);
SArray
*
serializeVgroupsDropTableBatch
(
SHashObj
*
pVgroupHashmap
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
include/libs/transport/trpc.h
浏览文件 @
e77931f1
...
@@ -27,7 +27,7 @@ extern "C" {
...
@@ -27,7 +27,7 @@ extern "C" {
#define TAOS_CONN_SERVER 0
#define TAOS_CONN_SERVER 0
#define TAOS_CONN_CLIENT 1
#define TAOS_CONN_CLIENT 1
#define IsReq(pMsg) (pMsg->msgType & 1U)
#define IsReq(pMsg)
(pMsg->msgType & 1U)
extern
int32_t
tsRpcHeadSize
;
extern
int32_t
tsRpcHeadSize
;
...
...
include/libs/wal/wal.h
浏览文件 @
e77931f1
...
@@ -24,42 +24,14 @@
...
@@ -24,42 +24,14 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
#define wFatal(...) \
// clang-format off
{ \
#define wFatal(...) { if (wDebugFlag & DEBUG_FATAL) { taosPrintLog("WAL FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); }}
if (wDebugFlag & DEBUG_FATAL) { \
#define wError(...) { if (wDebugFlag & DEBUG_ERROR) { taosPrintLog("WAL ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }}
taosPrintLog("WAL FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); \
#define wWarn(...) { if (wDebugFlag & DEBUG_WARN) { taosPrintLog("WAL WARN ", DEBUG_WARN, 255, __VA_ARGS__); }}
} \
#define wInfo(...) { if (wDebugFlag & DEBUG_INFO) { taosPrintLog("WAL ", DEBUG_INFO, 255, __VA_ARGS__); }}
}
#define wDebug(...) { if (wDebugFlag & DEBUG_DEBUG) { taosPrintLog("WAL ", DEBUG_DEBUG, wDebugFlag, __VA_ARGS__); }}
#define wError(...) \
#define wTrace(...) { if (wDebugFlag & DEBUG_TRACE) { taosPrintLog("WAL ", DEBUG_TRACE, wDebugFlag, __VA_ARGS__); }}
{ \
// clang-format on
if (wDebugFlag & DEBUG_ERROR) { \
taosPrintLog("WAL ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); \
} \
}
#define wWarn(...) \
{ \
if (wDebugFlag & DEBUG_WARN) { \
taosPrintLog("WAL WARN ", DEBUG_WARN, 255, __VA_ARGS__); \
} \
}
#define wInfo(...) \
{ \
if (wDebugFlag & DEBUG_INFO) { \
taosPrintLog("WAL ", DEBUG_INFO, 255, __VA_ARGS__); \
} \
}
#define wDebug(...) \
{ \
if (wDebugFlag & DEBUG_DEBUG) { \
taosPrintLog("WAL ", DEBUG_DEBUG, wDebugFlag, __VA_ARGS__); \
} \
}
#define wTrace(...) \
{ \
if (wDebugFlag & DEBUG_TRACE) { \
taosPrintLog("WAL ", DEBUG_TRACE, wDebugFlag, __VA_ARGS__); \
} \
}
#define WAL_PROTO_VER 0
#define WAL_PROTO_VER 0
#define WAL_NOSUFFIX_LEN 20
#define WAL_NOSUFFIX_LEN 20
...
@@ -161,6 +133,7 @@ typedef struct {
...
@@ -161,6 +133,7 @@ typedef struct {
int64_t
curFileFirstVer
;
int64_t
curFileFirstVer
;
int64_t
curVersion
;
int64_t
curVersion
;
int64_t
capacity
;
int64_t
capacity
;
int8_t
curInvalid
;
TdThreadMutex
mutex
;
TdThreadMutex
mutex
;
SWalFilterCond
cond
;
SWalFilterCond
cond
;
SWalCkHead
*
pHead
;
SWalCkHead
*
pHead
;
...
@@ -194,6 +167,7 @@ int32_t walRestoreFromSnapshot(SWal *, int64_t ver);
...
@@ -194,6 +167,7 @@ int32_t walRestoreFromSnapshot(SWal *, int64_t ver);
SWalReader
*
walOpenReader
(
SWal
*
,
SWalFilterCond
*
pCond
);
SWalReader
*
walOpenReader
(
SWal
*
,
SWalFilterCond
*
pCond
);
void
walCloseReader
(
SWalReader
*
pRead
);
void
walCloseReader
(
SWalReader
*
pRead
);
int32_t
walReadVer
(
SWalReader
*
pRead
,
int64_t
ver
);
int32_t
walReadVer
(
SWalReader
*
pRead
,
int64_t
ver
);
int32_t
walReadSeekVer
(
SWalReader
*
pRead
,
int64_t
ver
);
int32_t
walNextValidMsg
(
SWalReader
*
pRead
);
int32_t
walNextValidMsg
(
SWalReader
*
pRead
);
// only for tq usage
// only for tq usage
...
...
include/util/taoserror.h
浏览文件 @
e77931f1
...
@@ -247,9 +247,11 @@ int32_t* taosGetErrno();
...
@@ -247,9 +247,11 @@ int32_t* taosGetErrno();
#define TSDB_CODE_MND_COLUMN_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x03AE)
#define TSDB_CODE_MND_COLUMN_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x03AE)
#define TSDB_CODE_MND_FIELD_CONFLICT_WITH_TOPIC TAOS_DEF_ERROR_CODE(0, 0x03AF)
#define TSDB_CODE_MND_FIELD_CONFLICT_WITH_TOPIC TAOS_DEF_ERROR_CODE(0, 0x03AF)
#define TSDB_CODE_MND_SINGLE_STB_MODE_DB TAOS_DEF_ERROR_CODE(0, 0x03B0)
#define TSDB_CODE_MND_SINGLE_STB_MODE_DB TAOS_DEF_ERROR_CODE(0, 0x03B0)
#define TSDB_CODE_MND_INVALID_SCHEMA_VER TAOS_DEF_ERROR_CODE(0, 0x03B1)
#define TSDB_CODE_MND_STABLE_UID_NOT_MATCH TAOS_DEF_ERROR_CODE(0, 0x03B2)
// mnode-infoSchema
// mnode-infoSchema
#define TSDB_CODE_MND_INVALID_SYS_TABLENAME
TAOS_DEF_ERROR_CODE(0, 0x03BA)
#define TSDB_CODE_MND_INVALID_SYS_TABLENAME TAOS_DEF_ERROR_CODE(0, 0x03BA)
// mnode-func
// mnode-func
#define TSDB_CODE_MND_FUNC_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03C0)
#define TSDB_CODE_MND_FUNC_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03C0)
...
...
include/util/tlog.h
浏览文件 @
e77931f1
...
@@ -94,7 +94,7 @@ void taosPrintLongString(const char *flags, ELogLevel level, int32_t dflag, cons
...
@@ -94,7 +94,7 @@ void taosPrintLongString(const char *flags, ELogLevel level, int32_t dflag, cons
#define pError(...) { taosPrintLog("APP ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }
#define pError(...) { taosPrintLog("APP ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }
#define pPrint(...) { taosPrintLog("APP ", DEBUG_INFO, 255, __VA_ARGS__); }
#define pPrint(...) { taosPrintLog("APP ", DEBUG_INFO, 255, __VA_ARGS__); }
// clang-format on
// clang-format on
#define BUF_PAGE_DEBUG
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
packaging/tools/install.sh
浏览文件 @
e77931f1
...
@@ -30,6 +30,7 @@ configDir="/etc/taos"
...
@@ -30,6 +30,7 @@ configDir="/etc/taos"
installDir
=
"/usr/local/taos"
installDir
=
"/usr/local/taos"
adapterName
=
"taosadapter"
adapterName
=
"taosadapter"
benchmarkName
=
"taosBenchmark"
benchmarkName
=
"taosBenchmark"
tmqName
=
"tmq_sim"
dumpName
=
"taosdump"
dumpName
=
"taosdump"
demoName
=
"taosdemo"
demoName
=
"taosdemo"
...
@@ -205,6 +206,7 @@ function install_bin() {
...
@@ -205,6 +206,7 @@ function install_bin() {
[
-x
${
install_main_dir
}
/bin/
${
adapterName
}
]
&&
${
csudo
}
ln
-s
${
install_main_dir
}
/bin/
${
adapterName
}
${
bin_link_dir
}
/
${
adapterName
}
||
:
[
-x
${
install_main_dir
}
/bin/
${
adapterName
}
]
&&
${
csudo
}
ln
-s
${
install_main_dir
}
/bin/
${
adapterName
}
${
bin_link_dir
}
/
${
adapterName
}
||
:
[
-x
${
install_main_dir
}
/bin/
${
benchmarkName
}
]
&&
${
csudo
}
ln
-s
${
install_main_dir
}
/bin/
${
benchmarkName
}
${
bin_link_dir
}
/
${
demoName
}
||
:
[
-x
${
install_main_dir
}
/bin/
${
benchmarkName
}
]
&&
${
csudo
}
ln
-s
${
install_main_dir
}
/bin/
${
benchmarkName
}
${
bin_link_dir
}
/
${
demoName
}
||
:
[
-x
${
install_main_dir
}
/bin/
${
benchmarkName
}
]
&&
${
csudo
}
ln
-s
${
install_main_dir
}
/bin/
${
benchmarkName
}
${
bin_link_dir
}
/
${
benchmarkName
}
||
:
[
-x
${
install_main_dir
}
/bin/
${
benchmarkName
}
]
&&
${
csudo
}
ln
-s
${
install_main_dir
}
/bin/
${
benchmarkName
}
${
bin_link_dir
}
/
${
benchmarkName
}
||
:
[
-x
${
install_main_dir
}
/bin/
${
tmqName
}
]
&&
${
csudo
}
ln
-s
${
install_main_dir
}
/bin/
${
tmqName
}
${
bin_link_dir
}
/
${
tmqName
}
||
:
[
-x
${
install_main_dir
}
/bin/
${
dumpName
}
]
&&
${
csudo
}
ln
-s
${
install_main_dir
}
/bin/
${
dumpName
}
${
bin_link_dir
}
/
${
dumpName
}
||
:
[
-x
${
install_main_dir
}
/bin/
${
dumpName
}
]
&&
${
csudo
}
ln
-s
${
install_main_dir
}
/bin/
${
dumpName
}
${
bin_link_dir
}
/
${
dumpName
}
||
:
[
-x
${
install_main_dir
}
/bin/TDinsight.sh
]
&&
${
csudo
}
ln
-s
${
install_main_dir
}
/bin/TDinsight.sh
${
bin_link_dir
}
/TDinsight.sh
||
:
[
-x
${
install_main_dir
}
/bin/TDinsight.sh
]
&&
${
csudo
}
ln
-s
${
install_main_dir
}
/bin/TDinsight.sh
${
bin_link_dir
}
/TDinsight.sh
||
:
[
-x
${
install_main_dir
}
/bin/remove.sh
]
&&
${
csudo
}
ln
-s
${
install_main_dir
}
/bin/remove.sh
${
bin_link_dir
}
/
${
uninstallScript
}
||
:
[
-x
${
install_main_dir
}
/bin/remove.sh
]
&&
${
csudo
}
ln
-s
${
install_main_dir
}
/bin/remove.sh
${
bin_link_dir
}
/
${
uninstallScript
}
||
:
...
...
packaging/tools/makepkg.sh
浏览文件 @
e77931f1
...
@@ -60,7 +60,7 @@ if [ "$pagMode" == "lite" ]; then
...
@@ -60,7 +60,7 @@ if [ "$pagMode" == "lite" ]; then
strip
${
build_dir
}
/bin/
${
serverName
}
strip
${
build_dir
}
/bin/
${
serverName
}
strip
${
build_dir
}
/bin/
${
clientName
}
strip
${
build_dir
}
/bin/
${
clientName
}
# lite version doesn't include taosadapter, which will lead to no restful interface
# lite version doesn't include taosadapter, which will lead to no restful interface
bin_files
=
"
${
build_dir
}
/bin/
${
serverName
}
${
build_dir
}
/bin/
${
clientName
}
${
script_dir
}
/remove.sh
${
script_dir
}
/startPre.sh
${
build_dir
}
/bin/taosBenchmark"
bin_files
=
"
${
build_dir
}
/bin/
${
serverName
}
${
build_dir
}
/bin/
${
clientName
}
${
script_dir
}
/remove.sh
${
script_dir
}
/startPre.sh
${
build_dir
}
/bin/taosBenchmark
${
build_dir
}
/bin/tmq_sim
"
taostools_bin_files
=
""
taostools_bin_files
=
""
else
else
...
@@ -78,6 +78,7 @@ else
...
@@ -78,6 +78,7 @@ else
taostools_bin_files
=
"
${
build_dir
}
/bin/taosdump
\
taostools_bin_files
=
"
${
build_dir
}
/bin/taosdump
\
${
build_dir
}
/bin/taosBenchmark
\
${
build_dir
}
/bin/taosBenchmark
\
${
build_dir
}
/bin/tmq_sim
\
${
build_dir
}
/bin/TDinsight.sh
\
${
build_dir
}
/bin/TDinsight.sh
\
$tdinsight_caches
"
$tdinsight_caches
"
...
...
source/client/src/clientHb.c
浏览文件 @
e77931f1
...
@@ -264,15 +264,12 @@ static int32_t hbQueryHbRspHandle(SAppHbMgr *pAppHbMgr, SClientHbRsp *pRsp) {
...
@@ -264,15 +264,12 @@ static int32_t hbQueryHbRspHandle(SAppHbMgr *pAppHbMgr, SClientHbRsp *pRsp) {
static
int32_t
hbAsyncCallBack
(
void
*
param
,
SDataBuf
*
pMsg
,
int32_t
code
)
{
static
int32_t
hbAsyncCallBack
(
void
*
param
,
SDataBuf
*
pMsg
,
int32_t
code
)
{
static
int32_t
emptyRspNum
=
0
;
static
int32_t
emptyRspNum
=
0
;
if
(
code
!=
0
)
{
taosMemoryFreeClear
(
param
);
return
-
1
;
}
char
*
key
=
(
char
*
)
param
;
char
*
key
=
(
char
*
)
param
;
SClientHbBatchRsp
pRsp
=
{
0
};
SClientHbBatchRsp
pRsp
=
{
0
};
tDeserializeSClientHbBatchRsp
(
pMsg
->
pData
,
pMsg
->
len
,
&
pRsp
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
tDeserializeSClientHbBatchRsp
(
pMsg
->
pData
,
pMsg
->
len
,
&
pRsp
);
}
int32_t
rspNum
=
taosArrayGetSize
(
pRsp
.
rsps
);
int32_t
rspNum
=
taosArrayGetSize
(
pRsp
.
rsps
);
taosThreadMutexLock
(
&
appInfo
.
mutex
);
taosThreadMutexLock
(
&
appInfo
.
mutex
);
...
@@ -288,6 +285,10 @@ static int32_t hbAsyncCallBack(void *param, SDataBuf *pMsg, int32_t code) {
...
@@ -288,6 +285,10 @@ static int32_t hbAsyncCallBack(void *param, SDataBuf *pMsg, int32_t code) {
taosMemoryFreeClear
(
param
);
taosMemoryFreeClear
(
param
);
if
(
code
!=
0
)
{
(
*
pInst
)
->
onlineDnodes
=
0
;
}
if
(
rspNum
)
{
if
(
rspNum
)
{
tscDebug
(
"hb got %d rsp, %d empty rsp received before"
,
rspNum
,
tscDebug
(
"hb got %d rsp, %d empty rsp received before"
,
rspNum
,
atomic_val_compare_exchange_32
(
&
emptyRspNum
,
emptyRspNum
,
0
));
atomic_val_compare_exchange_32
(
&
emptyRspNum
,
emptyRspNum
,
0
));
...
...
source/client/src/clientImpl.c
浏览文件 @
e77931f1
...
@@ -325,11 +325,13 @@ int32_t updateQnodeList(SAppInstInfo* pInfo, SArray* pNodeList) {
...
@@ -325,11 +325,13 @@ int32_t updateQnodeList(SAppInstInfo* pInfo, SArray* pNodeList) {
if
(
pInfo
->
pQnodeList
)
{
if
(
pInfo
->
pQnodeList
)
{
taosArrayDestroy
(
pInfo
->
pQnodeList
);
taosArrayDestroy
(
pInfo
->
pQnodeList
);
pInfo
->
pQnodeList
=
NULL
;
pInfo
->
pQnodeList
=
NULL
;
tscDebug
(
"QnodeList cleared in cluster 0x%"
PRIx64
,
pInfo
->
clusterId
);
}
}
if
(
pNodeList
)
{
if
(
pNodeList
)
{
pInfo
->
pQnodeList
=
taosArrayDup
(
pNodeList
);
pInfo
->
pQnodeList
=
taosArrayDup
(
pNodeList
);
taosArraySort
(
pInfo
->
pQnodeList
,
compareQueryNodeLoad
);
taosArraySort
(
pInfo
->
pQnodeList
,
compareQueryNodeLoad
);
tscDebug
(
"QnodeList updated in cluster 0x%"
PRIx64
", num:%d"
,
pInfo
->
clusterId
,
taosArrayGetSize
(
pInfo
->
pQnodeList
));
}
}
taosThreadMutexUnlock
(
&
pInfo
->
qnodeMutex
);
taosThreadMutexUnlock
(
&
pInfo
->
qnodeMutex
);
...
...
source/client/src/clientSml.c
浏览文件 @
e77931f1
...
@@ -1570,41 +1570,40 @@ static int32_t smlParseTSFromJSONObj(SSmlHandle *info, cJSON *root, int64_t *tsV
...
@@ -1570,41 +1570,40 @@ static int32_t smlParseTSFromJSONObj(SSmlHandle *info, cJSON *root, int64_t *tsV
return
TSDB_CODE_TSC_INVALID_TIME_STAMP
;
return
TSDB_CODE_TSC_INVALID_TIME_STAMP
;
}
}
*
tsVal
=
timeDouble
;
size_t
typeLen
=
strlen
(
type
->
valuestring
);
size_t
typeLen
=
strlen
(
type
->
valuestring
);
if
(
typeLen
==
1
&&
(
type
->
valuestring
[
0
]
==
's'
||
type
->
valuestring
[
0
]
==
'S'
))
{
if
(
typeLen
==
1
&&
(
type
->
valuestring
[
0
]
==
's'
||
type
->
valuestring
[
0
]
==
'S'
))
{
// seconds
// seconds
timeDouble
=
timeDouble
*
1e9
;
*
tsVal
=
*
tsVal
*
NANOSECOND_PER_SEC
;
timeDouble
=
timeDouble
*
NANOSECOND_PER_SEC
;
if
(
smlDoubleToInt64OverFlow
(
timeDouble
))
{
if
(
smlDoubleToInt64OverFlow
(
timeDouble
))
{
smlBuildInvalidDataMsg
(
&
info
->
msgBuf
,
"timestamp is too large"
,
NULL
);
smlBuildInvalidDataMsg
(
&
info
->
msgBuf
,
"timestamp is too large"
,
NULL
);
return
TSDB_CODE_TSC_INVALID_TIME_STAMP
;
return
TSDB_CODE_TSC_INVALID_TIME_STAMP
;
}
}
*
tsVal
=
timeDouble
;
}
else
if
(
typeLen
==
2
&&
(
type
->
valuestring
[
1
]
==
's'
||
type
->
valuestring
[
1
]
==
'S'
))
{
}
else
if
(
typeLen
==
2
&&
(
type
->
valuestring
[
1
]
==
's'
||
type
->
valuestring
[
1
]
==
'S'
))
{
switch
(
type
->
valuestring
[
0
])
{
switch
(
type
->
valuestring
[
0
])
{
case
'm'
:
case
'm'
:
case
'M'
:
case
'M'
:
// milliseconds
// milliseconds
timeDouble
=
timeDouble
*
1e6
;
*
tsVal
=
*
tsVal
*
NANOSECOND_PER_MSEC
;
timeDouble
=
timeDouble
*
NANOSECOND_PER_MSEC
;
if
(
smlDoubleToInt64OverFlow
(
timeDouble
))
{
if
(
smlDoubleToInt64OverFlow
(
timeDouble
))
{
smlBuildInvalidDataMsg
(
&
info
->
msgBuf
,
"timestamp is too large"
,
NULL
);
smlBuildInvalidDataMsg
(
&
info
->
msgBuf
,
"timestamp is too large"
,
NULL
);
return
TSDB_CODE_TSC_INVALID_TIME_STAMP
;
return
TSDB_CODE_TSC_INVALID_TIME_STAMP
;
}
}
*
tsVal
=
timeDouble
;
break
;
break
;
case
'u'
:
case
'u'
:
case
'U'
:
case
'U'
:
// microseconds
// microseconds
timeDouble
=
timeDouble
*
1e3
;
*
tsVal
=
*
tsVal
*
NANOSECOND_PER_USEC
;
timeDouble
=
timeDouble
*
NANOSECOND_PER_USEC
;
if
(
smlDoubleToInt64OverFlow
(
timeDouble
))
{
if
(
smlDoubleToInt64OverFlow
(
timeDouble
))
{
smlBuildInvalidDataMsg
(
&
info
->
msgBuf
,
"timestamp is too large"
,
NULL
);
smlBuildInvalidDataMsg
(
&
info
->
msgBuf
,
"timestamp is too large"
,
NULL
);
return
TSDB_CODE_TSC_INVALID_TIME_STAMP
;
return
TSDB_CODE_TSC_INVALID_TIME_STAMP
;
}
}
*
tsVal
=
timeDouble
;
break
;
break
;
case
'n'
:
case
'n'
:
case
'N'
:
case
'N'
:
// nanoseconds
*
tsVal
=
timeDouble
;
break
;
break
;
default:
default:
return
TSDB_CODE_TSC_INVALID_JSON
;
return
TSDB_CODE_TSC_INVALID_JSON
;
...
@@ -1641,21 +1640,23 @@ static int32_t smlParseTSFromJSON(SSmlHandle *info, cJSON *root, SArray *cols) {
...
@@ -1641,21 +1640,23 @@ static int32_t smlParseTSFromJSON(SSmlHandle *info, cJSON *root, SArray *cols) {
if
(
timeDouble
<
0
)
{
if
(
timeDouble
<
0
)
{
return
TSDB_CODE_TSC_INVALID_TIME_STAMP
;
return
TSDB_CODE_TSC_INVALID_TIME_STAMP
;
}
}
uint8_t
tsLen
=
smlGetTimestampLen
((
int64_t
)
timeDouble
);
uint8_t
tsLen
=
smlGetTimestampLen
((
int64_t
)
timeDouble
);
tsVal
=
(
int64_t
)
timeDouble
;
if
(
tsLen
==
TSDB_TIME_PRECISION_SEC_DIGITS
)
{
if
(
tsLen
==
TSDB_TIME_PRECISION_SEC_DIGITS
)
{
timeDouble
=
timeDouble
*
1e9
;
tsVal
=
tsVal
*
NANOSECOND_PER_SEC
;
timeDouble
=
timeDouble
*
NANOSECOND_PER_SEC
;
if
(
smlDoubleToInt64OverFlow
(
timeDouble
))
{
if
(
smlDoubleToInt64OverFlow
(
timeDouble
))
{
smlBuildInvalidDataMsg
(
&
info
->
msgBuf
,
"timestamp is too large"
,
NULL
);
smlBuildInvalidDataMsg
(
&
info
->
msgBuf
,
"timestamp is too large"
,
NULL
);
return
TSDB_CODE_TSC_INVALID_TIME_STAMP
;
return
TSDB_CODE_TSC_INVALID_TIME_STAMP
;
}
}
tsVal
=
timeDouble
;
}
else
if
(
tsLen
==
TSDB_TIME_PRECISION_MILLI_DIGITS
)
{
}
else
if
(
tsLen
==
TSDB_TIME_PRECISION_MILLI_DIGITS
)
{
timeDouble
=
timeDouble
*
1e6
;
tsVal
=
tsVal
*
NANOSECOND_PER_MSEC
;
timeDouble
=
timeDouble
*
NANOSECOND_PER_MSEC
;
if
(
smlDoubleToInt64OverFlow
(
timeDouble
))
{
if
(
smlDoubleToInt64OverFlow
(
timeDouble
))
{
smlBuildInvalidDataMsg
(
&
info
->
msgBuf
,
"timestamp is too large"
,
NULL
);
smlBuildInvalidDataMsg
(
&
info
->
msgBuf
,
"timestamp is too large"
,
NULL
);
return
TSDB_CODE_TSC_INVALID_TIME_STAMP
;
return
TSDB_CODE_TSC_INVALID_TIME_STAMP
;
}
}
tsVal
=
timeDouble
;
}
else
if
(
timeDouble
==
0
)
{
}
else
if
(
timeDouble
==
0
)
{
tsVal
=
taosGetTimestampNs
();
tsVal
=
taosGetTimestampNs
();
}
else
{
}
else
{
...
...
source/client/src/tmq.c
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/client/test/smlTest.cpp
浏览文件 @
e77931f1
...
@@ -1284,4 +1284,210 @@ TEST(testCase, sml_dup_time_Test) {
...
@@ -1284,4 +1284,210 @@ TEST(testCase, sml_dup_time_Test) {
ASSERT_EQ(taos_errno(pRes), 0);
ASSERT_EQ(taos_errno(pRes), 0);
taos_free_result(pRes);
taos_free_result(pRes);
}
}
*/
TEST(testCase, sml_16960_Test) {
TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0);
ASSERT_NE(taos, nullptr);
TAOS_RES* pRes = taos_query(taos, "create database if not exists d16368 schemaless 1");
taos_free_result(pRes);
pRes = taos_query(taos, "use d16368");
taos_free_result(pRes);
const char *sql[] = {
"[\n"
"{\n"
"\"timestamp\":\n"
"\n"
"{ \"value\": 1349020800000, \"type\": \"ms\" }\n"
",\n"
"\"value\":\n"
"\n"
"{ \"value\": 830525384, \"type\": \"int\" }\n"
",\n"
"\"tags\": {\n"
"\"id\": \"stb00_0\",\n"
"\"t0\":\n"
"\n"
"{ \"value\": 83972721, \"type\": \"int\" }\n"
",\n"
"\"t1\":\n"
"\n"
"{ \"value\": 539147525, \"type\": \"int\" }\n"
",\n"
"\"t2\":\n"
"\n"
"{ \"value\": 618258572, \"type\": \"int\" }\n"
",\n"
"\"t3\":\n"
"\n"
"{ \"value\": -10536201, \"type\": \"int\" }\n"
",\n"
"\"t4\":\n"
"\n"
"{ \"value\": 349227409, \"type\": \"int\" }\n"
",\n"
"\"t5\":\n"
"\n"
"{ \"value\": 249347042, \"type\": \"int\" }\n"
"},\n"
"\"metric\": \"stb0\"\n"
"},\n"
"{\n"
"\"timestamp\":\n"
"\n"
"{ \"value\": 1349020800001, \"type\": \"ms\" }\n"
",\n"
"\"value\":\n"
"\n"
"{ \"value\": -588348364, \"type\": \"int\" }\n"
",\n"
"\"tags\": {\n"
"\"id\": \"stb00_0\",\n"
"\"t0\":\n"
"\n"
"{ \"value\": 83972721, \"type\": \"int\" }\n"
",\n"
"\"t1\":\n"
"\n"
"{ \"value\": 539147525, \"type\": \"int\" }\n"
",\n"
"\"t2\":\n"
"\n"
"{ \"value\": 618258572, \"type\": \"int\" }\n"
",\n"
"\"t3\":\n"
"\n"
"{ \"value\": -10536201, \"type\": \"int\" }\n"
",\n"
"\"t4\":\n"
"\n"
"{ \"value\": 349227409, \"type\": \"int\" }\n"
",\n"
"\"t5\":\n"
"\n"
"{ \"value\": 249347042, \"type\": \"int\" }\n"
"},\n"
"\"metric\": \"stb0\"\n"
"},\n"
"{\n"
"\"timestamp\":\n"
"\n"
"{ \"value\": 1349020800002, \"type\": \"ms\" }\n"
",\n"
"\"value\":\n"
"\n"
"{ \"value\": -370310823, \"type\": \"int\" }\n"
",\n"
"\"tags\": {\n"
"\"id\": \"stb00_0\",\n"
"\"t0\":\n"
"\n"
"{ \"value\": 83972721, \"type\": \"int\" }\n"
",\n"
"\"t1\":\n"
"\n"
"{ \"value\": 539147525, \"type\": \"int\" }\n"
",\n"
"\"t2\":\n"
"\n"
"{ \"value\": 618258572, \"type\": \"int\" }\n"
",\n"
"\"t3\":\n"
"\n"
"{ \"value\": -10536201, \"type\": \"int\" }\n"
",\n"
"\"t4\":\n"
"\n"
"{ \"value\": 349227409, \"type\": \"int\" }\n"
",\n"
"\"t5\":\n"
"\n"
"{ \"value\": 249347042, \"type\": \"int\" }\n"
"},\n"
"\"metric\": \"stb0\"\n"
"},\n"
"{\n"
"\"timestamp\":\n"
"\n"
"{ \"value\": 1349020800003, \"type\": \"ms\" }\n"
",\n"
"\"value\":\n"
"\n"
"{ \"value\": -811250191, \"type\": \"int\" }\n"
",\n"
"\"tags\": {\n"
"\"id\": \"stb00_0\",\n"
"\"t0\":\n"
"\n"
"{ \"value\": 83972721, \"type\": \"int\" }\n"
",\n"
"\"t1\":\n"
"\n"
"{ \"value\": 539147525, \"type\": \"int\" }\n"
",\n"
"\"t2\":\n"
"\n"
"{ \"value\": 618258572, \"type\": \"int\" }\n"
",\n"
"\"t3\":\n"
"\n"
"{ \"value\": -10536201, \"type\": \"int\" }\n"
",\n"
"\"t4\":\n"
"\n"
"{ \"value\": 349227409, \"type\": \"int\" }\n"
",\n"
"\"t5\":\n"
"\n"
"{ \"value\": 249347042, \"type\": \"int\" }\n"
"},\n"
"\"metric\": \"stb0\"\n"
"},\n"
"{\n"
"\"timestamp\":\n"
"\n"
"{ \"value\": 1349020800004, \"type\": \"ms\" }\n"
",\n"
"\"value\":\n"
"\n"
"{ \"value\": -330340558, \"type\": \"int\" }\n"
",\n"
"\"tags\": {\n"
"\"id\": \"stb00_0\",\n"
"\"t0\":\n"
"\n"
"{ \"value\": 83972721, \"type\": \"int\" }\n"
",\n"
"\"t1\":\n"
"\n"
"{ \"value\": 539147525, \"type\": \"int\" }\n"
",\n"
"\"t2\":\n"
"\n"
"{ \"value\": 618258572, \"type\": \"int\" }\n"
",\n"
"\"t3\":\n"
"\n"
"{ \"value\": -10536201, \"type\": \"int\" }\n"
",\n"
"\"t4\":\n"
"\n"
"{ \"value\": 349227409, \"type\": \"int\" }\n"
",\n"
"\"t5\":\n"
"\n"
"{ \"value\": 249347042, \"type\": \"int\" }\n"
"},\n"
"\"metric\": \"stb0\"\n"
"}\n"
"]"
};
pRes = taos_schemaless_insert(taos, (char**)sql, sizeof(sql)/sizeof(sql[0]), TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_MILLI_SECONDS);
ASSERT_EQ(taos_errno(pRes), 0);
taos_free_result(pRes);
}
*/
\ No newline at end of file
source/common/src/tdatablock.c
浏览文件 @
e77931f1
...
@@ -1356,7 +1356,7 @@ SColumnInfoData createColumnInfoData(int16_t type, int32_t bytes, int16_t colId)
...
@@ -1356,7 +1356,7 @@ SColumnInfoData createColumnInfoData(int16_t type, int32_t bytes, int16_t colId)
return
col
;
return
col
;
}
}
SColumnInfoData
*
bdGetColumnInfoData
(
SSDataBlock
*
pBlock
,
int32_t
index
)
{
SColumnInfoData
*
bdGetColumnInfoData
(
const
SSDataBlock
*
pBlock
,
int32_t
index
)
{
ASSERT
(
pBlock
!=
NULL
);
ASSERT
(
pBlock
!=
NULL
);
if
(
index
>=
taosArrayGetSize
(
pBlock
->
pDataBlock
))
{
if
(
index
>=
taosArrayGetSize
(
pBlock
->
pDataBlock
))
{
return
NULL
;
return
NULL
;
...
@@ -1735,9 +1735,9 @@ char* dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf)
...
@@ -1735,9 +1735,9 @@ char* dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf)
int32_t
colNum
=
taosArrayGetSize
(
pDataBlock
->
pDataBlock
);
int32_t
colNum
=
taosArrayGetSize
(
pDataBlock
->
pDataBlock
);
int32_t
rows
=
pDataBlock
->
info
.
rows
;
int32_t
rows
=
pDataBlock
->
info
.
rows
;
int32_t
len
=
0
;
int32_t
len
=
0
;
len
+=
snprintf
(
dumpBuf
+
len
,
size
-
len
,
"
\n
%s |block type %d |child id %d|group id
%lu
|
\n
"
,
flag
,
len
+=
snprintf
(
dumpBuf
+
len
,
size
-
len
,
"
\n
%s |block type %d |child id %d|group id
:%"
PRIu64
"
|
\n
"
,
flag
,
(
int32_t
)
pDataBlock
->
info
.
type
,
pDataBlock
->
info
.
childId
,
pDataBlock
->
info
.
groupId
);
(
int32_t
)
pDataBlock
->
info
.
type
,
pDataBlock
->
info
.
childId
,
pDataBlock
->
info
.
groupId
);
if
(
len
>=
size
-
1
)
return
dumpBuf
;
if
(
len
>=
size
-
1
)
return
dumpBuf
;
for
(
int32_t
j
=
0
;
j
<
rows
;
j
++
)
{
for
(
int32_t
j
=
0
;
j
<
rows
;
j
++
)
{
len
+=
snprintf
(
dumpBuf
+
len
,
size
-
len
,
"%s |"
,
flag
);
len
+=
snprintf
(
dumpBuf
+
len
,
size
-
len
,
"%s |"
,
flag
);
...
...
source/common/src/tmsg.c
浏览文件 @
e77931f1
...
@@ -381,9 +381,11 @@ static int32_t tDeserializeSClientHbRsp(SDecoder *pDecoder, SClientHbRsp *pRsp)
...
@@ -381,9 +381,11 @@ static int32_t tDeserializeSClientHbRsp(SDecoder *pDecoder, SClientHbRsp *pRsp)
if
(
pQnodeNum
>
0
)
{
if
(
pQnodeNum
>
0
)
{
pRsp
->
query
->
pQnodeList
=
taosArrayInit
(
pQnodeNum
,
sizeof
(
SQueryNodeLoad
));
pRsp
->
query
->
pQnodeList
=
taosArrayInit
(
pQnodeNum
,
sizeof
(
SQueryNodeLoad
));
if
(
NULL
==
pRsp
->
query
->
pQnodeList
)
return
-
1
;
if
(
NULL
==
pRsp
->
query
->
pQnodeList
)
return
-
1
;
SQueryNodeLoad
load
=
{
0
};
for
(
int32_t
i
=
0
;
i
<
pQnodeNum
;
++
i
)
{
if
(
tDecodeSQueryNodeLoad
(
pDecoder
,
&
load
)
<
0
)
return
-
1
;
SQueryNodeLoad
load
=
{
0
};
taosArrayPush
(
pRsp
->
query
->
pQnodeList
,
&
load
);
if
(
tDecodeSQueryNodeLoad
(
pDecoder
,
&
load
)
<
0
)
return
-
1
;
taosArrayPush
(
pRsp
->
query
->
pQnodeList
,
&
load
);
}
}
}
}
}
...
@@ -496,11 +498,18 @@ int32_t tSerializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pReq
...
@@ -496,11 +498,18 @@ int32_t tSerializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pReq
if
(
tStartEncode
(
&
encoder
)
<
0
)
return
-
1
;
if
(
tStartEncode
(
&
encoder
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
name
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
name
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
igExists
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
igExists
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
source
)
<
0
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
sizeof
(
pReq
->
reserved
)
/
sizeof
(
int8_t
);
++
i
)
{
if
(
tEncodeI8
(
&
encoder
,
pReq
->
reserved
[
i
])
<
0
)
return
-
1
;
}
if
(
tEncodeI64
(
&
encoder
,
pReq
->
suid
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
&
encoder
,
pReq
->
delay1
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
&
encoder
,
pReq
->
delay1
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
&
encoder
,
pReq
->
delay2
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
&
encoder
,
pReq
->
delay2
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
&
encoder
,
pReq
->
watermark1
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
&
encoder
,
pReq
->
watermark1
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
&
encoder
,
pReq
->
watermark2
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
&
encoder
,
pReq
->
watermark2
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
ttl
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
ttl
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
colVer
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
tagVer
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
numOfColumns
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
numOfColumns
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
numOfTags
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
numOfTags
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
numOfFuncs
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
numOfFuncs
)
<
0
)
return
-
1
;
...
@@ -553,11 +562,18 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR
...
@@ -553,11 +562,18 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
name
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
name
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
igExists
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
igExists
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
source
)
<
0
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
sizeof
(
pReq
->
reserved
)
/
sizeof
(
int8_t
);
++
i
)
{
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
reserved
[
i
])
<
0
)
return
-
1
;
}
if
(
tDecodeI64
(
&
decoder
,
&
pReq
->
suid
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
&
decoder
,
&
pReq
->
delay1
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
&
decoder
,
&
pReq
->
delay1
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
&
decoder
,
&
pReq
->
delay2
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
&
decoder
,
&
pReq
->
delay2
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
&
decoder
,
&
pReq
->
watermark1
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
&
decoder
,
&
pReq
->
watermark1
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
&
decoder
,
&
pReq
->
watermark2
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
&
decoder
,
&
pReq
->
watermark2
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
ttl
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
ttl
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
colVer
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
tagVer
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
numOfColumns
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
numOfColumns
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
numOfTags
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
numOfTags
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
numOfFuncs
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
numOfFuncs
)
<
0
)
return
-
1
;
...
@@ -645,6 +661,11 @@ int32_t tSerializeSMDropStbReq(void *buf, int32_t bufLen, SMDropStbReq *pReq) {
...
@@ -645,6 +661,11 @@ int32_t tSerializeSMDropStbReq(void *buf, int32_t bufLen, SMDropStbReq *pReq) {
if
(
tStartEncode
(
&
encoder
)
<
0
)
return
-
1
;
if
(
tStartEncode
(
&
encoder
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
name
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
name
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
igNotExists
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
igNotExists
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
source
)
<
0
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
sizeof
(
pReq
->
reserved
)
/
sizeof
(
int8_t
);
++
i
)
{
if
(
tEncodeI8
(
&
encoder
,
pReq
->
reserved
[
i
])
<
0
)
return
-
1
;
}
if
(
tEncodeI64
(
&
encoder
,
pReq
->
suid
)
<
0
)
return
-
1
;
tEndEncode
(
&
encoder
);
tEndEncode
(
&
encoder
);
int32_t
tlen
=
encoder
.
pos
;
int32_t
tlen
=
encoder
.
pos
;
...
@@ -659,6 +680,12 @@ int32_t tDeserializeSMDropStbReq(void *buf, int32_t bufLen, SMDropStbReq *pReq)
...
@@ -659,6 +680,12 @@ int32_t tDeserializeSMDropStbReq(void *buf, int32_t bufLen, SMDropStbReq *pReq)
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
name
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
name
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
igNotExists
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
igNotExists
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
source
)
<
0
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
sizeof
(
pReq
->
reserved
)
/
sizeof
(
int8_t
);
++
i
)
{
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
reserved
[
i
])
<
0
)
return
-
1
;
}
if
(
tDecodeI64
(
&
decoder
,
&
pReq
->
suid
)
<
0
)
return
-
1
;
tEndDecode
(
&
decoder
);
tEndDecode
(
&
decoder
);
tDecoderClear
(
&
decoder
);
tDecoderClear
(
&
decoder
);
...
@@ -672,8 +699,6 @@ int32_t tSerializeSMAlterStbReq(void *buf, int32_t bufLen, SMAlterStbReq *pReq)
...
@@ -672,8 +699,6 @@ int32_t tSerializeSMAlterStbReq(void *buf, int32_t bufLen, SMAlterStbReq *pReq)
if
(
tStartEncode
(
&
encoder
)
<
0
)
return
-
1
;
if
(
tStartEncode
(
&
encoder
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
name
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
name
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
alterType
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
alterType
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
tagVer
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
colVer
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
numOfFields
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
numOfFields
)
<
0
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
pReq
->
numOfFields
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pReq
->
numOfFields
;
++
i
)
{
SField
*
pField
=
taosArrayGet
(
pReq
->
pFields
,
i
);
SField
*
pField
=
taosArrayGet
(
pReq
->
pFields
,
i
);
...
@@ -700,8 +725,6 @@ int32_t tDeserializeSMAlterStbReq(void *buf, int32_t bufLen, SMAlterStbReq *pReq
...
@@ -700,8 +725,6 @@ int32_t tDeserializeSMAlterStbReq(void *buf, int32_t bufLen, SMAlterStbReq *pReq
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
name
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
name
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
alterType
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
alterType
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
tagVer
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
colVer
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
numOfFields
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
numOfFields
)
<
0
)
return
-
1
;
pReq
->
pFields
=
taosArrayInit
(
pReq
->
numOfFields
,
sizeof
(
SField
));
pReq
->
pFields
=
taosArrayInit
(
pReq
->
numOfFields
,
sizeof
(
SField
));
if
(
pReq
->
pFields
==
NULL
)
{
if
(
pReq
->
pFields
==
NULL
)
{
...
@@ -5406,11 +5429,11 @@ int32_t tFormatOffset(char *buf, int32_t maxLen, const STqOffsetVal *pVal) {
...
@@ -5406,11 +5429,11 @@ int32_t tFormatOffset(char *buf, int32_t maxLen, const STqOffsetVal *pVal) {
}
else
if
(
pVal
->
type
==
TMQ_OFFSET__RESET_LATEST
)
{
}
else
if
(
pVal
->
type
==
TMQ_OFFSET__RESET_LATEST
)
{
snprintf
(
buf
,
maxLen
,
"offset(reset to latest)"
);
snprintf
(
buf
,
maxLen
,
"offset(reset to latest)"
);
}
else
if
(
pVal
->
type
==
TMQ_OFFSET__LOG
)
{
}
else
if
(
pVal
->
type
==
TMQ_OFFSET__LOG
)
{
snprintf
(
buf
,
maxLen
,
"offset(log) ver:%
ld"
,
pVal
->
version
);
snprintf
(
buf
,
maxLen
,
"offset(log) ver:%
"
PRId64
,
pVal
->
version
);
}
else
if
(
pVal
->
type
==
TMQ_OFFSET__SNAPSHOT_DATA
)
{
}
else
if
(
pVal
->
type
==
TMQ_OFFSET__SNAPSHOT_DATA
)
{
snprintf
(
buf
,
maxLen
,
"offset(ss data) uid:%
ld, ts:%ld"
,
pVal
->
uid
,
pVal
->
ts
);
snprintf
(
buf
,
maxLen
,
"offset(ss data) uid:%
"
PRId64
", ts:%"
PRId64
,
pVal
->
uid
,
pVal
->
ts
);
}
else
if
(
pVal
->
type
==
TMQ_OFFSET__SNAPSHOT_META
)
{
}
else
if
(
pVal
->
type
==
TMQ_OFFSET__SNAPSHOT_META
)
{
snprintf
(
buf
,
maxLen
,
"offset(ss meta) uid:%
ld, ts:%ld"
,
pVal
->
uid
,
pVal
->
ts
);
snprintf
(
buf
,
maxLen
,
"offset(ss meta) uid:%
"
PRId64
", ts:%"
PRId64
,
pVal
->
uid
,
pVal
->
ts
);
}
else
{
}
else
{
ASSERT
(
0
);
ASSERT
(
0
);
}
}
...
...
source/common/src/tname.c
浏览文件 @
e77931f1
...
@@ -115,6 +115,14 @@ int64_t taosGetIntervalStartTimestamp(int64_t startTime, int64_t slidingTime, in
...
@@ -115,6 +115,14 @@ int64_t taosGetIntervalStartTimestamp(int64_t startTime, int64_t slidingTime, in
#endif
#endif
SName
*
toName
(
int32_t
acctId
,
const
char
*
pDbName
,
const
char
*
pTableName
,
SName
*
pName
)
{
pName
->
type
=
TSDB_TABLE_NAME_T
;
pName
->
acctId
=
acctId
;
strcpy
(
pName
->
dbname
,
pDbName
);
strcpy
(
pName
->
tname
,
pTableName
);
return
pName
;
}
int32_t
tNameExtractFullName
(
const
SName
*
name
,
char
*
dst
)
{
int32_t
tNameExtractFullName
(
const
SName
*
name
,
char
*
dst
)
{
assert
(
name
!=
NULL
&&
dst
!=
NULL
);
assert
(
name
!=
NULL
&&
dst
!=
NULL
);
...
...
source/dnode/mgmt/mgmt_dnode/src/dmHandle.c
浏览文件 @
e77931f1
...
@@ -21,7 +21,7 @@ extern SConfig *tsCfg;
...
@@ -21,7 +21,7 @@ extern SConfig *tsCfg;
static
void
dmUpdateDnodeCfg
(
SDnodeMgmt
*
pMgmt
,
SDnodeCfg
*
pCfg
)
{
static
void
dmUpdateDnodeCfg
(
SDnodeMgmt
*
pMgmt
,
SDnodeCfg
*
pCfg
)
{
if
(
pMgmt
->
pData
->
dnodeId
==
0
||
pMgmt
->
pData
->
clusterId
==
0
)
{
if
(
pMgmt
->
pData
->
dnodeId
==
0
||
pMgmt
->
pData
->
clusterId
==
0
)
{
dInfo
(
"set dnodeId:%d clusterId:%"
PRId64
,
pCfg
->
dnodeId
,
pCfg
->
clusterId
);
dInfo
(
"set
local info,
dnodeId:%d clusterId:%"
PRId64
,
pCfg
->
dnodeId
,
pCfg
->
clusterId
);
taosThreadRwlockWrlock
(
&
pMgmt
->
pData
->
lock
);
taosThreadRwlockWrlock
(
&
pMgmt
->
pData
->
lock
);
pMgmt
->
pData
->
dnodeId
=
pCfg
->
dnodeId
;
pMgmt
->
pData
->
dnodeId
=
pCfg
->
dnodeId
;
pMgmt
->
pData
->
clusterId
=
pCfg
->
clusterId
;
pMgmt
->
pData
->
clusterId
=
pCfg
->
clusterId
;
...
...
source/dnode/mgmt/mgmt_mnode/src/mmWorker.c
浏览文件 @
e77931f1
...
@@ -167,7 +167,7 @@ int32_t mmPutMsgToQueue(SMnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc) {
...
@@ -167,7 +167,7 @@ int32_t mmPutMsgToQueue(SMnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc) {
if
(
pMsg
==
NULL
)
return
-
1
;
if
(
pMsg
==
NULL
)
return
-
1
;
memcpy
(
pMsg
,
pRpc
,
sizeof
(
SRpcMsg
));
memcpy
(
pMsg
,
pRpc
,
sizeof
(
SRpcMsg
));
dTrace
(
"msg:%p, is created and will put int
%s queue"
,
pMsg
,
pWorker
->
name
);
dTrace
(
"msg:%p, is created and will put int
o %s queue, type:%s"
,
pMsg
,
pWorker
->
name
,
TMSG_INFO
(
pRpc
->
msgType
)
);
return
mmPutMsgToWorker
(
pMgmt
,
pWorker
,
pMsg
);
return
mmPutMsgToWorker
(
pMgmt
,
pWorker
,
pMsg
);
}
}
...
...
source/dnode/mgmt/node_mgmt/src/dmNodes.c
浏览文件 @
e77931f1
...
@@ -277,7 +277,7 @@ int32_t dmRunDnode(SDnode *pDnode) {
...
@@ -277,7 +277,7 @@ int32_t dmRunDnode(SDnode *pDnode) {
while
(
1
)
{
while
(
1
)
{
if
(
pDnode
->
stop
)
{
if
(
pDnode
->
stop
)
{
dInfo
(
"
dnod
e is about to stop"
);
dInfo
(
"
TDengin
e is about to stop"
);
dmSetStatus
(
pDnode
,
DND_STAT_STOPPED
);
dmSetStatus
(
pDnode
,
DND_STAT_STOPPED
);
dmStopNodes
(
pDnode
);
dmStopNodes
(
pDnode
);
dmCloseNodes
(
pDnode
);
dmCloseNodes
(
pDnode
);
...
...
source/dnode/mnode/impl/inc/mndInt.h
浏览文件 @
e77931f1
...
@@ -34,8 +34,6 @@ extern "C" {
...
@@ -34,8 +34,6 @@ extern "C" {
#endif
#endif
// clang-format off
// clang-format off
#define mFatal(...) { if (mDebugFlag & DEBUG_FATAL) { taosPrintLog("MND FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); }}
#define mFatal(...) { if (mDebugFlag & DEBUG_FATAL) { taosPrintLog("MND FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); }}
#define mError(...) { if (mDebugFlag & DEBUG_ERROR) { taosPrintLog("MND ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }}
#define mError(...) { if (mDebugFlag & DEBUG_ERROR) { taosPrintLog("MND ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }}
#define mWarn(...) { if (mDebugFlag & DEBUG_WARN) { taosPrintLog("MND WARN ", DEBUG_WARN, 255, __VA_ARGS__); }}
#define mWarn(...) { if (mDebugFlag & DEBUG_WARN) { taosPrintLog("MND WARN ", DEBUG_WARN, 255, __VA_ARGS__); }}
...
@@ -49,7 +47,6 @@ extern "C" {
...
@@ -49,7 +47,6 @@ extern "C" {
#define mGInfo(param, ...) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); mInfo (param ", gtid:%s", __VA_ARGS__, buf);}
#define mGInfo(param, ...) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); mInfo (param ", gtid:%s", __VA_ARGS__, buf);}
#define mGDebug(param, ...) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); mDebug(param ", gtid:%s", __VA_ARGS__, buf);}
#define mGDebug(param, ...) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); mDebug(param ", gtid:%s", __VA_ARGS__, buf);}
#define mGTrace(param, ...) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); mTrace(param ", gtid:%s", __VA_ARGS__, buf);}
#define mGTrace(param, ...) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); mTrace(param ", gtid:%s", __VA_ARGS__, buf);}
// clang-format on
// clang-format on
#define SYSTABLE_SCH_TABLE_NAME_LEN ((TSDB_TABLE_NAME_LEN - 1) + VARSTR_HEADER_SIZE)
#define SYSTABLE_SCH_TABLE_NAME_LEN ((TSDB_TABLE_NAME_LEN - 1) + VARSTR_HEADER_SIZE)
...
...
source/dnode/mnode/impl/src/mndConsumer.c
浏览文件 @
e77931f1
...
@@ -92,7 +92,7 @@ static int32_t mndProcessConsumerLostMsg(SRpcMsg *pMsg) {
...
@@ -92,7 +92,7 @@ static int32_t mndProcessConsumerLostMsg(SRpcMsg *pMsg) {
SMqConsumerObj
*
pConsumer
=
mndAcquireConsumer
(
pMnode
,
pLostMsg
->
consumerId
);
SMqConsumerObj
*
pConsumer
=
mndAcquireConsumer
(
pMnode
,
pLostMsg
->
consumerId
);
ASSERT
(
pConsumer
);
ASSERT
(
pConsumer
);
mInfo
(
"receive consumer lost msg, consumer id %
ld
, status %s"
,
pLostMsg
->
consumerId
,
mInfo
(
"receive consumer lost msg, consumer id %
"
PRId64
"
, status %s"
,
pLostMsg
->
consumerId
,
mndConsumerStatusName
(
pConsumer
->
status
));
mndConsumerStatusName
(
pConsumer
->
status
));
if
(
pConsumer
->
status
!=
MQ_CONSUMER_STATUS__READY
)
{
if
(
pConsumer
->
status
!=
MQ_CONSUMER_STATUS__READY
)
{
...
@@ -124,7 +124,7 @@ static int32_t mndProcessConsumerRecoverMsg(SRpcMsg *pMsg) {
...
@@ -124,7 +124,7 @@ static int32_t mndProcessConsumerRecoverMsg(SRpcMsg *pMsg) {
SMqConsumerObj
*
pConsumer
=
mndAcquireConsumer
(
pMnode
,
pRecoverMsg
->
consumerId
);
SMqConsumerObj
*
pConsumer
=
mndAcquireConsumer
(
pMnode
,
pRecoverMsg
->
consumerId
);
ASSERT
(
pConsumer
);
ASSERT
(
pConsumer
);
mInfo
(
"receive consumer recover msg, consumer id %
ld
, status %s"
,
pRecoverMsg
->
consumerId
,
mInfo
(
"receive consumer recover msg, consumer id %
"
PRId64
"
, status %s"
,
pRecoverMsg
->
consumerId
,
mndConsumerStatusName
(
pConsumer
->
status
));
mndConsumerStatusName
(
pConsumer
->
status
));
if
(
pConsumer
->
status
!=
MQ_CONSUMER_STATUS__READY
)
{
if
(
pConsumer
->
status
!=
MQ_CONSUMER_STATUS__READY
)
{
...
@@ -296,7 +296,7 @@ static int32_t mndProcessAskEpReq(SRpcMsg *pMsg) {
...
@@ -296,7 +296,7 @@ static int32_t mndProcessAskEpReq(SRpcMsg *pMsg) {
// 2. check epoch, only send ep info when epoches do not match
// 2. check epoch, only send ep info when epoches do not match
if
(
epoch
!=
serverEpoch
)
{
if
(
epoch
!=
serverEpoch
)
{
taosRLockLatch
(
&
pConsumer
->
lock
);
taosRLockLatch
(
&
pConsumer
->
lock
);
mInfo
(
"process ask ep, consumer
%ld
(epoch %d), server epoch %d"
,
consumerId
,
epoch
,
serverEpoch
);
mInfo
(
"process ask ep, consumer
:%"
PRId64
"
(epoch %d), server epoch %d"
,
consumerId
,
epoch
,
serverEpoch
);
int32_t
numOfTopics
=
taosArrayGetSize
(
pConsumer
->
currentTopics
);
int32_t
numOfTopics
=
taosArrayGetSize
(
pConsumer
->
currentTopics
);
rsp
.
topics
=
taosArrayInit
(
numOfTopics
,
sizeof
(
SMqSubTopicEp
));
rsp
.
topics
=
taosArrayInit
(
numOfTopics
,
sizeof
(
SMqSubTopicEp
));
...
@@ -441,7 +441,7 @@ static int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) {
...
@@ -441,7 +441,7 @@ static int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) {
SMqTopicObj topicObj = {0};
SMqTopicObj topicObj = {0};
memcpy(&topicObj, pTopic, sizeof(SMqTopicObj));
memcpy(&topicObj, pTopic, sizeof(SMqTopicObj));
topicObj.refConsumerCnt = pTopic->refConsumerCnt + 1;
topicObj.refConsumerCnt = pTopic->refConsumerCnt + 1;
mInfo("subscribe topic %s by consumer
%ld
cgroup %s, refcnt %d", pTopic->name, consumerId, cgroup,
mInfo("subscribe topic %s by consumer
:%" PRId64 ",
cgroup %s, refcnt %d", pTopic->name, consumerId, cgroup,
topicObj.refConsumerCnt);
topicObj.refConsumerCnt);
if (mndSetTopicCommitLogs(pMnode, pTrans, &topicObj) != 0) goto SUBSCRIBE_OVER;
if (mndSetTopicCommitLogs(pMnode, pTrans, &topicObj) != 0) goto SUBSCRIBE_OVER;
#endif
#endif
...
@@ -451,7 +451,7 @@ static int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) {
...
@@ -451,7 +451,7 @@ static int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) {
pConsumerOld
=
mndAcquireConsumer
(
pMnode
,
consumerId
);
pConsumerOld
=
mndAcquireConsumer
(
pMnode
,
consumerId
);
if
(
pConsumerOld
==
NULL
)
{
if
(
pConsumerOld
==
NULL
)
{
mInfo
(
"receive subscribe request from new consumer:
%ld"
,
consumerId
);
mInfo
(
"receive subscribe request from new consumer:
%"
PRId64
,
consumerId
);
pConsumerNew
=
tNewSMqConsumerObj
(
consumerId
,
cgroup
);
pConsumerNew
=
tNewSMqConsumerObj
(
consumerId
,
cgroup
);
tstrncpy
(
pConsumerNew
->
clientId
,
subscribe
.
clientId
,
256
);
tstrncpy
(
pConsumerNew
->
clientId
,
subscribe
.
clientId
,
256
);
...
@@ -472,7 +472,7 @@ static int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) {
...
@@ -472,7 +472,7 @@ static int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) {
int32_t
status
=
atomic_load_32
(
&
pConsumerOld
->
status
);
int32_t
status
=
atomic_load_32
(
&
pConsumerOld
->
status
);
mInfo
(
"receive subscribe request from old consumer:
%ld
, current status: %s"
,
consumerId
,
mInfo
(
"receive subscribe request from old consumer:
%"
PRId64
"
, current status: %s"
,
consumerId
,
mndConsumerStatusName
(
status
));
mndConsumerStatusName
(
status
));
if
(
status
!=
MQ_CONSUMER_STATUS__READY
)
{
if
(
status
!=
MQ_CONSUMER_STATUS__READY
)
{
...
...
source/dnode/mnode/impl/src/mndDnode.c
浏览文件 @
e77931f1
...
@@ -406,7 +406,7 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
...
@@ -406,7 +406,7 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
}
}
if
(
statusReq
.
dnodeId
==
0
)
{
if
(
statusReq
.
dnodeId
==
0
)
{
mInfo
(
"dnode:%d, %s first access,
set clusterId
%"
PRId64
,
pDnode
->
id
,
pDnode
->
ep
,
pMnode
->
clusterId
);
mInfo
(
"dnode:%d, %s first access,
clusterId:
%"
PRId64
,
pDnode
->
id
,
pDnode
->
ep
,
pMnode
->
clusterId
);
}
else
{
}
else
{
if
(
statusReq
.
clusterId
!=
pMnode
->
clusterId
)
{
if
(
statusReq
.
clusterId
!=
pMnode
->
clusterId
)
{
if
(
pDnode
!=
NULL
)
{
if
(
pDnode
!=
NULL
)
{
...
...
source/dnode/mnode/impl/src/mndOffset.c
浏览文件 @
e77931f1
...
@@ -185,7 +185,7 @@ static int32_t mndProcessCommitOffsetReq(SRpcMsg *pMsg) {
...
@@ -185,7 +185,7 @@ static int32_t mndProcessCommitOffsetReq(SRpcMsg *pMsg) {
for
(
int32_t
i
=
0
;
i
<
commitOffsetReq
.
num
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
commitOffsetReq
.
num
;
i
++
)
{
SMqOffset
*
pOffset
=
&
commitOffsetReq
.
offsets
[
i
];
SMqOffset
*
pOffset
=
&
commitOffsetReq
.
offsets
[
i
];
mInfo
(
"commit offset %
ld to vg
%d of consumer group %s on topic %s"
,
pOffset
->
offset
,
pOffset
->
vgId
,
mInfo
(
"commit offset %
"
PRId64
" to vgId:
%d of consumer group %s on topic %s"
,
pOffset
->
offset
,
pOffset
->
vgId
,
pOffset
->
cgroup
,
pOffset
->
topicName
);
pOffset
->
cgroup
,
pOffset
->
topicName
);
if
(
mndMakePartitionKey
(
key
,
pOffset
->
cgroup
,
pOffset
->
topicName
,
pOffset
->
vgId
)
<
0
)
{
if
(
mndMakePartitionKey
(
key
,
pOffset
->
cgroup
,
pOffset
->
topicName
,
pOffset
->
vgId
)
<
0
)
{
mError
(
"submit offset to topic %s failed"
,
pOffset
->
topicName
);
mError
(
"submit offset to topic %s failed"
,
pOffset
->
topicName
);
...
...
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
e77931f1
...
@@ -45,6 +45,7 @@ static int32_t mndProcessTableMetaReq(SRpcMsg *pReq);
...
@@ -45,6 +45,7 @@ static int32_t mndProcessTableMetaReq(SRpcMsg *pReq);
static
int32_t
mndRetrieveStb
(
SRpcMsg
*
pReq
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rows
);
static
int32_t
mndRetrieveStb
(
SRpcMsg
*
pReq
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rows
);
static
void
mndCancelGetNextStb
(
SMnode
*
pMnode
,
void
*
pIter
);
static
void
mndCancelGetNextStb
(
SMnode
*
pMnode
,
void
*
pIter
);
static
int32_t
mndProcessTableCfgReq
(
SRpcMsg
*
pReq
);
static
int32_t
mndProcessTableCfgReq
(
SRpcMsg
*
pReq
);
static
int32_t
mndAlterStbImp
(
SMnode
*
pMnode
,
SRpcMsg
*
pReq
,
SDbObj
*
pDb
,
SStbObj
*
pStb
,
bool
needRsp
);
int32_t
mndInitStb
(
SMnode
*
pMnode
)
{
int32_t
mndInitStb
(
SMnode
*
pMnode
)
{
SSdbTable
table
=
{
SSdbTable
table
=
{
...
@@ -705,10 +706,10 @@ int32_t mndBuildStbFromReq(SMnode *pMnode, SStbObj *pDst, SMCreateStbReq *pCreat
...
@@ -705,10 +706,10 @@ int32_t mndBuildStbFromReq(SMnode *pMnode, SStbObj *pDst, SMCreateStbReq *pCreat
memcpy
(
pDst
->
db
,
pDb
->
name
,
TSDB_DB_FNAME_LEN
);
memcpy
(
pDst
->
db
,
pDb
->
name
,
TSDB_DB_FNAME_LEN
);
pDst
->
createdTime
=
taosGetTimestampMs
();
pDst
->
createdTime
=
taosGetTimestampMs
();
pDst
->
updateTime
=
pDst
->
createdTime
;
pDst
->
updateTime
=
pDst
->
createdTime
;
pDst
->
uid
=
mndGenerateUid
(
pCreate
->
name
,
TSDB_TABLE_FNAME_LEN
);
pDst
->
uid
=
(
pCreate
->
source
==
1
)
?
pCreate
->
suid
:
mndGenerateUid
(
pCreate
->
name
,
TSDB_TABLE_FNAME_LEN
);
pDst
->
dbUid
=
pDb
->
uid
;
pDst
->
dbUid
=
pDb
->
uid
;
pDst
->
tagVer
=
1
;
pDst
->
tagVer
=
(
pCreate
->
source
!=
TD_REQ_FROM_APP
)
?
pCreate
->
tagVer
:
1
;
pDst
->
colVer
=
1
;
pDst
->
colVer
=
(
pCreate
->
source
!=
TD_REQ_FROM_APP
)
?
pCreate
->
colVer
:
1
;
pDst
->
smaVer
=
1
;
pDst
->
smaVer
=
1
;
pDst
->
nextColId
=
1
;
pDst
->
nextColId
=
1
;
pDst
->
maxdelay
[
0
]
=
pCreate
->
delay1
;
pDst
->
maxdelay
[
0
]
=
pCreate
->
delay1
;
...
@@ -854,6 +855,7 @@ static int32_t mndProcessCreateStbReq(SRpcMsg *pReq) {
...
@@ -854,6 +855,7 @@ static int32_t mndProcessCreateStbReq(SRpcMsg *pReq) {
SStbObj
*
pStb
=
NULL
;
SStbObj
*
pStb
=
NULL
;
SDbObj
*
pDb
=
NULL
;
SDbObj
*
pDb
=
NULL
;
SMCreateStbReq
createReq
=
{
0
};
SMCreateStbReq
createReq
=
{
0
};
bool
isAlter
=
false
;
if
(
tDeserializeSMCreateStbReq
(
pReq
->
pCont
,
pReq
->
contLen
,
&
createReq
)
!=
0
)
{
if
(
tDeserializeSMCreateStbReq
(
pReq
->
pCont
,
pReq
->
contLen
,
&
createReq
)
!=
0
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
terrno
=
TSDB_CODE_INVALID_MSG
;
...
@@ -869,9 +871,39 @@ static int32_t mndProcessCreateStbReq(SRpcMsg *pReq) {
...
@@ -869,9 +871,39 @@ static int32_t mndProcessCreateStbReq(SRpcMsg *pReq) {
pStb
=
mndAcquireStb
(
pMnode
,
createReq
.
name
);
pStb
=
mndAcquireStb
(
pMnode
,
createReq
.
name
);
if
(
pStb
!=
NULL
)
{
if
(
pStb
!=
NULL
)
{
if
(
createReq
.
igExists
)
{
if
(
createReq
.
igExists
)
{
mDebug
(
"stb:%s, already exist, ignore exist is set"
,
createReq
.
name
);
if
(
createReq
.
source
==
TD_REQ_FROM_APP
)
{
code
=
0
;
mDebug
(
"stb:%s, already exist, ignore exist is set"
,
createReq
.
name
);
goto
_OVER
;
code
=
0
;
goto
_OVER
;
}
else
if
(
pStb
->
uid
!=
createReq
.
suid
)
{
mError
(
"stb:%s, already exist while create, input suid:%"
PRId64
" not match with exist suid:%"
PRId64
,
createReq
.
name
,
createReq
.
suid
,
pStb
->
uid
);
terrno
=
TSDB_CODE_MND_STABLE_UID_NOT_MATCH
;
goto
_OVER
;
}
else
if
(
createReq
.
tagVer
>
0
||
createReq
.
colVer
>
0
)
{
int32_t
tagDelta
=
pStb
->
tagVer
-
createReq
.
tagVer
;
int32_t
colDelta
=
pStb
->
colVer
-
createReq
.
colVer
;
int32_t
verDelta
=
tagDelta
+
verDelta
;
mInfo
(
"stb:%s, already exist while create, input tagVer:%d colVer:%d, exist tagVer:%d colVer:%d"
,
createReq
.
name
,
createReq
.
tagVer
,
createReq
.
colVer
,
pStb
->
tagVer
,
pStb
->
colVer
);
if
(
tagDelta
<=
0
&&
colDelta
<=
0
)
{
mInfo
(
"stb:%s, schema version is not incremented and nothing needs to be done"
,
createReq
.
name
);
code
=
0
;
goto
_OVER
;
}
else
if
((
tagDelta
==
1
||
colDelta
==
1
)
&&
(
verDelta
==
1
))
{
isAlter
=
true
;
mInfo
(
"stb:%s, schema version is only increased by 1 number, do alter operation"
,
createReq
.
name
);
}
else
{
mError
(
"stb:%s, schema version increase more than 1 number, error is returned"
,
createReq
.
name
);
terrno
=
TSDB_CODE_MND_INVALID_SCHEMA_VER
;
goto
_OVER
;
}
}
else
{
mError
(
"stb:%s, already exist while create, input tagVer:%d colVer:%d is invalid"
,
createReq
.
name
,
createReq
.
tagVer
,
createReq
.
colVer
,
pStb
->
tagVer
,
pStb
->
colVer
);
terrno
=
TSDB_CODE_MND_INVALID_SCHEMA_VER
;
goto
_OVER
;
}
}
else
{
}
else
{
terrno
=
TSDB_CODE_MND_STB_ALREADY_EXIST
;
terrno
=
TSDB_CODE_MND_STB_ALREADY_EXIST
;
goto
_OVER
;
goto
_OVER
;
...
@@ -900,7 +932,12 @@ static int32_t mndProcessCreateStbReq(SRpcMsg *pReq) {
...
@@ -900,7 +932,12 @@ static int32_t mndProcessCreateStbReq(SRpcMsg *pReq) {
goto
_OVER
;
goto
_OVER
;
}
}
code
=
mndCreateStb
(
pMnode
,
pReq
,
&
createReq
,
pDb
);
if
(
isAlter
)
{
bool
needRsp
=
false
;
code
=
mndAlterStbImp
(
pMnode
,
pReq
,
pDb
,
pStb
,
needRsp
);
}
else
{
code
=
mndCreateStb
(
pMnode
,
pReq
,
&
createReq
,
pDb
);
}
if
(
code
==
0
)
code
=
TSDB_CODE_ACTION_IN_PROGRESS
;
if
(
code
==
0
)
code
=
TSDB_CODE_ACTION_IN_PROGRESS
;
_OVER:
_OVER:
...
@@ -1466,14 +1503,13 @@ static int32_t mndBuildStbCfg(SMnode *pMnode, const char *dbFName, const char *t
...
@@ -1466,14 +1503,13 @@ static int32_t mndBuildStbCfg(SMnode *pMnode, const char *dbFName, const char *t
return
code
;
return
code
;
}
}
static
int32_t
mndBuildSMAlterStbRsp
(
SDbObj
*
pDb
,
const
SMAlterStbReq
*
pAlter
,
SStbObj
*
pObj
,
void
**
pCont
,
static
int32_t
mndBuildSMAlterStbRsp
(
SDbObj
*
pDb
,
SStbObj
*
pObj
,
void
**
pCont
,
int32_t
*
pLen
)
{
int32_t
*
pLen
)
{
int32_t
ret
;
int32_t
ret
;
SEncoder
ec
=
{
0
};
SEncoder
ec
=
{
0
};
uint32_t
contLen
=
0
;
uint32_t
contLen
=
0
;
SMAlterStbRsp
alterRsp
=
{
0
};
SMAlterStbRsp
alterRsp
=
{
0
};
SName
name
=
{
0
};
SName
name
=
{
0
};
tNameFromString
(
&
name
,
p
Alter
->
name
,
T_NAME_ACCT
|
T_NAME_DB
|
T_NAME_TABLE
);
tNameFromString
(
&
name
,
p
Obj
->
name
,
T_NAME_ACCT
|
T_NAME_DB
|
T_NAME_TABLE
);
alterRsp
.
pMeta
=
taosMemoryCalloc
(
1
,
sizeof
(
STableMetaRsp
));
alterRsp
.
pMeta
=
taosMemoryCalloc
(
1
,
sizeof
(
STableMetaRsp
));
if
(
NULL
==
alterRsp
.
pMeta
)
{
if
(
NULL
==
alterRsp
.
pMeta
)
{
...
@@ -1506,10 +1542,36 @@ static int32_t mndBuildSMAlterStbRsp(SDbObj *pDb, const SMAlterStbReq *pAlter, S
...
@@ -1506,10 +1542,36 @@ static int32_t mndBuildSMAlterStbRsp(SDbObj *pDb, const SMAlterStbReq *pAlter, S
return
0
;
return
0
;
}
}
static
int32_t
mndAlterStbImp
(
SMnode
*
pMnode
,
SRpcMsg
*
pReq
,
SDbObj
*
pDb
,
SStbObj
*
pStb
,
bool
needRsp
)
{
int32_t
code
=
-
1
;
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_RETRY
,
TRN_CONFLICT_DB_INSIDE
,
pReq
);
if
(
pTrans
==
NULL
)
goto
_OVER
;
mDebug
(
"trans:%d, used to alter stb:%s"
,
pTrans
->
id
,
pStb
->
name
);
mndTransSetDbName
(
pTrans
,
pDb
->
name
,
NULL
);
if
(
needRsp
)
{
void
*
pCont
=
NULL
;
int32_t
contLen
=
0
;
if
(
mndBuildSMAlterStbRsp
(
pDb
,
pStb
,
&
pCont
,
&
contLen
)
!=
0
)
goto
_OVER
;
mndTransSetRpcRsp
(
pTrans
,
pCont
,
contLen
);
}
if
(
mndSetAlterStbRedoLogs
(
pMnode
,
pTrans
,
pDb
,
pStb
)
!=
0
)
goto
_OVER
;
if
(
mndSetAlterStbCommitLogs
(
pMnode
,
pTrans
,
pDb
,
pStb
)
!=
0
)
goto
_OVER
;
if
(
mndSetAlterStbRedoActions
(
pMnode
,
pTrans
,
pDb
,
pStb
)
!=
0
)
goto
_OVER
;
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
goto
_OVER
;
code
=
0
;
_OVER:
mndTransDrop
(
pTrans
);
return
code
;
}
static
int32_t
mndAlterStb
(
SMnode
*
pMnode
,
SRpcMsg
*
pReq
,
const
SMAlterStbReq
*
pAlter
,
SDbObj
*
pDb
,
SStbObj
*
pOld
)
{
static
int32_t
mndAlterStb
(
SMnode
*
pMnode
,
SRpcMsg
*
pReq
,
const
SMAlterStbReq
*
pAlter
,
SDbObj
*
pDb
,
SStbObj
*
pOld
)
{
bool
needRsp
=
true
;
bool
needRsp
=
true
;
int32_t
code
=
-
1
;
int32_t
code
=
-
1
;
STrans
*
pTrans
=
NULL
;
SField
*
pField0
=
NULL
;
SField
*
pField0
=
NULL
;
SStbObj
stbObj
=
{
0
};
SStbObj
stbObj
=
{
0
};
...
@@ -1558,30 +1620,9 @@ static int32_t mndAlterStb(SMnode *pMnode, SRpcMsg *pReq, const SMAlterStbReq *p
...
@@ -1558,30 +1620,9 @@ static int32_t mndAlterStb(SMnode *pMnode, SRpcMsg *pReq, const SMAlterStbReq *p
}
}
if
(
code
!=
0
)
goto
_OVER
;
if
(
code
!=
0
)
goto
_OVER
;
code
=
mndAlterStbImp
(
pMnode
,
pReq
,
pDb
,
&
stbObj
,
needRsp
);
code
=
-
1
;
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_RETRY
,
TRN_CONFLICT_DB_INSIDE
,
pReq
);
if
(
pTrans
==
NULL
)
goto
_OVER
;
mDebug
(
"trans:%d, used to alter stb:%s"
,
pTrans
->
id
,
pAlter
->
name
);
mndTransSetDbName
(
pTrans
,
pDb
->
name
,
NULL
);
if
(
needRsp
)
{
void
*
pCont
=
NULL
;
int32_t
contLen
=
0
;
if
(
mndBuildSMAlterStbRsp
(
pDb
,
pAlter
,
&
stbObj
,
&
pCont
,
&
contLen
)
!=
0
)
goto
_OVER
;
mndTransSetRpcRsp
(
pTrans
,
pCont
,
contLen
);
}
if
(
mndSetAlterStbRedoLogs
(
pMnode
,
pTrans
,
pDb
,
&
stbObj
)
!=
0
)
goto
_OVER
;
if
(
mndSetAlterStbCommitLogs
(
pMnode
,
pTrans
,
pDb
,
&
stbObj
)
!=
0
)
goto
_OVER
;
if
(
mndSetAlterStbRedoActions
(
pMnode
,
pTrans
,
pDb
,
&
stbObj
)
!=
0
)
goto
_OVER
;
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
goto
_OVER
;
code
=
0
;
_OVER:
_OVER:
mndTransDrop
(
pTrans
);
taosMemoryFreeClear
(
stbObj
.
pTags
);
taosMemoryFreeClear
(
stbObj
.
pTags
);
taosMemoryFreeClear
(
stbObj
.
pColumns
);
taosMemoryFreeClear
(
stbObj
.
pColumns
);
return
code
;
return
code
;
...
@@ -1614,14 +1655,6 @@ static int32_t mndProcessAlterStbReq(SRpcMsg *pReq) {
...
@@ -1614,14 +1655,6 @@ static int32_t mndProcessAlterStbReq(SRpcMsg *pReq) {
goto
_OVER
;
goto
_OVER
;
}
}
if
((
alterReq
.
tagVer
>
0
&&
alterReq
.
colVer
>
0
)
&&
(
alterReq
.
tagVer
<=
pStb
->
tagVer
||
alterReq
.
colVer
<=
pStb
->
colVer
))
{
mDebug
(
"stb:%s, already exist, tagVer:%d colVer:%d smaller than in mnode, tagVer:%d colVer:%d, alter success"
,
alterReq
.
name
,
alterReq
.
tagVer
,
alterReq
.
colVer
,
pStb
->
tagVer
,
pStb
->
colVer
);
code
=
0
;
goto
_OVER
;
}
if
(
mndCheckDbPrivilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_WRITE_DB
,
pDb
)
!=
0
)
{
if
(
mndCheckDbPrivilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_WRITE_DB
,
pDb
)
!=
0
)
{
goto
_OVER
;
goto
_OVER
;
}
}
...
@@ -1752,6 +1785,11 @@ static int32_t mndProcessDropStbReq(SRpcMsg *pReq) {
...
@@ -1752,6 +1785,11 @@ static int32_t mndProcessDropStbReq(SRpcMsg *pReq) {
}
}
}
}
if
(
dropReq
.
source
!=
TD_REQ_FROM_APP
&&
pStb
->
uid
!=
dropReq
.
suid
)
{
terrno
=
TSDB_CODE_MND_STB_NOT_EXIST
;
goto
_OVER
;
}
pDb
=
mndAcquireDbByStb
(
pMnode
,
dropReq
.
name
);
pDb
=
mndAcquireDbByStb
(
pMnode
,
dropReq
.
name
);
if
(
pDb
==
NULL
)
{
if
(
pDb
==
NULL
)
{
terrno
=
TSDB_CODE_MND_DB_NOT_SELECTED
;
terrno
=
TSDB_CODE_MND_DB_NOT_SELECTED
;
...
...
source/dnode/mnode/impl/src/mndSubscribe.c
浏览文件 @
e77931f1
...
@@ -235,7 +235,7 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
...
@@ -235,7 +235,7 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
.
pVgEp
=
pVgEp
,
.
pVgEp
=
pVgEp
,
};
};
taosHashPut
(
pHash
,
&
pVgEp
->
vgId
,
sizeof
(
int32_t
),
&
outputVg
,
sizeof
(
SMqRebOutputVg
));
taosHashPut
(
pHash
,
&
pVgEp
->
vgId
,
sizeof
(
int32_t
),
&
outputVg
,
sizeof
(
SMqRebOutputVg
));
mInfo
(
"mq rebalance: remove vg
%d from consumer %ld"
,
pVgEp
->
vgId
,
consumerId
);
mInfo
(
"mq rebalance: remove vg
Id:%d from consumer:%"
PRId64
,
pVgEp
->
vgId
,
consumerId
);
}
}
taosHashRemove
(
pOutput
->
pSub
->
consumerHash
,
&
consumerId
,
sizeof
(
int64_t
));
taosHashRemove
(
pOutput
->
pSub
->
consumerHash
,
&
consumerId
,
sizeof
(
int64_t
));
// put into removed
// put into removed
...
@@ -255,7 +255,7 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
...
@@ -255,7 +255,7 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
.
pVgEp
=
pVgEp
,
.
pVgEp
=
pVgEp
,
};
};
taosHashPut
(
pHash
,
&
pVgEp
->
vgId
,
sizeof
(
int32_t
),
&
rebOutput
,
sizeof
(
SMqRebOutputVg
));
taosHashPut
(
pHash
,
&
pVgEp
->
vgId
,
sizeof
(
int32_t
),
&
rebOutput
,
sizeof
(
SMqRebOutputVg
));
mInfo
(
"mq rebalance: remove vg
%d from unassigned"
,
pVgEp
->
vgId
);
mInfo
(
"mq rebalance: remove vg
Id:
%d from unassigned"
,
pVgEp
->
vgId
);
}
}
}
}
...
@@ -298,7 +298,7 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
...
@@ -298,7 +298,7 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
.
pVgEp
=
pVgEp
,
.
pVgEp
=
pVgEp
,
};
};
taosHashPut
(
pHash
,
&
pVgEp
->
vgId
,
sizeof
(
int32_t
),
&
outputVg
,
sizeof
(
SMqRebOutputVg
));
taosHashPut
(
pHash
,
&
pVgEp
->
vgId
,
sizeof
(
int32_t
),
&
outputVg
,
sizeof
(
SMqRebOutputVg
));
mInfo
(
"mq rebalance: remove vg
%d from consumer %ld
(first scan)"
,
pVgEp
->
vgId
,
pConsumerEp
->
consumerId
);
mInfo
(
"mq rebalance: remove vg
Id:%d from consumer:%"
PRId64
",
(first scan)"
,
pVgEp
->
vgId
,
pConsumerEp
->
consumerId
);
}
}
imbCnt
++
;
imbCnt
++
;
}
}
...
@@ -312,7 +312,7 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
...
@@ -312,7 +312,7 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
.
pVgEp
=
pVgEp
,
.
pVgEp
=
pVgEp
,
};
};
taosHashPut
(
pHash
,
&
pVgEp
->
vgId
,
sizeof
(
int32_t
),
&
outputVg
,
sizeof
(
SMqRebOutputVg
));
taosHashPut
(
pHash
,
&
pVgEp
->
vgId
,
sizeof
(
int32_t
),
&
outputVg
,
sizeof
(
SMqRebOutputVg
));
mInfo
(
"mq rebalance: remove vg
%d from consumer %ld
(first scan)"
,
pVgEp
->
vgId
,
pConsumerEp
->
consumerId
);
mInfo
(
"mq rebalance: remove vg
Id:%d from consumer:%"
PRId64
",
(first scan)"
,
pVgEp
->
vgId
,
pConsumerEp
->
consumerId
);
}
}
}
}
}
}
...
@@ -329,7 +329,7 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
...
@@ -329,7 +329,7 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
newConsumerEp
.
vgs
=
taosArrayInit
(
0
,
sizeof
(
void
*
));
newConsumerEp
.
vgs
=
taosArrayInit
(
0
,
sizeof
(
void
*
));
taosHashPut
(
pOutput
->
pSub
->
consumerHash
,
&
consumerId
,
sizeof
(
int64_t
),
&
newConsumerEp
,
sizeof
(
SMqConsumerEp
));
taosHashPut
(
pOutput
->
pSub
->
consumerHash
,
&
consumerId
,
sizeof
(
int64_t
),
&
newConsumerEp
,
sizeof
(
SMqConsumerEp
));
taosArrayPush
(
pOutput
->
newConsumers
,
&
consumerId
);
taosArrayPush
(
pOutput
->
newConsumers
,
&
consumerId
);
mInfo
(
"mq rebalance: add new consumer
%ld"
,
consumerId
);
mInfo
(
"mq rebalance: add new consumer
:%"
PRId64
,
consumerId
);
}
}
}
}
...
@@ -354,7 +354,7 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
...
@@ -354,7 +354,7 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
taosArrayPush
(
pConsumerEp
->
vgs
,
&
pRebVg
->
pVgEp
);
taosArrayPush
(
pConsumerEp
->
vgs
,
&
pRebVg
->
pVgEp
);
pRebVg
->
newConsumerId
=
pConsumerEp
->
consumerId
;
pRebVg
->
newConsumerId
=
pConsumerEp
->
consumerId
;
taosArrayPush
(
pOutput
->
rebVgs
,
pRebVg
);
taosArrayPush
(
pOutput
->
rebVgs
,
pRebVg
);
mInfo
(
"mq rebalance: add vg
%d to consumer %ld
(second scan)"
,
pRebVg
->
pVgEp
->
vgId
,
pConsumerEp
->
consumerId
);
mInfo
(
"mq rebalance: add vg
Id:%d to consumer:%"
PRId64
",
(second scan)"
,
pRebVg
->
pVgEp
->
vgId
,
pConsumerEp
->
consumerId
);
}
}
}
}
...
@@ -372,7 +372,7 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
...
@@ -372,7 +372,7 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
taosArrayPush
(
pConsumerEp
->
vgs
,
&
pRebVg
->
pVgEp
);
taosArrayPush
(
pConsumerEp
->
vgs
,
&
pRebVg
->
pVgEp
);
pRebVg
->
newConsumerId
=
pConsumerEp
->
consumerId
;
pRebVg
->
newConsumerId
=
pConsumerEp
->
consumerId
;
taosArrayPush
(
pOutput
->
rebVgs
,
pRebVg
);
taosArrayPush
(
pOutput
->
rebVgs
,
pRebVg
);
mInfo
(
"mq rebalance: add vg
%d to consumer %ld
(second scan)"
,
pRebVg
->
pVgEp
->
vgId
,
pConsumerEp
->
consumerId
);
mInfo
(
"mq rebalance: add vg
Id:%d to consumer:%"
PRId64
",
(second scan)"
,
pRebVg
->
pVgEp
->
vgId
,
pConsumerEp
->
consumerId
);
}
}
}
else
{
}
else
{
// if all consumer is removed, put all vg into unassigned
// if all consumer is removed, put all vg into unassigned
...
@@ -385,7 +385,7 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
...
@@ -385,7 +385,7 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
ASSERT
(
pRebOutput
->
newConsumerId
==
-
1
);
ASSERT
(
pRebOutput
->
newConsumerId
==
-
1
);
taosArrayPush
(
pOutput
->
pSub
->
unassignedVgs
,
&
pRebOutput
->
pVgEp
);
taosArrayPush
(
pOutput
->
pSub
->
unassignedVgs
,
&
pRebOutput
->
pVgEp
);
taosArrayPush
(
pOutput
->
rebVgs
,
pRebOutput
);
taosArrayPush
(
pOutput
->
rebVgs
,
pRebOutput
);
mInfo
(
"mq rebalance: unassign vg
%d (second scan)"
,
pRebOutput
->
pVgEp
->
vgId
);
mInfo
(
"mq rebalance: unassign vg
Id:
%d (second scan)"
,
pRebOutput
->
pVgEp
->
vgId
);
}
}
}
}
...
@@ -393,7 +393,7 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
...
@@ -393,7 +393,7 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
mInfo
(
"rebalance calculation completed, rebalanced vg:"
);
mInfo
(
"rebalance calculation completed, rebalanced vg:"
);
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pOutput
->
rebVgs
);
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pOutput
->
rebVgs
);
i
++
)
{
SMqRebOutputVg
*
pOutputRebVg
=
taosArrayGet
(
pOutput
->
rebVgs
,
i
);
SMqRebOutputVg
*
pOutputRebVg
=
taosArrayGet
(
pOutput
->
rebVgs
,
i
);
mInfo
(
"vgId:%d, moved from consumer
%"
PRId64
" to consumer
%"
PRId64
,
pOutputRebVg
->
pVgEp
->
vgId
,
mInfo
(
"vgId:%d, moved from consumer
:%"
PRId64
", to consumer:
%"
PRId64
,
pOutputRebVg
->
pVgEp
->
vgId
,
pOutputRebVg
->
oldConsumerId
,
pOutputRebVg
->
newConsumerId
);
pOutputRebVg
->
oldConsumerId
,
pOutputRebVg
->
newConsumerId
);
}
}
...
@@ -546,7 +546,11 @@ static int32_t mndProcessRebalanceReq(SRpcMsg *pMsg) {
...
@@ -546,7 +546,11 @@ static int32_t mndProcessRebalanceReq(SRpcMsg *pMsg) {
char
cgroup
[
TSDB_CGROUP_LEN
];
char
cgroup
[
TSDB_CGROUP_LEN
];
mndSplitSubscribeKey
(
pRebInfo
->
key
,
topic
,
cgroup
,
true
);
mndSplitSubscribeKey
(
pRebInfo
->
key
,
topic
,
cgroup
,
true
);
SMqTopicObj
*
pTopic
=
mndAcquireTopic
(
pMnode
,
topic
);
SMqTopicObj
*
pTopic
=
mndAcquireTopic
(
pMnode
,
topic
);
ASSERT
(
pTopic
);
/*ASSERT(pTopic);*/
if
(
pTopic
==
NULL
)
{
mError
(
"rebalance %s failed since topic %s was dropped, abort"
,
pRebInfo
->
key
,
topic
);
continue
;
}
taosRLockLatch
(
&
pTopic
->
lock
);
taosRLockLatch
(
&
pTopic
->
lock
);
rebOutput
.
pSub
=
mndCreateSub
(
pMnode
,
pTopic
,
pRebInfo
->
key
);
rebOutput
.
pSub
=
mndCreateSub
(
pMnode
,
pTopic
,
pRebInfo
->
key
);
...
...
source/dnode/mnode/impl/src/mndTopic.c
浏览文件 @
e77931f1
...
@@ -558,7 +558,7 @@ static int32_t mndProcessDropTopicReq(SRpcMsg *pReq) {
...
@@ -558,7 +558,7 @@ static int32_t mndProcessDropTopicReq(SRpcMsg *pReq) {
mndReleaseConsumer
(
pMnode
,
pConsumer
);
mndReleaseConsumer
(
pMnode
,
pConsumer
);
mndReleaseTopic
(
pMnode
,
pTopic
);
mndReleaseTopic
(
pMnode
,
pTopic
);
terrno
=
TSDB_CODE_MND_TOPIC_SUBSCRIBED
;
terrno
=
TSDB_CODE_MND_TOPIC_SUBSCRIBED
;
mError
(
"topic:%s, failed to drop since subscribed by consumer
%ld
in consumer group %s"
,
dropReq
.
name
,
mError
(
"topic:%s, failed to drop since subscribed by consumer
:%"
PRId64
",
in consumer group %s"
,
dropReq
.
name
,
pConsumer
->
consumerId
,
pConsumer
->
cgroup
);
pConsumer
->
consumerId
,
pConsumer
->
cgroup
);
return
-
1
;
return
-
1
;
}
}
...
...
source/dnode/mnode/impl/test/stb/stb.cpp
浏览文件 @
e77931f1
...
@@ -277,8 +277,6 @@ void* MndTestStb::BuildAlterStbUpdateColumnBytesReq(const char* stbname, const c
...
@@ -277,8 +277,6 @@ void* MndTestStb::BuildAlterStbUpdateColumnBytesReq(const char* stbname, const c
req
.
numOfFields
=
1
;
req
.
numOfFields
=
1
;
req
.
pFields
=
taosArrayInit
(
1
,
sizeof
(
SField
));
req
.
pFields
=
taosArrayInit
(
1
,
sizeof
(
SField
));
req
.
alterType
=
TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES
;
req
.
alterType
=
TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES
;
req
.
tagVer
=
verInBlock
;
req
.
colVer
=
verInBlock
;
SField
field
=
{
0
};
SField
field
=
{
0
};
field
.
bytes
=
bytes
;
field
.
bytes
=
bytes
;
...
@@ -818,7 +816,7 @@ TEST_F(MndTestStb, 08_Alter_Stb_AlterTagBytes) {
...
@@ -818,7 +816,7 @@ TEST_F(MndTestStb, 08_Alter_Stb_AlterTagBytes) {
{
{
void
*
pReq
=
BuildAlterStbUpdateColumnBytesReq
(
stbname
,
"col_not_exist"
,
20
,
&
contLen
,
1
);
void
*
pReq
=
BuildAlterStbUpdateColumnBytesReq
(
stbname
,
"col_not_exist"
,
20
,
&
contLen
,
1
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_COLUMN_NOT_EXIST
);
test
.
SendShowReq
(
TSDB_MGMT_TABLE_STB
,
"user_stables"
,
dbname
);
test
.
SendShowReq
(
TSDB_MGMT_TABLE_STB
,
"user_stables"
,
dbname
);
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
...
...
source/dnode/snode/src/snode.c
浏览文件 @
e77931f1
...
@@ -111,7 +111,7 @@ static int32_t sndProcessTaskDeployReq(SSnode *pNode, SRpcMsg *pMsg) {
...
@@ -111,7 +111,7 @@ static int32_t sndProcessTaskDeployReq(SSnode *pNode, SRpcMsg *pMsg) {
streamSetupTrigger
(
pTask
);
streamSetupTrigger
(
pTask
);
qInfo
(
"deploy stream: stream id %
ld
task id %d child id %d on snode"
,
pTask
->
streamId
,
pTask
->
taskId
,
qInfo
(
"deploy stream: stream id %
"
PRId64
"
task id %d child id %d on snode"
,
pTask
->
streamId
,
pTask
->
taskId
,
pTask
->
selfChildId
);
pTask
->
selfChildId
);
taosHashPut
(
pMeta
->
pHash
,
&
pTask
->
taskId
,
sizeof
(
int32_t
),
&
pTask
,
sizeof
(
void
*
));
taosHashPut
(
pMeta
->
pHash
,
&
pTask
->
taskId
,
sizeof
(
int32_t
),
&
pTask
,
sizeof
(
void
*
));
...
...
source/dnode/vnode/CMakeLists.txt
浏览文件 @
e77931f1
...
@@ -3,6 +3,7 @@ add_library(vnode STATIC "")
...
@@ -3,6 +3,7 @@ add_library(vnode STATIC "")
target_sources
(
target_sources
(
vnode
vnode
PRIVATE
PRIVATE
# vnode
# vnode
"src/vnd/vnodeOpen.c"
"src/vnd/vnodeOpen.c"
"src/vnd/vnodeBufPool.c"
"src/vnd/vnodeBufPool.c"
...
@@ -13,7 +14,6 @@ target_sources(
...
@@ -13,7 +14,6 @@ target_sources(
"src/vnd/vnodeSvr.c"
"src/vnd/vnodeSvr.c"
"src/vnd/vnodeSync.c"
"src/vnd/vnodeSync.c"
"src/vnd/vnodeSnapshot.c"
"src/vnd/vnodeSnapshot.c"
"src/vnd/vnodeUtil.c"
# meta
# meta
"src/meta/metaOpen.c"
"src/meta/metaOpen.c"
...
@@ -26,7 +26,6 @@ target_sources(
...
@@ -26,7 +26,6 @@ target_sources(
"src/meta/metaSnapshot.c"
"src/meta/metaSnapshot.c"
# sma
# sma
"src/sma/sma.c"
"src/sma/smaEnv.c"
"src/sma/smaEnv.c"
"src/sma/smaUtil.c"
"src/sma/smaUtil.c"
"src/sma/smaOpen.c"
"src/sma/smaOpen.c"
...
@@ -47,6 +46,7 @@ target_sources(
...
@@ -47,6 +46,7 @@ target_sources(
"src/tsdb/tsdbUtil.c"
"src/tsdb/tsdbUtil.c"
"src/tsdb/tsdbSnapshot.c"
"src/tsdb/tsdbSnapshot.c"
"src/tsdb/tsdbCacheRead.c"
"src/tsdb/tsdbCacheRead.c"
"src/tsdb/tsdbRetention.c"
# tq
# tq
"src/tq/tq.c"
"src/tq/tq.c"
...
@@ -63,7 +63,6 @@ target_include_directories(
...
@@ -63,7 +63,6 @@ target_include_directories(
PUBLIC
"inc"
PUBLIC
"inc"
PRIVATE
"src/inc"
PRIVATE
"src/inc"
PUBLIC
"
${
TD_SOURCE_DIR
}
/include/libs/scalar"
PUBLIC
"
${
TD_SOURCE_DIR
}
/include/libs/scalar"
)
)
target_link_libraries
(
target_link_libraries
(
vnode
vnode
...
@@ -77,18 +76,19 @@ target_link_libraries(
...
@@ -77,18 +76,19 @@ target_link_libraries(
PUBLIC executor
PUBLIC executor
PUBLIC scheduler
PUBLIC scheduler
PUBLIC tdb
PUBLIC tdb
#PUBLIC bdb
#PUBLIC scalar
# PUBLIC bdb
# PUBLIC scalar
PUBLIC transport
PUBLIC transport
PUBLIC stream
PUBLIC stream
PUBLIC index
PUBLIC index
)
)
target_compile_definitions
(
vnode PUBLIC -DMETA_REFACT
)
target_compile_definitions
(
vnode PUBLIC -DMETA_REFACT
)
if
(
${
BUILD_WITH_INVERTEDINDEX
}
)
add_definitions
(
-DUSE_INVERTED_INDEX
)
if
(
${
BUILD_WITH_INVERTEDINDEX
}
)
add_definitions
(
-DUSE_INVERTED_INDEX
)
endif
(
${
BUILD_WITH_INVERTEDINDEX
}
)
endif
(
${
BUILD_WITH_INVERTEDINDEX
}
)
if
(
${
BUILD_TEST
}
)
if
(
${
BUILD_TEST
}
)
add_subdirectory
(
test
)
add_subdirectory
(
test
)
endif
(
${
BUILD_TEST
}
)
endif
(
${
BUILD_TEST
}
)
source/dnode/vnode/inc/vnode.h
浏览文件 @
e77931f1
...
@@ -38,10 +38,11 @@ extern "C" {
...
@@ -38,10 +38,11 @@ extern "C" {
#endif
#endif
// vnode
// vnode
typedef
struct
SVnode
SVnode
;
typedef
struct
SVnode
SVnode
;
typedef
struct
STsdbCfg
STsdbCfg
;
// todo: remove
typedef
struct
STsdbCfg
STsdbCfg
;
// todo: remove
typedef
struct
SVnodeCfg
SVnodeCfg
;
typedef
struct
SVnodeCfg
SVnodeCfg
;
typedef
struct
SVSnapshotReader
SVSnapshotReader
;
typedef
struct
SVSnapReader
SVSnapReader
;
typedef
struct
SVSnapWriter
SVSnapWriter
;
extern
const
SVnodeCfg
vnodeCfgDefault
;
extern
const
SVnodeCfg
vnodeCfgDefault
;
...
@@ -57,10 +58,6 @@ void vnodeStop(SVnode *pVnode);
...
@@ -57,10 +58,6 @@ void vnodeStop(SVnode *pVnode);
int64_t
vnodeGetSyncHandle
(
SVnode
*
pVnode
);
int64_t
vnodeGetSyncHandle
(
SVnode
*
pVnode
);
void
vnodeGetSnapshot
(
SVnode
*
pVnode
,
SSnapshot
*
pSnapshot
);
void
vnodeGetSnapshot
(
SVnode
*
pVnode
,
SSnapshot
*
pSnapshot
);
void
vnodeGetInfo
(
SVnode
*
pVnode
,
const
char
**
dbname
,
int32_t
*
vgId
);
void
vnodeGetInfo
(
SVnode
*
pVnode
,
const
char
**
dbname
,
int32_t
*
vgId
);
int32_t
vnodeSnapshotReaderOpen
(
SVnode
*
pVnode
,
SVSnapshotReader
**
ppReader
,
int64_t
sver
,
int64_t
ever
);
int32_t
vnodeSnapshotReaderClose
(
SVSnapshotReader
*
pReader
);
int32_t
vnodeSnapshotRead
(
SVSnapshotReader
*
pReader
,
const
void
**
ppData
,
uint32_t
*
nData
);
int32_t
vnodeProcessCreateTSma
(
SVnode
*
pVnode
,
void
*
pCont
,
uint32_t
contLen
);
int32_t
vnodeProcessCreateTSma
(
SVnode
*
pVnode
,
void
*
pCont
,
uint32_t
contLen
);
int32_t
vnodeGetAllTableList
(
SVnode
*
pVnode
,
uint64_t
uid
,
SArray
*
list
);
int32_t
vnodeGetAllTableList
(
SVnode
*
pVnode
,
uint64_t
uid
,
SArray
*
list
);
int32_t
vnodeGetCtbIdList
(
SVnode
*
pVnode
,
int64_t
suid
,
SArray
*
list
);
int32_t
vnodeGetCtbIdList
(
SVnode
*
pVnode
,
int64_t
suid
,
SArray
*
list
);
...
@@ -174,6 +171,9 @@ int32_t tqReaderSetTbUidList(STqReader *pReader, const SArray *tbUidList);
...
@@ -174,6 +171,9 @@ int32_t tqReaderSetTbUidList(STqReader *pReader, const SArray *tbUidList);
int32_t
tqReaderAddTbUidList
(
STqReader
*
pReader
,
const
SArray
*
tbUidList
);
int32_t
tqReaderAddTbUidList
(
STqReader
*
pReader
,
const
SArray
*
tbUidList
);
int32_t
tqReaderRemoveTbUidList
(
STqReader
*
pReader
,
const
SArray
*
tbUidList
);
int32_t
tqReaderRemoveTbUidList
(
STqReader
*
pReader
,
const
SArray
*
tbUidList
);
int32_t
tqSeekVer
(
STqReader
*
pReader
,
int64_t
ver
);
int32_t
tqNextBlock
(
STqReader
*
pReader
,
SFetchRet
*
ret
);
int32_t
tqReaderSetDataMsg
(
STqReader
*
pReader
,
SSubmitReq
*
pMsg
,
int64_t
ver
);
int32_t
tqReaderSetDataMsg
(
STqReader
*
pReader
,
SSubmitReq
*
pMsg
,
int64_t
ver
);
bool
tqNextDataBlock
(
STqReader
*
pReader
);
bool
tqNextDataBlock
(
STqReader
*
pReader
);
bool
tqNextDataBlockFilterOut
(
STqReader
*
pReader
,
SHashObj
*
filterOutUids
);
bool
tqNextDataBlockFilterOut
(
STqReader
*
pReader
,
SHashObj
*
filterOutUids
);
...
@@ -182,7 +182,14 @@ int32_t tqRetrieveDataBlock(SSDataBlock *pBlock, STqReader *pReader);
...
@@ -182,7 +182,14 @@ int32_t tqRetrieveDataBlock(SSDataBlock *pBlock, STqReader *pReader);
// sma
// sma
int32_t
smaGetTSmaDays
(
SVnodeCfg
*
pCfg
,
void
*
pCont
,
uint32_t
contLen
,
int32_t
*
days
);
int32_t
smaGetTSmaDays
(
SVnodeCfg
*
pCfg
,
void
*
pCont
,
uint32_t
contLen
,
int32_t
*
days
);
// need to reposition
// SVSnapReader
int32_t
vnodeSnapReaderOpen
(
SVnode
*
pVnode
,
int64_t
sver
,
int64_t
ever
,
SVSnapReader
**
ppReader
);
int32_t
vnodeSnapReaderClose
(
SVSnapReader
*
pReader
);
int32_t
vnodeSnapRead
(
SVSnapReader
*
pReader
,
uint8_t
**
ppData
,
uint32_t
*
nData
);
// SVSnapWriter
int32_t
vnodeSnapWriterOpen
(
SVnode
*
pVnode
,
int64_t
sver
,
int64_t
ever
,
SVSnapWriter
**
ppWriter
);
int32_t
vnodeSnapWriterClose
(
SVSnapWriter
*
pWriter
,
int8_t
rollback
);
int32_t
vnodeSnapWrite
(
SVSnapWriter
*
pWriter
,
uint8_t
*
pData
,
uint32_t
nData
);
// structs
// structs
struct
STsdbCfg
{
struct
STsdbCfg
{
...
...
source/dnode/vnode/src/inc/meta.h
浏览文件 @
e77931f1
...
@@ -57,6 +57,9 @@ int metaRemoveTableFromIdx(SMeta* pMeta, tb_uid_t uid);
...
@@ -57,6 +57,9 @@ int metaRemoveTableFromIdx(SMeta* pMeta, tb_uid_t uid);
// metaCommit ==================
// metaCommit ==================
static
FORCE_INLINE
tb_uid_t
metaGenerateUid
(
SMeta
*
pMeta
)
{
return
tGenIdPI64
();
}
static
FORCE_INLINE
tb_uid_t
metaGenerateUid
(
SMeta
*
pMeta
)
{
return
tGenIdPI64
();
}
// metaTable ==================
int
metaHandleEntry
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
);
struct
SMeta
{
struct
SMeta
{
TdThreadRwlock
lock
;
TdThreadRwlock
lock
;
...
...
source/dnode/vnode/src/inc/sma.h
浏览文件 @
e77931f1
...
@@ -47,7 +47,9 @@ struct SSmaEnv {
...
@@ -47,7 +47,9 @@ struct SSmaEnv {
};
};
typedef
struct
{
typedef
struct
{
int32_t
smaRef
;
int8_t
inited
;
int32_t
rsetId
;
void
*
tmrHandle
;
// shared by all fetch tasks
}
SSmaMgmt
;
}
SSmaMgmt
;
#define SMA_ENV_LOCK(env) ((env)->lock)
#define SMA_ENV_LOCK(env) ((env)->lock)
...
@@ -64,7 +66,6 @@ struct SRSmaStat {
...
@@ -64,7 +66,6 @@ struct SRSmaStat {
SSma
*
pSma
;
SSma
*
pSma
;
int64_t
submitVer
;
int64_t
submitVer
;
int64_t
refId
;
// shared by fetch tasks
int64_t
refId
;
// shared by fetch tasks
void
*
tmrHandle
;
// shared by fetch tasks
int8_t
triggerStat
;
// shared by fetch tasks
int8_t
triggerStat
;
// shared by fetch tasks
int8_t
runningStat
;
// for persistence task
int8_t
runningStat
;
// for persistence task
SHashObj
*
rsmaInfoHash
;
// key: stbUid, value: SRSmaInfo;
SHashObj
*
rsmaInfoHash
;
// key: stbUid, value: SRSmaInfo;
...
@@ -81,7 +82,6 @@ struct SSmaStat {
...
@@ -81,7 +82,6 @@ struct SSmaStat {
#define SMA_TSMA_STAT(s) (&(s)->tsmaStat)
#define SMA_TSMA_STAT(s) (&(s)->tsmaStat)
#define SMA_RSMA_STAT(s) (&(s)->rsmaStat)
#define SMA_RSMA_STAT(s) (&(s)->rsmaStat)
#define RSMA_INFO_HASH(r) ((r)->rsmaInfoHash)
#define RSMA_INFO_HASH(r) ((r)->rsmaInfoHash)
#define RSMA_TMR_HANDLE(r) ((r)->tmrHandle)
#define RSMA_TRIGGER_STAT(r) (&(r)->triggerStat)
#define RSMA_TRIGGER_STAT(r) (&(r)->triggerStat)
#define RSMA_RUNNING_STAT(r) (&(r)->runningStat)
#define RSMA_RUNNING_STAT(r) (&(r)->runningStat)
#define RSMA_REF_ID(r) ((r)->refId)
#define RSMA_REF_ID(r) ((r)->refId)
...
@@ -95,6 +95,7 @@ enum {
...
@@ -95,6 +95,7 @@ enum {
TASK_TRIGGER_STAT_CANCELLED
=
4
,
TASK_TRIGGER_STAT_CANCELLED
=
4
,
TASK_TRIGGER_STAT_FINISHED
=
5
,
TASK_TRIGGER_STAT_FINISHED
=
5
,
};
};
void
tdDestroySmaEnv
(
SSmaEnv
*
pSmaEnv
);
void
tdDestroySmaEnv
(
SSmaEnv
*
pSmaEnv
);
void
*
tdFreeSmaEnv
(
SSmaEnv
*
pSmaEnv
);
void
*
tdFreeSmaEnv
(
SSmaEnv
*
pSmaEnv
);
...
@@ -104,6 +105,10 @@ int32_t tdInsertRSmaData(SSma *pSma, char *msg);
...
@@ -104,6 +105,10 @@ int32_t tdInsertRSmaData(SSma *pSma, char *msg);
int32_t
tdRefSmaStat
(
SSma
*
pSma
,
SSmaStat
*
pStat
);
int32_t
tdRefSmaStat
(
SSma
*
pSma
,
SSmaStat
*
pStat
);
int32_t
tdUnRefSmaStat
(
SSma
*
pSma
,
SSmaStat
*
pStat
);
int32_t
tdUnRefSmaStat
(
SSma
*
pSma
,
SSmaStat
*
pStat
);
void
*
tdAcquireSmaRef
(
int32_t
rsetId
,
int64_t
refId
,
const
char
*
tags
,
int32_t
ln
);
int32_t
tdReleaseSmaRef
(
int32_t
rsetId
,
int64_t
refId
,
const
char
*
tags
,
int32_t
ln
);
int32_t
tdCheckAndInitSmaEnv
(
SSma
*
pSma
,
int8_t
smaType
);
int32_t
tdCheckAndInitSmaEnv
(
SSma
*
pSma
,
int8_t
smaType
);
int32_t
tdLockSma
(
SSma
*
pSma
);
int32_t
tdLockSma
(
SSma
*
pSma
);
...
@@ -183,7 +188,7 @@ static FORCE_INLINE void tdSmaStatSetDropped(STSmaStat *pTStat) {
...
@@ -183,7 +188,7 @@ static FORCE_INLINE void tdSmaStatSetDropped(STSmaStat *pTStat) {
static
int32_t
tdDestroySmaState
(
SSmaStat
*
pSmaStat
,
int8_t
smaType
);
static
int32_t
tdDestroySmaState
(
SSmaStat
*
pSmaStat
,
int8_t
smaType
);
void
*
tdFreeSmaState
(
SSmaStat
*
pSmaStat
,
int8_t
smaType
);
void
*
tdFreeSmaState
(
SSmaStat
*
pSmaStat
,
int8_t
smaType
);
void
*
tdFreeRSmaInfo
(
SRSmaInfo
*
pInfo
);
void
*
tdFreeRSmaInfo
(
S
Sma
*
pSma
,
S
RSmaInfo
*
pInfo
);
int32_t
tdRSmaPersistExecImpl
(
SRSmaStat
*
pRSmaStat
);
int32_t
tdRSmaPersistExecImpl
(
SRSmaStat
*
pRSmaStat
);
int32_t
tdProcessRSmaCreateImpl
(
SSma
*
pSma
,
SRSmaParam
*
param
,
int64_t
suid
,
const
char
*
tbName
);
int32_t
tdProcessRSmaCreateImpl
(
SSma
*
pSma
,
SRSmaParam
*
param
,
int64_t
suid
,
const
char
*
tbName
);
...
...
source/dnode/vnode/src/inc/tq.h
浏览文件 @
e77931f1
...
@@ -129,6 +129,7 @@ typedef struct {
...
@@ -129,6 +129,7 @@ typedef struct {
static
STqMgmt
tqMgmt
=
{
0
};
static
STqMgmt
tqMgmt
=
{
0
};
// tqRead
// tqRead
int64_t
tqScan
(
STQ
*
pTq
,
const
STqExecHandle
*
pExec
,
SMqDataRsp
*
pRsp
,
STqOffsetVal
*
offset
);
int64_t
tqFetchLog
(
STQ
*
pTq
,
STqHandle
*
pHandle
,
int64_t
*
fetchOffset
,
SWalCkHead
**
pHeadWithCkSum
);
int64_t
tqFetchLog
(
STQ
*
pTq
,
STqHandle
*
pHandle
,
int64_t
*
fetchOffset
,
SWalCkHead
**
pHeadWithCkSum
);
// tqExec
// tqExec
...
...
source/dnode/vnode/src/inc/tsdb.h
浏览文件 @
e77931f1
...
@@ -64,6 +64,7 @@ typedef struct SRowIter SRowIter;
...
@@ -64,6 +64,7 @@ typedef struct SRowIter SRowIter;
typedef
struct
STsdbFS
STsdbFS
;
typedef
struct
STsdbFS
STsdbFS
;
typedef
struct
SRowMerger
SRowMerger
;
typedef
struct
SRowMerger
SRowMerger
;
typedef
struct
STsdbFSState
STsdbFSState
;
typedef
struct
STsdbFSState
STsdbFSState
;
typedef
struct
STsdbSnapHdr
STsdbSnapHdr
;
#define TSDB_MAX_SUBBLOCKS 8
#define TSDB_MAX_SUBBLOCKS 8
#define TSDB_FHDR_SIZE 512
#define TSDB_FHDR_SIZE 512
...
...
source/dnode/vnode/src/inc/vnodeInt.h
浏览文件 @
e77931f1
...
@@ -49,17 +49,20 @@
...
@@ -49,17 +49,20 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
typedef
struct
SVnodeInfo
SVnodeInfo
;
typedef
struct
SVnodeInfo
SVnodeInfo
;
typedef
struct
SMeta
SMeta
;
typedef
struct
SMeta
SMeta
;
typedef
struct
SSma
SSma
;
typedef
struct
SSma
SSma
;
typedef
struct
STsdb
STsdb
;
typedef
struct
STsdb
STsdb
;
typedef
struct
STQ
STQ
;
typedef
struct
STQ
STQ
;
typedef
struct
SVState
SVState
;
typedef
struct
SVState
SVState
;
typedef
struct
SVBufPool
SVBufPool
;
typedef
struct
SVBufPool
SVBufPool
;
typedef
struct
SQWorker
SQHandle
;
typedef
struct
SQWorker
SQHandle
;
typedef
struct
STsdbKeepCfg
STsdbKeepCfg
;
typedef
struct
STsdbKeepCfg
STsdbKeepCfg
;
typedef
struct
SMetaSnapshotReader
SMetaSnapshotReader
;
typedef
struct
SMetaSnapReader
SMetaSnapReader
;
typedef
struct
STsdbSnapshotReader
STsdbSnapshotReader
;
typedef
struct
SMetaSnapWriter
SMetaSnapWriter
;
typedef
struct
STsdbSnapReader
STsdbSnapReader
;
typedef
struct
STsdbSnapWriter
STsdbSnapWriter
;
typedef
struct
SSnapDataHdr
SSnapDataHdr
;
#define VNODE_META_DIR "meta"
#define VNODE_META_DIR "meta"
#define VNODE_TSDB_DIR "tsdb"
#define VNODE_TSDB_DIR "tsdb"
...
@@ -72,10 +75,8 @@ typedef struct STsdbSnapshotReader STsdbSnapshotReader;
...
@@ -72,10 +75,8 @@ typedef struct STsdbSnapshotReader STsdbSnapshotReader;
#define VNODE_RSMA2_DIR "rsma2"
#define VNODE_RSMA2_DIR "rsma2"
// vnd.h
// vnd.h
void
*
vnodeBufPoolMalloc
(
SVBufPool
*
pPool
,
int
size
);
void
*
vnodeBufPoolMalloc
(
SVBufPool
*
pPool
,
int
size
);
void
vnodeBufPoolFree
(
SVBufPool
*
pPool
,
void
*
p
);
void
vnodeBufPoolFree
(
SVBufPool
*
pPool
,
void
*
p
);
int32_t
vnodeRealloc
(
void
**
pp
,
int32_t
size
);
void
vnodeFree
(
void
*
p
);
// meta
// meta
typedef
struct
SMCtbCursor
SMCtbCursor
;
typedef
struct
SMCtbCursor
SMCtbCursor
;
...
@@ -109,9 +110,6 @@ STSma* metaGetSmaInfoByIndex(SMeta* pMeta, int64_t indexUid);
...
@@ -109,9 +110,6 @@ STSma* metaGetSmaInfoByIndex(SMeta* pMeta, int64_t indexUid);
STSmaWrapper
*
metaGetSmaInfoByTable
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
bool
deepCopy
);
STSmaWrapper
*
metaGetSmaInfoByTable
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
bool
deepCopy
);
SArray
*
metaGetSmaIdsByTable
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
SArray
*
metaGetSmaIdsByTable
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
SArray
*
metaGetSmaTbUids
(
SMeta
*
pMeta
);
SArray
*
metaGetSmaTbUids
(
SMeta
*
pMeta
);
int32_t
metaSnapshotReaderOpen
(
SMeta
*
pMeta
,
SMetaSnapshotReader
**
ppReader
,
int64_t
sver
,
int64_t
ever
);
int32_t
metaSnapshotReaderClose
(
SMetaSnapshotReader
*
pReader
);
int32_t
metaSnapshotRead
(
SMetaSnapshotReader
*
pReader
,
void
**
ppData
,
uint32_t
*
nData
);
void
*
metaGetIdx
(
SMeta
*
pMeta
);
void
*
metaGetIdx
(
SMeta
*
pMeta
);
void
*
metaGetIvtIdx
(
SMeta
*
pMeta
);
void
*
metaGetIvtIdx
(
SMeta
*
pMeta
);
int
metaTtlSmaller
(
SMeta
*
pMeta
,
uint64_t
time
,
SArray
*
uidList
);
int
metaTtlSmaller
(
SMeta
*
pMeta
,
uint64_t
time
,
SArray
*
uidList
);
...
@@ -131,9 +129,6 @@ int32_t tsdbInsertTableData(STsdb* pTsdb, int64_t version, SSubmitMsgIter* p
...
@@ -131,9 +129,6 @@ int32_t tsdbInsertTableData(STsdb* pTsdb, int64_t version, SSubmitMsgIter* p
int32_t
tsdbDeleteTableData
(
STsdb
*
pTsdb
,
int64_t
version
,
tb_uid_t
suid
,
tb_uid_t
uid
,
TSKEY
sKey
,
TSKEY
eKey
);
int32_t
tsdbDeleteTableData
(
STsdb
*
pTsdb
,
int64_t
version
,
tb_uid_t
suid
,
tb_uid_t
uid
,
TSKEY
sKey
,
TSKEY
eKey
);
STsdbReader
tsdbQueryCacheLastT
(
STsdb
*
tsdb
,
SQueryTableDataCond
*
pCond
,
STableListInfo
*
tableList
,
uint64_t
qId
,
STsdbReader
tsdbQueryCacheLastT
(
STsdb
*
tsdb
,
SQueryTableDataCond
*
pCond
,
STableListInfo
*
tableList
,
uint64_t
qId
,
void
*
pMemRef
);
void
*
pMemRef
);
int32_t
tsdbSnapshotReaderOpen
(
STsdb
*
pTsdb
,
STsdbSnapshotReader
**
ppReader
,
int64_t
sver
,
int64_t
ever
);
int32_t
tsdbSnapshotReaderClose
(
STsdbSnapshotReader
*
pReader
);
int32_t
tsdbSnapshotRead
(
STsdbSnapshotReader
*
pReader
,
void
**
ppData
,
uint32_t
*
nData
);
// tq
// tq
int
tqInit
();
int
tqInit
();
...
@@ -163,6 +158,8 @@ SSubmitReq* tdBlockToSubmit(const SArray* pBlocks, const STSchema* pSchema, bool
...
@@ -163,6 +158,8 @@ SSubmitReq* tdBlockToSubmit(const SArray* pBlocks, const STSchema* pSchema, bool
const
char
*
stbFullName
,
int32_t
vgId
);
const
char
*
stbFullName
,
int32_t
vgId
);
// sma
// sma
int32_t
smaInit
();
void
smaCleanUp
();
int32_t
smaOpen
(
SVnode
*
pVnode
);
int32_t
smaOpen
(
SVnode
*
pVnode
);
int32_t
smaClose
(
SSma
*
pSma
);
int32_t
smaClose
(
SSma
*
pSma
);
int32_t
smaBegin
(
SSma
*
pSma
);
int32_t
smaBegin
(
SSma
*
pSma
);
...
@@ -181,6 +178,23 @@ int32_t tdUpdateTbUidList(SSma* pSma, STbUidStore* pUidStore);
...
@@ -181,6 +178,23 @@ int32_t tdUpdateTbUidList(SSma* pSma, STbUidStore* pUidStore);
void
tdUidStoreDestory
(
STbUidStore
*
pStore
);
void
tdUidStoreDestory
(
STbUidStore
*
pStore
);
void
*
tdUidStoreFree
(
STbUidStore
*
pStore
);
void
*
tdUidStoreFree
(
STbUidStore
*
pStore
);
// SMetaSnapReader ========================================
int32_t
metaSnapReaderOpen
(
SMeta
*
pMeta
,
int64_t
sver
,
int64_t
ever
,
SMetaSnapReader
**
ppReader
);
int32_t
metaSnapReaderClose
(
SMetaSnapReader
**
ppReader
);
int32_t
metaSnapRead
(
SMetaSnapReader
*
pReader
,
uint8_t
**
ppData
);
// SMetaSnapWriter ========================================
int32_t
metaSnapWriterOpen
(
SMeta
*
pMeta
,
int64_t
sver
,
int64_t
ever
,
SMetaSnapWriter
**
ppWriter
);
int32_t
metaSnapWrite
(
SMetaSnapWriter
*
pWriter
,
uint8_t
*
pData
,
uint32_t
nData
);
int32_t
metaSnapWriterClose
(
SMetaSnapWriter
**
ppWriter
,
int8_t
rollback
);
// STsdbSnapReader ========================================
int32_t
tsdbSnapReaderOpen
(
STsdb
*
pTsdb
,
int64_t
sver
,
int64_t
ever
,
STsdbSnapReader
**
ppReader
);
int32_t
tsdbSnapReaderClose
(
STsdbSnapReader
**
ppReader
);
int32_t
tsdbSnapRead
(
STsdbSnapReader
*
pReader
,
uint8_t
**
ppData
);
// STsdbSnapWriter ========================================
int32_t
tsdbSnapWriterOpen
(
STsdb
*
pTsdb
,
int64_t
sver
,
int64_t
ever
,
STsdbSnapWriter
**
ppWriter
);
int32_t
tsdbSnapWrite
(
STsdbSnapWriter
*
pWriter
,
uint8_t
*
pData
,
uint32_t
nData
);
int32_t
tsdbSnapWriterClose
(
STsdbSnapWriter
**
ppWriter
,
int8_t
rollback
);
typedef
struct
{
typedef
struct
{
int8_t
streamType
;
// sma or other
int8_t
streamType
;
// sma or other
int8_t
dstType
;
int8_t
dstType
;
...
@@ -200,7 +214,9 @@ typedef struct {
...
@@ -200,7 +214,9 @@ typedef struct {
struct
SVState
{
struct
SVState
{
int64_t
committed
;
int64_t
committed
;
int64_t
applied
;
int64_t
applied
;
int64_t
applyTerm
;
int64_t
commitID
;
int64_t
commitID
;
int64_t
commitTerm
;
};
};
struct
SVnodeInfo
{
struct
SVnodeInfo
{
...
@@ -289,6 +305,12 @@ struct SSma {
...
@@ -289,6 +305,12 @@ struct SSma {
// sma
// sma
void
smaHandleRes
(
void
*
pVnode
,
int64_t
smaId
,
const
SArray
*
data
);
void
smaHandleRes
(
void
*
pVnode
,
int64_t
smaId
,
const
SArray
*
data
);
struct
SSnapDataHdr
{
int8_t
type
;
int64_t
size
;
uint8_t
data
[];
};
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
source/dnode/vnode/src/meta/metaSnapshot.c
浏览文件 @
e77931f1
...
@@ -15,53 +15,57 @@
...
@@ -15,53 +15,57 @@
#include "meta.h"
#include "meta.h"
struct
SMetaSnapshotReader
{
// SMetaSnapReader ========================================
struct
SMetaSnapReader
{
SMeta
*
pMeta
;
SMeta
*
pMeta
;
TBC
*
pTbc
;
int64_t
sver
;
int64_t
sver
;
int64_t
ever
;
int64_t
ever
;
TBC
*
pTbc
;
};
};
int32_t
metaSnap
shotReaderOpen
(
SMeta
*
pMeta
,
SMetaSnapshotReader
**
ppReader
,
int64_t
sver
,
int64_t
ev
er
)
{
int32_t
metaSnap
ReaderOpen
(
SMeta
*
pMeta
,
int64_t
sver
,
int64_t
ever
,
SMetaSnapReader
**
ppRead
er
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
int32_t
c
=
0
;
int32_t
c
=
0
;
SMetaSnap
shotReader
*
pMeta
Reader
=
NULL
;
SMetaSnap
Reader
*
pMetaSnap
Reader
=
NULL
;
pMetaReader
=
(
SMetaSnapshotReader
*
)
taosMemoryCalloc
(
1
,
sizeof
(
*
pMetaReader
));
// alloc
if
(
pMetaReader
==
NULL
)
{
pMetaSnapReader
=
(
SMetaSnapReader
*
)
taosMemoryCalloc
(
1
,
sizeof
(
*
pMetaSnapReader
));
if
(
pMetaSnapReader
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_err
;
goto
_err
;
}
}
pMetaReader
->
pMeta
=
pMeta
;
pMetaSnapReader
->
pMeta
=
pMeta
;
pMetaReader
->
sver
=
sver
;
pMetaSnapReader
->
sver
=
sver
;
pMetaReader
->
ever
=
ever
;
pMetaSnapReader
->
ever
=
ever
;
code
=
tdbTbcOpen
(
pMeta
->
pTbDb
,
&
pMetaReader
->
pTbc
,
NULL
);
// impl
code
=
tdbTbcOpen
(
pMeta
->
pTbDb
,
&
pMetaSnapReader
->
pTbc
,
NULL
);
if
(
code
)
{
if
(
code
)
{
goto
_err
;
goto
_err
;
}
}
code
=
tdbTbcMoveTo
(
pMetaReader
->
pTbc
,
&
(
STbDbKey
){.
version
=
sver
,
.
uid
=
INT64_MIN
},
sizeof
(
STbDbKey
),
&
c
);
code
=
tdbTbcMoveTo
(
pMeta
Snap
Reader
->
pTbc
,
&
(
STbDbKey
){.
version
=
sver
,
.
uid
=
INT64_MIN
},
sizeof
(
STbDbKey
),
&
c
);
if
(
code
)
{
if
(
code
)
{
goto
_err
;
goto
_err
;
}
}
*
ppReader
=
pMetaReader
;
*
ppReader
=
pMeta
Snap
Reader
;
return
code
;
return
code
;
_err:
_err:
metaError
(
"vgId:%d meta snap reader open failed since %s"
,
TD_VID
(
pMeta
->
pVnode
),
tstrerror
(
code
));
*
ppReader
=
NULL
;
*
ppReader
=
NULL
;
return
code
;
return
code
;
}
}
int32_t
metaSnapshotReaderClose
(
SMetaSnapshotReader
*
pReader
)
{
int32_t
metaSnapReaderClose
(
SMetaSnapReader
**
ppReader
)
{
if
(
pReader
)
{
tdbTbcClose
((
*
ppReader
)
->
pTbc
);
tdbTbcClose
(
pReader
->
pTbc
);
taosMemoryFree
(
*
ppReader
);
taosMemoryFree
(
pReader
);
*
ppReader
=
NULL
;
}
return
0
;
return
0
;
}
}
int32_t
metaSnap
shotRead
(
SMetaSnapshotReader
*
pReader
,
void
**
ppData
,
uint32_t
*
nDatap
)
{
int32_t
metaSnap
Read
(
SMetaSnapReader
*
pReader
,
uint8_t
**
ppData
)
{
const
void
*
pKey
=
NULL
;
const
void
*
pKey
=
NULL
;
const
void
*
pData
=
NULL
;
const
void
*
pData
=
NULL
;
int32_t
nKey
=
0
;
int32_t
nKey
=
0
;
...
@@ -71,23 +75,110 @@ int32_t metaSnapshotRead(SMetaSnapshotReader* pReader, void** ppData, uint32_t*
...
@@ -71,23 +75,110 @@ int32_t metaSnapshotRead(SMetaSnapshotReader* pReader, void** ppData, uint32_t*
for
(;;)
{
for
(;;)
{
code
=
tdbTbcGet
(
pReader
->
pTbc
,
&
pKey
,
&
nKey
,
&
pData
,
&
nData
);
code
=
tdbTbcGet
(
pReader
->
pTbc
,
&
pKey
,
&
nKey
,
&
pData
,
&
nData
);
if
(
code
||
((
STbDbKey
*
)
pData
)
->
version
>
pReader
->
ever
)
{
if
(
code
||
((
STbDbKey
*
)
pData
)
->
version
>
pReader
->
ever
)
{
return
TSDB_CODE_VND_READ_END
;
code
=
TSDB_CODE_VND_READ_END
;
goto
_exit
;
}
}
if
(((
STbDbKey
*
)
pData
)
->
version
<
pReader
->
sver
)
{
if
(((
STbDbKey
*
)
pData
)
->
version
<
pReader
->
sver
)
{
tdbTbcMoveToNext
(
pReader
->
pTbc
);
continue
;
continue
;
}
}
tdbTbcMoveToNext
(
pReader
->
pTbc
);
break
;
break
;
}
}
// copy the data
// copy the data
if
(
vnodeRealloc
(
ppData
,
nData
)
<
0
)
{
if
(
tRealloc
(
ppData
,
sizeof
(
SSnapDataHdr
)
+
nData
)
<
0
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
code
=
TSDB_CODE_OUT_OF_MEMORY
;
return
code
;
return
code
;
}
}
((
SSnapDataHdr
*
)(
*
ppData
))
->
type
=
0
;
// TODO: use macro
((
SSnapDataHdr
*
)(
*
ppData
))
->
size
=
nData
;
memcpy
(((
SSnapDataHdr
*
)(
*
ppData
))
->
data
,
pData
,
nData
);
_exit:
return
code
;
}
memcpy
(
*
ppData
,
pData
,
nData
);
// SMetaSnapWriter ========================================
*
nDatap
=
nData
;
struct
SMetaSnapWriter
{
SMeta
*
pMeta
;
int64_t
sver
;
int64_t
ever
;
};
static
int32_t
metaSnapRollback
(
SMetaSnapWriter
*
pWriter
)
{
int32_t
code
=
0
;
// TODO
return
code
;
}
static
int32_t
metaSnapCommit
(
SMetaSnapWriter
*
pWriter
)
{
int32_t
code
=
0
;
// TODO
return
code
;
}
int32_t
metaSnapWriterOpen
(
SMeta
*
pMeta
,
int64_t
sver
,
int64_t
ever
,
SMetaSnapWriter
**
ppWriter
)
{
int32_t
code
=
0
;
SMetaSnapWriter
*
pWriter
;
// alloc
pWriter
=
(
SMetaSnapWriter
*
)
taosMemoryCalloc
(
1
,
sizeof
(
*
pWriter
));
if
(
pWriter
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_err
;
}
pWriter
->
pMeta
=
pMeta
;
pWriter
->
sver
=
sver
;
pWriter
->
ever
=
ever
;
*
ppWriter
=
pWriter
;
return
code
;
_err:
metaError
(
"vgId:%d meta snapshot writer open failed since %s"
,
TD_VID
(
pMeta
->
pVnode
),
tstrerror
(
code
));
*
ppWriter
=
NULL
;
return
code
;
}
int32_t
metaSnapWriterClose
(
SMetaSnapWriter
**
ppWriter
,
int8_t
rollback
)
{
int32_t
code
=
0
;
SMetaSnapWriter
*
pWriter
=
*
ppWriter
;
if
(
rollback
)
{
code
=
metaSnapRollback
(
pWriter
);
if
(
code
)
goto
_err
;
}
else
{
code
=
metaSnapCommit
(
pWriter
);
if
(
code
)
goto
_err
;
}
taosMemoryFree
(
pWriter
);
*
ppWriter
=
NULL
;
return
code
;
_err:
metaError
(
"vgId:%d meta snapshot writer close failed since %s"
,
TD_VID
(
pWriter
->
pMeta
->
pVnode
),
tstrerror
(
code
));
return
code
;
}
int32_t
metaSnapWrite
(
SMetaSnapWriter
*
pWriter
,
uint8_t
*
pData
,
uint32_t
nData
)
{
int32_t
code
=
0
;
SMeta
*
pMeta
=
pWriter
->
pMeta
;
SMetaEntry
metaEntry
=
{
0
};
SDecoder
*
pDecoder
=
&
(
SDecoder
){
0
};
tDecoderInit
(
pDecoder
,
pData
,
nData
);
metaDecodeEntry
(
pDecoder
,
&
metaEntry
);
code
=
metaHandleEntry
(
pMeta
,
&
metaEntry
);
if
(
code
)
goto
_err
;
return
code
;
_err:
metaError
(
"vgId:%d meta snapshot write failed since %s"
,
TD_VID
(
pMeta
->
pVnode
),
tstrerror
(
code
));
return
code
;
return
code
;
}
}
\ No newline at end of file
source/dnode/vnode/src/meta/metaTable.c
浏览文件 @
e77931f1
...
@@ -17,7 +17,6 @@
...
@@ -17,7 +17,6 @@
static
int
metaSaveJsonVarToIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pCtbEntry
,
const
SSchema
*
pSchema
);
static
int
metaSaveJsonVarToIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pCtbEntry
,
const
SSchema
*
pSchema
);
static
int
metaDelJsonVarFromIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pCtbEntry
,
const
SSchema
*
pSchema
);
static
int
metaDelJsonVarFromIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pCtbEntry
,
const
SSchema
*
pSchema
);
static
int
metaHandleEntry
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
);
static
int
metaSaveToTbDb
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
);
static
int
metaSaveToTbDb
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
);
static
int
metaUpdateUidIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
);
static
int
metaUpdateUidIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
);
static
int
metaUpdateNameIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
);
static
int
metaUpdateNameIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
);
...
@@ -51,7 +50,7 @@ static int metaSaveJsonVarToIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const
...
@@ -51,7 +50,7 @@ static int metaSaveJsonVarToIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const
if
(
pMeta
->
pTagIvtIdx
==
NULL
||
pCtbEntry
==
NULL
)
{
if
(
pMeta
->
pTagIvtIdx
==
NULL
||
pCtbEntry
==
NULL
)
{
return
-
1
;
return
-
1
;
}
}
void
*
data
=
pCtbEntry
->
ctbEntry
.
pTags
;
void
*
data
=
pCtbEntry
->
ctbEntry
.
pTags
;
const
char
*
tagName
=
pSchema
->
name
;
const
char
*
tagName
=
pSchema
->
name
;
tb_uid_t
suid
=
pCtbEntry
->
ctbEntry
.
suid
;
tb_uid_t
suid
=
pCtbEntry
->
ctbEntry
.
suid
;
...
@@ -70,7 +69,7 @@ static int metaSaveJsonVarToIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const
...
@@ -70,7 +69,7 @@ static int metaSaveJsonVarToIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const
STagVal
*
pTagVal
=
(
STagVal
*
)
taosArrayGet
(
pTagVals
,
i
);
STagVal
*
pTagVal
=
(
STagVal
*
)
taosArrayGet
(
pTagVals
,
i
);
char
type
=
pTagVal
->
type
;
char
type
=
pTagVal
->
type
;
char
*
key
=
pTagVal
->
pKey
;
char
*
key
=
pTagVal
->
pKey
;
int32_t
nKey
=
strlen
(
key
);
int32_t
nKey
=
strlen
(
key
);
SIndexTerm
*
term
=
NULL
;
SIndexTerm
*
term
=
NULL
;
...
@@ -78,7 +77,7 @@ static int metaSaveJsonVarToIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const
...
@@ -78,7 +77,7 @@ static int metaSaveJsonVarToIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const
term
=
indexTermCreate
(
suid
,
ADD_VALUE
,
TSDB_DATA_TYPE_VARCHAR
,
key
,
nKey
,
NULL
,
0
);
term
=
indexTermCreate
(
suid
,
ADD_VALUE
,
TSDB_DATA_TYPE_VARCHAR
,
key
,
nKey
,
NULL
,
0
);
}
else
if
(
type
==
TSDB_DATA_TYPE_NCHAR
)
{
}
else
if
(
type
==
TSDB_DATA_TYPE_NCHAR
)
{
if
(
pTagVal
->
nData
>
0
)
{
if
(
pTagVal
->
nData
>
0
)
{
char
*
val
=
taosMemoryCalloc
(
1
,
pTagVal
->
nData
+
VARSTR_HEADER_SIZE
);
char
*
val
=
taosMemoryCalloc
(
1
,
pTagVal
->
nData
+
VARSTR_HEADER_SIZE
);
int32_t
len
=
taosUcs4ToMbs
((
TdUcs4
*
)
pTagVal
->
pData
,
pTagVal
->
nData
,
val
+
VARSTR_HEADER_SIZE
);
int32_t
len
=
taosUcs4ToMbs
((
TdUcs4
*
)
pTagVal
->
pData
,
pTagVal
->
nData
,
val
+
VARSTR_HEADER_SIZE
);
memcpy
(
val
,
(
uint16_t
*
)
&
len
,
VARSTR_HEADER_SIZE
);
memcpy
(
val
,
(
uint16_t
*
)
&
len
,
VARSTR_HEADER_SIZE
);
type
=
TSDB_DATA_TYPE_VARCHAR
;
type
=
TSDB_DATA_TYPE_VARCHAR
;
...
@@ -109,7 +108,7 @@ int metaDelJsonVarFromIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const SSche
...
@@ -109,7 +108,7 @@ int metaDelJsonVarFromIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const SSche
if
(
pMeta
->
pTagIvtIdx
==
NULL
||
pCtbEntry
==
NULL
)
{
if
(
pMeta
->
pTagIvtIdx
==
NULL
||
pCtbEntry
==
NULL
)
{
return
-
1
;
return
-
1
;
}
}
void
*
data
=
pCtbEntry
->
ctbEntry
.
pTags
;
void
*
data
=
pCtbEntry
->
ctbEntry
.
pTags
;
const
char
*
tagName
=
pSchema
->
name
;
const
char
*
tagName
=
pSchema
->
name
;
tb_uid_t
suid
=
pCtbEntry
->
ctbEntry
.
suid
;
tb_uid_t
suid
=
pCtbEntry
->
ctbEntry
.
suid
;
...
@@ -128,7 +127,7 @@ int metaDelJsonVarFromIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const SSche
...
@@ -128,7 +127,7 @@ int metaDelJsonVarFromIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const SSche
STagVal
*
pTagVal
=
(
STagVal
*
)
taosArrayGet
(
pTagVals
,
i
);
STagVal
*
pTagVal
=
(
STagVal
*
)
taosArrayGet
(
pTagVals
,
i
);
char
type
=
pTagVal
->
type
;
char
type
=
pTagVal
->
type
;
char
*
key
=
pTagVal
->
pKey
;
char
*
key
=
pTagVal
->
pKey
;
int32_t
nKey
=
strlen
(
key
);
int32_t
nKey
=
strlen
(
key
);
SIndexTerm
*
term
=
NULL
;
SIndexTerm
*
term
=
NULL
;
...
@@ -136,7 +135,7 @@ int metaDelJsonVarFromIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const SSche
...
@@ -136,7 +135,7 @@ int metaDelJsonVarFromIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const SSche
term
=
indexTermCreate
(
suid
,
DEL_VALUE
,
TSDB_DATA_TYPE_VARCHAR
,
key
,
nKey
,
NULL
,
0
);
term
=
indexTermCreate
(
suid
,
DEL_VALUE
,
TSDB_DATA_TYPE_VARCHAR
,
key
,
nKey
,
NULL
,
0
);
}
else
if
(
type
==
TSDB_DATA_TYPE_NCHAR
)
{
}
else
if
(
type
==
TSDB_DATA_TYPE_NCHAR
)
{
if
(
pTagVal
->
nData
>
0
)
{
if
(
pTagVal
->
nData
>
0
)
{
char
*
val
=
taosMemoryCalloc
(
1
,
pTagVal
->
nData
+
VARSTR_HEADER_SIZE
);
char
*
val
=
taosMemoryCalloc
(
1
,
pTagVal
->
nData
+
VARSTR_HEADER_SIZE
);
int32_t
len
=
taosUcs4ToMbs
((
TdUcs4
*
)
pTagVal
->
pData
,
pTagVal
->
nData
,
val
+
VARSTR_HEADER_SIZE
);
int32_t
len
=
taosUcs4ToMbs
((
TdUcs4
*
)
pTagVal
->
pData
,
pTagVal
->
nData
,
val
+
VARSTR_HEADER_SIZE
);
memcpy
(
val
,
(
uint16_t
*
)
&
len
,
VARSTR_HEADER_SIZE
);
memcpy
(
val
,
(
uint16_t
*
)
&
len
,
VARSTR_HEADER_SIZE
);
type
=
TSDB_DATA_TYPE_VARCHAR
;
type
=
TSDB_DATA_TYPE_VARCHAR
;
...
@@ -169,9 +168,9 @@ int metaCreateSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
...
@@ -169,9 +168,9 @@ int metaCreateSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
int
vLen
=
0
;
int
vLen
=
0
;
const
void
*
pKey
=
NULL
;
const
void
*
pKey
=
NULL
;
const
void
*
pVal
=
NULL
;
const
void
*
pVal
=
NULL
;
void
*
pBuf
=
NULL
;
void
*
pBuf
=
NULL
;
int32_t
szBuf
=
0
;
int32_t
szBuf
=
0
;
void
*
p
=
NULL
;
void
*
p
=
NULL
;
SMetaReader
mr
=
{
0
};
SMetaReader
mr
=
{
0
};
// validate req
// validate req
...
@@ -229,7 +228,7 @@ int metaDropSTable(SMeta *pMeta, int64_t verison, SVDropStbReq *pReq) {
...
@@ -229,7 +228,7 @@ int metaDropSTable(SMeta *pMeta, int64_t verison, SVDropStbReq *pReq) {
}
}
// drop all child tables
// drop all child tables
TBC
*
pCtbIdxc
=
NULL
;
TBC
*
pCtbIdxc
=
NULL
;
SArray
*
pArray
=
taosArrayInit
(
8
,
sizeof
(
tb_uid_t
));
SArray
*
pArray
=
taosArrayInit
(
8
,
sizeof
(
tb_uid_t
));
tdbTbcOpen
(
pMeta
->
pCtbIdx
,
&
pCtbIdxc
,
&
pMeta
->
txn
);
tdbTbcOpen
(
pMeta
->
pCtbIdx
,
&
pCtbIdxc
,
&
pMeta
->
txn
);
...
@@ -285,8 +284,8 @@ _exit:
...
@@ -285,8 +284,8 @@ _exit:
int
metaAlterSTable
(
SMeta
*
pMeta
,
int64_t
version
,
SVCreateStbReq
*
pReq
)
{
int
metaAlterSTable
(
SMeta
*
pMeta
,
int64_t
version
,
SVCreateStbReq
*
pReq
)
{
SMetaEntry
oStbEntry
=
{
0
};
SMetaEntry
oStbEntry
=
{
0
};
SMetaEntry
nStbEntry
=
{
0
};
SMetaEntry
nStbEntry
=
{
0
};
TBC
*
pUidIdxc
=
NULL
;
TBC
*
pUidIdxc
=
NULL
;
TBC
*
pTbDbc
=
NULL
;
TBC
*
pTbDbc
=
NULL
;
const
void
*
pData
;
const
void
*
pData
;
int
nData
;
int
nData
;
int64_t
oversion
;
int64_t
oversion
;
...
@@ -409,7 +408,7 @@ _err:
...
@@ -409,7 +408,7 @@ _err:
}
}
int
metaDropTable
(
SMeta
*
pMeta
,
int64_t
version
,
SVDropTbReq
*
pReq
,
SArray
*
tbUids
)
{
int
metaDropTable
(
SMeta
*
pMeta
,
int64_t
version
,
SVDropTbReq
*
pReq
,
SArray
*
tbUids
)
{
void
*
pData
=
NULL
;
void
*
pData
=
NULL
;
int
nData
=
0
;
int
nData
=
0
;
int
rc
=
0
;
int
rc
=
0
;
tb_uid_t
uid
;
tb_uid_t
uid
;
...
@@ -477,7 +476,7 @@ static int metaDeleteTtlIdx(SMeta *pMeta, const SMetaEntry *pME) {
...
@@ -477,7 +476,7 @@ static int metaDeleteTtlIdx(SMeta *pMeta, const SMetaEntry *pME) {
}
}
static
int
metaDropTableByUid
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int
*
type
)
{
static
int
metaDropTableByUid
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int
*
type
)
{
void
*
pData
=
NULL
;
void
*
pData
=
NULL
;
int
nData
=
0
;
int
nData
=
0
;
int
rc
=
0
;
int
rc
=
0
;
SMetaEntry
e
=
{
0
};
SMetaEntry
e
=
{
0
};
...
@@ -538,14 +537,14 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type) {
...
@@ -538,14 +537,14 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type) {
}
}
static
int
metaAlterTableColumn
(
SMeta
*
pMeta
,
int64_t
version
,
SVAlterTbReq
*
pAlterTbReq
,
STableMetaRsp
*
pMetaRsp
)
{
static
int
metaAlterTableColumn
(
SMeta
*
pMeta
,
int64_t
version
,
SVAlterTbReq
*
pAlterTbReq
,
STableMetaRsp
*
pMetaRsp
)
{
void
*
pVal
=
NULL
;
void
*
pVal
=
NULL
;
int
nVal
=
0
;
int
nVal
=
0
;
const
void
*
pData
=
NULL
;
const
void
*
pData
=
NULL
;
int
nData
=
0
;
int
nData
=
0
;
int
ret
=
0
;
int
ret
=
0
;
tb_uid_t
uid
;
tb_uid_t
uid
;
int64_t
oversion
;
int64_t
oversion
;
SSchema
*
pColumn
=
NULL
;
SSchema
*
pColumn
=
NULL
;
SMetaEntry
entry
=
{
0
};
SMetaEntry
entry
=
{
0
};
SSchemaWrapper
*
pSchema
;
SSchemaWrapper
*
pSchema
;
int
c
;
int
c
;
...
@@ -699,7 +698,7 @@ _err:
...
@@ -699,7 +698,7 @@ _err:
static
int
metaUpdateTableTagVal
(
SMeta
*
pMeta
,
int64_t
version
,
SVAlterTbReq
*
pAlterTbReq
)
{
static
int
metaUpdateTableTagVal
(
SMeta
*
pMeta
,
int64_t
version
,
SVAlterTbReq
*
pAlterTbReq
)
{
SMetaEntry
ctbEntry
=
{
0
};
SMetaEntry
ctbEntry
=
{
0
};
SMetaEntry
stbEntry
=
{
0
};
SMetaEntry
stbEntry
=
{
0
};
void
*
pVal
=
NULL
;
void
*
pVal
=
NULL
;
int
nVal
=
0
;
int
nVal
=
0
;
int
ret
;
int
ret
;
int
c
;
int
c
;
...
@@ -730,7 +729,7 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
...
@@ -730,7 +729,7 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
oversion
=
*
(
int64_t
*
)
pData
;
oversion
=
*
(
int64_t
*
)
pData
;
// search table.db
// search table.db
TBC
*
pTbDbc
=
NULL
;
TBC
*
pTbDbc
=
NULL
;
SDecoder
dc1
=
{
0
};
SDecoder
dc1
=
{
0
};
SDecoder
dc2
=
{
0
};
SDecoder
dc2
=
{
0
};
...
@@ -754,7 +753,7 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
...
@@ -754,7 +753,7 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
metaDecodeEntry
(
&
dc2
,
&
stbEntry
);
metaDecodeEntry
(
&
dc2
,
&
stbEntry
);
SSchemaWrapper
*
pTagSchema
=
&
stbEntry
.
stbEntry
.
schemaTag
;
SSchemaWrapper
*
pTagSchema
=
&
stbEntry
.
stbEntry
.
schemaTag
;
SSchema
*
pColumn
=
NULL
;
SSchema
*
pColumn
=
NULL
;
int32_t
iCol
=
0
;
int32_t
iCol
=
0
;
for
(;;)
{
for
(;;)
{
pColumn
=
NULL
;
pColumn
=
NULL
;
...
@@ -784,8 +783,8 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
...
@@ -784,8 +783,8 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
memcpy
((
void
*
)
ctbEntry
.
ctbEntry
.
pTags
,
pAlterTbReq
->
pTagVal
,
pAlterTbReq
->
nTagVal
);
memcpy
((
void
*
)
ctbEntry
.
ctbEntry
.
pTags
,
pAlterTbReq
->
pTagVal
,
pAlterTbReq
->
nTagVal
);
}
else
{
}
else
{
const
STag
*
pOldTag
=
(
const
STag
*
)
ctbEntry
.
ctbEntry
.
pTags
;
const
STag
*
pOldTag
=
(
const
STag
*
)
ctbEntry
.
ctbEntry
.
pTags
;
STag
*
pNewTag
=
NULL
;
STag
*
pNewTag
=
NULL
;
SArray
*
pTagArray
=
taosArrayInit
(
pTagSchema
->
nCols
,
sizeof
(
STagVal
));
SArray
*
pTagArray
=
taosArrayInit
(
pTagSchema
->
nCols
,
sizeof
(
STagVal
));
if
(
!
pTagArray
)
{
if
(
!
pTagArray
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_err
;
goto
_err
;
...
@@ -844,7 +843,7 @@ _err:
...
@@ -844,7 +843,7 @@ _err:
}
}
static
int
metaUpdateTableOptions
(
SMeta
*
pMeta
,
int64_t
version
,
SVAlterTbReq
*
pAlterTbReq
)
{
static
int
metaUpdateTableOptions
(
SMeta
*
pMeta
,
int64_t
version
,
SVAlterTbReq
*
pAlterTbReq
)
{
void
*
pVal
=
NULL
;
void
*
pVal
=
NULL
;
int
nVal
=
0
;
int
nVal
=
0
;
const
void
*
pData
=
NULL
;
const
void
*
pData
=
NULL
;
int
nData
=
0
;
int
nData
=
0
;
...
@@ -948,8 +947,8 @@ int metaAlterTable(SMeta *pMeta, int64_t version, SVAlterTbReq *pReq, STableMeta
...
@@ -948,8 +947,8 @@ int metaAlterTable(SMeta *pMeta, int64_t version, SVAlterTbReq *pReq, STableMeta
static
int
metaSaveToTbDb
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
)
{
static
int
metaSaveToTbDb
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
)
{
STbDbKey
tbDbKey
;
STbDbKey
tbDbKey
;
void
*
pKey
=
NULL
;
void
*
pKey
=
NULL
;
void
*
pVal
=
NULL
;
void
*
pVal
=
NULL
;
int
kLen
=
0
;
int
kLen
=
0
;
int
vLen
=
0
;
int
vLen
=
0
;
SEncoder
coder
=
{
0
};
SEncoder
coder
=
{
0
};
...
@@ -1055,14 +1054,14 @@ static void metaDestroyTagIdxKey(STagIdxKey *pTagIdxKey) {
...
@@ -1055,14 +1054,14 @@ static void metaDestroyTagIdxKey(STagIdxKey *pTagIdxKey) {
}
}
static
int
metaUpdateTagIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pCtbEntry
)
{
static
int
metaUpdateTagIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pCtbEntry
)
{
void
*
pData
=
NULL
;
void
*
pData
=
NULL
;
int
nData
=
0
;
int
nData
=
0
;
STbDbKey
tbDbKey
=
{
0
};
STbDbKey
tbDbKey
=
{
0
};
SMetaEntry
stbEntry
=
{
0
};
SMetaEntry
stbEntry
=
{
0
};
STagIdxKey
*
pTagIdxKey
=
NULL
;
STagIdxKey
*
pTagIdxKey
=
NULL
;
int32_t
nTagIdxKey
;
int32_t
nTagIdxKey
;
const
SSchema
*
pTagColumn
;
// = &stbEntry.stbEntry.schema.pSchema[0];
const
SSchema
*
pTagColumn
;
// = &stbEntry.stbEntry.schema.pSchema[0];
const
void
*
pTagData
=
NULL
;
//
const
void
*
pTagData
=
NULL
;
//
int32_t
nTagData
=
0
;
int32_t
nTagData
=
0
;
SDecoder
dc
=
{
0
};
SDecoder
dc
=
{
0
};
...
@@ -1109,7 +1108,7 @@ static int metaUpdateTagIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry) {
...
@@ -1109,7 +1108,7 @@ static int metaUpdateTagIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry) {
static
int
metaSaveToSkmDb
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
)
{
static
int
metaSaveToSkmDb
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
)
{
SEncoder
coder
=
{
0
};
SEncoder
coder
=
{
0
};
void
*
pVal
=
NULL
;
void
*
pVal
=
NULL
;
int
vLen
=
0
;
int
vLen
=
0
;
int
rcode
=
0
;
int
rcode
=
0
;
SSkmDbKey
skmDbKey
=
{
0
};
SSkmDbKey
skmDbKey
=
{
0
};
...
@@ -1151,7 +1150,7 @@ _exit:
...
@@ -1151,7 +1150,7 @@ _exit:
return
rcode
;
return
rcode
;
}
}
static
int
metaHandleEntry
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
)
{
int
metaHandleEntry
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
)
{
metaWLock
(
pMeta
);
metaWLock
(
pMeta
);
// save to table.db
// save to table.db
...
...
source/dnode/vnode/src/sma/sma.c
已删除
100644 → 0
浏览文件 @
06fe7f6a
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "sma.h"
// functions for external invocation
// TODO: Who is responsible for resource allocate and release?
int32_t
tdProcessTSmaInsert
(
SSma
*
pSma
,
int64_t
indexUid
,
const
char
*
msg
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
if
((
code
=
tdProcessTSmaInsertImpl
(
pSma
,
indexUid
,
msg
))
<
0
)
{
smaWarn
(
"vgId:%d, insert tsma data failed since %s"
,
SMA_VID
(
pSma
),
tstrerror
(
terrno
));
}
// TODO: destroy SSDataBlocks(msg)
return
code
;
}
int32_t
tdProcessTSmaCreate
(
SSma
*
pSma
,
int64_t
version
,
const
char
*
msg
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
if
((
code
=
tdProcessTSmaCreateImpl
(
pSma
,
version
,
msg
))
<
0
)
{
smaWarn
(
"vgId:%d, create tsma failed since %s"
,
SMA_VID
(
pSma
),
tstrerror
(
terrno
));
}
// TODO: destroy SSDataBlocks(msg)
return
code
;
}
int32_t
smaGetTSmaDays
(
SVnodeCfg
*
pCfg
,
void
*
pCont
,
uint32_t
contLen
,
int32_t
*
days
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
if
((
code
=
tdProcessTSmaGetDaysImpl
(
pCfg
,
pCont
,
contLen
,
days
))
<
0
)
{
smaWarn
(
"vgId:%d, get tsma days failed since %s"
,
pCfg
->
vgId
,
tstrerror
(
terrno
));
}
smaDebug
(
"vgId:%d, get tsma days %d"
,
pCfg
->
vgId
,
*
days
);
return
code
;
}
// functions for internal invocation
#if 0
/**
* @brief TODO: Assume that the final generated result it less than 3M
*
* @param pReq
* @param pDataBlocks
* @param vgId
* @param suid // TODO: check with Liao whether suid response is reasonable
*
* TODO: colId should be set
*/
int32_t buildSubmitReqFromDataBlock(SSubmitReq** pReq, const SArray* pDataBlocks, STSchema* pTSchema, int32_t vgId,
tb_uid_t suid, const char* stbName, bool isCreateCtb) {
int32_t sz = taosArrayGetSize(pDataBlocks);
int32_t bufSize = sizeof(SSubmitReq);
for (int32_t i = 0; i < sz; ++i) {
SDataBlockInfo* pBlkInfo = &((SSDataBlock*)taosArrayGet(pDataBlocks, i))->info;
bufSize += pBlkInfo->rows * (TD_ROW_HEAD_LEN + pBlkInfo->rowSize + BitmapLen(pBlkInfo->numOfCols));
bufSize += sizeof(SSubmitBlk);
}
*pReq = taosMemoryCalloc(1, bufSize);
if (!(*pReq)) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return TSDB_CODE_FAILED;
}
void* pDataBuf = *pReq;
SArray* pTagArray = NULL;
int32_t msgLen = sizeof(SSubmitReq);
int32_t numOfBlks = 0;
int32_t schemaLen = 0;
SRowBuilder rb = {0};
tdSRowInit(&rb, pTSchema->version);
for (int32_t i = 0; i < sz; ++i) {
SSDataBlock* pDataBlock = taosArrayGet(pDataBlocks, i);
SDataBlockInfo* pDataBlkInfo = &pDataBlock->info;
int32_t colNum = pDataBlkInfo->numOfCols;
int32_t rows = pDataBlkInfo->rows;
int32_t rowSize = pDataBlkInfo->rowSize;
int64_t groupId = pDataBlkInfo->groupId;
if (rb.nCols != colNum) {
tdSRowSetTpInfo(&rb, colNum, pTSchema->flen);
}
if(isCreateCtb) {
SMetaReader mr = {0};
const char* ctbName = buildCtbNameByGroupId(stbName, pDataBlock->info.groupId);
if (metaGetTableEntryByName(&mr, ctbName) != 0) {
smaDebug("vgId:%d, no tsma ctb %s exists", vgId, ctbName);
}
SVCreateTbReq ctbReq = {0};
ctbReq.name = ctbName;
ctbReq.type = TSDB_CHILD_TABLE;
ctbReq.ctb.suid = suid;
STagVal tagVal = {.cid = colNum + PRIMARYKEY_TIMESTAMP_COL_ID,
.type = TSDB_DATA_TYPE_BIGINT,
.i64 = groupId};
STag* pTag = NULL;
if(!pTagArray) {
pTagArray = taosArrayInit(1, sizeof(STagVal));
if (!pTagArray) goto _err;
}
taosArrayClear(pTagArray);
taosArrayPush(pTagArray, &tagVal);
tTagNew(pTagArray, 1, false, &pTag);
if (pTag == NULL) {
tdDestroySVCreateTbReq(&ctbReq);
goto _err;
}
ctbReq.ctb.pTag = (uint8_t*)pTag;
int32_t code;
tEncodeSize(tEncodeSVCreateTbReq, &ctbReq, schemaLen, code);
tdDestroySVCreateTbReq(&ctbReq);
if (code < 0) {
goto _err;
}
}
SSubmitBlk* pSubmitBlk = POINTER_SHIFT(pDataBuf, msgLen);
pSubmitBlk->suid = suid;
pSubmitBlk->uid = groupId;
pSubmitBlk->numOfRows = rows;
msgLen += sizeof(SSubmitBlk);
int32_t dataLen = 0;
for (int32_t j = 0; j < rows; ++j) { // iterate by row
tdSRowResetBuf(&rb, POINTER_SHIFT(pDataBuf, msgLen)); // set row buf
bool isStartKey = false;
int32_t offset = 0;
for (int32_t k = 0; k < colNum; ++k) { // iterate by column
SColumnInfoData* pColInfoData = taosArrayGet(pDataBlock->pDataBlock, k);
STColumn* pCol = &pTSchema->columns[k];
void* var = POINTER_SHIFT(pColInfoData->pData, j * pColInfoData->info.bytes);
switch (pColInfoData->info.type) {
case TSDB_DATA_TYPE_TIMESTAMP:
if (!isStartKey) {
isStartKey = true;
tdAppendColValToRow(&rb, PRIMARYKEY_TIMESTAMP_COL_ID, TSDB_DATA_TYPE_TIMESTAMP, TD_VTYPE_NORM, var, true,
offset, k);
} else {
tdAppendColValToRow(&rb, PRIMARYKEY_TIMESTAMP_COL_ID + k, TSDB_DATA_TYPE_TIMESTAMP, TD_VTYPE_NORM, var,
true, offset, k);
}
break;
case TSDB_DATA_TYPE_NCHAR: {
tdAppendColValToRow(&rb, PRIMARYKEY_TIMESTAMP_COL_ID + k, TSDB_DATA_TYPE_NCHAR, TD_VTYPE_NORM, var, true,
offset, k);
break;
}
case TSDB_DATA_TYPE_VARCHAR: { // TSDB_DATA_TYPE_BINARY
tdAppendColValToRow(&rb, PRIMARYKEY_TIMESTAMP_COL_ID + k, TSDB_DATA_TYPE_VARCHAR, TD_VTYPE_NORM, var, true,
offset, k);
break;
}
case TSDB_DATA_TYPE_VARBINARY:
case TSDB_DATA_TYPE_DECIMAL:
case TSDB_DATA_TYPE_BLOB:
case TSDB_DATA_TYPE_JSON:
case TSDB_DATA_TYPE_MEDIUMBLOB:
uError("the column type %" PRIi16 " is defined but not implemented yet", pColInfoData->info.type);
TASSERT(0);
break;
default:
if (pColInfoData->info.type < TSDB_DATA_TYPE_MAX && pColInfoData->info.type > TSDB_DATA_TYPE_NULL) {
if (pCol->type == pColInfoData->info.type) {
tdAppendColValToRow(&rb, PRIMARYKEY_TIMESTAMP_COL_ID + k, pCol->type, TD_VTYPE_NORM, var, true, offset,
k);
} else {
char tv[8] = {0};
if (pColInfoData->info.type == TSDB_DATA_TYPE_FLOAT) {
float v = 0;
GET_TYPED_DATA(v, float, pColInfoData->info.type, var);
SET_TYPED_DATA(&tv, pCol->type, v);
} else if (pColInfoData->info.type == TSDB_DATA_TYPE_DOUBLE) {
double v = 0;
GET_TYPED_DATA(v, double, pColInfoData->info.type, var);
SET_TYPED_DATA(&tv, pCol->type, v);
} else if (IS_SIGNED_NUMERIC_TYPE(pColInfoData->info.type)) {
int64_t v = 0;
GET_TYPED_DATA(v, int64_t, pColInfoData->info.type, var);
SET_TYPED_DATA(&tv, pCol->type, v);
} else {
uint64_t v = 0;
GET_TYPED_DATA(v, uint64_t, pColInfoData->info.type, var);
SET_TYPED_DATA(&tv, pCol->type, v);
}
tdAppendColValToRow(&rb, PRIMARYKEY_TIMESTAMP_COL_ID + k, pCol->type, TD_VTYPE_NORM, tv, true, offset,
k);
}
} else {
uError("the column type %" PRIi16 " is undefined\n", pColInfoData->info.type);
TASSERT(0);
}
break;
}
offset += TYPE_BYTES[pCol->type]; // sum/avg would convert to int64_t/uint64_t/double during aggregation
}
dataLen += TD_ROW_LEN(rb.pBuf);
#ifdef TD_DEBUG_PRINT_ROW
tdSRowPrint(rb.pBuf, pTSchema, __func__);
#endif
}
++numOfBlks;
pSubmitBlk->dataLen = dataLen;
msgLen += pSubmitBlk->dataLen;
}
(*pReq)->length = msgLen;
(*pReq)->header.vgId = htonl(vgId);
(*pReq)->header.contLen = htonl(msgLen);
(*pReq)->length = (*pReq)->header.contLen;
(*pReq)->numOfBlocks = htonl(numOfBlks);
SSubmitBlk* blk = (SSubmitBlk*)((*pReq) + 1);
while (numOfBlks--) {
int32_t dataLen = blk->dataLen;
blk->uid = htobe64(blk->uid);
blk->suid = htobe64(blk->suid);
blk->padding = htonl(blk->padding);
blk->sversion = htonl(blk->sversion);
blk->dataLen = htonl(blk->dataLen);
blk->schemaLen = htonl(blk->schemaLen);
blk->numOfRows = htons(blk->numOfRows);
blk = (SSubmitBlk*)(blk->data + dataLen);
}
return TSDB_CODE_SUCCESS;
_err:
taosMemoryFreeClear(*pReq);
taosArrayDestroy(pTagArray);
return TSDB_CODE_FAILED;
}
#endif
source/dnode/vnode/src/sma/smaCommit.c
浏览文件 @
e77931f1
...
@@ -121,7 +121,7 @@ static int32_t tdProcessRSmaPreCommitImpl(SSma *pSma) {
...
@@ -121,7 +121,7 @@ static int32_t tdProcessRSmaPreCommitImpl(SSma *pSma) {
// step 3: perform persist task for qTaskInfo
// step 3: perform persist task for qTaskInfo
tdRSmaPersistExecImpl
(
pRSmaStat
);
tdRSmaPersistExecImpl
(
pRSmaStat
);
smaDebug
(
"vgId:%d, rsma pre commit succe
e
ss"
,
SMA_VID
(
pSma
));
smaDebug
(
"vgId:%d, rsma pre commit success"
,
SMA_VID
(
pSma
));
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -173,6 +173,7 @@ static int32_t tdProcessRSmaPostCommitImpl(SSma *pSma) {
...
@@ -173,6 +173,7 @@ static int32_t tdProcessRSmaPostCommitImpl(SSma *pSma) {
}
}
if
((
pDir
=
taosOpenDir
(
dir
))
==
NULL
)
{
if
((
pDir
=
taosOpenDir
(
dir
))
==
NULL
)
{
regfree
(
&
regex
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
smaWarn
(
"vgId:%d, rsma post commit, open dir %s failed since %s"
,
TD_VID
(
pVnode
),
dir
,
terrstr
());
smaWarn
(
"vgId:%d, rsma post commit, open dir %s failed since %s"
,
TD_VID
(
pVnode
),
dir
,
terrstr
());
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
...
...
source/dnode/vnode/src/sma/smaEnv.c
浏览文件 @
e77931f1
...
@@ -18,7 +18,7 @@
...
@@ -18,7 +18,7 @@
typedef
struct
SSmaStat
SSmaStat
;
typedef
struct
SSmaStat
SSmaStat
;
#define RSMA_TASK_INFO_HASH_SLOT 8
#define RSMA_TASK_INFO_HASH_SLOT 8
#define SMA_MGMT_REF_NUM 1024
#define SMA_MGMT_REF_NUM 1024
0
extern
SSmaMgmt
smaMgmt
;
extern
SSmaMgmt
smaMgmt
;
...
@@ -30,7 +30,73 @@ static int32_t tdInitSmaEnv(SSma *pSma, int8_t smaType, const char *path, SSmaE
...
@@ -30,7 +30,73 @@ static int32_t tdInitSmaEnv(SSma *pSma, int8_t smaType, const char *path, SSmaE
static
void
*
tdFreeTSmaStat
(
STSmaStat
*
pStat
);
static
void
*
tdFreeTSmaStat
(
STSmaStat
*
pStat
);
static
void
tdDestroyRSmaStat
(
void
*
pRSmaStat
);
static
void
tdDestroyRSmaStat
(
void
*
pRSmaStat
);
/**
* @brief rsma init
*
* @return int32_t
*/
// implementation
// implementation
int32_t
smaInit
()
{
int8_t
old
;
int32_t
nLoops
=
0
;
while
(
1
)
{
old
=
atomic_val_compare_exchange_8
(
&
smaMgmt
.
inited
,
0
,
2
);
if
(
old
!=
2
)
break
;
if
(
++
nLoops
>
1000
)
{
sched_yield
();
nLoops
=
0
;
}
}
if
(
old
==
0
)
{
// init tref rset
smaMgmt
.
rsetId
=
taosOpenRef
(
SMA_MGMT_REF_NUM
,
tdDestroyRSmaStat
);
if
(
smaMgmt
.
rsetId
<
0
)
{
atomic_store_8
(
&
smaMgmt
.
inited
,
0
);
smaError
(
"failed to init sma rset since %s"
,
terrstr
());
return
TSDB_CODE_FAILED
;
}
// init fetch timer handle
smaMgmt
.
tmrHandle
=
taosTmrInit
(
10000
,
100
,
10000
,
"RSMA"
);
if
(
!
smaMgmt
.
tmrHandle
)
{
taosCloseRef
(
smaMgmt
.
rsetId
);
atomic_store_8
(
&
smaMgmt
.
inited
,
0
);
smaError
(
"failed to init sma tmr hanle since %s"
,
terrstr
());
return
TSDB_CODE_FAILED
;
}
atomic_store_8
(
&
smaMgmt
.
inited
,
1
);
smaInfo
(
"sma mgmt env is initialized, rsetId:%d, tmrHandle:%p"
,
smaMgmt
.
rsetId
,
smaMgmt
.
tmrHandle
);
}
return
TSDB_CODE_SUCCESS
;
}
/**
* @brief rsma cleanup
*
*/
void
smaCleanUp
()
{
int8_t
old
;
int32_t
nLoops
=
0
;
while
(
1
)
{
old
=
atomic_val_compare_exchange_8
(
&
smaMgmt
.
inited
,
1
,
2
);
if
(
old
!=
2
)
break
;
if
(
++
nLoops
>
1000
)
{
sched_yield
();
nLoops
=
0
;
}
}
if
(
old
==
1
)
{
taosCloseRef
(
smaMgmt
.
rsetId
);
taosTmrCleanUp
(
smaMgmt
.
tmrHandle
);
smaInfo
(
"sma mgmt env is cleaned up, rsetId:%d, tmrHandle:%p"
,
smaMgmt
.
rsetId
,
smaMgmt
.
tmrHandle
);
atomic_store_8
(
&
smaMgmt
.
inited
,
0
);
}
}
static
SSmaEnv
*
tdNewSmaEnv
(
const
SSma
*
pSma
,
int8_t
smaType
,
const
char
*
path
)
{
static
SSmaEnv
*
tdNewSmaEnv
(
const
SSma
*
pSma
,
int8_t
smaType
,
const
char
*
path
)
{
SSmaEnv
*
pEnv
=
NULL
;
SSmaEnv
*
pEnv
=
NULL
;
...
@@ -135,34 +201,24 @@ static int32_t tdInitSmaStat(SSmaStat **pSmaStat, int8_t smaType, const SSma *pS
...
@@ -135,34 +201,24 @@ static int32_t tdInitSmaStat(SSmaStat **pSmaStat, int8_t smaType, const SSma *pS
atomic_store_8
(
RSMA_TRIGGER_STAT
(
pRSmaStat
),
TASK_TRIGGER_STAT_INIT
);
atomic_store_8
(
RSMA_TRIGGER_STAT
(
pRSmaStat
),
TASK_TRIGGER_STAT_INIT
);
// init smaMgmt
// init smaMgmt
smaMgmt
.
smaRef
=
taosOpenRef
(
SMA_MGMT_REF_NUM
,
tdDestroyRSmaStat
);
smaInit
();
if
(
smaMgmt
.
smaRef
<
0
)
{
smaError
(
"init smaRef failed, num:%d"
,
SMA_MGMT_REF_NUM
);
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_FAILED
;
}
int64_t
refId
=
taosAddRef
(
smaMgmt
.
smaRef
,
pRSmaStat
);
int64_t
refId
=
taosAddRef
(
smaMgmt
.
rsetId
,
pRSmaStat
);
if
(
refId
<
0
)
{
if
(
refId
<
0
)
{
smaError
(
"taosAddRef smaRef failed, since:%s"
,
tstrerror
(
terrno
));
smaError
(
"vgId:%d, taosAddRef refId:%"
PRIi64
" to rsetId rsetId:%d max:%d failed since:%s"
,
SMA_VID
(
pSma
),
refId
,
smaMgmt
.
rsetId
,
SMA_MGMT_REF_NUM
,
tstrerror
(
terrno
));
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
else
{
smaDebug
(
"vgId:%d, taosAddRef refId:%"
PRIi64
" to rsetId rsetId:%d max:%d succeed"
,
SMA_VID
(
pSma
),
refId
,
smaMgmt
.
rsetId
,
SMA_MGMT_REF_NUM
);
}
}
pRSmaStat
->
refId
=
refId
;
pRSmaStat
->
refId
=
refId
;
// init timer
RSMA_TMR_HANDLE
(
pRSmaStat
)
=
taosTmrInit
(
10000
,
100
,
10000
,
"RSMA"
);
if
(
!
RSMA_TMR_HANDLE
(
pRSmaStat
))
{
taosMemoryFreeClear
(
*
pSmaStat
);
return
TSDB_CODE_FAILED
;
}
// init hash
// init hash
RSMA_INFO_HASH
(
pRSmaStat
)
=
taosHashInit
(
RSMA_INFO_HASH
(
pRSmaStat
)
=
taosHashInit
(
RSMA_TASK_INFO_HASH_SLOT
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
true
,
HASH_ENTRY_LOCK
);
RSMA_TASK_INFO_HASH_SLOT
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
true
,
HASH_ENTRY_LOCK
);
if
(
!
RSMA_INFO_HASH
(
pRSmaStat
))
{
if
(
!
RSMA_INFO_HASH
(
pRSmaStat
))
{
if
(
RSMA_TMR_HANDLE
(
pRSmaStat
))
{
taosTmrCleanUp
(
RSMA_TMR_HANDLE
(
pRSmaStat
));
}
taosMemoryFreeClear
(
*
pSmaStat
);
taosMemoryFreeClear
(
*
pSmaStat
);
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
...
@@ -223,7 +279,7 @@ static void tdDestroyRSmaStat(void *pRSmaStat) {
...
@@ -223,7 +279,7 @@ static void tdDestroyRSmaStat(void *pRSmaStat) {
void
*
infoHash
=
taosHashIterate
(
RSMA_INFO_HASH
(
pStat
),
NULL
);
void
*
infoHash
=
taosHashIterate
(
RSMA_INFO_HASH
(
pStat
),
NULL
);
while
(
infoHash
)
{
while
(
infoHash
)
{
SRSmaInfo
*
pSmaInfo
=
*
(
SRSmaInfo
**
)
infoHash
;
SRSmaInfo
*
pSmaInfo
=
*
(
SRSmaInfo
**
)
infoHash
;
tdFreeRSmaInfo
(
pSmaInfo
);
tdFreeRSmaInfo
(
pSma
,
pSma
Info
);
infoHash
=
taosHashIterate
(
RSMA_INFO_HASH
(
pStat
),
infoHash
);
infoHash
=
taosHashIterate
(
RSMA_INFO_HASH
(
pStat
),
infoHash
);
}
}
}
}
...
@@ -244,11 +300,6 @@ static void tdDestroyRSmaStat(void *pRSmaStat) {
...
@@ -244,11 +300,6 @@ static void tdDestroyRSmaStat(void *pRSmaStat) {
nLoops
=
0
;
nLoops
=
0
;
}
}
}
}
// step 6: cleanup the timer handle
if
(
RSMA_TMR_HANDLE
(
pStat
))
{
taosTmrCleanUp
(
RSMA_TMR_HANDLE
(
pStat
));
}
}
}
}
}
...
@@ -275,8 +326,13 @@ int32_t tdDestroySmaState(SSmaStat *pSmaStat, int8_t smaType) {
...
@@ -275,8 +326,13 @@ int32_t tdDestroySmaState(SSmaStat *pSmaStat, int8_t smaType) {
tdDestroyTSmaStat
(
SMA_TSMA_STAT
(
pSmaStat
));
tdDestroyTSmaStat
(
SMA_TSMA_STAT
(
pSmaStat
));
}
else
if
(
smaType
==
TSDB_SMA_TYPE_ROLLUP
)
{
}
else
if
(
smaType
==
TSDB_SMA_TYPE_ROLLUP
)
{
SRSmaStat
*
pRSmaStat
=
SMA_RSMA_STAT
(
pSmaStat
);
SRSmaStat
*
pRSmaStat
=
SMA_RSMA_STAT
(
pSmaStat
);
if
(
taosRemoveRef
(
smaMgmt
.
smaRef
,
RSMA_REF_ID
(
pRSmaStat
))
<
0
)
{
if
(
taosRemoveRef
(
smaMgmt
.
rsetId
,
RSMA_REF_ID
(
pRSmaStat
))
<
0
)
{
smaError
(
"remove refId from rsmaRef:0x%"
PRIx64
" failed since %s"
,
RSMA_REF_ID
(
pRSmaStat
),
terrstr
());
smaError
(
"vgId:%d, remove refId:%"
PRIi64
" from rsmaRef:%"
PRIi32
" failed since %s"
,
SMA_VID
(
pRSmaStat
->
pSma
),
RSMA_REF_ID
(
pRSmaStat
),
smaMgmt
.
rsetId
,
terrstr
());
ASSERT
(
0
);
}
else
{
smaDebug
(
"vgId:%d, remove refId:%"
PRIi64
" from rsmaRef:%"
PRIi32
" succeed"
,
SMA_VID
(
pRSmaStat
->
pSma
),
RSMA_REF_ID
(
pRSmaStat
),
smaMgmt
.
rsetId
);
}
}
}
else
{
}
else
{
ASSERT
(
0
);
ASSERT
(
0
);
...
@@ -323,7 +379,7 @@ int32_t tdCheckAndInitSmaEnv(SSma *pSma, int8_t smaType) {
...
@@ -323,7 +379,7 @@ int32_t tdCheckAndInitSmaEnv(SSma *pSma, int8_t smaType) {
}
}
break
;
break
;
default:
default:
TASSERT
(
0
);
smaError
(
"vgId:%d undefined smaType:%"
,
SMA_VID
(
pSma
),
smaType
);
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
...
...
source/dnode/vnode/src/sma/smaRollup.c
浏览文件 @
e77931f1
...
@@ -19,23 +19,27 @@
...
@@ -19,23 +19,27 @@
#define RSMA_QTASKINFO_HEAD_LEN (sizeof(int32_t) + sizeof(int8_t) + sizeof(int64_t)) // len + type + suid
#define RSMA_QTASKINFO_HEAD_LEN (sizeof(int32_t) + sizeof(int8_t) + sizeof(int64_t)) // len + type + suid
SSmaMgmt
smaMgmt
=
{
SSmaMgmt
smaMgmt
=
{
.
smaRef
=
-
1
,
.
inited
=
0
,
.
rsetId
=
-
1
,
};
};
#define TD_QTASKINFO_FNAME_PREFIX "qtaskinfo.ver"
#define TD_QTASKINFO_FNAME_PREFIX "qtaskinfo.ver"
typedef
struct
SRSmaQTaskInfoItem
SRSmaQTaskInfoItem
;
typedef
struct
SRSmaQTaskInfoItem
SRSmaQTaskInfoItem
;
typedef
struct
SRSmaQTaskInfoIter
SRSmaQTaskInfoIter
;
typedef
struct
SRSmaQTaskInfoIter
SRSmaQTaskInfoIter
;
static
int32_t
tdUidStorePut
(
STbUidStore
*
pStore
,
tb_uid_t
suid
,
tb_uid_t
*
uid
);
static
int32_t
tdUidStorePut
(
STbUidStore
*
pStore
,
tb_uid_t
suid
,
tb_uid_t
*
uid
);
static
int32_t
tdUpdateTbUidListImpl
(
SSma
*
pSma
,
tb_uid_t
*
suid
,
SArray
*
tbUids
);
static
int32_t
tdUpdateTbUidListImpl
(
SSma
*
pSma
,
tb_uid_t
*
suid
,
SArray
*
tbUids
);
static
int32_t
tdSetRSmaInfoItemParams
(
SSma
*
pSma
,
SRSmaParam
*
param
,
SRSmaInfo
*
pRSmaInfo
,
SReadHandle
*
handle
,
static
int32_t
tdSetRSmaInfoItemParams
(
SSma
*
pSma
,
SRSmaParam
*
param
,
SRSmaStat
*
pStat
,
SRSmaInfo
*
pRSmaInfo
,
int8_t
idx
);
SReadHandle
*
handle
,
int8_t
idx
);
static
int32_t
tdExecuteRSmaImpl
(
SSma
*
pSma
,
const
void
*
pMsg
,
int32_t
inputType
,
SRSmaInfoItem
*
rsmaItem
,
static
int32_t
tdExecuteRSmaImpl
(
SSma
*
pSma
,
const
void
*
pMsg
,
int32_t
inputType
,
SRSmaInfoItem
*
rsmaItem
,
tb_uid_t
suid
,
int8_t
level
);
STSchema
*
pTSchema
,
tb_uid_t
suid
,
int8_t
level
);
static
void
tdRSmaFetchTrigger
(
void
*
param
,
void
*
tmrId
);
static
SRSmaInfo
*
tdGetRSmaInfoBySuid
(
SSma
*
pSma
,
int64_t
suid
);
static
void
tdRSmaPersistTrigger
(
void
*
param
,
void
*
tmrId
);
static
int32_t
tdRSmaFetchAndSubmitResult
(
SRSmaInfoItem
*
pItem
,
STSchema
*
pTSchema
,
int64_t
suid
,
SRSmaStat
*
pStat
,
static
void
*
tdRSmaPersistExec
(
void
*
param
);
int8_t
blkType
);
static
void
tdRSmaQTaskInfoGetFName
(
int32_t
vid
,
int64_t
version
,
char
*
outputName
);
static
void
tdRSmaFetchTrigger
(
void
*
param
,
void
*
tmrId
);
static
void
tdRSmaPersistTrigger
(
void
*
param
,
void
*
tmrId
);
static
void
*
tdRSmaPersistExec
(
void
*
param
);
static
void
tdRSmaQTaskInfoGetFName
(
int32_t
vid
,
int64_t
version
,
char
*
outputName
);
static
int32_t
tdRSmaQTaskInfoIterInit
(
SRSmaQTaskInfoIter
*
pIter
,
STFile
*
pTFile
);
static
int32_t
tdRSmaQTaskInfoIterInit
(
SRSmaQTaskInfoIter
*
pIter
,
STFile
*
pTFile
);
static
int32_t
tdRSmaQTaskInfoIterNextBlock
(
SRSmaQTaskInfoIter
*
pIter
,
bool
*
isFinish
);
static
int32_t
tdRSmaQTaskInfoIterNextBlock
(
SRSmaQTaskInfoIter
*
pIter
,
bool
*
isFinish
);
...
@@ -47,25 +51,26 @@ static int32_t tdRSmaRestoreQTaskInfoReload(SSma *pSma, int64_t *committed);
...
@@ -47,25 +51,26 @@ static int32_t tdRSmaRestoreQTaskInfoReload(SSma *pSma, int64_t *committed);
static
int32_t
tdRSmaRestoreTSDataReload
(
SSma
*
pSma
,
int64_t
committed
);
static
int32_t
tdRSmaRestoreTSDataReload
(
SSma
*
pSma
,
int64_t
committed
);
struct
SRSmaInfoItem
{
struct
SRSmaInfoItem
{
SRSmaInfo
*
pRsmaInfo
;
void
*
taskInfo
;
// qTaskInfo_t
int64_t
refId
;
int64_t
refId
;
void
*
taskInfo
;
// qTaskInfo_t
tmr_h
tmrId
;
tmr_h
tmrId
;
int32_t
maxDelay
;
int8_t
level
;
int8_t
level
;
int8_t
tmrInitFlag
;
int8_t
triggerStat
;
int8_t
triggerStat
;
int32_t
maxDelay
;
};
};
struct
SRSmaInfo
{
struct
SRSmaInfo
{
STSchema
*
pTSchema
;
STSchema
*
pTSchema
;
SRSmaStat
*
pStat
;
int64_t
suid
;
int64_t
suid
;
SRSmaInfoItem
items
[
TSDB_RETENTION_L2
];
SRSmaInfoItem
items
[
TSDB_RETENTION_L2
];
};
};
#define RSMA_INFO_SMA(r) ((r)->pStat->pSma)
static
SRSmaInfo
*
tdGetRSmaInfoByItem
(
SRSmaInfoItem
*
pItem
)
{
#define RSMA_INFO_STAT(r) ((r)->pStat)
// adapt accordingly if definition of SRSmaInfo update
int32_t
rsmaInfoHeadLen
=
sizeof
(
int64_t
)
+
sizeof
(
STSchema
*
);
ASSERT
(
pItem
->
level
==
1
||
pItem
->
level
==
2
);
return
(
SRSmaInfo
*
)
POINTER_SHIFT
(
pItem
,
-
sizeof
(
SRSmaInfoItem
)
*
(
pItem
->
level
-
1
)
-
rsmaInfoHeadLen
);
}
struct
SRSmaQTaskInfoItem
{
struct
SRSmaQTaskInfoItem
{
int32_t
len
;
int32_t
len
;
...
@@ -107,9 +112,8 @@ static FORCE_INLINE void tdFreeTaskHandle(qTaskInfo_t *taskHandle, int32_t vgId,
...
@@ -107,9 +112,8 @@ static FORCE_INLINE void tdFreeTaskHandle(qTaskInfo_t *taskHandle, int32_t vgId,
}
}
}
}
void
*
tdFreeRSmaInfo
(
SRSmaInfo
*
pInfo
)
{
void
*
tdFreeRSmaInfo
(
S
Sma
*
pSma
,
S
RSmaInfo
*
pInfo
)
{
if
(
pInfo
)
{
if
(
pInfo
)
{
SSma
*
pSma
=
RSMA_INFO_SMA
(
pInfo
);
for
(
int32_t
i
=
0
;
i
<
TSDB_RETENTION_L2
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
TSDB_RETENTION_L2
;
++
i
)
{
SRSmaInfoItem
*
pItem
=
&
pInfo
->
items
[
i
];
SRSmaInfoItem
*
pItem
=
&
pInfo
->
items
[
i
];
if
(
pItem
->
taskInfo
)
{
if
(
pItem
->
taskInfo
)
{
...
@@ -142,8 +146,6 @@ static FORCE_INLINE int32_t tdUidStoreInit(STbUidStore **pStore) {
...
@@ -142,8 +146,6 @@ static FORCE_INLINE int32_t tdUidStoreInit(STbUidStore **pStore) {
}
}
static
int32_t
tdUpdateTbUidListImpl
(
SSma
*
pSma
,
tb_uid_t
*
suid
,
SArray
*
tbUids
)
{
static
int32_t
tdUpdateTbUidListImpl
(
SSma
*
pSma
,
tb_uid_t
*
suid
,
SArray
*
tbUids
)
{
SSmaEnv
*
pEnv
=
SMA_RSMA_ENV
(
pSma
);
SRSmaStat
*
pStat
=
(
SRSmaStat
*
)
SMA_ENV_STAT
(
pEnv
);
SRSmaInfo
*
pRSmaInfo
=
NULL
;
SRSmaInfo
*
pRSmaInfo
=
NULL
;
if
(
!
suid
||
!
tbUids
)
{
if
(
!
suid
||
!
tbUids
)
{
...
@@ -152,8 +154,9 @@ static int32_t tdUpdateTbUidListImpl(SSma *pSma, tb_uid_t *suid, SArray *tbUids)
...
@@ -152,8 +154,9 @@ static int32_t tdUpdateTbUidListImpl(SSma *pSma, tb_uid_t *suid, SArray *tbUids)
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
pRSmaInfo
=
taosHashGet
(
RSMA_INFO_HASH
(
pStat
),
suid
,
sizeof
(
tb_uid_t
));
pRSmaInfo
=
tdGetRSmaInfoBySuid
(
pSma
,
*
suid
);
if
(
!
pRSmaInfo
||
!
(
pRSmaInfo
=
*
(
SRSmaInfo
**
)
pRSmaInfo
))
{
if
(
!
pRSmaInfo
)
{
smaError
(
"vgId:%d, failed to get rsma info for uid:%"
PRIi64
,
SMA_VID
(
pSma
),
*
suid
);
smaError
(
"vgId:%d, failed to get rsma info for uid:%"
PRIi64
,
SMA_VID
(
pSma
),
*
suid
);
terrno
=
TSDB_CODE_RSMA_INVALID_STAT
;
terrno
=
TSDB_CODE_RSMA_INVALID_STAT
;
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
...
@@ -251,15 +254,14 @@ int32_t tdFetchTbUidList(SSma *pSma, STbUidStore **ppStore, tb_uid_t suid, tb_ui
...
@@ -251,15 +254,14 @@ int32_t tdFetchTbUidList(SSma *pSma, STbUidStore **ppStore, tb_uid_t suid, tb_ui
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
tdSetRSmaInfoItemParams
(
SSma
*
pSma
,
SRSmaParam
*
param
,
SRSma
Info
*
pRSmaInfo
,
SReadHandle
*
pReadHandle
,
static
int32_t
tdSetRSmaInfoItemParams
(
SSma
*
pSma
,
SRSmaParam
*
param
,
SRSma
Stat
*
pStat
,
SRSmaInfo
*
pRSmaInfo
,
int8_t
idx
)
{
SReadHandle
*
pReadHandle
,
int8_t
idx
)
{
SRetention
*
pRetention
=
SMA_RETENTION
(
pSma
);
SRetention
*
pRetention
=
SMA_RETENTION
(
pSma
);
STsdbCfg
*
pTsdbCfg
=
SMA_TSDB_CFG
(
pSma
);
STsdbCfg
*
pTsdbCfg
=
SMA_TSDB_CFG
(
pSma
);
if
(
param
->
qmsg
[
idx
])
{
if
(
param
->
qmsg
[
idx
])
{
SRSmaInfoItem
*
pItem
=
&
(
pRSmaInfo
->
items
[
idx
]);
SRSmaInfoItem
*
pItem
=
&
(
pRSmaInfo
->
items
[
idx
]);
pItem
->
refId
=
RSMA_REF_ID
(
pRSmaInfo
->
pStat
);
pItem
->
refId
=
RSMA_REF_ID
(
pStat
);
pItem
->
pRsmaInfo
=
pRSmaInfo
;
pItem
->
taskInfo
=
qCreateStreamExecTaskInfo
(
param
->
qmsg
[
idx
],
pReadHandle
);
pItem
->
taskInfo
=
qCreateStreamExecTaskInfo
(
param
->
qmsg
[
idx
],
pReadHandle
);
if
(
!
pItem
->
taskInfo
)
{
if
(
!
pItem
->
taskInfo
)
{
terrno
=
TSDB_CODE_RSMA_QTASKINFO_CREATE
;
terrno
=
TSDB_CODE_RSMA_QTASKINFO_CREATE
;
...
@@ -347,14 +349,13 @@ int32_t tdProcessRSmaCreateImpl(SSma *pSma, SRSmaParam *param, int64_t suid, con
...
@@ -347,14 +349,13 @@ int32_t tdProcessRSmaCreateImpl(SSma *pSma, SRSmaParam *param, int64_t suid, con
goto
_err
;
goto
_err
;
}
}
pRSmaInfo
->
pTSchema
=
pTSchema
;
pRSmaInfo
->
pTSchema
=
pTSchema
;
pRSmaInfo
->
pStat
=
pStat
;
pRSmaInfo
->
suid
=
suid
;
pRSmaInfo
->
suid
=
suid
;
if
(
tdSetRSmaInfoItemParams
(
pSma
,
param
,
pRSmaInfo
,
&
handle
,
0
)
<
0
)
{
if
(
tdSetRSmaInfoItemParams
(
pSma
,
param
,
p
Stat
,
p
RSmaInfo
,
&
handle
,
0
)
<
0
)
{
goto
_err
;
goto
_err
;
}
}
if
(
tdSetRSmaInfoItemParams
(
pSma
,
param
,
pRSmaInfo
,
&
handle
,
1
)
<
0
)
{
if
(
tdSetRSmaInfoItemParams
(
pSma
,
param
,
p
Stat
,
p
RSmaInfo
,
&
handle
,
1
)
<
0
)
{
goto
_err
;
goto
_err
;
}
}
...
@@ -366,7 +367,7 @@ int32_t tdProcessRSmaCreateImpl(SSma *pSma, SRSmaParam *param, int64_t suid, con
...
@@ -366,7 +367,7 @@ int32_t tdProcessRSmaCreateImpl(SSma *pSma, SRSmaParam *param, int64_t suid, con
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
_err:
_err:
tdFreeRSmaInfo
(
pRSmaInfo
);
tdFreeRSmaInfo
(
p
Sma
,
p
RSmaInfo
);
taosMemoryFree
(
pReader
);
taosMemoryFree
(
pReader
);
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
...
@@ -537,10 +538,10 @@ int64_t tdRSmaGetMaxSubmitVer(SSma *pSma, int8_t level) {
...
@@ -537,10 +538,10 @@ int64_t tdRSmaGetMaxSubmitVer(SSma *pSma, int8_t level) {
return
atomic_load_64
(
&
pRSmaStat
->
submitVer
);
return
atomic_load_64
(
&
pRSmaStat
->
submitVer
);
}
}
static
int32_t
td
FetchAndSubmitRSmaResult
(
SRSmaInfoItem
*
pItem
,
int8_t
blkType
)
{
static
int32_t
td
RSmaFetchAndSubmitResult
(
SRSmaInfoItem
*
pItem
,
STSchema
*
pTSchema
,
int64_t
suid
,
SRSmaStat
*
pStat
,
SArray
*
pResult
=
NULL
;
int8_t
blkType
)
{
S
RSmaInfo
*
pRSmaInfo
=
pItem
->
pRsmaInfo
;
S
Array
*
pResult
=
NULL
;
SSma
*
pSma
=
RSMA_INFO_SMA
(
pRSmaInfo
)
;
SSma
*
pSma
=
pStat
->
pSma
;
while
(
1
)
{
while
(
1
)
{
SSDataBlock
*
output
=
NULL
;
SSDataBlock
*
output
=
NULL
;
...
@@ -572,16 +573,16 @@ static int32_t tdFetchAndSubmitRSmaResult(SRSmaInfoItem *pItem, int8_t blkType)
...
@@ -572,16 +573,16 @@ static int32_t tdFetchAndSubmitRSmaResult(SRSmaInfoItem *pItem, int8_t blkType)
STsdb
*
sinkTsdb
=
(
pItem
->
level
==
TSDB_RETENTION_L1
?
pSma
->
pRSmaTsdb1
:
pSma
->
pRSmaTsdb2
);
STsdb
*
sinkTsdb
=
(
pItem
->
level
==
TSDB_RETENTION_L1
?
pSma
->
pRSmaTsdb1
:
pSma
->
pRSmaTsdb2
);
SSubmitReq
*
pReq
=
NULL
;
SSubmitReq
*
pReq
=
NULL
;
// TODO: the schema update should be handled
// TODO: the schema update should be handled
if
(
buildSubmitReqFromDataBlock
(
&
pReq
,
pResult
,
p
RSmaInfo
->
pTSchema
,
SMA_VID
(
pSma
),
pRSmaInfo
->
suid
)
<
0
)
{
if
(
buildSubmitReqFromDataBlock
(
&
pReq
,
pResult
,
p
TSchema
,
SMA_VID
(
pSma
),
suid
)
<
0
)
{
smaError
(
"vgId:%d, build submit req for rsma table %"
PRIi64
"l evel %"
PRIi8
" failed since %s"
,
SMA_VID
(
pSma
),
smaError
(
"vgId:%d, build submit req for rsma table %"
PRIi64
"l evel %"
PRIi8
" failed since %s"
,
SMA_VID
(
pSma
),
pRSmaInfo
->
suid
,
pItem
->
level
,
terrstr
());
suid
,
pItem
->
level
,
terrstr
());
goto
_err
;
goto
_err
;
}
}
if
(
pReq
&&
tdProcessSubmitReq
(
sinkTsdb
,
atomic_add_fetch_64
(
&
p
RSmaInfo
->
p
Stat
->
submitVer
,
1
),
pReq
)
<
0
)
{
if
(
pReq
&&
tdProcessSubmitReq
(
sinkTsdb
,
atomic_add_fetch_64
(
&
pStat
->
submitVer
,
1
),
pReq
)
<
0
)
{
taosMemoryFreeClear
(
pReq
);
taosMemoryFreeClear
(
pReq
);
smaError
(
"vgId:%d, process submit req for rsma table %"
PRIi64
" level %"
PRIi8
" failed since %s"
,
SMA_VID
(
pSma
),
smaError
(
"vgId:%d, process submit req for rsma table %"
PRIi64
" level %"
PRIi8
" failed since %s"
,
SMA_VID
(
pSma
),
pRSmaInfo
->
suid
,
pItem
->
level
,
terrstr
());
suid
,
pItem
->
level
,
terrstr
());
goto
_err
;
goto
_err
;
}
}
...
@@ -599,81 +600,16 @@ _err:
...
@@ -599,81 +600,16 @@ _err:
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
/**
static
int32_t
tdExecuteRSmaImpl
(
SSma
*
pSma
,
const
void
*
pMsg
,
int32_t
inputType
,
SRSmaInfoItem
*
pItem
,
* @brief trigger to get rsma result
STSchema
*
pTSchema
,
tb_uid_t
suid
,
int8_t
level
)
{
*
* @param param
* @param tmrId
*/
static
void
tdRSmaFetchTrigger
(
void
*
param
,
void
*
tmrId
)
{
SRSmaInfoItem
*
pItem
=
param
;
SSma
*
pSma
=
NULL
;
SRSmaStat
*
pStat
=
(
SRSmaStat
*
)
taosAcquireRef
(
smaMgmt
.
smaRef
,
pItem
->
refId
);
if
(
!
pStat
)
{
smaDebug
(
"rsma fetch task not start since already destroyed"
);
return
;
}
pSma
=
RSMA_INFO_SMA
(
pItem
->
pRsmaInfo
);
// if rsma trigger stat in paused, cancelled or finished, not start fetch task
int8_t
rsmaTriggerStat
=
atomic_load_8
(
RSMA_TRIGGER_STAT
(
pStat
));
switch
(
rsmaTriggerStat
)
{
case
TASK_TRIGGER_STAT_PAUSED
:
case
TASK_TRIGGER_STAT_CANCELLED
:
case
TASK_TRIGGER_STAT_FINISHED
:
{
taosReleaseRef
(
smaMgmt
.
smaRef
,
pItem
->
refId
);
smaDebug
(
"vgId:%d, not fetch rsma level %"
PRIi8
" data for table:%"
PRIi64
" since stat is cancelled"
,
SMA_VID
(
pSma
),
pItem
->
level
,
pItem
->
pRsmaInfo
->
suid
);
return
;
}
default:
break
;
}
int8_t
fetchTriggerStat
=
atomic_val_compare_exchange_8
(
&
pItem
->
triggerStat
,
TASK_TRIGGER_STAT_ACTIVE
,
TASK_TRIGGER_STAT_INACTIVE
);
switch
(
fetchTriggerStat
)
{
case
TASK_TRIGGER_STAT_ACTIVE
:
{
smaDebug
(
"vgId:%d, fetch rsma level %"
PRIi8
" data for table:%"
PRIi64
" since stat is active"
,
SMA_VID
(
pSma
),
pItem
->
level
,
pItem
->
pRsmaInfo
->
suid
);
tdRefSmaStat
(
pSma
,
(
SSmaStat
*
)
pStat
);
SSDataBlock
dataBlock
=
{.
info
.
type
=
STREAM_GET_ALL
};
qSetStreamInput
(
pItem
->
taskInfo
,
&
dataBlock
,
STREAM_INPUT__DATA_BLOCK
,
false
);
tdFetchAndSubmitRSmaResult
(
pItem
,
STREAM_INPUT__DATA_BLOCK
);
tdUnRefSmaStat
(
pSma
,
(
SSmaStat
*
)
pStat
);
}
break
;
case
TASK_TRIGGER_STAT_PAUSED
:
{
smaDebug
(
"vgId:%d, not fetch rsma level %"
PRIi8
" data for table:%"
PRIi64
" since stat is paused"
,
SMA_VID
(
pSma
),
pItem
->
level
,
pItem
->
pRsmaInfo
->
suid
);
}
break
;
case
TASK_TRIGGER_STAT_INACTIVE
:
{
smaDebug
(
"vgId:%d, not fetch rsma level %"
PRIi8
" data for table:%"
PRIi64
" since stat is inactive"
,
SMA_VID
(
pSma
),
pItem
->
level
,
pItem
->
pRsmaInfo
->
suid
);
}
break
;
case
TASK_TRIGGER_STAT_INIT
:
{
smaDebug
(
"vgId:%d, not fetch rsma level %"
PRIi8
" data for table:%"
PRIi64
" since stat is init"
,
SMA_VID
(
pSma
),
pItem
->
level
,
pItem
->
pRsmaInfo
->
suid
);
}
break
;
default:
{
smaWarn
(
"vgId:%d, not fetch rsma level %"
PRIi8
" data for table:%"
PRIi64
" since stat is unknown"
,
SMA_VID
(
pSma
),
pItem
->
level
,
pItem
->
pRsmaInfo
->
suid
);
}
break
;
}
_end:
taosReleaseRef
(
smaMgmt
.
smaRef
,
pItem
->
refId
);
}
static
int32_t
tdExecuteRSmaImpl
(
SSma
*
pSma
,
const
void
*
pMsg
,
int32_t
inputType
,
SRSmaInfoItem
*
pItem
,
tb_uid_t
suid
,
int8_t
level
)
{
if
(
!
pItem
||
!
pItem
->
taskInfo
)
{
if
(
!
pItem
||
!
pItem
->
taskInfo
)
{
smaDebug
(
"vgId:%d, no qTaskInfo to execute rsma %"
PRIi8
" task for suid:%"
PRIu64
,
SMA_VID
(
pSma
),
level
,
suid
);
smaDebug
(
"vgId:%d, no qTaskInfo to execute rsma %"
PRIi8
" task for suid:%"
PRIu64
,
SMA_VID
(
pSma
),
level
,
suid
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
if
(
!
pTSchema
)
{
smaWarn
(
"vgId:%d, no schema to execute rsma %"
PRIi8
" task for suid:%"
PRIu64
,
SMA_VID
(
pSma
),
level
,
suid
);
return
TSDB_CODE_FAILED
;
}
smaDebug
(
"vgId:%d, execute rsma %"
PRIi8
" task for qTaskInfo:%p suid:%"
PRIu64
,
SMA_VID
(
pSma
),
level
,
smaDebug
(
"vgId:%d, execute rsma %"
PRIi8
" task for qTaskInfo:%p suid:%"
PRIu64
,
SMA_VID
(
pSma
),
level
,
pItem
->
taskInfo
,
suid
);
pItem
->
taskInfo
,
suid
);
...
@@ -683,14 +619,14 @@ static int32_t tdExecuteRSmaImpl(SSma *pSma, const void *pMsg, int32_t inputType
...
@@ -683,14 +619,14 @@ static int32_t tdExecuteRSmaImpl(SSma *pSma, const void *pMsg, int32_t inputType
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
tdFetchAndSubmitRSmaResult
(
pItem
,
STREAM_INPUT__DATA_SUBMIT
);
atomic_store_8
(
&
pItem
->
triggerStat
,
TASK_TRIGGER_STAT_ACTIVE
);
SSmaEnv
*
pEnv
=
SMA_RSMA_ENV
(
pSma
);
SSmaEnv
*
pEnv
=
SMA_RSMA_ENV
(
pSma
);
SRSmaStat
*
pStat
=
SMA_RSMA_STAT
(
pEnv
->
pStat
);
SRSmaStat
*
pStat
=
SMA_RSMA_STAT
(
pEnv
->
pStat
);
if
(
pStat
->
tmrHandle
)
{
tdRSmaFetchAndSubmitResult
(
pItem
,
pTSchema
,
suid
,
pStat
,
STREAM_INPUT__DATA_SUBMIT
);
taosTmrReset
(
tdRSmaFetchTrigger
,
pItem
->
maxDelay
,
pItem
,
pStat
->
tmrHandle
,
&
pItem
->
tmrId
);
atomic_store_8
(
&
pItem
->
triggerStat
,
TASK_TRIGGER_STAT_ACTIVE
);
if
(
smaMgmt
.
tmrHandle
)
{
taosTmrReset
(
tdRSmaFetchTrigger
,
pItem
->
maxDelay
,
pItem
,
smaMgmt
.
tmrHandle
,
&
pItem
->
tmrId
);
}
else
{
}
else
{
ASSERT
(
0
);
ASSERT
(
0
);
}
}
...
@@ -698,19 +634,29 @@ static int32_t tdExecuteRSmaImpl(SSma *pSma, const void *pMsg, int32_t inputType
...
@@ -698,19 +634,29 @@ static int32_t tdExecuteRSmaImpl(SSma *pSma, const void *pMsg, int32_t inputType
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
tdExecuteRSma
(
SSma
*
pSma
,
const
void
*
pMsg
,
int32_t
inputType
,
tb_uid_t
suid
)
{
static
SRSmaInfo
*
tdGetRSmaInfoBySuid
(
SSma
*
pSma
,
int64_t
suid
)
{
SSmaEnv
*
pEnv
=
SMA_RSMA_ENV
(
pSma
);
SSmaEnv
*
pEnv
=
SMA_RSMA_ENV
(
pSma
);
SRSmaStat
*
pStat
=
NULL
;
if
(
!
pEnv
)
{
if
(
!
pEnv
)
{
// only applicable when rsma env exists
// only applicable when rsma env exists
return
TSDB_CODE_SUCCESS
;
return
NULL
;
}
}
SRSmaStat
*
pStat
=
(
SRSmaStat
*
)
SMA_ENV_STAT
(
pEnv
);
pStat
=
(
SRSmaStat
*
)
SMA_ENV_STAT
(
pEnv
);
SRSmaInfo
*
pRSmaInfo
=
NULL
;
if
(
!
pStat
||
!
RSMA_INFO_HASH
(
pStat
))
{
return
NULL
;
pRSmaInfo
=
taosHashGet
(
RSMA_INFO_HASH
(
pStat
),
&
suid
,
sizeof
(
tb_uid_t
));
}
SRSmaInfo
*
pRSmaInfo
=
taosHashGet
(
RSMA_INFO_HASH
(
pStat
),
&
suid
,
sizeof
(
tb_uid_t
));
if
(
!
pRSmaInfo
||
!
(
pRSmaInfo
=
*
(
SRSmaInfo
**
)
pRSmaInfo
))
{
if
(
!
pRSmaInfo
||
!
(
pRSmaInfo
=
*
(
SRSmaInfo
**
)
pRSmaInfo
))
{
return
NULL
;
}
return
pRSmaInfo
;
}
static
int32_t
tdExecuteRSma
(
SSma
*
pSma
,
const
void
*
pMsg
,
int32_t
inputType
,
tb_uid_t
suid
)
{
SRSmaInfo
*
pRSmaInfo
=
tdGetRSmaInfoBySuid
(
pSma
,
suid
);
if
(
!
pRSmaInfo
)
{
smaDebug
(
"vgId:%d, return as no rsma info for suid:%"
PRIu64
,
SMA_VID
(
pSma
),
suid
);
smaDebug
(
"vgId:%d, return as no rsma info for suid:%"
PRIu64
,
SMA_VID
(
pSma
),
suid
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -721,8 +667,8 @@ static int32_t tdExecuteRSma(SSma *pSma, const void *pMsg, int32_t inputType, tb
...
@@ -721,8 +667,8 @@ static int32_t tdExecuteRSma(SSma *pSma, const void *pMsg, int32_t inputType, tb
}
}
if
(
inputType
==
STREAM_INPUT__DATA_SUBMIT
)
{
if
(
inputType
==
STREAM_INPUT__DATA_SUBMIT
)
{
tdExecuteRSmaImpl
(
pSma
,
pMsg
,
inputType
,
&
pRSmaInfo
->
items
[
0
],
suid
,
TSDB_RETENTION_L1
);
tdExecuteRSmaImpl
(
pSma
,
pMsg
,
inputType
,
&
pRSmaInfo
->
items
[
0
],
pRSmaInfo
->
pTSchema
,
suid
,
TSDB_RETENTION_L1
);
tdExecuteRSmaImpl
(
pSma
,
pMsg
,
inputType
,
&
pRSmaInfo
->
items
[
1
],
suid
,
TSDB_RETENTION_L2
);
tdExecuteRSmaImpl
(
pSma
,
pMsg
,
inputType
,
&
pRSmaInfo
->
items
[
1
],
pRSmaInfo
->
pTSchema
,
suid
,
TSDB_RETENTION_L2
);
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -935,13 +881,11 @@ _err:
...
@@ -935,13 +881,11 @@ _err:
}
}
static
int32_t
tdRSmaQTaskInfoItemRestore
(
SSma
*
pSma
,
const
SRSmaQTaskInfoItem
*
pItem
)
{
static
int32_t
tdRSmaQTaskInfoItemRestore
(
SSma
*
pSma
,
const
SRSmaQTaskInfoItem
*
pItem
)
{
SRSmaStat
*
pStat
=
(
SRSmaStat
*
)
SMA_ENV_STAT
((
SSmaEnv
*
)
pSma
->
pRSmaEnv
);
SRSmaInfo
*
pRSmaInfo
=
NULL
;
SRSmaInfo
*
pRSmaInfo
=
NULL
;
void
*
qTaskInfo
=
NULL
;
void
*
qTaskInfo
=
NULL
;
pRSmaInfo
=
taosHashGet
(
RSMA_INFO_HASH
(
pStat
),
&
pItem
->
suid
,
sizeof
(
pItem
->
suid
));
pRSmaInfo
=
tdGetRSmaInfoBySuid
(
pSma
,
pItem
->
suid
);
if
(
!
pRSmaInfo
)
{
if
(
!
pRSmaInfo
||
!
(
pRSmaInfo
=
*
(
SRSmaInfo
**
)
pRSmaInfo
))
{
smaDebug
(
"vgId:%d, no restore as no rsma info for table:%"
PRIu64
,
SMA_VID
(
pSma
),
pItem
->
suid
);
smaDebug
(
"vgId:%d, no restore as no rsma info for table:%"
PRIu64
,
SMA_VID
(
pSma
),
pItem
->
suid
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -1258,7 +1202,8 @@ _end:
...
@@ -1258,7 +1202,8 @@ _end:
}
}
atomic_store_8
(
RSMA_RUNNING_STAT
(
pRSmaStat
),
0
);
atomic_store_8
(
RSMA_RUNNING_STAT
(
pRSmaStat
),
0
);
taosReleaseRef
(
smaMgmt
.
smaRef
,
pRSmaStat
->
refId
);
smaDebug
(
"vgId:%d, release rsetId rsetId:%"
PRIi64
" refId:%d"
,
SMA_VID
(
pSma
),
smaMgmt
.
rsetId
,
pRSmaStat
->
refId
);
tdReleaseSmaRef
(
smaMgmt
.
rsetId
,
pRSmaStat
->
refId
,
__func__
,
__LINE__
);
taosThreadExit
(
NULL
);
taosThreadExit
(
NULL
);
return
NULL
;
return
NULL
;
}
}
...
@@ -1283,7 +1228,9 @@ static void tdRSmaPersistTask(SRSmaStat *pRSmaStat) {
...
@@ -1283,7 +1228,9 @@ static void tdRSmaPersistTask(SRSmaStat *pRSmaStat) {
atomic_load_8
(
RSMA_TRIGGER_STAT
(
pRSmaStat
)));
atomic_load_8
(
RSMA_TRIGGER_STAT
(
pRSmaStat
)));
}
}
atomic_store_8
(
RSMA_RUNNING_STAT
(
pRSmaStat
),
0
);
atomic_store_8
(
RSMA_RUNNING_STAT
(
pRSmaStat
),
0
);
taosReleaseRef
(
smaMgmt
.
smaRef
,
pRSmaStat
->
refId
);
smaDebug
(
"vgId:%d, release rsetId rsetId:%"
PRIi64
" refId:%d)"
,
SMA_VID
(
pRSmaStat
->
pSma
),
smaMgmt
.
rsetId
,
pRSmaStat
->
refId
);
tdReleaseSmaRef
(
smaMgmt
.
rsetId
,
pRSmaStat
->
refId
,
__func__
,
__LINE__
);
}
}
taosThreadAttrDestroy
(
&
thAttr
);
taosThreadAttrDestroy
(
&
thAttr
);
...
@@ -1297,8 +1244,8 @@ static void tdRSmaPersistTask(SRSmaStat *pRSmaStat) {
...
@@ -1297,8 +1244,8 @@ static void tdRSmaPersistTask(SRSmaStat *pRSmaStat) {
*/
*/
static
void
tdRSmaPersistTrigger
(
void
*
param
,
void
*
tmrId
)
{
static
void
tdRSmaPersistTrigger
(
void
*
param
,
void
*
tmrId
)
{
SRSmaStat
*
rsmaStat
=
param
;
SRSmaStat
*
rsmaStat
=
param
;
SRSmaStat
*
pRSmaStat
=
(
SRSmaStat
*
)
taosAcquireRef
(
smaMgmt
.
smaRef
,
rsmaStat
->
refId
);
SRSmaStat
*
pRSmaStat
=
(
SRSmaStat
*
)
taosAcquireRef
(
smaMgmt
.
rsetId
,
rsmaStat
->
refId
);
ASSERT
(
0
);
if
(
!
pRSmaStat
)
{
if
(
!
pRSmaStat
)
{
smaDebug
(
"rsma persistence task not start since already destroyed"
);
smaDebug
(
"rsma persistence task not start since already destroyed"
);
return
;
return
;
...
@@ -1341,5 +1288,81 @@ static void tdRSmaPersistTrigger(void *param, void *tmrId) {
...
@@ -1341,5 +1288,81 @@ static void tdRSmaPersistTrigger(void *param, void *tmrId) {
smaWarn
(
"rsma persistence not start since unknown stat %"
PRIi8
,
tmrStat
);
smaWarn
(
"rsma persistence not start since unknown stat %"
PRIi8
,
tmrStat
);
}
break
;
}
break
;
}
}
taosReleaseRef
(
smaMgmt
.
smaRef
,
rsmaStat
->
refId
);
taosReleaseRef
(
smaMgmt
.
rsetId
,
rsmaStat
->
refId
);
}
/**
* @brief trigger to get rsma result
*
* @param param
* @param tmrId
*/
static
void
tdRSmaFetchTrigger
(
void
*
param
,
void
*
tmrId
)
{
SRSmaInfoItem
*
pItem
=
param
;
SSma
*
pSma
=
NULL
;
SRSmaStat
*
pStat
=
(
SRSmaStat
*
)
tdAcquireSmaRef
(
smaMgmt
.
rsetId
,
pItem
->
refId
,
__func__
,
__LINE__
);
if
(
!
pStat
)
{
smaDebug
(
"rsma fetch task not start since already destroyed, rsetId rsetId:%"
PRIi64
" refId:%d)"
,
smaMgmt
.
rsetId
,
pItem
->
refId
);
return
;
}
pSma
=
pStat
->
pSma
;
// if rsma trigger stat in paused, cancelled or finished, not start fetch task
int8_t
rsmaTriggerStat
=
atomic_load_8
(
RSMA_TRIGGER_STAT
(
pStat
));
switch
(
rsmaTriggerStat
)
{
case
TASK_TRIGGER_STAT_PAUSED
:
case
TASK_TRIGGER_STAT_CANCELLED
:
case
TASK_TRIGGER_STAT_FINISHED
:
{
tdReleaseSmaRef
(
smaMgmt
.
rsetId
,
pItem
->
refId
,
__func__
,
__LINE__
);
smaDebug
(
"vgId:%d, not fetch rsma level %"
PRIi8
" data since stat is %"
PRIi8
", rsetId rsetId:%"
PRIi64
" refId:%d"
,
SMA_VID
(
pSma
),
pItem
->
level
,
rsmaTriggerStat
,
smaMgmt
.
rsetId
,
pItem
->
refId
);
return
;
}
default:
break
;
}
SRSmaInfo
*
pRSmaInfo
=
tdGetRSmaInfoByItem
(
pItem
);
ASSERT
(
pRSmaInfo
->
suid
>
0
);
int8_t
fetchTriggerStat
=
atomic_val_compare_exchange_8
(
&
pItem
->
triggerStat
,
TASK_TRIGGER_STAT_ACTIVE
,
TASK_TRIGGER_STAT_INACTIVE
);
switch
(
fetchTriggerStat
)
{
case
TASK_TRIGGER_STAT_ACTIVE
:
{
smaDebug
(
"vgId:%d, fetch rsma level %"
PRIi8
" data for table:%"
PRIi64
" since stat is active"
,
SMA_VID
(
pSma
),
pItem
->
level
,
pRSmaInfo
->
suid
);
tdRefSmaStat
(
pSma
,
(
SSmaStat
*
)
pStat
);
SSDataBlock
dataBlock
=
{.
info
.
type
=
STREAM_GET_ALL
};
qSetStreamInput
(
pItem
->
taskInfo
,
&
dataBlock
,
STREAM_INPUT__DATA_BLOCK
,
false
);
tdRSmaFetchAndSubmitResult
(
pItem
,
pRSmaInfo
->
pTSchema
,
pRSmaInfo
->
suid
,
pStat
,
STREAM_INPUT__DATA_BLOCK
);
tdUnRefSmaStat
(
pSma
,
(
SSmaStat
*
)
pStat
);
}
break
;
case
TASK_TRIGGER_STAT_PAUSED
:
{
smaDebug
(
"vgId:%d, not fetch rsma level %"
PRIi8
" data for table:%"
PRIi64
" since stat is paused"
,
SMA_VID
(
pSma
),
pItem
->
level
,
pRSmaInfo
->
suid
);
}
break
;
case
TASK_TRIGGER_STAT_INACTIVE
:
{
smaDebug
(
"vgId:%d, not fetch rsma level %"
PRIi8
" data for table:%"
PRIi64
" since stat is inactive"
,
SMA_VID
(
pSma
),
pItem
->
level
,
pRSmaInfo
->
suid
);
}
break
;
case
TASK_TRIGGER_STAT_INIT
:
{
smaDebug
(
"vgId:%d, not fetch rsma level %"
PRIi8
" data for table:%"
PRIi64
" since stat is init"
,
SMA_VID
(
pSma
),
pItem
->
level
,
pRSmaInfo
->
suid
);
}
break
;
default:
{
smaWarn
(
"vgId:%d, not fetch rsma level %"
PRIi8
" data for table:%"
PRIi64
" since stat is unknown"
,
SMA_VID
(
pSma
),
pItem
->
level
,
pRSmaInfo
->
suid
);
}
break
;
}
_end:
tdReleaseSmaRef
(
smaMgmt
.
rsetId
,
pItem
->
refId
,
__func__
,
__LINE__
);
}
}
source/dnode/vnode/src/sma/smaTimeRange.c
浏览文件 @
e77931f1
...
@@ -20,6 +20,36 @@
...
@@ -20,6 +20,36 @@
#define SMA_STORAGE_MINUTES_DAY 1440
#define SMA_STORAGE_MINUTES_DAY 1440
#define SMA_STORAGE_SPLIT_FACTOR 14400 // least records in tsma file
#define SMA_STORAGE_SPLIT_FACTOR 14400 // least records in tsma file
// TODO: Who is responsible for resource allocate and release?
int32_t
tdProcessTSmaInsert
(
SSma
*
pSma
,
int64_t
indexUid
,
const
char
*
msg
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
if
((
code
=
tdProcessTSmaInsertImpl
(
pSma
,
indexUid
,
msg
))
<
0
)
{
smaWarn
(
"vgId:%d, insert tsma data failed since %s"
,
SMA_VID
(
pSma
),
tstrerror
(
terrno
));
}
// TODO: destroy SSDataBlocks(msg)
return
code
;
}
int32_t
tdProcessTSmaCreate
(
SSma
*
pSma
,
int64_t
version
,
const
char
*
msg
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
if
((
code
=
tdProcessTSmaCreateImpl
(
pSma
,
version
,
msg
))
<
0
)
{
smaWarn
(
"vgId:%d, create tsma failed since %s"
,
SMA_VID
(
pSma
),
tstrerror
(
terrno
));
}
// TODO: destroy SSDataBlocks(msg)
return
code
;
}
int32_t
smaGetTSmaDays
(
SVnodeCfg
*
pCfg
,
void
*
pCont
,
uint32_t
contLen
,
int32_t
*
days
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
if
((
code
=
tdProcessTSmaGetDaysImpl
(
pCfg
,
pCont
,
contLen
,
days
))
<
0
)
{
smaWarn
(
"vgId:%d, get tsma days failed since %s"
,
pCfg
->
vgId
,
tstrerror
(
terrno
));
}
smaDebug
(
"vgId:%d, get tsma days %d"
,
pCfg
->
vgId
,
*
days
);
return
code
;
}
/**
/**
* @brief Judge the tsma file split days
* @brief Judge the tsma file split days
*
*
...
...
source/dnode/vnode/src/sma/smaUtil.c
浏览文件 @
e77931f1
...
@@ -294,4 +294,23 @@ int32_t tdRemoveTFile(STFile *pTFile) {
...
@@ -294,4 +294,23 @@ int32_t tdRemoveTFile(STFile *pTFile) {
}
}
// smaXXXUtil ================
// smaXXXUtil ================
void
*
tdAcquireSmaRef
(
int32_t
rsetId
,
int64_t
refId
,
const
char
*
tags
,
int32_t
ln
)
{
void
*
pResult
=
taosAcquireRef
(
rsetId
,
refId
);
if
(
!
pResult
)
{
smaWarn
(
"%s:%d taosAcquireRef for rsetId:%"
PRIi64
" refId:%d failed since %s"
,
tags
,
ln
,
rsetId
,
refId
,
terrstr
());
}
else
{
smaDebug
(
"%s:%d taosAcquireRef for rsetId:%"
PRIi64
" refId:%d success"
,
tags
,
ln
,
rsetId
,
refId
);
}
return
pResult
;
}
int32_t
tdReleaseSmaRef
(
int32_t
rsetId
,
int64_t
refId
,
const
char
*
tags
,
int32_t
ln
)
{
if
(
taosReleaseRef
(
rsetId
,
refId
)
<
0
)
{
smaWarn
(
"%s:%d taosReleaseRef for rsetId:%"
PRIi64
" refId:%d failed since %s"
,
tags
,
ln
,
rsetId
,
refId
,
terrstr
());
return
TSDB_CODE_FAILED
;
}
smaDebug
(
"%s:%d taosReleaseRef for rsetId:%"
PRIi64
" refId:%d success"
,
tags
,
ln
,
rsetId
,
refId
);
return
TSDB_CODE_SUCCESS
;
}
// ...
// ...
\ No newline at end of file
source/dnode/vnode/src/tq/tq.c
浏览文件 @
e77931f1
...
@@ -112,7 +112,8 @@ int32_t tqSendMetaPollRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq,
...
@@ -112,7 +112,8 @@ int32_t tqSendMetaPollRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq,
};
};
tmsgSendRsp
(
&
resp
);
tmsgSendRsp
(
&
resp
);
tqDebug
(
"vg %d from consumer %ld (epoch %d) send rsp, res msg type %d, reqOffset: %ld, rspOffset: %ld"
,
tqDebug
(
"vgId:%d from consumer:%"
PRId64
", (epoch %d) send rsp, res msg type %d, reqOffset:%"
PRId64
", rspOffset:%"
PRId64
,
TD_VID
(
pTq
->
pVnode
),
pReq
->
consumerId
,
pReq
->
epoch
,
pRsp
->
resMsgType
,
pRsp
->
reqOffset
,
pRsp
->
rspOffset
);
TD_VID
(
pTq
->
pVnode
),
pReq
->
consumerId
,
pReq
->
epoch
,
pRsp
->
resMsgType
,
pRsp
->
reqOffset
,
pRsp
->
rspOffset
);
return
0
;
return
0
;
...
@@ -162,7 +163,7 @@ int32_t tqSendDataRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq, con
...
@@ -162,7 +163,7 @@ int32_t tqSendDataRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq, con
char
buf2
[
80
];
char
buf2
[
80
];
tFormatOffset
(
buf1
,
80
,
&
pRsp
->
reqOffset
);
tFormatOffset
(
buf1
,
80
,
&
pRsp
->
reqOffset
);
tFormatOffset
(
buf2
,
80
,
&
pRsp
->
rspOffset
);
tFormatOffset
(
buf2
,
80
,
&
pRsp
->
rspOffset
);
tqDebug
(
"vg
%d from consumer %ld (epoch %d) send rsp, block num: %d, reqOffset: %s, rspOffset:
%s"
,
tqDebug
(
"vg
Id:%d from consumer:%"
PRId64
", (epoch %d) send rsp, block num: %d, reqOffset:%s, rspOffset:
%s"
,
TD_VID
(
pTq
->
pVnode
),
pReq
->
consumerId
,
pReq
->
epoch
,
pRsp
->
blockNum
,
buf1
,
buf2
);
TD_VID
(
pTq
->
pVnode
),
pReq
->
consumerId
,
pReq
->
epoch
,
pRsp
->
blockNum
,
buf1
,
buf2
);
return
0
;
return
0
;
...
@@ -179,10 +180,10 @@ int32_t tqProcessOffsetCommitReq(STQ* pTq, char* msg, int32_t msgLen) {
...
@@ -179,10 +180,10 @@ int32_t tqProcessOffsetCommitReq(STQ* pTq, char* msg, int32_t msgLen) {
tDecoderClear
(
&
decoder
);
tDecoderClear
(
&
decoder
);
if
(
offset
.
val
.
type
==
TMQ_OFFSET__SNAPSHOT_DATA
)
{
if
(
offset
.
val
.
type
==
TMQ_OFFSET__SNAPSHOT_DATA
)
{
tqDebug
(
"receive offset commit msg to %s on vg
%d, offset(type:snapshot) uid: %ld, ts: %ld"
,
offset
.
subKey
,
tqDebug
(
"receive offset commit msg to %s on vg
Id:%d, offset(type:snapshot) uid:%"
PRId64
", ts:%"
PRId64
,
TD_VID
(
pTq
->
pVnode
),
offset
.
val
.
uid
,
offset
.
val
.
ts
);
offset
.
subKey
,
TD_VID
(
pTq
->
pVnode
),
offset
.
val
.
uid
,
offset
.
val
.
ts
);
}
else
if
(
offset
.
val
.
type
==
TMQ_OFFSET__LOG
)
{
}
else
if
(
offset
.
val
.
type
==
TMQ_OFFSET__LOG
)
{
tqDebug
(
"receive offset commit msg to %s on vg
%d, offset(type:log) version: %ld"
,
offset
.
subKey
,
tqDebug
(
"receive offset commit msg to %s on vg
Id:%d, offset(type:log) version:%"
PRId64
,
offset
.
subKey
,
TD_VID
(
pTq
->
pVnode
),
offset
.
val
.
version
);
TD_VID
(
pTq
->
pVnode
),
offset
.
val
.
version
);
}
else
{
}
else
{
ASSERT
(
0
);
ASSERT
(
0
);
...
@@ -244,22 +245,18 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
...
@@ -244,22 +245,18 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
STqOffsetVal
fetchOffsetNew
;
STqOffsetVal
fetchOffsetNew
;
// 1.find handle
// 1.find handle
char
buf
[
80
];
tFormatOffset
(
buf
,
80
,
&
reqOffset
);
tqDebug
(
"tmq poll: consumer %ld (epoch %d) recv poll req in vg %d, req offset %s"
,
consumerId
,
pReq
->
epoch
,
TD_VID
(
pTq
->
pVnode
),
buf
);
STqHandle
*
pHandle
=
taosHashGet
(
pTq
->
handles
,
pReq
->
subKey
,
strlen
(
pReq
->
subKey
));
STqHandle
*
pHandle
=
taosHashGet
(
pTq
->
handles
,
pReq
->
subKey
,
strlen
(
pReq
->
subKey
));
/*ASSERT(pHandle);*/
/*ASSERT(pHandle);*/
if
(
pHandle
==
NULL
)
{
if
(
pHandle
==
NULL
)
{
tqError
(
"tmq poll: no consumer handle for consumer
%ld in vg %d, subkey %s"
,
consumerId
,
TD_VID
(
pTq
->
pVnode
)
,
tqError
(
"tmq poll: no consumer handle for consumer
:%"
PRId64
", in vgId:%d, subkey %s"
,
consumerId
,
pReq
->
subKey
);
TD_VID
(
pTq
->
pVnode
),
pReq
->
subKey
);
return
-
1
;
return
-
1
;
}
}
// check rebalance
// check rebalance
if
(
pHandle
->
consumerId
!=
consumerId
)
{
if
(
pHandle
->
consumerId
!=
consumerId
)
{
tqError
(
"tmq poll: consumer handle mismatch for consumer %ld in vg %d, subkey %s, handle consumer id %ld"
,
tqError
(
"tmq poll: consumer handle mismatch for consumer:%"
PRId64
", in vgId:%d, subkey %s, handle consumer id %"
PRId64
,
consumerId
,
TD_VID
(
pTq
->
pVnode
),
pReq
->
subKey
,
pHandle
->
consumerId
);
consumerId
,
TD_VID
(
pTq
->
pVnode
),
pReq
->
subKey
,
pHandle
->
consumerId
);
return
-
1
;
return
-
1
;
}
}
...
@@ -270,6 +267,14 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
...
@@ -270,6 +267,14 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
consumerEpoch
=
atomic_val_compare_exchange_32
(
&
pHandle
->
epoch
,
consumerEpoch
,
reqEpoch
);
consumerEpoch
=
atomic_val_compare_exchange_32
(
&
pHandle
->
epoch
,
consumerEpoch
,
reqEpoch
);
}
}
char
buf
[
80
];
tFormatOffset
(
buf
,
80
,
&
reqOffset
);
tqDebug
(
"tmq poll: consumer %ld (epoch %d), subkey %s, recv poll req in vg %d, req offset %s"
,
consumerId
,
pReq
->
epoch
,
pHandle
->
subKey
,
TD_VID
(
pTq
->
pVnode
),
buf
);
SMqDataRsp
dataRsp
=
{
0
};
tqInitDataRsp
(
&
dataRsp
,
pReq
,
pHandle
->
execHandle
.
subType
);
// 2.reset offset if needed
// 2.reset offset if needed
if
(
reqOffset
.
type
>
0
)
{
if
(
reqOffset
.
type
>
0
)
{
fetchOffsetNew
=
reqOffset
;
fetchOffsetNew
=
reqOffset
;
...
@@ -279,7 +284,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
...
@@ -279,7 +284,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
fetchOffsetNew
=
pOffset
->
val
;
fetchOffsetNew
=
pOffset
->
val
;
char
formatBuf
[
80
];
char
formatBuf
[
80
];
tFormatOffset
(
formatBuf
,
80
,
&
fetchOffsetNew
);
tFormatOffset
(
formatBuf
,
80
,
&
fetchOffsetNew
);
tqDebug
(
"tmq poll: consumer %
ld, offset reset to %s"
,
consumerId
,
formatBuf
);
tqDebug
(
"tmq poll: consumer %
"
PRId64
", subkey %s, offset reset to %s"
,
consumerId
,
pHandle
->
subKey
,
formatBuf
);
}
else
{
}
else
{
if
(
reqOffset
.
type
==
TMQ_OFFSET__RESET_EARLIEAST
)
{
if
(
reqOffset
.
type
==
TMQ_OFFSET__RESET_EARLIEAST
)
{
if
(
pReq
->
useSnapshot
&&
pHandle
->
execHandle
.
subType
==
TOPIC_SUB_TYPE__COLUMN
)
{
if
(
pReq
->
useSnapshot
&&
pHandle
->
execHandle
.
subType
==
TOPIC_SUB_TYPE__COLUMN
)
{
...
@@ -293,25 +298,50 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
...
@@ -293,25 +298,50 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
tqOffsetResetToLog
(
&
fetchOffsetNew
,
walGetFirstVer
(
pTq
->
pVnode
->
pWal
));
tqOffsetResetToLog
(
&
fetchOffsetNew
,
walGetFirstVer
(
pTq
->
pVnode
->
pWal
));
}
}
}
else
if
(
reqOffset
.
type
==
TMQ_OFFSET__RESET_LATEST
)
{
}
else
if
(
reqOffset
.
type
==
TMQ_OFFSET__RESET_LATEST
)
{
tqOffsetResetToLog
(
&
fetchOffsetNew
,
walGetLastVer
(
pTq
->
pVnode
->
pWal
));
tqOffsetResetToLog
(
&
dataRsp
.
rspOffset
,
walGetLastVer
(
pTq
->
pVnode
->
pWal
));
tqDebug
(
"tmq poll: consumer %ld, subkey %s, offset reset to %ld"
,
consumerId
,
pHandle
->
subKey
,
dataRsp
.
rspOffset
.
version
);
if
(
tqSendDataRsp
(
pTq
,
pMsg
,
pReq
,
&
dataRsp
)
<
0
)
{
code
=
-
1
;
}
goto
OVER
;
}
else
if
(
reqOffset
.
type
==
TMQ_OFFSET__RESET_NONE
)
{
}
else
if
(
reqOffset
.
type
==
TMQ_OFFSET__RESET_NONE
)
{
tqError
(
"tmq poll: no offset committed for consumer %ld in vg %d, subkey %s, reset none failed"
,
consumerId
,
tqError
(
"tmq poll: subkey %s, no offset committed for consumer %"
PRId64
TD_VID
(
pTq
->
pVnode
),
pReq
->
subKey
);
" in vg %d, subkey %s, reset none failed"
,
pHandle
->
subKey
,
consumerId
,
TD_VID
(
pTq
->
pVnode
),
pReq
->
subKey
);
terrno
=
TSDB_CODE_TQ_NO_COMMITTED_OFFSET
;
terrno
=
TSDB_CODE_TQ_NO_COMMITTED_OFFSET
;
return
-
1
;
code
=
-
1
;
goto
OVER
;
}
}
}
}
}
}
// 3.query
// 3.query
SMqDataRsp
dataRsp
=
{
0
};
if
(
pHandle
->
execHandle
.
subType
==
TOPIC_SUB_TYPE__COLUMN
)
{
tqInitDataRsp
(
&
dataRsp
,
pReq
,
pHandle
->
execHandle
.
subType
);
if
(
fetchOffsetNew
.
type
==
TMQ_OFFSET__LOG
)
{
fetchOffsetNew
.
version
++
;
}
if
(
tqScan
(
pTq
,
&
pHandle
->
execHandle
,
&
dataRsp
,
&
fetchOffsetNew
)
<
0
)
{
ASSERT
(
0
);
code
=
-
1
;
goto
OVER
;
}
if
(
dataRsp
.
blockNum
==
0
)
{
// TODO add to async task pool
/*dataRsp.rspOffset.version--;*/
}
if
(
tqSendDataRsp
(
pTq
,
pMsg
,
pReq
,
&
dataRsp
)
<
0
)
{
code
=
-
1
;
}
goto
OVER
;
}
if
(
fetchOffsetNew
.
type
==
TMQ_OFFSET__LOG
)
{
if
(
pHandle
->
execHandle
.
subType
!=
TOPIC_SUB_TYPE__COLUMN
)
{
int64_t
fetchVer
=
fetchOffsetNew
.
version
+
1
;
int64_t
fetchVer
=
fetchOffsetNew
.
version
+
1
;
SWalCkHead
*
pCkHead
=
taosMemoryMalloc
(
sizeof
(
SWalCkHead
)
+
2048
);
SWalCkHead
*
pCkHead
=
taosMemoryMalloc
(
sizeof
(
SWalCkHead
)
+
2048
);
if
(
pCkHead
==
NULL
)
{
if
(
pCkHead
==
NULL
)
{
return
-
1
;
code
=
-
1
;
goto
OVER
;
}
}
walSetReaderCapacity
(
pHandle
->
pWalReader
,
2048
);
walSetReaderCapacity
(
pHandle
->
pWalReader
,
2048
);
...
@@ -319,8 +349,9 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
...
@@ -319,8 +349,9 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
while
(
1
)
{
while
(
1
)
{
consumerEpoch
=
atomic_load_32
(
&
pHandle
->
epoch
);
consumerEpoch
=
atomic_load_32
(
&
pHandle
->
epoch
);
if
(
consumerEpoch
>
reqEpoch
)
{
if
(
consumerEpoch
>
reqEpoch
)
{
tqWarn
(
"tmq poll: consumer %ld (epoch %d) vg %d offset %ld, found new consumer epoch %d, discard req epoch %d"
,
tqWarn
(
"tmq poll: consumer %ld (epoch %d), subkey %s, vg %d offset %"
PRId64
consumerId
,
pReq
->
epoch
,
TD_VID
(
pTq
->
pVnode
),
fetchVer
,
consumerEpoch
,
reqEpoch
);
", found new consumer epoch %d, discard req epoch %d"
,
consumerId
,
pReq
->
epoch
,
pHandle
->
subKey
,
TD_VID
(
pTq
->
pVnode
),
fetchVer
,
consumerEpoch
,
reqEpoch
);
break
;
break
;
}
}
...
@@ -337,8 +368,8 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
...
@@ -337,8 +368,8 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
SWalCont
*
pHead
=
&
pCkHead
->
head
;
SWalCont
*
pHead
=
&
pCkHead
->
head
;
tqDebug
(
"tmq poll: consumer
%ld (epoch %d) iter log, vg %d offset %ld msgType %d"
,
consumerId
,
pReq
->
epoch
,
tqDebug
(
"tmq poll: consumer
:%"
PRId64
", (epoch %d) iter log, vgId:%d offset %"
PRId64
" msgType %d"
,
consumerId
,
TD_VID
(
pTq
->
pVnode
),
fetchVer
,
pHead
->
msgType
);
pReq
->
epoch
,
TD_VID
(
pTq
->
pVnode
),
fetchVer
,
pHead
->
msgType
);
if
(
pHead
->
msgType
==
TDMT_VND_SUBMIT
)
{
if
(
pHead
->
msgType
==
TDMT_VND_SUBMIT
)
{
SSubmitReq
*
pCont
=
(
SSubmitReq
*
)
&
pHead
->
body
;
SSubmitReq
*
pCont
=
(
SSubmitReq
*
)
&
pHead
->
body
;
...
@@ -363,7 +394,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
...
@@ -363,7 +394,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
}
else
{
}
else
{
ASSERT
(
pHandle
->
fetchMeta
);
ASSERT
(
pHandle
->
fetchMeta
);
ASSERT
(
IS_META_MSG
(
pHead
->
msgType
));
ASSERT
(
IS_META_MSG
(
pHead
->
msgType
));
tqInfo
(
"fetch meta msg, ver:
%ld, type:
%d"
,
pHead
->
version
,
pHead
->
msgType
);
tqInfo
(
"fetch meta msg, ver:
%"
PRId64
", type:
%d"
,
pHead
->
version
,
pHead
->
msgType
);
SMqMetaRsp
metaRsp
=
{
0
};
SMqMetaRsp
metaRsp
=
{
0
};
/*metaRsp.reqOffset = pReq->reqOffset.version;*/
/*metaRsp.reqOffset = pReq->reqOffset.version;*/
/*metaRsp.rspOffset = fetchVer;*/
/*metaRsp.rspOffset = fetchVer;*/
...
@@ -383,8 +414,9 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
...
@@ -383,8 +414,9 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
}
}
taosMemoryFree
(
pCkHead
);
taosMemoryFree
(
pCkHead
);
#if 0
} else if (fetchOffsetNew.type == TMQ_OFFSET__SNAPSHOT_DATA) {
} else if (fetchOffsetNew.type == TMQ_OFFSET__SNAPSHOT_DATA) {
tqInfo
(
"retrieve using snapshot actual offset: uid %
ld ts %ld"
,
fetchOffsetNew
.
uid
,
fetchOffsetNew
.
ts
);
tqInfo("retrieve using snapshot actual offset: uid %
" PRId64 " ts %" PRId64
, fetchOffsetNew.uid, fetchOffsetNew.ts);
if (tqScanSnapshot(pTq, &pHandle->execHandle, &dataRsp, fetchOffsetNew, workerId) < 0) {
if (tqScanSnapshot(pTq, &pHandle->execHandle, &dataRsp, fetchOffsetNew, workerId) < 0) {
ASSERT(0);
ASSERT(0);
}
}
...
@@ -393,6 +425,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
...
@@ -393,6 +425,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
if (tqSendDataRsp(pTq, pMsg, pReq, &dataRsp) < 0) {
if (tqSendDataRsp(pTq, pMsg, pReq, &dataRsp) < 0) {
code = -1;
code = -1;
}
}
#endif
}
else
if
(
fetchOffsetNew
.
type
==
TMQ_OFFSET__SNAPSHOT_META
)
{
}
else
if
(
fetchOffsetNew
.
type
==
TMQ_OFFSET__SNAPSHOT_META
)
{
ASSERT
(
0
);
ASSERT
(
0
);
}
}
...
@@ -482,10 +515,10 @@ int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen) {
...
@@ -482,10 +515,10 @@ int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen) {
pHandle
->
execHandle
.
execTb
.
suid
=
req
.
suid
;
pHandle
->
execHandle
.
execTb
.
suid
=
req
.
suid
;
SArray
*
tbUidList
=
taosArrayInit
(
0
,
sizeof
(
int64_t
));
SArray
*
tbUidList
=
taosArrayInit
(
0
,
sizeof
(
int64_t
));
vnodeGetCtbIdList
(
pTq
->
pVnode
,
req
.
suid
,
tbUidList
);
vnodeGetCtbIdList
(
pTq
->
pVnode
,
req
.
suid
,
tbUidList
);
tqDebug
(
"vg
%d, tq try get suid: %ld"
,
pTq
->
pVnode
->
config
.
vgId
,
req
.
suid
);
tqDebug
(
"vg
Id:%d, tq try get suid:%"
PRId64
,
pTq
->
pVnode
->
config
.
vgId
,
req
.
suid
);
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
tbUidList
);
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
tbUidList
);
i
++
)
{
int64_t
tbUid
=
*
(
int64_t
*
)
taosArrayGet
(
tbUidList
,
i
);
int64_t
tbUid
=
*
(
int64_t
*
)
taosArrayGet
(
tbUidList
,
i
);
tqDebug
(
"vg
%d, idx %d, uid: %ld"
,
TD_VID
(
pTq
->
pVnode
),
i
,
tbUid
);
tqDebug
(
"vg
Id:%d, idx %d, uid:%"
PRId64
,
TD_VID
(
pTq
->
pVnode
),
i
,
tbUid
);
}
}
for
(
int32_t
i
=
0
;
i
<
5
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
5
;
i
++
)
{
tqReaderSetTbUidList
(
pHandle
->
execHandle
.
pExecReader
[
i
],
tbUidList
);
tqReaderSetTbUidList
(
pHandle
->
execHandle
.
pExecReader
[
i
],
tbUidList
);
...
@@ -572,7 +605,7 @@ int32_t tqProcessTaskDeployReq(STQ* pTq, char* msg, int32_t msgLen) {
...
@@ -572,7 +605,7 @@ int32_t tqProcessTaskDeployReq(STQ* pTq, char* msg, int32_t msgLen) {
streamSetupTrigger
(
pTask
);
streamSetupTrigger
(
pTask
);
tqInfo
(
"deploy stream task id %d child id %d on vg
%d"
,
pTask
->
taskId
,
pTask
->
selfChildId
,
TD_VID
(
pTq
->
pVnode
));
tqInfo
(
"deploy stream task id %d child id %d on vg
Id:
%d"
,
pTask
->
taskId
,
pTask
->
selfChildId
,
TD_VID
(
pTq
->
pVnode
));
taosHashPut
(
pTq
->
pStreamTasks
,
&
pTask
->
taskId
,
sizeof
(
int32_t
),
&
pTask
,
sizeof
(
void
*
));
taosHashPut
(
pTq
->
pStreamTasks
,
&
pTask
->
taskId
,
sizeof
(
int32_t
),
&
pTask
,
sizeof
(
void
*
));
...
...
source/dnode/vnode/src/tq/tqExec.c
浏览文件 @
e77931f1
...
@@ -46,7 +46,7 @@ static int32_t tqAddBlockSchemaToRsp(const STqExecHandle* pExec, int32_t workerI
...
@@ -46,7 +46,7 @@ static int32_t tqAddBlockSchemaToRsp(const STqExecHandle* pExec, int32_t workerI
return
0
;
return
0
;
}
}
static
int32_t
tqAddTbNameToRsp
(
const
STQ
*
pTq
,
int64_t
uid
,
SMqDataRsp
*
pRsp
,
int32_t
workerId
)
{
static
int32_t
tqAddTbNameToRsp
(
const
STQ
*
pTq
,
int64_t
uid
,
SMqDataRsp
*
pRsp
)
{
SMetaReader
mr
=
{
0
};
SMetaReader
mr
=
{
0
};
metaReaderInit
(
&
mr
,
pTq
->
pVnode
->
pMeta
,
0
);
metaReaderInit
(
&
mr
,
pTq
->
pVnode
->
pMeta
,
0
);
if
(
metaGetTableEntryByUid
(
&
mr
,
uid
)
<
0
)
{
if
(
metaGetTableEntryByUid
(
&
mr
,
uid
)
<
0
)
{
...
@@ -59,15 +59,70 @@ static int32_t tqAddTbNameToRsp(const STQ* pTq, int64_t uid, SMqDataRsp* pRsp, i
...
@@ -59,15 +59,70 @@ static int32_t tqAddTbNameToRsp(const STQ* pTq, int64_t uid, SMqDataRsp* pRsp, i
return
0
;
return
0
;
}
}
int64_t
tqScan
(
STQ
*
pTq
,
const
STqExecHandle
*
pExec
,
SMqDataRsp
*
pRsp
,
STqOffsetVal
*
pOffset
)
{
qTaskInfo_t
task
=
pExec
->
execCol
.
task
[
0
];
if
(
qStreamPrepareScan
(
task
,
pOffset
)
<
0
)
{
ASSERT
(
pOffset
->
type
==
TMQ_OFFSET__LOG
);
pRsp
->
rspOffset
=
*
pOffset
;
pRsp
->
rspOffset
.
version
--
;
return
0
;
}
int32_t
rowCnt
=
0
;
while
(
1
)
{
SSDataBlock
*
pDataBlock
=
NULL
;
uint64_t
ts
=
0
;
if
(
qExecTask
(
task
,
&
pDataBlock
,
&
ts
)
<
0
)
{
ASSERT
(
0
);
}
if
(
pDataBlock
!=
NULL
)
{
tqAddBlockDataToRsp
(
pDataBlock
,
pRsp
);
pRsp
->
blockNum
++
;
if
(
pRsp
->
withTbName
)
{
if
(
pOffset
->
type
==
TMQ_OFFSET__LOG
)
{
int64_t
uid
=
pExec
->
pExecReader
[
0
]
->
msgIter
.
uid
;
tqAddTbNameToRsp
(
pTq
,
uid
,
pRsp
);
}
else
{
pRsp
->
withTbName
=
0
;
}
}
if
(
pOffset
->
type
==
TMQ_OFFSET__LOG
)
{
continue
;
}
else
{
rowCnt
+=
pDataBlock
->
info
.
rows
;
if
(
rowCnt
<=
4096
)
continue
;
}
}
void
*
meta
=
qStreamExtractMetaMsg
(
task
);
if
(
meta
!=
NULL
)
{
// tq add meta to rsp
}
if
(
qStreamExtractOffset
(
task
,
&
pRsp
->
rspOffset
)
<
0
)
{
ASSERT
(
0
);
}
ASSERT
(
pRsp
->
rspOffset
.
type
!=
0
);
if
(
pRsp
->
rspOffset
.
type
==
TMQ_OFFSET__LOG
)
{
ASSERT
(
pRsp
->
rspOffset
.
version
+
1
>=
pRsp
->
reqOffset
.
version
);
}
break
;
}
return
0
;
}
#if 0
int32_t tqScanSnapshot(STQ* pTq, const STqExecHandle* pExec, SMqDataRsp* pRsp, STqOffsetVal offset, int32_t workerId) {
int32_t tqScanSnapshot(STQ* pTq, const STqExecHandle* pExec, SMqDataRsp* pRsp, STqOffsetVal offset, int32_t workerId) {
ASSERT(pExec->subType == TOPIC_SUB_TYPE__COLUMN);
ASSERT(pExec->subType == TOPIC_SUB_TYPE__COLUMN);
qTaskInfo_t task = pExec->execCol.task[workerId];
qTaskInfo_t task = pExec->execCol.task[workerId];
/*if (qStreamScanSnapshot(task) < 0) {*/
if (qStreamPrepareTsdbScan(task, offset.uid, offset.ts) < 0) {
/*ASSERT(0);*/
/*}*/
if
(
qStreamPrepareScan
(
task
,
offset
.
uid
,
offset
.
ts
)
<
0
)
{
ASSERT(0);
ASSERT(0);
}
}
...
@@ -93,7 +148,7 @@ int32_t tqScanSnapshot(STQ* pTq, const STqExecHandle* pExec, SMqDataRsp* pRsp, S
...
@@ -93,7 +148,7 @@ int32_t tqScanSnapshot(STQ* pTq, const STqExecHandle* pExec, SMqDataRsp* pRsp, S
if (qGetStreamScanStatus(task, &uid, &ts) < 0) {
if (qGetStreamScanStatus(task, &uid, &ts) < 0) {
ASSERT(0);
ASSERT(0);
}
}
tqAddTbNameToRsp(pTq, uid, pRsp
, workerId
);
tqAddTbNameToRsp(pTq, uid, pRsp);
#endif
#endif
}
}
pRsp->blockNum++;
pRsp->blockNum++;
...
@@ -110,6 +165,7 @@ int32_t tqScanSnapshot(STQ* pTq, const STqExecHandle* pExec, SMqDataRsp* pRsp, S
...
@@ -110,6 +165,7 @@ int32_t tqScanSnapshot(STQ* pTq, const STqExecHandle* pExec, SMqDataRsp* pRsp, S
return 0;
return 0;
}
}
#endif
int32_t
tqLogScanExec
(
STQ
*
pTq
,
STqExecHandle
*
pExec
,
SSubmitReq
*
pReq
,
SMqDataRsp
*
pRsp
,
int32_t
workerId
)
{
int32_t
tqLogScanExec
(
STQ
*
pTq
,
STqExecHandle
*
pExec
,
SSubmitReq
*
pReq
,
SMqDataRsp
*
pRsp
,
int32_t
workerId
)
{
if
(
pExec
->
subType
==
TOPIC_SUB_TYPE__COLUMN
)
{
if
(
pExec
->
subType
==
TOPIC_SUB_TYPE__COLUMN
)
{
...
@@ -129,7 +185,7 @@ int32_t tqLogScanExec(STQ* pTq, STqExecHandle* pExec, SSubmitReq* pReq, SMqDataR
...
@@ -129,7 +185,7 @@ int32_t tqLogScanExec(STQ* pTq, STqExecHandle* pExec, SSubmitReq* pReq, SMqDataR
tqAddBlockDataToRsp
(
pDataBlock
,
pRsp
);
tqAddBlockDataToRsp
(
pDataBlock
,
pRsp
);
if
(
pRsp
->
withTbName
)
{
if
(
pRsp
->
withTbName
)
{
int64_t
uid
=
pExec
->
pExecReader
[
workerId
]
->
msgIter
.
uid
;
int64_t
uid
=
pExec
->
pExecReader
[
workerId
]
->
msgIter
.
uid
;
tqAddTbNameToRsp
(
pTq
,
uid
,
pRsp
,
workerId
);
tqAddTbNameToRsp
(
pTq
,
uid
,
pRsp
);
}
}
pRsp
->
blockNum
++
;
pRsp
->
blockNum
++
;
}
}
...
@@ -146,7 +202,7 @@ int32_t tqLogScanExec(STQ* pTq, STqExecHandle* pExec, SSubmitReq* pReq, SMqDataR
...
@@ -146,7 +202,7 @@ int32_t tqLogScanExec(STQ* pTq, STqExecHandle* pExec, SSubmitReq* pReq, SMqDataR
tqAddBlockDataToRsp
(
&
block
,
pRsp
);
tqAddBlockDataToRsp
(
&
block
,
pRsp
);
if
(
pRsp
->
withTbName
)
{
if
(
pRsp
->
withTbName
)
{
int64_t
uid
=
pExec
->
pExecReader
[
workerId
]
->
msgIter
.
uid
;
int64_t
uid
=
pExec
->
pExecReader
[
workerId
]
->
msgIter
.
uid
;
tqAddTbNameToRsp
(
pTq
,
uid
,
pRsp
,
workerId
);
tqAddTbNameToRsp
(
pTq
,
uid
,
pRsp
);
}
}
tqAddBlockSchemaToRsp
(
pExec
,
workerId
,
pRsp
);
tqAddBlockSchemaToRsp
(
pExec
,
workerId
,
pRsp
);
pRsp
->
blockNum
++
;
pRsp
->
blockNum
++
;
...
@@ -164,7 +220,7 @@ int32_t tqLogScanExec(STQ* pTq, STqExecHandle* pExec, SSubmitReq* pReq, SMqDataR
...
@@ -164,7 +220,7 @@ int32_t tqLogScanExec(STQ* pTq, STqExecHandle* pExec, SSubmitReq* pReq, SMqDataR
tqAddBlockDataToRsp
(
&
block
,
pRsp
);
tqAddBlockDataToRsp
(
&
block
,
pRsp
);
if
(
pRsp
->
withTbName
)
{
if
(
pRsp
->
withTbName
)
{
int64_t
uid
=
pExec
->
pExecReader
[
workerId
]
->
msgIter
.
uid
;
int64_t
uid
=
pExec
->
pExecReader
[
workerId
]
->
msgIter
.
uid
;
tqAddTbNameToRsp
(
pTq
,
uid
,
pRsp
,
workerId
);
tqAddTbNameToRsp
(
pTq
,
uid
,
pRsp
);
}
}
tqAddBlockSchemaToRsp
(
pExec
,
workerId
,
pRsp
);
tqAddBlockSchemaToRsp
(
pExec
,
workerId
,
pRsp
);
pRsp
->
blockNum
++
;
pRsp
->
blockNum
++
;
...
...
source/dnode/vnode/src/tq/tqOffset.c
浏览文件 @
e77931f1
...
@@ -139,7 +139,7 @@ int32_t tqOffsetSnapshot(STqOffsetStore* pStore) {
...
@@ -139,7 +139,7 @@ int32_t tqOffsetSnapshot(STqOffsetStore* pStore) {
int64_t
writeLen
;
int64_t
writeLen
;
if
((
writeLen
=
taosWriteFile
(
pFile
,
buf
,
totLen
))
!=
totLen
)
{
if
((
writeLen
=
taosWriteFile
(
pFile
,
buf
,
totLen
))
!=
totLen
)
{
ASSERT
(
0
);
ASSERT
(
0
);
tqError
(
"write offset incomplete, len %d, write len %
ld"
,
bodyLen
,
writeLen
);
tqError
(
"write offset incomplete, len %d, write len %
"
PRId64
,
bodyLen
,
writeLen
);
taosHashCancelIterate
(
pStore
->
pHash
,
pIter
);
taosHashCancelIterate
(
pStore
->
pHash
,
pIter
);
return
-
1
;
return
-
1
;
}
}
...
...
source/dnode/vnode/src/tq/tqPush.c
浏览文件 @
e77931f1
...
@@ -223,7 +223,7 @@ int32_t tqPushMsgNew(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_
...
@@ -223,7 +223,7 @@ int32_t tqPushMsgNew(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_
memset(&pHandle->pushHandle.rpcInfo, 0, sizeof(SRpcHandleInfo));
memset(&pHandle->pushHandle.rpcInfo, 0, sizeof(SRpcHandleInfo));
taosWUnLockLatch(&pHandle->pushHandle.lock);
taosWUnLockLatch(&pHandle->pushHandle.lock);
tqDebug("vg
%d offset %ld from consumer %ld (epoch %d) send rsp, block num: %d, reqOffset: %ld, rspOffset: %ld"
,
tqDebug("vg
Id:%d offset %" PRId64 " from consumer:%" PRId64 ", (epoch %d) send rsp, block num: %d, reqOffset:%" PRId64 ", rspOffset:%" PRId64
,
TD_VID(pTq->pVnode), fetchOffset, pHandle->pushHandle.consumerId, pHandle->pushHandle.epoch, rsp.blockNum,
TD_VID(pTq->pVnode), fetchOffset, pHandle->pushHandle.consumerId, pHandle->pushHandle.epoch, rsp.blockNum,
rsp.reqOffset, rsp.rspOffset);
rsp.reqOffset, rsp.rspOffset);
...
...
source/dnode/vnode/src/tq/tqRead.c
浏览文件 @
e77931f1
...
@@ -15,11 +15,6 @@
...
@@ -15,11 +15,6 @@
#include "tq.h"
#include "tq.h"
int64_t
tqScanLog
(
STQ
*
pTq
,
const
STqExecHandle
*
pExec
,
SMqDataRsp
*
pRsp
,
STqOffsetVal
offset
)
{
/*if ()*/
return
0
;
}
int64_t
tqFetchLog
(
STQ
*
pTq
,
STqHandle
*
pHandle
,
int64_t
*
fetchOffset
,
SWalCkHead
**
ppCkHead
)
{
int64_t
tqFetchLog
(
STQ
*
pTq
,
STqHandle
*
pHandle
,
int64_t
*
fetchOffset
,
SWalCkHead
**
ppCkHead
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
taosThreadMutexLock
(
&
pHandle
->
pWalReader
->
mutex
);
taosThreadMutexLock
(
&
pHandle
->
pWalReader
->
mutex
);
...
@@ -27,8 +22,8 @@ int64_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, SWalCkHea
...
@@ -27,8 +22,8 @@ int64_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, SWalCkHea
while
(
1
)
{
while
(
1
)
{
if
(
walFetchHead
(
pHandle
->
pWalReader
,
offset
,
*
ppCkHead
)
<
0
)
{
if
(
walFetchHead
(
pHandle
->
pWalReader
,
offset
,
*
ppCkHead
)
<
0
)
{
tqDebug
(
"tmq poll: consumer
%ld (epoch %d) vg %d offset %ld, no more log to return"
,
pHandle
->
consumerId
,
tqDebug
(
"tmq poll: consumer
:%"
PRId64
", (epoch %d) vgId:%d offset %"
PRId64
", no more log to return"
,
pHandle
->
epoch
,
TD_VID
(
pTq
->
pVnode
),
offset
);
pHandle
->
consumerId
,
pHandle
->
epoch
,
TD_VID
(
pTq
->
pVnode
),
offset
);
*
fetchOffset
=
offset
-
1
;
*
fetchOffset
=
offset
-
1
;
code
=
-
1
;
code
=
-
1
;
goto
END
;
goto
END
;
...
@@ -84,8 +79,10 @@ STqReader* tqOpenReader(SVnode* pVnode) {
...
@@ -84,8 +79,10 @@ STqReader* tqOpenReader(SVnode* pVnode) {
return
NULL
;
return
NULL
;
}
}
// TODO open
pReader
->
pWalReader
=
walOpenReader
(
pVnode
->
pWal
,
NULL
);
/*pReader->pWalReader = walOpenReader(pVnode->pWal, NULL);*/
if
(
pReader
->
pWalReader
==
NULL
)
{
return
NULL
;
}
pReader
->
pVnodeMeta
=
pVnode
->
pMeta
;
pReader
->
pVnodeMeta
=
pVnode
->
pMeta
;
pReader
->
pMsg
=
NULL
;
pReader
->
pMsg
=
NULL
;
...
@@ -106,13 +103,27 @@ void tqCloseReader(STqReader* pReader) {
...
@@ -106,13 +103,27 @@ void tqCloseReader(STqReader* pReader) {
taosMemoryFree
(
pReader
);
taosMemoryFree
(
pReader
);
}
}
int32_t
tqSeekVer
(
STqReader
*
pReader
,
int64_t
ver
)
{
if
(
walReadSeekVer
(
pReader
->
pWalReader
,
ver
)
<
0
)
{
ASSERT
(
pReader
->
pWalReader
->
curInvalid
);
ASSERT
(
pReader
->
pWalReader
->
curVersion
==
ver
);
return
-
1
;
}
ASSERT
(
pReader
->
pWalReader
->
curVersion
==
ver
);
return
0
;
}
int32_t
tqNextBlock
(
STqReader
*
pReader
,
SFetchRet
*
ret
)
{
int32_t
tqNextBlock
(
STqReader
*
pReader
,
SFetchRet
*
ret
)
{
bool
fromProcessedMsg
=
pReader
->
pMsg
!=
NULL
;
bool
fromProcessedMsg
=
pReader
->
pMsg
!=
NULL
;
while
(
1
)
{
while
(
1
)
{
if
(
!
fromProcessedMsg
)
{
if
(
!
fromProcessedMsg
)
{
if
(
walNextValidMsg
(
pReader
->
pWalReader
)
<
0
)
{
if
(
walNextValidMsg
(
pReader
->
pWalReader
)
<
0
)
{
pReader
->
ver
=
pReader
->
pWalReader
->
curVersion
-
pReader
->
pWalReader
->
curInvalid
;
ret
->
offset
.
type
=
TMQ_OFFSET__LOG
;
ret
->
offset
.
version
=
pReader
->
ver
;
ret
->
fetchType
=
FETCH_TYPE__NONE
;
ret
->
fetchType
=
FETCH_TYPE__NONE
;
ASSERT
(
ret
->
offset
.
version
>=
0
);
return
-
1
;
return
-
1
;
}
}
void
*
body
=
pReader
->
pWalReader
->
pHead
->
head
.
body
;
void
*
body
=
pReader
->
pWalReader
->
pHead
->
head
.
body
;
...
@@ -127,22 +138,21 @@ int32_t tqNextBlock(STqReader* pReader, SFetchRet* ret) {
...
@@ -127,22 +138,21 @@ int32_t tqNextBlock(STqReader* pReader, SFetchRet* ret) {
}
}
while
(
tqNextDataBlock
(
pReader
))
{
while
(
tqNextDataBlock
(
pReader
))
{
// TODO mem free
memset
(
&
ret
->
data
,
0
,
sizeof
(
SSDataBlock
));
memset
(
&
ret
->
data
,
0
,
sizeof
(
SSDataBlock
));
int32_t
code
=
tqRetrieveDataBlock
(
&
ret
->
data
,
pReader
);
int32_t
code
=
tqRetrieveDataBlock
(
&
ret
->
data
,
pReader
);
if
(
code
!=
0
||
ret
->
data
.
info
.
rows
==
0
)
{
if
(
code
!=
0
||
ret
->
data
.
info
.
rows
==
0
)
{
if
(
fromProcessedMsg
)
{
ASSERT
(
0
);
ret
->
fetchType
=
FETCH_TYPE__NONE
;
continue
;
return
0
;
}
else
{
break
;
}
}
}
ret
->
fetchType
=
FETCH_TYPE__DATA
;
ret
->
fetchType
=
FETCH_TYPE__DATA
;
return
0
;
return
0
;
}
}
if
(
fromProcessedMsg
)
{
if
(
fromProcessedMsg
)
{
ret
->
offset
.
type
=
TMQ_OFFSET__LOG
;
ret
->
offset
.
version
=
pReader
->
ver
;
ASSERT
(
pReader
->
ver
>=
0
);
ret
->
fetchType
=
FETCH_TYPE__NONE
;
ret
->
fetchType
=
FETCH_TYPE__NONE
;
return
0
;
return
0
;
}
}
...
@@ -179,9 +189,9 @@ bool tqNextDataBlock(STqReader* pReader) {
...
@@ -179,9 +189,9 @@ bool tqNextDataBlock(STqReader* pReader) {
return
true
;
return
true
;
}
}
void
*
ret
=
taosHashGet
(
pReader
->
tbIdHash
,
&
pReader
->
msgIter
.
uid
,
sizeof
(
int64_t
));
void
*
ret
=
taosHashGet
(
pReader
->
tbIdHash
,
&
pReader
->
msgIter
.
uid
,
sizeof
(
int64_t
));
/*tqDebug("search uid %
ld"
, pHandle->msgIter.uid);*/
/*tqDebug("search uid %
" PRId64
, pHandle->msgIter.uid);*/
if
(
ret
!=
NULL
)
{
if
(
ret
!=
NULL
)
{
/*tqDebug("find uid %
ld"
, pHandle->msgIter.uid);*/
/*tqDebug("find uid %
" PRId64
, pHandle->msgIter.uid);*/
return
true
;
return
true
;
}
}
}
}
...
@@ -212,7 +222,7 @@ int32_t tqRetrieveDataBlock(SSDataBlock* pBlock, STqReader* pReader) {
...
@@ -212,7 +222,7 @@ int32_t tqRetrieveDataBlock(SSDataBlock* pBlock, STqReader* pReader) {
if
(
pReader
->
pSchema
)
taosMemoryFree
(
pReader
->
pSchema
);
if
(
pReader
->
pSchema
)
taosMemoryFree
(
pReader
->
pSchema
);
pReader
->
pSchema
=
metaGetTbTSchema
(
pReader
->
pVnodeMeta
,
pReader
->
msgIter
.
uid
,
sversion
);
pReader
->
pSchema
=
metaGetTbTSchema
(
pReader
->
pVnodeMeta
,
pReader
->
msgIter
.
uid
,
sversion
);
if
(
pReader
->
pSchema
==
NULL
)
{
if
(
pReader
->
pSchema
==
NULL
)
{
tqWarn
(
"cannot found tsschema for table: uid:
%ld (suid: %ld
), version %d, possibly dropped table"
,
tqWarn
(
"cannot found tsschema for table: uid:
%"
PRId64
" (suid:%"
PRId64
"
), version %d, possibly dropped table"
,
pReader
->
msgIter
.
uid
,
pReader
->
msgIter
.
suid
,
pReader
->
cachedSchemaVer
);
pReader
->
msgIter
.
uid
,
pReader
->
msgIter
.
suid
,
pReader
->
cachedSchemaVer
);
/*ASSERT(0);*/
/*ASSERT(0);*/
terrno
=
TSDB_CODE_TQ_TABLE_SCHEMA_NOT_FOUND
;
terrno
=
TSDB_CODE_TQ_TABLE_SCHEMA_NOT_FOUND
;
...
@@ -222,7 +232,7 @@ int32_t tqRetrieveDataBlock(SSDataBlock* pBlock, STqReader* pReader) {
...
@@ -222,7 +232,7 @@ int32_t tqRetrieveDataBlock(SSDataBlock* pBlock, STqReader* pReader) {
if
(
pReader
->
pSchemaWrapper
)
tDeleteSSchemaWrapper
(
pReader
->
pSchemaWrapper
);
if
(
pReader
->
pSchemaWrapper
)
tDeleteSSchemaWrapper
(
pReader
->
pSchemaWrapper
);
pReader
->
pSchemaWrapper
=
metaGetTableSchema
(
pReader
->
pVnodeMeta
,
pReader
->
msgIter
.
uid
,
sversion
,
true
);
pReader
->
pSchemaWrapper
=
metaGetTableSchema
(
pReader
->
pVnodeMeta
,
pReader
->
msgIter
.
uid
,
sversion
,
true
);
if
(
pReader
->
pSchemaWrapper
==
NULL
)
{
if
(
pReader
->
pSchemaWrapper
==
NULL
)
{
tqWarn
(
"cannot found schema wrapper for table: suid:
%ld
, version %d, possibly dropped table"
,
tqWarn
(
"cannot found schema wrapper for table: suid:
%"
PRId64
"
, version %d, possibly dropped table"
,
pReader
->
msgIter
.
uid
,
pReader
->
cachedSchemaVer
);
pReader
->
msgIter
.
uid
,
pReader
->
cachedSchemaVer
);
/*ASSERT(0);*/
/*ASSERT(0);*/
terrno
=
TSDB_CODE_TQ_TABLE_SCHEMA_NOT_FOUND
;
terrno
=
TSDB_CODE_TQ_TABLE_SCHEMA_NOT_FOUND
;
...
...
source/dnode/vnode/src/tsdb/tsdbRead.c
浏览文件 @
e77931f1
...
@@ -2182,12 +2182,21 @@ static STsdb* getTsdbByRetentions(SVnode* pVnode, TSKEY winSKey, SRetention* ret
...
@@ -2182,12 +2182,21 @@ static STsdb* getTsdbByRetentions(SVnode* pVnode, TSKEY winSKey, SRetention* ret
return
VND_TSDB
(
pVnode
);
return
VND_TSDB
(
pVnode
);
}
}
static
SVersionRange
getQueryVerRange
(
SVnode
*
pVnode
,
SQueryTableDataCond
*
pCond
,
int8_t
level
)
{
SVersionRange
getQueryVerRange
(
SVnode
*
pVnode
,
SQueryTableDataCond
*
pCond
,
int8_t
level
)
{
int64_t
startVer
=
(
pCond
->
startVersion
==
-
1
)
?
0
:
pCond
->
startVersion
;
if
(
VND_IS_RSMA
(
pVnode
))
{
if
(
VND_IS_RSMA
(
pVnode
))
{
return
(
SVersionRange
){.
minVer
=
pCond
->
startVersion
,
.
maxVer
=
tdRSmaGetMaxSubmitVer
(
pVnode
->
pSma
,
level
)};
return
(
SVersionRange
){.
minVer
=
startVer
,
.
maxVer
=
tdRSmaGetMaxSubmitVer
(
pVnode
->
pSma
,
level
)};
}
int64_t
endVer
=
0
;
if
(
pCond
->
endVersion
==
-
1
)
{
// user not specified end version, set current maximum version of vnode as the endVersion
endVer
=
pVnode
->
state
.
applied
;
}
else
{
endVer
=
(
pCond
->
endVersion
>
pVnode
->
state
.
applied
)
?
pVnode
->
state
.
applied
:
pCond
->
endVersion
;
}
}
return
(
SVersionRange
){.
minVer
=
pCond
->
startVersion
,
.
maxVer
=
pVnode
->
state
.
applied
};
return
(
SVersionRange
){.
minVer
=
startVer
,
.
maxVer
=
endVer
};
}
}
// // todo not unref yet, since it is not support multi-group interpolation query
// // todo not unref yet, since it is not support multi-group interpolation query
...
...
source/dnode/vnode/src/
vnd/vnodeUtil
.c
→
source/dnode/vnode/src/
tsdb/tsdbRetention
.c
浏览文件 @
e77931f1
...
@@ -13,33 +13,30 @@
...
@@ -13,33 +13,30 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include "
vnd
.h"
#include "
tsdb
.h"
int32_t
vnodeRealloc
(
void
**
pp
,
int32_t
size
)
{
int32_t
tsdbDoRetention
(
STsdb
*
pTsdb
,
int64_t
now
)
{
uint8_t
*
p
=
NULL
;
int32_t
code
=
0
;
int32_t
csize
=
0
;
if
(
*
pp
)
{
// begin
p
=
(
uint8_t
*
)(
*
pp
)
-
sizeof
(
int32_t
);
code
=
tsdbFSBegin
(
pTsdb
->
fs
);
csize
=
*
(
int32_t
*
)
p
;
if
(
code
)
goto
_err
;
}
if
(
csize
>=
size
)
{
// do retention
return
0
;
for
(
int32_t
iSet
=
0
;
iSet
<
taosArrayGetSize
(
pTsdb
->
fs
->
nState
->
aDFileSet
);
iSet
++
)
{
}
SDFileSet
*
pDFileSet
=
(
SDFileSet
*
)
taosArrayGet
(
pTsdb
->
fs
->
nState
->
aDFileSet
,
iSet
);
p
=
(
uint8_t
*
)
taosMemoryRealloc
(
p
,
size
);
// TODO
if
(
p
==
NULL
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
*
(
int32_t
*
)
p
=
size
;
*
pp
=
p
+
sizeof
(
int32_t
);
return
0
;
// commit
}
code
=
tsdbFSCommit
(
pTsdb
->
fs
);
if
(
code
)
goto
_err
;
void
vnodeFree
(
void
*
p
)
{
_exit:
if
(
p
)
{
return
code
;
taosMemoryFree
(((
uint8_t
*
)
p
)
-
sizeof
(
int32_t
));
}
_err:
tsdbError
(
"vgId:%d tsdb do retention failed since %s"
,
TD_VID
(
pTsdb
->
pVnode
),
tstrerror
(
code
));
return
code
;
}
}
\ No newline at end of file
source/dnode/vnode/src/tsdb/tsdbSnapshot.c
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/dnode/vnode/src/tsdb/tsdbUtil.c
浏览文件 @
e77931f1
...
@@ -87,8 +87,10 @@ int32_t tPutMapData(uint8_t *p, SMapData *pMapData) {
...
@@ -87,8 +87,10 @@ int32_t tPutMapData(uint8_t *p, SMapData *pMapData) {
n
+=
tPutI32v
(
p
?
p
+
n
:
p
,
pMapData
->
nItem
);
n
+=
tPutI32v
(
p
?
p
+
n
:
p
,
pMapData
->
nItem
);
if
(
pMapData
->
nItem
)
{
if
(
pMapData
->
nItem
)
{
int32_t
lOffset
=
0
;
for
(
int32_t
iItem
=
0
;
iItem
<
pMapData
->
nItem
;
iItem
++
)
{
for
(
int32_t
iItem
=
0
;
iItem
<
pMapData
->
nItem
;
iItem
++
)
{
n
+=
tPutI32v
(
p
?
p
+
n
:
p
,
pMapData
->
aOffset
[
iItem
]);
n
+=
tPutI32v
(
p
?
p
+
n
:
p
,
pMapData
->
aOffset
[
iItem
]
-
lOffset
);
lOffset
=
pMapData
->
aOffset
[
iItem
];
}
}
n
+=
tPutI32v
(
p
?
p
+
n
:
p
,
pMapData
->
nData
);
n
+=
tPutI32v
(
p
?
p
+
n
:
p
,
pMapData
->
nData
);
...
@@ -111,8 +113,11 @@ int32_t tGetMapData(uint8_t *p, SMapData *pMapData) {
...
@@ -111,8 +113,11 @@ int32_t tGetMapData(uint8_t *p, SMapData *pMapData) {
if
(
pMapData
->
nItem
)
{
if
(
pMapData
->
nItem
)
{
if
(
tRealloc
((
uint8_t
**
)
&
pMapData
->
aOffset
,
sizeof
(
int32_t
)
*
pMapData
->
nItem
))
return
-
1
;
if
(
tRealloc
((
uint8_t
**
)
&
pMapData
->
aOffset
,
sizeof
(
int32_t
)
*
pMapData
->
nItem
))
return
-
1
;
int32_t
lOffset
=
0
;
for
(
int32_t
iItem
=
0
;
iItem
<
pMapData
->
nItem
;
iItem
++
)
{
for
(
int32_t
iItem
=
0
;
iItem
<
pMapData
->
nItem
;
iItem
++
)
{
n
+=
tGetI32v
(
p
+
n
,
&
pMapData
->
aOffset
[
iItem
]);
n
+=
tGetI32v
(
p
+
n
,
&
pMapData
->
aOffset
[
iItem
]);
pMapData
->
aOffset
[
iItem
]
+=
lOffset
;
lOffset
=
pMapData
->
aOffset
[
iItem
];
}
}
n
+=
tGetI32v
(
p
+
n
,
&
pMapData
->
nData
);
n
+=
tGetI32v
(
p
+
n
,
&
pMapData
->
nData
);
...
...
source/dnode/vnode/src/vnd/vnodeCommit.c
浏览文件 @
e77931f1
...
@@ -223,6 +223,7 @@ int vnodeCommit(SVnode *pVnode) {
...
@@ -223,6 +223,7 @@ int vnodeCommit(SVnode *pVnode) {
// save info
// save info
info
.
config
=
pVnode
->
config
;
info
.
config
=
pVnode
->
config
;
info
.
state
.
committed
=
pVnode
->
state
.
applied
;
info
.
state
.
committed
=
pVnode
->
state
.
applied
;
info
.
state
.
commitTerm
=
pVnode
->
state
.
applyTerm
;
info
.
state
.
commitID
=
pVnode
->
state
.
commitID
;
info
.
state
.
commitID
=
pVnode
->
state
.
commitID
;
snprintf
(
dir
,
TSDB_FILENAME_LEN
,
"%s%s%s"
,
tfsGetPrimaryPath
(
pVnode
->
pTfs
),
TD_DIRSEP
,
pVnode
->
path
);
snprintf
(
dir
,
TSDB_FILENAME_LEN
,
"%s%s%s"
,
tfsGetPrimaryPath
(
pVnode
->
pTfs
),
TD_DIRSEP
,
pVnode
->
path
);
if
(
vnodeSaveInfo
(
dir
,
&
info
)
<
0
)
{
if
(
vnodeSaveInfo
(
dir
,
&
info
)
<
0
)
{
...
@@ -270,7 +271,7 @@ int vnodeCommit(SVnode *pVnode) {
...
@@ -270,7 +271,7 @@ int vnodeCommit(SVnode *pVnode) {
ASSERT
(
0
);
ASSERT
(
0
);
return
-
1
;
return
-
1
;
}
}
pVnode
->
state
.
committed
=
info
.
state
.
committed
;
pVnode
->
state
.
committed
=
info
.
state
.
committed
;
// postCommit
// postCommit
...
@@ -316,6 +317,7 @@ static int vnodeEncodeState(const void *pObj, SJson *pJson) {
...
@@ -316,6 +317,7 @@ static int vnodeEncodeState(const void *pObj, SJson *pJson) {
if
(
tjsonAddIntegerToObject
(
pJson
,
"commit version"
,
pState
->
committed
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"commit version"
,
pState
->
committed
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"commit ID"
,
pState
->
commitID
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"commit ID"
,
pState
->
commitID
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"commit term"
,
pState
->
commitTerm
)
<
0
)
return
-
1
;
return
0
;
return
0
;
}
}
...
@@ -328,6 +330,8 @@ static int vnodeDecodeState(const SJson *pJson, void *pObj) {
...
@@ -328,6 +330,8 @@ static int vnodeDecodeState(const SJson *pJson, void *pObj) {
if
(
code
<
0
)
return
-
1
;
if
(
code
<
0
)
return
-
1
;
tjsonGetNumberValue
(
pJson
,
"commit ID"
,
pState
->
commitID
,
code
);
tjsonGetNumberValue
(
pJson
,
"commit ID"
,
pState
->
commitID
,
code
);
if
(
code
<
0
)
return
-
1
;
if
(
code
<
0
)
return
-
1
;
tjsonGetNumberValue
(
pJson
,
"commit term"
,
pState
->
commitTerm
,
code
);
if
(
code
<
0
)
return
-
1
;
return
0
;
return
0
;
}
}
...
...
source/dnode/vnode/src/vnd/vnodeModule.c
浏览文件 @
e77931f1
...
@@ -100,6 +100,7 @@ void vnodeCleanup() {
...
@@ -100,6 +100,7 @@ void vnodeCleanup() {
walCleanUp
();
walCleanUp
();
tqCleanUp
();
tqCleanUp
();
smaCleanUp
();
}
}
int
vnodeScheduleTask
(
int
(
*
execute
)(
void
*
),
void
*
arg
)
{
int
vnodeScheduleTask
(
int
(
*
execute
)(
void
*
),
void
*
arg
)
{
...
...
source/dnode/vnode/src/vnd/vnodeOpen.c
浏览文件 @
e77931f1
...
@@ -79,8 +79,10 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) {
...
@@ -79,8 +79,10 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) {
strcpy
(
pVnode
->
path
,
path
);
strcpy
(
pVnode
->
path
,
path
);
pVnode
->
config
=
info
.
config
;
pVnode
->
config
=
info
.
config
;
pVnode
->
state
.
committed
=
info
.
state
.
committed
;
pVnode
->
state
.
committed
=
info
.
state
.
committed
;
pVnode
->
state
.
commitTerm
=
info
.
state
.
commitTerm
;
pVnode
->
state
.
applied
=
info
.
state
.
committed
;
pVnode
->
state
.
applied
=
info
.
state
.
committed
;
pVnode
->
state
.
commitID
=
info
.
state
.
commitID
;
pVnode
->
state
.
commitID
=
info
.
state
.
commitID
;
pVnode
->
state
.
commitTerm
=
info
.
state
.
commitTerm
;
pVnode
->
pTfs
=
pTfs
;
pVnode
->
pTfs
=
pTfs
;
pVnode
->
msgCb
=
msgCb
;
pVnode
->
msgCb
=
msgCb
;
pVnode
->
blockCount
=
0
;
pVnode
->
blockCount
=
0
;
...
@@ -194,4 +196,9 @@ void vnodeStop(SVnode *pVnode) {}
...
@@ -194,4 +196,9 @@ void vnodeStop(SVnode *pVnode) {}
int64_t
vnodeGetSyncHandle
(
SVnode
*
pVnode
)
{
return
pVnode
->
sync
;
}
int64_t
vnodeGetSyncHandle
(
SVnode
*
pVnode
)
{
return
pVnode
->
sync
;
}
void
vnodeGetSnapshot
(
SVnode
*
pVnode
,
SSnapshot
*
pSnapshot
)
{
pSnapshot
->
lastApplyIndex
=
pVnode
->
state
.
committed
;
}
void
vnodeGetSnapshot
(
SVnode
*
pVnode
,
SSnapshot
*
pSnapshot
)
{
pSnapshot
->
data
=
NULL
;
pSnapshot
->
lastApplyIndex
=
pVnode
->
state
.
committed
;
pSnapshot
->
lastApplyTerm
=
pVnode
->
state
.
commitTerm
;
pSnapshot
->
lastConfigIndex
=
-
1
;
}
source/dnode/vnode/src/vnd/vnodeSnapshot.c
浏览文件 @
e77931f1
...
@@ -13,24 +13,27 @@
...
@@ -13,24 +13,27 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include "vnodeInt.h"
#include "vnd.h"
struct
SVSnapshotReader
{
// SVSnapReader ========================================================
SVnode
*
pVnode
;
struct
SVSnapReader
{
int64_t
sver
;
SVnode
*
pVnode
;
int64_t
ever
;
int64_t
sver
;
int8_t
isMetaEnd
;
int64_t
ever
;
int8_t
isTsdbEnd
;
// meta
SMetaSnapshotReader
*
pMetaReader
;
int8_t
metaDone
;
STsdbSnapshotReader
*
pTsdbReader
;
SMetaSnapReader
*
pMetaReader
;
void
*
pData
;
// tsdb
int32_t
nData
;
int8_t
tsdbDone
;
STsdbSnapReader
*
pTsdbReader
;
uint8_t
*
pData
;
};
};
int32_t
vnodeSnapshotReaderOpen
(
SVnode
*
pVnode
,
SVSnapshotReader
**
ppReader
,
int64_t
sver
,
int64_t
ever
)
{
int32_t
vnodeSnapReaderOpen
(
SVnode
*
pVnode
,
int64_t
sver
,
int64_t
ever
,
SVSnapReader
**
ppReader
)
{
SVSnapshotReader
*
pReader
=
NULL
;
int32_t
code
=
0
;
SVSnapReader
*
pReader
=
NULL
;
pReader
=
(
SVSnap
shot
Reader
*
)
taosMemoryCalloc
(
1
,
sizeof
(
*
pReader
));
pReader
=
(
SVSnapReader
*
)
taosMemoryCalloc
(
1
,
sizeof
(
*
pReader
));
if
(
pReader
==
NULL
)
{
if
(
pReader
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_err
;
goto
_err
;
...
@@ -38,72 +41,169 @@ int32_t vnodeSnapshotReaderOpen(SVnode *pVnode, SVSnapshotReader **ppReader, int
...
@@ -38,72 +41,169 @@ int32_t vnodeSnapshotReaderOpen(SVnode *pVnode, SVSnapshotReader **ppReader, int
pReader
->
pVnode
=
pVnode
;
pReader
->
pVnode
=
pVnode
;
pReader
->
sver
=
sver
;
pReader
->
sver
=
sver
;
pReader
->
ever
=
ever
;
pReader
->
ever
=
ever
;
pReader
->
isMetaEnd
=
0
;
pReader
->
isTsdbEnd
=
0
;
if
(
metaSnapshotReaderOpen
(
pVnode
->
pMeta
,
&
pReader
->
pMetaReader
,
sver
,
ever
)
<
0
)
{
code
=
metaSnapReaderOpen
(
pVnode
->
pMeta
,
sver
,
ever
,
&
pReader
->
pMetaReader
);
taosMemoryFree
(
pReader
);
if
(
code
)
goto
_err
;
goto
_err
;
}
if
(
tsdbSnapshotReaderOpen
(
pVnode
->
pTsdb
,
&
pReader
->
pTsdbReader
,
sver
,
ever
)
<
0
)
{
code
=
tsdbSnapReaderOpen
(
pVnode
->
pTsdb
,
sver
,
ever
,
&
pReader
->
pTsdbReader
);
metaSnapshotReaderClose
(
pReader
->
pMetaReader
);
if
(
code
)
goto
_err
;
taosMemoryFree
(
pReader
);
goto
_err
;
}
_exit:
*
ppReader
=
pReader
;
*
ppReader
=
pReader
;
return
0
;
return
code
;
_err:
_err:
vError
(
"vgId:%d vnode snapshot reader open failed since %s"
,
TD_VID
(
pVnode
),
tstrerror
(
code
));
*
ppReader
=
NULL
;
*
ppReader
=
NULL
;
return
-
1
;
return
code
;
}
}
int32_t
vnodeSnapshotReaderClose
(
SVSnapshotReader
*
pReader
)
{
int32_t
vnodeSnapReaderClose
(
SVSnapReader
*
pReader
)
{
if
(
pReader
)
{
int32_t
code
=
0
;
vnodeFree
(
pReader
->
pData
);
tsdbSnapshotReaderClose
(
pReader
->
pTsdbReader
);
tFree
(
pReader
->
pData
);
metaSnapshotReaderClose
(
pReader
->
pMetaReader
);
if
(
pReader
->
pTsdbReader
)
tsdbSnapReaderClose
(
&
pReader
->
pTsdbReader
);
taosMemoryFree
(
pReader
);
if
(
pReader
->
pMetaReader
)
metaSnapReaderClose
(
&
pReader
->
pMetaReader
);
}
taosMemoryFree
(
pReader
);
return
0
;
return
code
;
}
}
int32_t
vnodeSnap
shotRead
(
SVSnapshotReader
*
pReader
,
const
void
**
ppData
,
uint32_t
*
nData
)
{
int32_t
vnodeSnap
Read
(
SVSnapReader
*
pReader
,
uint8_t
**
ppData
,
uint32_t
*
nData
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
if
(
!
pReader
->
isMetaEnd
)
{
if
(
!
pReader
->
metaDone
)
{
code
=
metaSnap
shotRead
(
pReader
->
pMetaReader
,
&
pReader
->
pData
,
&
pReader
->
n
Data
);
code
=
metaSnap
Read
(
pReader
->
pMetaReader
,
&
pReader
->
p
Data
);
if
(
code
)
{
if
(
code
)
{
if
(
code
==
TSDB_CODE_VND_READ_END
)
{
if
(
code
==
TSDB_CODE_VND_READ_END
)
{
pReader
->
isMetaEnd
=
1
;
pReader
->
metaDone
=
1
;
}
else
{
}
else
{
return
code
;
goto
_err
;
}
}
}
else
{
}
else
{
*
ppData
=
pReader
->
pData
;
*
ppData
=
pReader
->
pData
;
*
nData
=
pReader
->
nData
;
*
nData
=
sizeof
(
SSnapDataHdr
)
+
((
SSnapDataHdr
*
)
pReader
->
pData
)
->
size
;
return
code
;
goto
_exit
;
}
}
}
}
if
(
!
pReader
->
isTsdbEnd
)
{
if
(
!
pReader
->
tsdbDone
)
{
code
=
tsdbSnap
shotRead
(
pReader
->
pTsdbReader
,
&
pReader
->
pData
,
&
pReader
->
n
Data
);
code
=
tsdbSnap
Read
(
pReader
->
pTsdbReader
,
&
pReader
->
p
Data
);
if
(
code
)
{
if
(
code
)
{
if
(
code
==
TSDB_CODE_VND_READ_END
)
{
if
(
code
==
TSDB_CODE_VND_READ_END
)
{
pReader
->
isTsdbEnd
=
1
;
pReader
->
tsdbDone
=
1
;
}
else
{
}
else
{
return
code
;
goto
_err
;
}
}
}
else
{
}
else
{
*
ppData
=
pReader
->
pData
;
*
ppData
=
pReader
->
pData
;
*
nData
=
pReader
->
nData
;
*
nData
=
sizeof
(
SSnapDataHdr
)
+
((
SSnapDataHdr
*
)
pReader
->
pData
)
->
size
;
return
code
;
goto
_exit
;
}
}
}
}
code
=
TSDB_CODE_VND_READ_END
;
code
=
TSDB_CODE_VND_READ_END
;
_exit:
return
code
;
_err:
vError
(
"vgId:% snapshot read failed since %s"
,
TD_VID
(
pReader
->
pVnode
),
tstrerror
(
code
));
return
code
;
}
// SVSnapWriter ========================================================
struct
SVSnapWriter
{
SVnode
*
pVnode
;
int64_t
sver
;
int64_t
ever
;
// meta
SMetaSnapWriter
*
pMetaSnapWriter
;
// tsdb
STsdbSnapWriter
*
pTsdbSnapWriter
;
};
static
int32_t
vnodeSnapRollback
(
SVSnapWriter
*
pWriter
)
{
int32_t
code
=
0
;
// TODO
return
code
;
}
static
int32_t
vnodeSnapCommit
(
SVSnapWriter
*
pWriter
)
{
int32_t
code
=
0
;
// TODO
return
code
;
}
int32_t
vnodeSnapWriterOpen
(
SVnode
*
pVnode
,
int64_t
sver
,
int64_t
ever
,
SVSnapWriter
**
ppWriter
)
{
int32_t
code
=
0
;
SVSnapWriter
*
pWriter
=
NULL
;
// alloc
pWriter
=
(
SVSnapWriter
*
)
taosMemoryCalloc
(
1
,
sizeof
(
*
pWriter
));
if
(
pWriter
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_err
;
}
pWriter
->
pVnode
=
pVnode
;
pWriter
->
sver
=
sver
;
pWriter
->
ever
=
ever
;
return
code
;
_err:
vError
(
"vgId:%d vnode snapshot writer open failed since %s"
,
TD_VID
(
pVnode
),
tstrerror
(
code
));
return
code
;
}
int32_t
vnodeSnapWriterClose
(
SVSnapWriter
*
pWriter
,
int8_t
rollback
)
{
int32_t
code
=
0
;
if
(
rollback
)
{
code
=
vnodeSnapRollback
(
pWriter
);
if
(
code
)
goto
_err
;
}
else
{
code
=
vnodeSnapCommit
(
pWriter
);
if
(
code
)
goto
_err
;
}
taosMemoryFree
(
pWriter
);
return
code
;
_err:
vError
(
"vgId:%d vnode snapshow writer close failed since %s"
,
TD_VID
(
pWriter
->
pVnode
),
tstrerror
(
code
));
return
code
;
}
int32_t
vnodeSnapWrite
(
SVSnapWriter
*
pWriter
,
uint8_t
*
pData
,
uint32_t
nData
)
{
int32_t
code
=
0
;
SSnapDataHdr
*
pSnapDataHdr
=
(
SSnapDataHdr
*
)
pData
;
SVnode
*
pVnode
=
pWriter
->
pVnode
;
ASSERT
(
pSnapDataHdr
->
size
+
sizeof
(
SSnapDataHdr
)
==
nData
);
if
(
pSnapDataHdr
->
type
==
0
)
{
// meta
if
(
pWriter
->
pMetaSnapWriter
==
NULL
)
{
code
=
metaSnapWriterOpen
(
pVnode
->
pMeta
,
pWriter
->
sver
,
pWriter
->
ever
,
&
pWriter
->
pMetaSnapWriter
);
if
(
code
)
goto
_err
;
}
code
=
metaSnapWrite
(
pWriter
->
pMetaSnapWriter
,
pData
+
sizeof
(
SSnapDataHdr
),
nData
-
sizeof
(
SSnapDataHdr
));
if
(
code
)
goto
_err
;
}
else
{
// tsdb
if
(
pWriter
->
pTsdbSnapWriter
==
NULL
)
{
code
=
tsdbSnapWriterOpen
(
pVnode
->
pTsdb
,
pWriter
->
sver
,
pWriter
->
ever
,
&
pWriter
->
pTsdbSnapWriter
);
if
(
code
)
goto
_err
;
}
code
=
tsdbSnapWrite
(
pWriter
->
pTsdbSnapWriter
,
pData
+
sizeof
(
SSnapDataHdr
),
nData
-
sizeof
(
SSnapDataHdr
));
if
(
code
)
goto
_err
;
}
return
code
;
_err:
vError
(
"vgId:%d vnode snapshot write failed since %s"
,
TD_VID
(
pVnode
),
tstrerror
(
code
));
return
code
;
return
code
;
}
}
\ No newline at end of file
source/dnode/vnode/src/vnd/vnodeSvr.c
浏览文件 @
e77931f1
...
@@ -143,6 +143,7 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRp
...
@@ -143,6 +143,7 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRp
version
);
version
);
pVnode
->
state
.
applied
=
version
;
pVnode
->
state
.
applied
=
version
;
pVnode
->
state
.
applyTerm
=
pMsg
->
info
.
conn
.
applyTerm
;
// skip header
// skip header
pReq
=
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
));
pReq
=
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
));
...
...
source/dnode/vnode/src/vnd/vnodeSync.c
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/catalog/inc/catalogInt.h
浏览文件 @
e77931f1
...
@@ -166,7 +166,7 @@ typedef struct SCtgDBCache {
...
@@ -166,7 +166,7 @@ typedef struct SCtgDBCache {
int8_t
deleted
;
int8_t
deleted
;
SCtgVgCache
vgCache
;
SCtgVgCache
vgCache
;
SHashObj
*
tbCache
;
// key:tbname, value:SCtgTbCache
SHashObj
*
tbCache
;
// key:tbname, value:SCtgTbCache
SHashObj
*
stbCache
;
// key:suid, value:
STableMeta
*
SHashObj
*
stbCache
;
// key:suid, value:
char
*
}
SCtgDBCache
;
}
SCtgDBCache
;
typedef
struct
SCtgRentSlot
{
typedef
struct
SCtgRentSlot
{
...
...
source/libs/catalog/src/ctgDbg.c
浏览文件 @
e77931f1
...
@@ -64,7 +64,7 @@ void ctgdUserCallback(SMetaData* pResult, void* param, int32_t code) {
...
@@ -64,7 +64,7 @@ void ctgdUserCallback(SMetaData* pResult, void* param, int32_t code) {
qDebug
(
"db %d vgInfo:"
,
i
);
qDebug
(
"db %d vgInfo:"
,
i
);
for
(
int32_t
j
=
0
;
j
<
vgNum
;
++
j
)
{
for
(
int32_t
j
=
0
;
j
<
vgNum
;
++
j
)
{
SVgroupInfo
*
pInfo
=
taosArrayGet
(
pDb
,
j
);
SVgroupInfo
*
pInfo
=
taosArrayGet
(
pDb
,
j
);
qDebug
(
"vg %d info: vgId:%d"
,
j
,
pInfo
->
vgId
);
qDebug
(
"vg
:
%d info: vgId:%d"
,
j
,
pInfo
->
vgId
);
}
}
}
}
}
else
{
}
else
{
...
...
source/libs/catalog/src/ctgUtil.c
浏览文件 @
e77931f1
...
@@ -731,7 +731,7 @@ int32_t ctgGetVgInfoFromHashValue(SCatalog *pCtg, SDBVgInfo *dbInfo, const SName
...
@@ -731,7 +731,7 @@ int32_t ctgGetVgInfoFromHashValue(SCatalog *pCtg, SDBVgInfo *dbInfo, const SName
*
pVgroup
=
*
vgInfo
;
*
pVgroup
=
*
vgInfo
;
ctgDebug
(
"Got tb %s hash vgroup, vgId
%d, epNum %d, current %s port %d"
,
tbFullName
,
vgInfo
->
vgId
,
vgInfo
->
epSet
.
numOfEps
,
ctgDebug
(
"Got tb %s hash vgroup, vgId
:
%d, epNum %d, current %s port %d"
,
tbFullName
,
vgInfo
->
vgId
,
vgInfo
->
epSet
.
numOfEps
,
vgInfo
->
epSet
.
eps
[
vgInfo
->
epSet
.
inUse
].
fqdn
,
vgInfo
->
epSet
.
eps
[
vgInfo
->
epSet
.
inUse
].
port
);
vgInfo
->
epSet
.
eps
[
vgInfo
->
epSet
.
inUse
].
fqdn
,
vgInfo
->
epSet
.
eps
[
vgInfo
->
epSet
.
inUse
].
port
);
CTG_RET
(
code
);
CTG_RET
(
code
);
...
...
source/libs/executor/inc/executorimpl.h
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/executor/src/executil.c
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/executor/src/executor.c
浏览文件 @
e77931f1
...
@@ -60,9 +60,9 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t nu
...
@@ -60,9 +60,9 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t nu
taosArrayAddAll
(
p
->
pDataBlock
,
pDataBlock
->
pDataBlock
);
taosArrayAddAll
(
p
->
pDataBlock
,
pDataBlock
->
pDataBlock
);
taosArrayPush
(
pInfo
->
pBlockLists
,
&
p
);
taosArrayPush
(
pInfo
->
pBlockLists
,
&
p
);
}
}
}
else
if
(
type
==
STREAM_INPUT__
DATA
_SCAN
)
{
}
else
if
(
type
==
STREAM_INPUT__
TABLE
_SCAN
)
{
// do nothing
// do nothing
ASSERT
(
pInfo
->
blockType
==
STREAM_INPUT__
DATA
_SCAN
);
ASSERT
(
pInfo
->
blockType
==
STREAM_INPUT__
TABLE
_SCAN
);
}
else
{
}
else
{
ASSERT
(
0
);
ASSERT
(
0
);
}
}
...
@@ -76,7 +76,7 @@ int32_t qStreamScanSnapshot(qTaskInfo_t tinfo) {
...
@@ -76,7 +76,7 @@ int32_t qStreamScanSnapshot(qTaskInfo_t tinfo) {
return
TSDB_CODE_QRY_APP_ERROR
;
return
TSDB_CODE_QRY_APP_ERROR
;
}
}
SExecTaskInfo
*
pTaskInfo
=
(
SExecTaskInfo
*
)
tinfo
;
SExecTaskInfo
*
pTaskInfo
=
(
SExecTaskInfo
*
)
tinfo
;
return
doSetStreamBlock
(
pTaskInfo
->
pRoot
,
NULL
,
0
,
STREAM_INPUT__
DATA
_SCAN
,
0
,
NULL
);
return
doSetStreamBlock
(
pTaskInfo
->
pRoot
,
NULL
,
0
,
STREAM_INPUT__
TABLE
_SCAN
,
0
,
NULL
);
}
}
int32_t
qSetStreamInput
(
qTaskInfo_t
tinfo
,
const
void
*
input
,
int32_t
type
,
bool
assignUid
)
{
int32_t
qSetStreamInput
(
qTaskInfo_t
tinfo
,
const
void
*
input
,
int32_t
type
,
bool
assignUid
)
{
...
...
source/libs/executor/src/executorMain.c
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/executor/src/executorimpl.c
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/executor/src/scanoperator.c
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/executor/src/timewindowoperator.c
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/executor/test/executorTests.cpp
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/executor/test/sortTests.cpp
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/function/inc/fnLog.h
浏览文件 @
e77931f1
...
@@ -14,7 +14,7 @@ extern "C" {
...
@@ -14,7 +14,7 @@ extern "C" {
#define fnFatal(...) { if (udfDebugFlag & DEBUG_FATAL) { taosPrintLog("UDF FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); }}
#define fnFatal(...) { if (udfDebugFlag & DEBUG_FATAL) { taosPrintLog("UDF FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); }}
#define fnError(...) { if (udfDebugFlag & DEBUG_ERROR) { taosPrintLog("UDF ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }}
#define fnError(...) { if (udfDebugFlag & DEBUG_ERROR) { taosPrintLog("UDF ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }}
#define fnWarn(...) { if (udfDebugFlag & DEBUG_WARN) { taosPrintLog("UDF WARN ", DEBUG_WARN, 255, __VA_ARGS__); }}
#define fnWarn(...) { if (udfDebugFlag & DEBUG_WARN) { taosPrintLog("UDF WARN ", DEBUG_WARN, 255, __VA_ARGS__); }}
#define fnInfo(...) { if (udfDebugFlag & DEBUG_INFO) { taosPrintLog("UDF
", DEBUG_INFO, 255, __VA_ARGS__); }}
#define fnInfo(...) { if (udfDebugFlag & DEBUG_INFO) { taosPrintLog("UDF ", DEBUG_INFO, 255, __VA_ARGS__); }}
#define fnDebug(...) { if (udfDebugFlag & DEBUG_DEBUG) { taosPrintLog("UDF ", DEBUG_DEBUG, udfDebugFlag, __VA_ARGS__); }}
#define fnDebug(...) { if (udfDebugFlag & DEBUG_DEBUG) { taosPrintLog("UDF ", DEBUG_DEBUG, udfDebugFlag, __VA_ARGS__); }}
#define fnTrace(...) { if (udfDebugFlag & DEBUG_TRACE) { taosPrintLog("UDF ", DEBUG_TRACE, udfDebugFlag, __VA_ARGS__); }}
#define fnTrace(...) { if (udfDebugFlag & DEBUG_TRACE) { taosPrintLog("UDF ", DEBUG_TRACE, udfDebugFlag, __VA_ARGS__); }}
// clang-format on
// clang-format on
...
...
source/libs/function/src/builtinsimpl.c
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/function/src/tudf.c
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/parser/src/parTranslater.c
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/qcom/src/querymsg.c
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/qworker/src/qwDbg.c
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/qworker/src/qworker.c
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/scalar/inc/sclInt.h
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/scalar/src/filter.c
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/scalar/src/scalar.c
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/scalar/src/sclvector.c
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/scalar/test/filter/filterTests.cpp
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/scalar/test/scalar/scalarTests.cpp
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/scheduler/inc/schInt.h
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/scheduler/src/schJob.c
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/scheduler/src/schRemote.c
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/scheduler/src/schTask.c
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/sync/src/syncAppendEntries.c
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/sync/src/syncAppendEntriesReply.c
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/sync/src/syncCommit.c
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/sync/src/syncElection.c
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/sync/src/syncIndexMgr.c
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/sync/src/syncMain.c
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/sync/src/syncMessage.c
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/sync/src/syncRaftCfg.c
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/sync/src/syncRaftEntry.c
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/sync/src/syncRaftLog.c
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/sync/src/syncReplication.c
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/sync/src/syncRequestVote.c
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/sync/src/syncRequestVoteReply.c
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/sync/src/syncRespMgr.c
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/sync/src/syncSnapshot.c
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/sync/src/syncVoteMgr.c
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/sync/test/syncConfigChangeSnapshotTest.cpp
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/sync/test/syncConfigChangeTest.cpp
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/sync/test/syncIndexMgrTest.cpp
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/sync/test/syncIndexTest.cpp
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/sync/test/syncRaftIdCheck.cpp
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/sync/test/syncRaftLogTest.cpp
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/sync/test/syncRaftLogTest2.cpp
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/sync/test/syncRaftLogTest3.cpp
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/sync/test/syncRefTest.cpp
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/sync/test/syncReplicateTest.cpp
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/sync/test/syncRespMgrTest.cpp
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/sync/test/syncSnapshotTest.cpp
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/sync/test/syncTestTool.cpp
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/sync/test/syncWriteTest.cpp
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/tdb/src/db/tdbPager.c
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/transport/inc/transComm.h
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/transport/src/trans.c
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/transport/src/transCli.c
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/transport/src/transComm.c
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/transport/src/transSvr.c
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/transport/test/pushServer.c
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/wal/src/walRead.c
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/libs/wal/src/walWrite.c
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/os/src/osSemaphore.c
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/util/src/terror.c
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
source/util/src/tjson.c
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
tests/script/jenkins/basic.txt
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
tests/script/tsim/valgrind/basic1.sim
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
tests/script/tsim/valgrind/basic2.sim
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
tests/script/tsim/valgrind/basic3.sim
0 → 100644
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
tests/script/tsim/valgrind/checkError1.sim
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
tests/script/tsim/valgrind/checkError3.sim
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
tests/system-test/0-others/taosShellError.py
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
tests/system-test/failed.txt
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
tests/system-test/fulltest.sh
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
tests/test/c/sdbDump.c
浏览文件 @
e77931f1
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录