Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
d3cdd75b
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1193
Star
22019
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看板
提交
d3cdd75b
编写于
7月 13, 2022
作者:
wmmhello
浏览文件
操作
浏览文件
下载
差异文件
Merge branch '3.0' into feature/TD-13041
上级
8aa04f8e
f69a995e
变更
83
显示空白变更内容
内联
并排
Showing
83 changed file
with
3385 addition
and
2811 deletion
+3385
-2811
include/common/tglobal.h
include/common/tglobal.h
+1
-0
include/common/tmsgcb.h
include/common/tmsgcb.h
+1
-0
include/common/ttime.h
include/common/ttime.h
+2
-0
include/libs/executor/executor.h
include/libs/executor/executor.h
+4
-1
include/libs/scalar/scalar.h
include/libs/scalar/scalar.h
+1
-0
include/libs/stream/tstream.h
include/libs/stream/tstream.h
+6
-2
include/libs/sync/sync.h
include/libs/sync/sync.h
+2
-0
include/util/taoserror.h
include/util/taoserror.h
+2
-1
source/common/src/tglobal.c
source/common/src/tglobal.c
+40
-0
source/common/src/ttime.c
source/common/src/ttime.c
+26
-0
source/dnode/mgmt/mgmt_vnode/inc/vmInt.h
source/dnode/mgmt/mgmt_vnode/inc/vmInt.h
+3
-0
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
+8
-8
source/dnode/mgmt/mgmt_vnode/src/vmInt.c
source/dnode/mgmt/mgmt_vnode/src/vmInt.c
+1
-0
source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
+38
-1
source/dnode/mnode/impl/src/mndDnode.c
source/dnode/mnode/impl/src/mndDnode.c
+45
-13
source/dnode/mnode/impl/src/mndMnode.c
source/dnode/mnode/impl/src/mndMnode.c
+4
-0
source/dnode/vnode/src/tsdb/tsdbCacheRead.c
source/dnode/vnode/src/tsdb/tsdbCacheRead.c
+12
-9
source/dnode/vnode/src/vnd/vnodeSync.c
source/dnode/vnode/src/vnd/vnodeSync.c
+16
-7
source/libs/command/src/command.c
source/libs/command/src/command.c
+7
-3
source/libs/executor/CMakeLists.txt
source/libs/executor/CMakeLists.txt
+1
-1
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+3
-0
source/libs/executor/src/executor.c
source/libs/executor/src/executor.c
+0
-2
source/libs/executor/src/executorMain.c
source/libs/executor/src/executorMain.c
+14
-0
source/libs/executor/src/scanoperator.c
source/libs/executor/src/scanoperator.c
+0
-23
source/libs/executor/src/sortoperator.c
source/libs/executor/src/sortoperator.c
+3
-1
source/libs/executor/src/timewindowoperator.c
source/libs/executor/src/timewindowoperator.c
+5
-4
source/libs/parser/src/parCalcConst.c
source/libs/parser/src/parCalcConst.c
+8
-3
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+1
-2
source/libs/planner/src/planOptimizer.c
source/libs/planner/src/planOptimizer.c
+6
-3
source/libs/qworker/CMakeLists.txt
source/libs/qworker/CMakeLists.txt
+1
-1
source/libs/scalar/inc/sclInt.h
source/libs/scalar/inc/sclInt.h
+1
-0
source/libs/scalar/src/scalar.c
source/libs/scalar/src/scalar.c
+64
-53
source/libs/scalar/src/sclvector.c
source/libs/scalar/src/sclvector.c
+26
-15
source/libs/stream/inc/streamInc.h
source/libs/stream/inc/streamInc.h
+3
-0
source/libs/stream/src/stream.c
source/libs/stream/src/stream.c
+1
-1
source/libs/stream/src/streamData.c
source/libs/stream/src/streamData.c
+26
-0
source/libs/stream/src/streamDispatch.c
source/libs/stream/src/streamDispatch.c
+3
-2
source/libs/stream/src/streamExec.c
source/libs/stream/src/streamExec.c
+32
-15
source/libs/sync/inc/syncRaftEntry.h
source/libs/sync/inc/syncRaftEntry.h
+39
-15
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+3
-10
source/libs/sync/src/syncRaftEntry.c
source/libs/sync/src/syncRaftEntry.c
+258
-16
source/libs/sync/src/syncRespMgr.c
source/libs/sync/src/syncRespMgr.c
+23
-32
source/libs/sync/src/syncTimeout.c
source/libs/sync/src/syncTimeout.c
+5
-0
source/libs/sync/test/CMakeLists.txt
source/libs/sync/test/CMakeLists.txt
+14
-0
source/libs/sync/test/syncEntryCacheTest.cpp
source/libs/sync/test/syncEntryCacheTest.cpp
+44
-189
source/libs/sync/test/syncHashCacheTest.cpp
source/libs/sync/test/syncHashCacheTest.cpp
+277
-0
source/util/src/terror.c
source/util/src/terror.c
+1
-0
tests/pytest/util/sqlset.py
tests/pytest/util/sqlset.py
+1
-1
tests/script/general/cache/testSuite.sim
tests/script/general/cache/testSuite.sim
+0
-3
tests/script/general/column/testSuite.sim
tests/script/general/column/testSuite.sim
+0
-3
tests/script/general/compress/testSuite.sim
tests/script/general/compress/testSuite.sim
+0
-4
tests/script/general/import/testSuite.sim
tests/script/general/import/testSuite.sim
+0
-4
tests/script/jenkins/basic.txt
tests/script/jenkins/basic.txt
+29
-1
tests/script/tsim/alter/cached_schema_after_alter.sim
tests/script/tsim/alter/cached_schema_after_alter.sim
+0
-0
tests/script/tsim/alter/dnode.sim
tests/script/tsim/alter/dnode.sim
+62
-0
tests/script/tsim/alter/table.sim
tests/script/tsim/alter/table.sim
+0
-2
tests/script/tsim/cache/new_metrics.sim
tests/script/tsim/cache/new_metrics.sim
+0
-16
tests/script/tsim/cache/restart_metrics.sim
tests/script/tsim/cache/restart_metrics.sim
+1
-8
tests/script/tsim/cache/restart_table.sim
tests/script/tsim/cache/restart_table.sim
+1
-8
tests/script/tsim/column/commit.sim
tests/script/tsim/column/commit.sim
+0
-10
tests/script/tsim/column/metrics.sim
tests/script/tsim/column/metrics.sim
+0
-10
tests/script/tsim/column/table.sim
tests/script/tsim/column/table.sim
+0
-9
tests/script/tsim/compress/commitlog.sim
tests/script/tsim/compress/commitlog.sim
+1
-9
tests/script/tsim/compress/compress.sim
tests/script/tsim/compress/compress.sim
+0
-9
tests/script/tsim/compress/compress2.sim
tests/script/tsim/compress/compress2.sim
+0
-8
tests/script/tsim/compress/uncompress.sim
tests/script/tsim/compress/uncompress.sim
+1
-9
tests/script/tsim/import/basic.sim
tests/script/tsim/import/basic.sim
+0
-26
tests/script/tsim/import/commit.sim
tests/script/tsim/import/commit.sim
+0
-28
tests/script/tsim/import/large.sim
tests/script/tsim/import/large.sim
+0
-26
tests/script/tsim/import/replica1.sim
tests/script/tsim/import/replica1.sim
+0
-31
tests/script/tsim/scalar/scalar.sim
tests/script/tsim/scalar/scalar.sim
+67
-0
tests/system-test/0-others/sysinfo.py
tests/system-test/0-others/sysinfo.py
+59
-0
tests/system-test/2-query/To_unixtimestamp.py
tests/system-test/2-query/To_unixtimestamp.py
+9
-9
tests/system-test/2-query/arccos.py
tests/system-test/2-query/arccos.py
+46
-46
tests/system-test/2-query/arcsin.py
tests/system-test/2-query/arcsin.py
+45
-45
tests/system-test/2-query/arctan.py
tests/system-test/2-query/arctan.py
+45
-45
tests/system-test/2-query/count.py
tests/system-test/2-query/count.py
+108
-179
tests/system-test/2-query/diff.py
tests/system-test/2-query/diff.py
+2
-2
tests/system-test/2-query/elapsed.py
tests/system-test/2-query/elapsed.py
+1
-1
tests/system-test/2-query/nestedQuery_str.py
tests/system-test/2-query/nestedQuery_str.py
+1750
-1750
tests/system-test/2-query/queryQnode.py
tests/system-test/2-query/queryQnode.py
+27
-27
tests/system-test/2-query/unique.py
tests/system-test/2-query/unique.py
+46
-46
tests/system-test/fulltest.sh
tests/system-test/fulltest.sh
+3
-3
未找到文件。
include/common/tglobal.h
浏览文件 @
d3cdd75b
...
...
@@ -64,6 +64,7 @@ extern int32_t tsNumOfMnodeQueryThreads;
extern
int32_t
tsNumOfMnodeFetchThreads
;
extern
int32_t
tsNumOfMnodeReadThreads
;
extern
int32_t
tsNumOfVnodeQueryThreads
;
extern
int32_t
tsNumOfVnodeStreamThreads
;
extern
int32_t
tsNumOfVnodeFetchThreads
;
extern
int32_t
tsNumOfVnodeWriteThreads
;
extern
int32_t
tsNumOfVnodeSyncThreads
;
...
...
include/common/tmsgcb.h
浏览文件 @
d3cdd75b
...
...
@@ -34,6 +34,7 @@ typedef enum {
WRITE_QUEUE
,
APPLY_QUEUE
,
SYNC_QUEUE
,
STREAM_QUEUE
,
QUEUE_MAX
,
}
EQueueType
;
...
...
include/common/ttime.h
浏览文件 @
d3cdd75b
...
...
@@ -72,6 +72,8 @@ static FORCE_INLINE int64_t taosGetTimestampToday(int32_t precision) {
}
int64_t
taosTimeAdd
(
int64_t
t
,
int64_t
duration
,
char
unit
,
int32_t
precision
);
int64_t
taosTimeSub
(
int64_t
t
,
int64_t
duration
,
char
unit
,
int32_t
precision
);
int64_t
taosTimeTruncate
(
int64_t
t
,
const
SInterval
*
pInterval
,
int32_t
precision
);
int32_t
taosTimeCountInterval
(
int64_t
skey
,
int64_t
ekey
,
int64_t
interval
,
char
unit
,
int32_t
precision
);
...
...
include/libs/executor/executor.h
浏览文件 @
d3cdd75b
...
...
@@ -187,8 +187,11 @@ int32_t qStreamExtractOffset(qTaskInfo_t tinfo, STqOffsetVal* pOffset);
void
*
qStreamExtractMetaMsg
(
qTaskInfo_t
tinfo
);
void
*
qExtractReaderFromStreamScanner
(
void
*
scanner
);
int32_t
qExtractStreamScanner
(
qTaskInfo_t
tinfo
,
void
**
scanner
);
int32_t
qStreamInput
(
qTaskInfo_t
tinfo
,
void
*
pItem
);
#ifdef __cplusplus
}
#endif
...
...
include/libs/scalar/scalar.h
浏览文件 @
d3cdd75b
...
...
@@ -32,6 +32,7 @@ pNode will be freed in API;
*pRes need to freed in caller
*/
int32_t
scalarCalculateConstants
(
SNode
*
pNode
,
SNode
**
pRes
);
int32_t
scalarCalculateConstantsFromDual
(
SNode
*
pNode
,
SNode
**
pRes
);
/*
pDst need to freed in caller
...
...
include/libs/stream/tstream.h
浏览文件 @
d3cdd75b
...
...
@@ -13,6 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "executor.h"
#include "os.h"
#include "query.h"
#include "tdatablock.h"
...
...
@@ -120,7 +121,6 @@ static FORCE_INLINE void* streamQueueCurItem(SStreamQueue* queue) { return queue
static
FORCE_INLINE
void
*
streamQueueNextItem
(
SStreamQueue
*
queue
)
{
int8_t
dequeueFlag
=
atomic_exchange_8
(
&
queue
->
status
,
STREAM_QUEUE__PROCESSING
);
if
(
dequeueFlag
==
STREAM_QUEUE__FAILED
)
{
ASSERT
(
0
);
ASSERT
(
queue
->
qItem
!=
NULL
);
return
streamQueueCurItem
(
queue
);
}
else
{
...
...
@@ -307,14 +307,18 @@ static FORCE_INLINE int32_t streamTaskInput(SStreamTask* pTask, SStreamQueueItem
atomic_store_8
(
&
pTask
->
inputStatus
,
TASK_INPUT_STATUS__FAILED
);
return
-
1
;
}
q
Info
(
"task %d %p submit enqueue %p %p %p"
,
pTask
->
taskId
,
pTask
,
pItem
,
pSubmitClone
,
pSubmitClone
->
data
);
q
Debug
(
"task %d %p submit enqueue %p %p %p"
,
pTask
->
taskId
,
pTask
,
pItem
,
pSubmitClone
,
pSubmitClone
->
data
);
taosWriteQitem
(
pTask
->
inputQueue
->
queue
,
pSubmitClone
);
// qStreamInput(pTask->exec.executor, pSubmitClone);
}
else
if
(
pItem
->
type
==
STREAM_INPUT__DATA_BLOCK
||
pItem
->
type
==
STREAM_INPUT__DATA_RETRIEVE
)
{
taosWriteQitem
(
pTask
->
inputQueue
->
queue
,
pItem
);
// qStreamInput(pTask->exec.executor, pItem);
}
else
if
(
pItem
->
type
==
STREAM_INPUT__CHECKPOINT
)
{
taosWriteQitem
(
pTask
->
inputQueue
->
queue
,
pItem
);
// qStreamInput(pTask->exec.executor, pItem);
}
else
if
(
pItem
->
type
==
STREAM_INPUT__TRIGGER
)
{
taosWriteQitem
(
pTask
->
inputQueue
->
queue
,
pItem
);
// qStreamInput(pTask->exec.executor, pItem);
}
if
(
pItem
->
type
!=
STREAM_INPUT__TRIGGER
&&
pItem
->
type
!=
STREAM_INPUT__CHECKPOINT
&&
pTask
->
triggerParam
!=
0
)
{
...
...
include/libs/sync/sync.h
浏览文件 @
d3cdd75b
...
...
@@ -26,6 +26,8 @@ extern "C" {
extern
bool
gRaftDetailLog
;
#define SYNC_RESP_TTL_MS 5000
#define SYNC_MAX_BATCH_SIZE 500
#define SYNC_INDEX_BEGIN 0
#define SYNC_INDEX_INVALID -1
...
...
include/util/taoserror.h
浏览文件 @
d3cdd75b
...
...
@@ -584,7 +584,8 @@ int32_t* taosGetErrno();
#define TSDB_CODE_PAR_INVALID_INTERP_CLAUSE TAOS_DEF_ERROR_CODE(0, 0x265D)
#define TSDB_CODE_PAR_NO_VALID_FUNC_IN_WIN TAOS_DEF_ERROR_CODE(0, 0x265E)
#define TSDB_CODE_PAR_ONLY_SUPPORT_SINGLE_TABLE TAOS_DEF_ERROR_CODE(0, 0x265F)
#define TSDB_CODE_PAR_INVALID_SMA_INDEX TAOS_DEF_ERROR_CODE(0, 0x265C)
#define TSDB_CODE_PAR_INVALID_SMA_INDEX TAOS_DEF_ERROR_CODE(0, 0x2660)
#define TSDB_CODE_PAR_INVALID_SELECTED_EXPR TAOS_DEF_ERROR_CODE(0, 0x2661)
//planner
#define TSDB_CODE_PLAN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2700)
...
...
source/common/src/tglobal.c
浏览文件 @
d3cdd75b
...
...
@@ -55,6 +55,7 @@ int32_t tsNumOfMnodeQueryThreads = 2;
int32_t
tsNumOfMnodeFetchThreads
=
1
;
int32_t
tsNumOfMnodeReadThreads
=
1
;
int32_t
tsNumOfVnodeQueryThreads
=
2
;
int32_t
tsNumOfVnodeStreamThreads
=
2
;
int32_t
tsNumOfVnodeFetchThreads
=
4
;
int32_t
tsNumOfVnodeWriteThreads
=
2
;
int32_t
tsNumOfVnodeSyncThreads
=
2
;
...
...
@@ -412,6 +413,10 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
tsNumOfVnodeQueryThreads
=
TMAX
(
tsNumOfVnodeQueryThreads
,
2
);
if
(
cfgAddInt32
(
pCfg
,
"numOfVnodeQueryThreads"
,
tsNumOfVnodeQueryThreads
,
1
,
1024
,
0
)
!=
0
)
return
-
1
;
tsNumOfVnodeStreamThreads
=
tsNumOfCores
/
4
;
tsNumOfVnodeStreamThreads
=
TMAX
(
tsNumOfVnodeStreamThreads
,
4
);
if
(
cfgAddInt32
(
pCfg
,
"numOfVnodeStreamThreads"
,
tsNumOfVnodeStreamThreads
,
1
,
1024
,
0
)
!=
0
)
return
-
1
;
tsNumOfVnodeFetchThreads
=
tsNumOfCores
/
4
;
tsNumOfVnodeFetchThreads
=
TMAX
(
tsNumOfVnodeFetchThreads
,
4
);
if
(
cfgAddInt32
(
pCfg
,
"numOfVnodeFetchThreads"
,
tsNumOfVnodeFetchThreads
,
1
,
1024
,
0
)
!=
0
)
return
-
1
;
...
...
@@ -587,6 +592,7 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
tsNumOfMnodeQueryThreads
=
cfgGetItem
(
pCfg
,
"numOfMnodeQueryThreads"
)
->
i32
;
tsNumOfMnodeReadThreads
=
cfgGetItem
(
pCfg
,
"numOfMnodeReadThreads"
)
->
i32
;
tsNumOfVnodeQueryThreads
=
cfgGetItem
(
pCfg
,
"numOfVnodeQueryThreads"
)
->
i32
;
tsNumOfVnodeStreamThreads
=
cfgGetItem
(
pCfg
,
"numOfVnodeStreamThreads"
)
->
i32
;
tsNumOfVnodeFetchThreads
=
cfgGetItem
(
pCfg
,
"numOfVnodeFetchThreads"
)
->
i32
;
tsNumOfVnodeWriteThreads
=
cfgGetItem
(
pCfg
,
"numOfVnodeWriteThreads"
)
->
i32
;
tsNumOfVnodeSyncThreads
=
cfgGetItem
(
pCfg
,
"numOfVnodeSyncThreads"
)
->
i32
;
...
...
@@ -1117,10 +1123,44 @@ void taosCfgDynamicOptions(const char *option, const char *value) {
if
(
strncasecmp
(
option
,
"debugFlag"
,
9
)
==
0
)
{
int32_t
flag
=
atoi
(
value
);
taosSetAllDebugFlag
(
flag
);
return
;
}
if
(
strcasecmp
(
option
,
"resetlog"
)
==
0
)
{
taosResetLog
();
cfgDumpCfg
(
tsCfg
,
0
,
false
);
return
;
}
if
(
strcasecmp
(
option
,
"monitor"
)
==
0
)
{
int32_t
monitor
=
atoi
(
value
);
uInfo
(
"monitor set from %d to %d"
,
tsEnableMonitor
,
monitor
);
tsEnableMonitor
=
monitor
;
return
;
}
const
char
*
options
[]
=
{
"dDebugFlag"
,
"vDebugFlag"
,
"mDebugFlag"
,
"wDebugFlag"
,
"sDebugFlag"
,
"tsdbDebugFlag"
,
"tqDebugFlag"
,
"fsDebugFlag"
,
"udfDebugFlag"
,
"smaDebugFlag"
,
"idxDebugFlag"
,
"tmrDebugFlag"
,
"uDebugFlag"
,
"smaDebugFlag"
,
"rpcDebugFlag"
,
"qDebugFlag"
,
};
int32_t
*
optionVars
[]
=
{
&
dDebugFlag
,
&
vDebugFlag
,
&
mDebugFlag
,
&
wDebugFlag
,
&
sDebugFlag
,
&
tsdbDebugFlag
,
&
tqDebugFlag
,
&
fsDebugFlag
,
&
udfDebugFlag
,
&
smaDebugFlag
,
&
idxDebugFlag
,
&
tmrDebugFlag
,
&
uDebugFlag
,
&
smaDebugFlag
,
&
rpcDebugFlag
,
&
qDebugFlag
,
};
int32_t
optionSize
=
tListLen
(
options
);
for
(
int32_t
d
=
0
;
d
<
optionSize
;
++
d
)
{
const
char
*
optName
=
options
[
d
];
int32_t
optLen
=
strlen
(
optName
);
if
(
strncasecmp
(
option
,
optName
,
optLen
)
!=
0
)
continue
;
int32_t
flag
=
atoi
(
value
);
uInfo
(
"%s set from %d to %d"
,
optName
,
*
optionVars
[
d
],
flag
);
*
optionVars
[
d
]
=
flag
;
return
;
}
uError
(
"failed to cfg dynamic option:%s value:%s"
,
option
,
value
);
}
source/common/src/ttime.c
浏览文件 @
d3cdd75b
...
...
@@ -710,6 +710,32 @@ int64_t taosTimeAdd(int64_t t, int64_t duration, char unit, int32_t precision) {
return
(
int64_t
)(
taosMktime
(
&
tm
)
*
TSDB_TICK_PER_SECOND
(
precision
));
}
int64_t
taosTimeSub
(
int64_t
t
,
int64_t
duration
,
char
unit
,
int32_t
precision
)
{
if
(
duration
==
0
)
{
return
t
;
}
if
(
unit
!=
'n'
&&
unit
!=
'y'
)
{
return
t
-
duration
;
}
// The following code handles the y/n time duration
int64_t
numOfMonth
=
duration
;
if
(
unit
==
'y'
)
{
numOfMonth
*=
12
;
}
struct
tm
tm
;
time_t
tt
=
(
time_t
)(
t
/
TSDB_TICK_PER_SECOND
(
precision
));
taosLocalTime
(
&
tt
,
&
tm
);
int32_t
mon
=
tm
.
tm_year
*
12
+
tm
.
tm_mon
-
(
int32_t
)
numOfMonth
;
tm
.
tm_year
=
mon
/
12
;
tm
.
tm_mon
=
mon
%
12
;
return
(
int64_t
)(
taosMktime
(
&
tm
)
*
TSDB_TICK_PER_SECOND
(
precision
));
}
int32_t
taosTimeCountInterval
(
int64_t
skey
,
int64_t
ekey
,
int64_t
interval
,
char
unit
,
int32_t
precision
)
{
if
(
ekey
<
skey
)
{
int64_t
tmp
=
ekey
;
...
...
source/dnode/mgmt/mgmt_vnode/inc/vmInt.h
浏览文件 @
d3cdd75b
...
...
@@ -31,6 +31,7 @@ typedef struct SVnodeMgmt {
const
char
*
path
;
const
char
*
name
;
SQWorkerPool
queryPool
;
SQWorkerPool
streamPool
;
SWWorkerPool
fetchPool
;
SWWorkerPool
syncPool
;
SWWorkerPool
writePool
;
...
...
@@ -61,6 +62,7 @@ typedef struct {
STaosQueue
*
pSyncQ
;
STaosQueue
*
pApplyQ
;
STaosQueue
*
pQueryQ
;
STaosQueue
*
pStreamQ
;
STaosQueue
*
pFetchQ
;
}
SVnodeObj
;
...
...
@@ -105,6 +107,7 @@ int32_t vmPutMsgToWriteQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
int32_t
vmPutMsgToSyncQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
vmPutMsgToQueryQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
vmPutMsgToFetchQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
vmPutMsgToStreamQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
vmPutMsgToMergeQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
vmPutMsgToMgmtQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
vmPutMsgToMonitorQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
...
...
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
浏览文件 @
d3cdd75b
...
...
@@ -357,16 +357,16 @@ SArray *vmGetMsgHandles() {
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_COMMIT
,
vmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SCH_QUERY_HEARTBEAT
,
vmPutMsgToFetchQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_STREAM_TRIGGER
,
vmPutMsgTo
Fetch
Queue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_STREAM_TRIGGER
,
vmPutMsgTo
Stream
Queue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_STREAM_TASK_DROP
,
vmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_STREAM_TASK_DEPLOY
,
vmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_STREAM_TASK_RUN
,
vmPutMsgTo
Fetch
Queue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_STREAM_TASK_DISPATCH
,
vmPutMsgTo
Fetch
Queue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_STREAM_TASK_DISPATCH_RSP
,
vmPutMsgTo
Fetch
Queue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_STREAM_TASK_RECOVER
,
vmPutMsgTo
Fetch
Queue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_STREAM_TASK_RECOVER_RSP
,
vmPutMsgTo
Fetch
Queue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_STREAM_RETRIEVE
,
vmPutMsgTo
Fetch
Queue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_STREAM_RETRIEVE_RSP
,
vmPutMsgTo
Fetch
Queue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_STREAM_TASK_RUN
,
vmPutMsgTo
Stream
Queue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_STREAM_TASK_DISPATCH
,
vmPutMsgTo
Stream
Queue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_STREAM_TASK_DISPATCH_RSP
,
vmPutMsgTo
Stream
Queue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_STREAM_TASK_RECOVER
,
vmPutMsgTo
Stream
Queue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_STREAM_TASK_RECOVER_RSP
,
vmPutMsgTo
Stream
Queue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_STREAM_RETRIEVE
,
vmPutMsgTo
Stream
Queue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_STREAM_RETRIEVE_RSP
,
vmPutMsgTo
Stream
Queue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_ALTER_REPLICA
,
vmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_ALTER_CONFIG
,
vmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
...
...
source/dnode/mgmt/mgmt_vnode/src/vmInt.c
浏览文件 @
d3cdd75b
...
...
@@ -92,6 +92,7 @@ void vmCloseVnode(SVnodeMgmt *pMgmt, SVnodeObj *pVnode) {
while
(
!
taosQueueEmpty
(
pVnode
->
pApplyQ
))
taosMsleep
(
10
);
while
(
!
taosQueueEmpty
(
pVnode
->
pQueryQ
))
taosMsleep
(
10
);
while
(
!
taosQueueEmpty
(
pVnode
->
pFetchQ
))
taosMsleep
(
10
);
while
(
!
taosQueueEmpty
(
pVnode
->
pStreamQ
))
taosMsleep
(
10
);
dTrace
(
"vgId:%d, vnode queue is empty"
,
pVnode
->
vgId
);
vmFreeQueue
(
pMgmt
,
pVnode
);
...
...
source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
浏览文件 @
d3cdd75b
...
...
@@ -81,6 +81,23 @@ static void vmProcessQueryQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
taosFreeQitem
(
pMsg
);
}
static
void
vmProcessStreamQueue
(
SQueueInfo
*
pInfo
,
SRpcMsg
*
pMsg
)
{
SVnodeObj
*
pVnode
=
pInfo
->
ahandle
;
const
STraceId
*
trace
=
&
pMsg
->
info
.
traceId
;
dGTrace
(
"vgId:%d, msg:%p get from vnode-stream queue"
,
pVnode
->
vgId
,
pMsg
);
int32_t
code
=
vnodeProcessFetchMsg
(
pVnode
->
pImpl
,
pMsg
,
pInfo
);
if
(
code
!=
0
)
{
if
(
terrno
!=
0
)
code
=
terrno
;
dGError
(
"vgId:%d, msg:%p failed to stream since %s"
,
pVnode
->
vgId
,
pMsg
,
terrstr
());
vmSendRsp
(
pMsg
,
code
);
}
dGTrace
(
"vgId:%d, msg:%p is freed, code:0x%x"
,
pVnode
->
vgId
,
pMsg
,
code
);
rpcFreeCont
(
pMsg
->
pCont
);
taosFreeQitem
(
pMsg
);
}
static
void
vmProcessFetchQueue
(
SQueueInfo
*
pInfo
,
STaosQall
*
qall
,
int32_t
numOfMsgs
)
{
SVnodeObj
*
pVnode
=
pInfo
->
ahandle
;
SRpcMsg
*
pMsg
=
NULL
;
...
...
@@ -140,6 +157,10 @@ static int32_t vmPutMsgToQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg, EQueueType qtyp
dGTrace
(
"vgId:%d, msg:%p put into vnode-query queue"
,
pVnode
->
vgId
,
pMsg
);
taosWriteQitem
(
pVnode
->
pQueryQ
,
pMsg
);
break
;
case
STREAM_QUEUE
:
dGTrace
(
"vgId:%d, msg:%p put into vnode-stream queue"
,
pVnode
->
vgId
,
pMsg
);
taosWriteQitem
(
pVnode
->
pStreamQ
,
pMsg
);
break
;
case
FETCH_QUEUE
:
dGTrace
(
"vgId:%d, msg:%p put into vnode-fetch queue"
,
pVnode
->
vgId
,
pMsg
);
taosWriteQitem
(
pVnode
->
pFetchQ
,
pMsg
);
...
...
@@ -174,6 +195,8 @@ int32_t vmPutMsgToQueryQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) { return vmPutMsg
int32_t
vmPutMsgToFetchQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
return
vmPutMsgToQueue
(
pMgmt
,
pMsg
,
FETCH_QUEUE
);
}
int32_t
vmPutMsgToStreamQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
return
vmPutMsgToQueue
(
pMgmt
,
pMsg
,
STREAM_QUEUE
);
}
int32_t
vmPutMsgToMgmtQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
const
STraceId
*
trace
=
&
pMsg
->
info
.
traceId
;
dGTrace
(
"msg:%p, put into vnode-mgmt queue"
,
pMsg
);
...
...
@@ -234,6 +257,9 @@ int32_t vmGetQueueSize(SVnodeMgmt *pMgmt, int32_t vgId, EQueueType qtype) {
case
FETCH_QUEUE
:
size
=
taosQueueItemSize
(
pVnode
->
pFetchQ
);
break
;
case
STREAM_QUEUE
:
size
=
taosQueueItemSize
(
pVnode
->
pStreamQ
);
break
;
default:
break
;
}
...
...
@@ -247,10 +273,11 @@ int32_t vmAllocQueue(SVnodeMgmt *pMgmt, SVnodeObj *pVnode) {
pVnode
->
pSyncQ
=
tWWorkerAllocQueue
(
&
pMgmt
->
syncPool
,
pVnode
,
(
FItems
)
vmProcessSyncQueue
);
pVnode
->
pApplyQ
=
tWWorkerAllocQueue
(
&
pMgmt
->
applyPool
,
pVnode
->
pImpl
,
(
FItems
)
vnodeApplyWriteMsg
);
pVnode
->
pQueryQ
=
tQWorkerAllocQueue
(
&
pMgmt
->
queryPool
,
pVnode
,
(
FItem
)
vmProcessQueryQueue
);
pVnode
->
pStreamQ
=
tQWorkerAllocQueue
(
&
pMgmt
->
streamPool
,
pVnode
,
(
FItem
)
vmProcessStreamQueue
);
pVnode
->
pFetchQ
=
tWWorkerAllocQueue
(
&
pMgmt
->
fetchPool
,
pVnode
,
(
FItems
)
vmProcessFetchQueue
);
if
(
pVnode
->
pWriteQ
==
NULL
||
pVnode
->
pSyncQ
==
NULL
||
pVnode
->
pApplyQ
==
NULL
||
pVnode
->
pQueryQ
==
NULL
||
pVnode
->
pFetchQ
==
NULL
)
{
pVnode
->
p
StreamQ
==
NULL
||
pVnode
->
p
FetchQ
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
...
...
@@ -259,6 +286,7 @@ int32_t vmAllocQueue(SVnodeMgmt *pMgmt, SVnodeObj *pVnode) {
dDebug
(
"vgId:%d, sync-queue:%p is alloced"
,
pVnode
->
vgId
,
pVnode
->
pSyncQ
);
dDebug
(
"vgId:%d, apply-queue:%p is alloced"
,
pVnode
->
vgId
,
pVnode
->
pApplyQ
);
dDebug
(
"vgId:%d, query-queue:%p is alloced"
,
pVnode
->
vgId
,
pVnode
->
pQueryQ
);
dDebug
(
"vgId:%d, stream-queue:%p is alloced"
,
pVnode
->
vgId
,
pVnode
->
pStreamQ
);
dDebug
(
"vgId:%d, fetch-queue:%p is alloced"
,
pVnode
->
vgId
,
pVnode
->
pFetchQ
);
return
0
;
}
...
...
@@ -268,11 +296,13 @@ void vmFreeQueue(SVnodeMgmt *pMgmt, SVnodeObj *pVnode) {
tWWorkerFreeQueue
(
&
pMgmt
->
applyPool
,
pVnode
->
pApplyQ
);
tWWorkerFreeQueue
(
&
pMgmt
->
syncPool
,
pVnode
->
pSyncQ
);
tQWorkerFreeQueue
(
&
pMgmt
->
queryPool
,
pVnode
->
pQueryQ
);
tQWorkerFreeQueue
(
&
pMgmt
->
streamPool
,
pVnode
->
pStreamQ
);
tWWorkerFreeQueue
(
&
pMgmt
->
fetchPool
,
pVnode
->
pFetchQ
);
pVnode
->
pWriteQ
=
NULL
;
pVnode
->
pSyncQ
=
NULL
;
pVnode
->
pApplyQ
=
NULL
;
pVnode
->
pQueryQ
=
NULL
;
pVnode
->
pStreamQ
=
NULL
;
pVnode
->
pFetchQ
=
NULL
;
dDebug
(
"vgId:%d, queue is freed"
,
pVnode
->
vgId
);
}
...
...
@@ -284,6 +314,12 @@ int32_t vmStartWorker(SVnodeMgmt *pMgmt) {
pQPool
->
max
=
tsNumOfVnodeQueryThreads
;
if
(
tQWorkerInit
(
pQPool
)
!=
0
)
return
-
1
;
SQWorkerPool
*
pStreamPool
=
&
pMgmt
->
streamPool
;
pStreamPool
->
name
=
"vnode-stream"
;
pStreamPool
->
min
=
tsNumOfVnodeStreamThreads
;
pStreamPool
->
max
=
tsNumOfVnodeStreamThreads
;
if
(
tQWorkerInit
(
pStreamPool
)
!=
0
)
return
-
1
;
SWWorkerPool
*
pFPool
=
&
pMgmt
->
fetchPool
;
pFPool
->
name
=
"vnode-fetch"
;
pFPool
->
max
=
tsNumOfVnodeFetchThreads
;
...
...
@@ -333,6 +369,7 @@ void vmStopWorker(SVnodeMgmt *pMgmt) {
tWWorkerCleanup
(
&
pMgmt
->
applyPool
);
tWWorkerCleanup
(
&
pMgmt
->
syncPool
);
tQWorkerCleanup
(
&
pMgmt
->
queryPool
);
tQWorkerCleanup
(
&
pMgmt
->
streamPool
);
tWWorkerCleanup
(
&
pMgmt
->
fetchPool
);
dDebug
(
"vnode workers are closed"
);
}
source/dnode/mnode/impl/src/mndDnode.c
浏览文件 @
d3cdd75b
...
...
@@ -782,6 +782,12 @@ _OVER:
static
int32_t
mndProcessConfigDnodeReq
(
SRpcMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
info
.
node
;
const
char
*
options
[]
=
{
"debugFlag"
,
"dDebugFlag"
,
"vDebugFlag"
,
"mDebugFlag"
,
"wDebugFlag"
,
"sDebugFlag"
,
"tsdbDebugFlag"
,
"tqDebugFlag"
,
"fsDebugFlag"
,
"udfDebugFlag"
,
"smaDebugFlag"
,
"idxDebugFlag"
,
"tmrDebugFlag"
,
"uDebugFlag"
,
"smaDebugFlag"
,
"rpcDebugFlag"
,
"qDebugFlag"
,
};
int32_t
optionSize
=
tListLen
(
options
);
SMCfgDnodeReq
cfgReq
=
{
0
};
if
(
tDeserializeSMCfgDnodeReq
(
pReq
->
pCont
,
pReq
->
contLen
,
&
cfgReq
)
!=
0
)
{
...
...
@@ -802,28 +808,53 @@ static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) {
SEpSet
epSet
=
mndGetDnodeEpset
(
pDnode
);
mndReleaseDnode
(
pMnode
,
pDnode
);
SDCfgDnodeReq
dcfgReq
=
{
0
};
if
(
strncasecmp
(
cfgReq
.
config
,
"debugFlag"
,
9
)
==
0
)
{
if
(
strcasecmp
(
cfgReq
.
config
,
"resetlog"
)
==
0
)
{
strcpy
(
dcfgReq
.
config
,
"resetlog"
);
}
else
if
(
strncasecmp
(
cfgReq
.
config
,
"monitor"
,
7
)
==
0
)
{
const
char
*
value
=
cfgReq
.
value
;
int32_t
flag
=
atoi
(
value
);
if
(
flag
<=
0
)
{
flag
=
atoi
(
cfgReq
.
config
+
10
);
flag
=
atoi
(
cfgReq
.
config
+
8
);
}
if
(
flag
<
=
0
||
flag
>
255
)
{
mError
(
"dnode:%d, failed to config
debugFlag
since value:%d"
,
cfgReq
.
dnodeId
,
flag
);
if
(
flag
<
0
||
flag
>
2
)
{
mError
(
"dnode:%d, failed to config
monitor
since value:%d"
,
cfgReq
.
dnodeId
,
flag
);
terrno
=
TSDB_CODE_INVALID_CFG
;
return
-
1
;
}
strcpy
(
dcfgReq
.
config
,
"
debugFlag
"
);
strcpy
(
dcfgReq
.
config
,
"
monitor
"
);
snprintf
(
dcfgReq
.
value
,
TSDB_DNODE_VALUE_LEN
,
"%d"
,
flag
);
}
else
if
(
strcasecmp
(
cfgReq
.
config
,
"resetlog"
)
==
0
)
{
strcpy
(
dcfgReq
.
config
,
"resetlog"
);
}
else
{
bool
findOpt
=
false
;
for
(
int32_t
d
=
0
;
d
<
optionSize
;
++
d
)
{
const
char
*
optName
=
options
[
d
];
int32_t
optLen
=
strlen
(
optName
);
if
(
strncasecmp
(
cfgReq
.
config
,
optName
,
optLen
)
!=
0
)
continue
;
const
char
*
value
=
cfgReq
.
value
;
int32_t
flag
=
atoi
(
value
);
if
(
flag
<=
0
)
{
flag
=
atoi
(
cfgReq
.
config
+
optLen
+
1
);
}
if
(
flag
<=
0
||
flag
>
255
)
{
mError
(
"dnode:%d, failed to config %s since value:%d"
,
cfgReq
.
dnodeId
,
optName
,
flag
);
terrno
=
TSDB_CODE_INVALID_CFG
;
return
-
1
;
}
tstrncpy
(
dcfgReq
.
config
,
optName
,
optLen
+
1
);
snprintf
(
dcfgReq
.
value
,
TSDB_DNODE_VALUE_LEN
,
"%d"
,
flag
);
findOpt
=
true
;
}
if
(
!
findOpt
)
{
terrno
=
TSDB_CODE_INVALID_CFG
;
mError
(
"dnode:%d, failed to config since %s"
,
cfgReq
.
dnodeId
,
terrstr
());
return
-
1
;
}
}
int32_t
bufLen
=
tSerializeSDCfgDnodeReq
(
NULL
,
0
,
&
dcfgReq
);
void
*
pBuf
=
rpcMallocCont
(
bufLen
);
...
...
@@ -831,13 +862,14 @@ static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) {
if
(
pBuf
==
NULL
)
return
-
1
;
tSerializeSDCfgDnodeReq
(
pBuf
,
bufLen
,
&
dcfgReq
);
mDebug
(
"dnode:%d, send config req to dnode, app:%p"
,
cfgReq
.
dnodeId
,
pReq
->
info
.
ahandle
);
mInfo
(
"dnode:%d, send config req to dnode, app:%p config:%s value:%s"
,
cfgReq
.
dnodeId
,
pReq
->
info
.
ahandle
,
dcfgReq
.
config
,
dcfgReq
.
value
);
SRpcMsg
rpcMsg
=
{.
msgType
=
TDMT_DND_CONFIG_DNODE
,
.
pCont
=
pBuf
,
.
contLen
=
bufLen
};
return
tmsgSendReq
(
&
epSet
,
&
rpcMsg
);
}
static
int32_t
mndProcessConfigDnodeRsp
(
SRpcMsg
*
pRsp
)
{
m
Debug
(
"config rsp from dnode, app:%p"
,
pRsp
->
info
.
ahandle
);
m
Info
(
"config rsp from dnode, app:%p"
,
pRsp
->
info
.
ahandle
);
return
0
;
}
...
...
source/dnode/mnode/impl/src/mndMnode.c
浏览文件 @
d3cdd75b
...
...
@@ -218,6 +218,7 @@ bool mndIsMnode(SMnode *pMnode, int32_t dnodeId) {
}
void
mndGetMnodeEpSet
(
SMnode
*
pMnode
,
SEpSet
*
pEpSet
)
{
#if 0
SSdb *pSdb = pMnode->pSdb;
int32_t totalMnodes = sdbGetSize(pSdb, SDB_MNODE);
void *pIter = NULL;
...
...
@@ -237,6 +238,9 @@ void mndGetMnodeEpSet(SMnode *pMnode, SEpSet *pEpSet) {
addEpIntoEpSet(pEpSet, pObj->pDnode->fqdn, pObj->pDnode->port);
sdbRelease(pSdb, pObj);
}
#else
syncGetRetryEpSet
(
pMnode
->
syncMgmt
.
sync
,
pEpSet
);
#endif
}
static
int32_t
mndSetCreateMnodeRedoLogs
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SMnodeObj
*
pObj
)
{
...
...
source/dnode/vnode/src/tsdb/tsdbCacheRead.c
浏览文件 @
d3cdd75b
...
...
@@ -94,12 +94,15 @@ int32_t tsdbLastRowReaderOpen(void* pVnode, int32_t type, SArray* pTableIdList,
int32_t
tsdbLastrowReaderClose
(
void
*
pReader
)
{
SLastrowReader
*
p
=
pReader
;
if
(
p
->
pSchema
!=
NULL
)
{
for
(
int32_t
i
=
0
;
i
<
p
->
pSchema
->
numOfCols
;
++
i
)
{
taosMemoryFreeClear
(
p
->
transferBuf
[
i
]);
}
taosMemoryFree
(
p
->
pSchema
);
taosMemoryFree
(
p
->
transferBuf
);
taosMemoryFree
(
p
->
pSchema
);
}
taosMemoryFree
(
pReader
);
return
TSDB_CODE_SUCCESS
;
}
...
...
source/dnode/vnode/src/vnd/vnodeSync.c
浏览文件 @
d3cdd75b
...
...
@@ -427,6 +427,7 @@ static void vnodeSyncCommitMsg(SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta c
syncGetVgId
(
pVnode
->
sync
),
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
syncUtilState2String
(
cbMeta
.
state
),
pMsg
->
msgType
,
TMSG_INFO
(
pMsg
->
msgType
));
if
(
cbMeta
.
code
==
0
)
{
SRpcMsg
rpcMsg
=
{.
msgType
=
pMsg
->
msgType
,
.
contLen
=
pMsg
->
contLen
};
rpcMsg
.
pCont
=
rpcMallocCont
(
rpcMsg
.
contLen
);
memcpy
(
rpcMsg
.
pCont
,
pMsg
->
pCont
,
pMsg
->
contLen
);
...
...
@@ -434,6 +435,14 @@ static void vnodeSyncCommitMsg(SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta c
rpcMsg
.
info
.
conn
.
applyIndex
=
cbMeta
.
index
;
rpcMsg
.
info
.
conn
.
applyTerm
=
cbMeta
.
term
;
tmsgPutToQueue
(
&
pVnode
->
msgCb
,
APPLY_QUEUE
,
&
rpcMsg
);
}
else
{
SRpcMsg
rsp
=
{.
code
=
cbMeta
.
code
,
.
info
=
pMsg
->
info
};
vError
(
"vgId:%d, sync commit error, msgtype:%d,%s, error:0x%X, errmsg:%s"
,
syncGetVgId
(
pVnode
->
sync
),
pMsg
->
msgType
,
TMSG_INFO
(
pMsg
->
msgType
),
cbMeta
.
code
,
tstrerror
(
cbMeta
.
code
));
if
(
rsp
.
info
.
handle
!=
NULL
)
{
tmsgSendRsp
(
&
rsp
);
}
}
}
static
void
vnodeSyncPreCommitMsg
(
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
)
{
...
...
source/libs/command/src/command.c
浏览文件 @
d3cdd75b
...
...
@@ -570,12 +570,16 @@ int32_t buildSelectResultDataBlock(SNodeList* pProjects, SSDataBlock* pBlock) {
int32_t
index
=
0
;
SNode
*
pProj
=
NULL
;
FOREACH
(
pProj
,
pProjects
)
{
if
(
QUERY_NODE_VALUE
!=
nodeType
(
pProj
))
{
return
TSDB_CODE_PAR_INVALID_SELECTED_EXPR
;
}
else
{
if
(((
SValueNode
*
)
pProj
)
->
isNull
)
{
colDataAppend
(
taosArrayGet
(
pBlock
->
pDataBlock
,
index
++
),
0
,
NULL
,
true
);
}
else
{
colDataAppend
(
taosArrayGet
(
pBlock
->
pDataBlock
,
index
++
),
0
,
nodesGetValueFromNode
((
SValueNode
*
)
pProj
),
false
);
}
}
}
pBlock
->
info
.
rows
=
1
;
return
TSDB_CODE_SUCCESS
;
...
...
source/libs/executor/CMakeLists.txt
浏览文件 @
d3cdd75b
...
...
@@ -8,7 +8,7 @@ add_library(executor STATIC ${EXECUTOR_SRC})
# )
target_link_libraries
(
executor
PRIVATE os util common function parser planner qcom vnode scalar nodes index
PRIVATE os util common function parser planner qcom vnode scalar nodes index stream
)
target_include_directories
(
...
...
source/libs/executor/inc/executorimpl.h
浏览文件 @
d3cdd75b
...
...
@@ -39,6 +39,7 @@ extern "C" {
#include "tmsg.h"
#include "tpagedbuf.h"
#include "tstreamUpdate.h"
#include "tstream.h"
#include "vnode.h"
#include "executorInt.h"
...
...
@@ -139,12 +140,14 @@ typedef struct STaskIdInfo {
}
STaskIdInfo
;
typedef
struct
{
//TODO remove prepareStatus
STqOffsetVal
prepareStatus
;
// for tmq
STqOffsetVal
lastStatus
;
// for tmq
void
*
metaBlk
;
// for tmq fetching meta
SSDataBlock
*
pullOverBlk
;
// for streaming
SWalFilterCond
cond
;
int64_t
lastScanUid
;
SStreamQueue
*
inputQueue
;
}
SStreamTaskInfo
;
typedef
struct
SExecTaskInfo
{
...
...
source/libs/executor/src/executor.c
浏览文件 @
d3cdd75b
...
...
@@ -60,8 +60,6 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t nu
taosArrayAddAll
(
p
->
pDataBlock
,
pDataBlock
->
pDataBlock
);
taosArrayPush
(
pInfo
->
pBlockLists
,
&
p
);
}
/*} else if (type == STREAM_INPUT__TABLE_SCAN) {*/
/*ASSERT(pInfo->blockType == STREAM_INPUT__TABLE_SCAN);*/
}
else
{
ASSERT
(
0
);
}
...
...
source/libs/executor/src/executorMain.c
浏览文件 @
d3cdd75b
...
...
@@ -44,6 +44,13 @@ int32_t qCreateExecTask(SReadHandle* readHandle, int32_t vgId, uint64_t taskId,
goto
_error
;
}
if
(
model
==
OPTR_EXEC_MODEL_STREAM
)
{
(
*
pTask
)
->
streamInfo
.
inputQueue
=
streamQueueOpen
();
if
((
*
pTask
)
->
streamInfo
.
inputQueue
==
NULL
)
{
goto
_error
;
}
}
SDataSinkMgtCfg
cfg
=
{.
maxDataBlockNum
=
1000
,
.
maxDataBlockNumPerQuery
=
100
};
code
=
dsDataSinkMgtInit
(
&
cfg
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
...
...
@@ -252,6 +259,13 @@ int32_t qExtractStreamScanner(qTaskInfo_t tinfo, void** scanner) {
}
}
int32_t
qStreamInput
(
qTaskInfo_t
tinfo
,
void
*
pItem
)
{
SExecTaskInfo
*
pTaskInfo
=
(
SExecTaskInfo
*
)
tinfo
;
ASSERT
(
pTaskInfo
->
execModel
==
OPTR_EXEC_MODEL_STREAM
);
taosWriteQitem
(
pTaskInfo
->
streamInfo
.
inputQueue
->
queue
,
pItem
);
return
0
;
}
void
*
qExtractReaderFromStreamScanner
(
void
*
scanner
)
{
SStreamScanInfo
*
pInfo
=
scanner
;
return
(
void
*
)
pInfo
->
tqReader
;
...
...
source/libs/executor/src/scanoperator.c
浏览文件 @
d3cdd75b
...
...
@@ -1202,15 +1202,6 @@ static int32_t setBlockIntoRes(SStreamScanInfo* pInfo, const SSDataBlock* pBlock
taosArrayDestroy
(
pBlock
->
pDataBlock
);
ASSERT
(
pInfo
->
pRes
->
pDataBlock
!=
NULL
);
#if 0
if (pInfo->pRes->pDataBlock == NULL) {
// TODO add log
updateInfoDestoryColseWinSBF(pInfo->pUpdateInfo);
pOperator->status = OP_EXEC_DONE;
pTaskInfo->code = terrno;
return -1;
}
#endif
// currently only the tbname pseudo column
if
(
pInfo
->
numOfPseudoExpr
>
0
)
{
...
...
@@ -1231,11 +1222,6 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) {
SExecTaskInfo
*
pTaskInfo
=
pOperator
->
pTaskInfo
;
SStreamScanInfo
*
pInfo
=
pOperator
->
info
;
/*pTaskInfo->code = pOperator->fpSet._openFn(pOperator);*/
/*if (pTaskInfo->code != TSDB_CODE_SUCCESS || pOperator->status == OP_EXEC_DONE) {*/
/*return NULL;*/
/*}*/
qDebug
(
"stream scan called"
);
if
(
pTaskInfo
->
streamInfo
.
prepareStatus
.
type
==
TMQ_OFFSET__LOG
)
{
while
(
1
)
{
...
...
@@ -1425,15 +1411,6 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) {
qDebug
(
"scan rows: %d"
,
pBlockInfo
->
rows
);
return
(
pBlockInfo
->
rows
==
0
)
?
NULL
:
pInfo
->
pRes
;
#if 0
} else if (pInfo->blockType == STREAM_INPUT__TABLE_SCAN) {
ASSERT(0);
// check reader last status
// if not match, reset status
SSDataBlock* pResult = doTableScan(pInfo->pTableScanOp);
return pResult && pResult->info.rows > 0 ? pResult : NULL;
#endif
}
else
{
ASSERT
(
0
);
return
NULL
;
...
...
source/libs/executor/src/sortoperator.c
浏览文件 @
d3cdd75b
...
...
@@ -621,7 +621,9 @@ SSDataBlock* getMultiwaySortedBlockData(SSortHandle* pHandle, SSDataBlock* pData
break
;
}
}
if
(
pInfo
->
groupSort
)
{
pInfo
->
hasGroupId
=
false
;
}
if
(
p
->
info
.
rows
>
0
)
{
// todo extract method
blockDataEnsureCapacity
(
pDataBlock
,
p
->
info
.
rows
);
int32_t
numOfCols
=
taosArrayGetSize
(
pColMatchInfo
);
...
...
source/libs/executor/src/timewindowoperator.c
浏览文件 @
d3cdd75b
...
...
@@ -1341,9 +1341,9 @@ static int32_t closeIntervalWindow(SHashObj* pHashMap, STimeWindowAggSupp* pSup,
uint64_t
groupId
=
*
(
uint64_t
*
)
key
;
ASSERT
(
keyLen
==
GET_RES_WINDOW_KEY_LEN
(
sizeof
(
TSKEY
)));
TSKEY
ts
=
*
(
int64_t
*
)((
char
*
)
key
+
sizeof
(
uint64_t
));
S
ResultRowInfo
dumyInfo
;
dumyInfo
.
cur
.
pageId
=
-
1
;
STimeWindow
win
=
getActiveTimeWindow
(
NULL
,
&
dumyInfo
,
ts
,
pInterval
,
TSDB_ORDER_ASC
)
;
S
TimeWindow
win
;
win
.
skey
=
ts
;
win
.
ekey
=
taosTimeAdd
(
win
.
skey
,
pInterval
->
interval
,
pInterval
->
intervalUnit
,
pInterval
->
precision
)
-
1
;
SWinRes
winRe
=
{
.
ts
=
win
.
skey
,
.
groupId
=
groupId
,
...
...
@@ -4507,13 +4507,14 @@ static SSDataBlock* doMergeAlignedIntervalAgg(SOperatorInfo* pOperator) {
setInputDataBlock
(
pOperator
,
pSup
->
pCtx
,
pBlock
,
iaInfo
->
order
,
scanFlag
,
true
);
doMergeAlignedIntervalAggImpl
(
pOperator
,
&
iaInfo
->
binfo
.
resultRowInfo
,
pBlock
,
scanFlag
,
pRes
);
doFilter
(
miaInfo
->
pCondition
,
pRes
);
if
(
pRes
->
info
.
rows
>
0
)
{
if
(
pRes
->
info
.
rows
>
=
pOperator
->
resultInfo
.
capacity
)
{
break
;
}
}
pRes
->
info
.
groupId
=
miaInfo
->
groupId
;
}
miaInfo
->
hasGroupId
=
false
;
if
(
miaInfo
->
inputBlocksFinished
)
{
doSetOperatorCompleted
(
pOperator
);
...
...
source/libs/parser/src/parCalcConst.c
浏览文件 @
d3cdd75b
...
...
@@ -166,7 +166,7 @@ static int32_t calcConstStmtCondition(SCalcConstContext* pCxt, SNode** pCond, bo
return
code
;
}
static
int32_t
calcConstProject
(
SNode
*
pProject
,
SNode
**
pNew
)
{
static
int32_t
calcConstProject
(
SNode
*
pProject
,
bool
dual
,
SNode
**
pNew
)
{
SArray
*
pAssociation
=
NULL
;
if
(
NULL
!=
((
SExprNode
*
)
pProject
)
->
pAssociation
)
{
pAssociation
=
taosArrayDup
(((
SExprNode
*
)
pProject
)
->
pAssociation
);
...
...
@@ -177,7 +177,12 @@ static int32_t calcConstProject(SNode* pProject, SNode** pNew) {
char
aliasName
[
TSDB_COL_NAME_LEN
]
=
{
0
};
strcpy
(
aliasName
,
((
SExprNode
*
)
pProject
)
->
aliasName
);
int32_t
code
=
scalarCalculateConstants
(
pProject
,
pNew
);
int32_t
code
=
TSDB_CODE_SUCCESS
;
if
(
dual
)
{
code
=
scalarCalculateConstantsFromDual
(
pProject
,
pNew
);
}
else
{
code
=
scalarCalculateConstants
(
pProject
,
pNew
);
}
if
(
TSDB_CODE_SUCCESS
==
code
&&
QUERY_NODE_VALUE
==
nodeType
(
*
pNew
)
&&
NULL
!=
pAssociation
)
{
strcpy
(((
SExprNode
*
)
*
pNew
)
->
aliasName
,
aliasName
);
int32_t
size
=
taosArrayGetSize
(
pAssociation
);
...
...
@@ -223,7 +228,7 @@ static int32_t calcConstProjections(SCalcConstContext* pCxt, SSelectStmt* pSelec
continue
;
}
SNode
*
pNew
=
NULL
;
int32_t
code
=
calcConstProject
(
pProj
,
&
pNew
);
int32_t
code
=
calcConstProject
(
pProj
,
(
NULL
==
pSelect
->
pFromTable
),
&
pNew
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
REPLACE_NODE
(
pNew
);
}
else
{
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
d3cdd75b
...
...
@@ -916,8 +916,6 @@ static EDealRes translateValueImpl(STranslateContext* pCxt, SValueNode* pVal, SD
}
if
(
TSDB_DATA_TYPE_NULL
==
pVal
->
node
.
resType
.
type
)
{
// TODO
// pVal->node.resType = targetDt;
pVal
->
translate
=
true
;
pVal
->
isNull
=
true
;
return
DEAL_RES_CONTINUE
;
...
...
@@ -932,6 +930,7 @@ static EDealRes translateValueImpl(STranslateContext* pCxt, SValueNode* pVal, SD
res
=
translateNormalValue
(
pCxt
,
pVal
,
targetDt
,
strict
);
}
pVal
->
node
.
resType
=
targetDt
;
pVal
->
node
.
resType
.
scale
=
pVal
->
unit
;
pVal
->
translate
=
true
;
return
res
;
}
...
...
source/libs/planner/src/planOptimizer.c
浏览文件 @
d3cdd75b
...
...
@@ -124,12 +124,15 @@ static bool scanPathOptMayBeOptimized(SLogicNode* pNode) {
QUERY_NODE_LOGIC_PLAN_PARTITION
!=
nodeType
(
pNode
->
pParent
)))
{
return
false
;
}
if
(
QUERY_NODE_LOGIC_PLAN_WINDOW
==
nodeType
(
pNode
->
pParent
)
||
if
(
(
QUERY_NODE_LOGIC_PLAN_WINDOW
==
nodeType
(
pNode
->
pParent
)
&&
WINDOW_TYPE_INTERVAL
==
((
SWindowLogicNode
*
)
pNode
->
pParent
)
->
winType
)
||
(
QUERY_NODE_LOGIC_PLAN_PARTITION
==
nodeType
(
pNode
->
pParent
)
&&
pNode
->
pParent
->
pParent
&&
QUERY_NODE_LOGIC_PLAN_WINDOW
==
nodeType
(
pNode
->
pParent
->
pParent
)))
{
QUERY_NODE_LOGIC_PLAN_WINDOW
==
nodeType
(
pNode
->
pParent
->
pParent
)
&&
WINDOW_TYPE_INTERVAL
==
((
SWindowLogicNode
*
)
pNode
->
pParent
)
->
winType
))
{
return
true
;
}
if
(
QUERY_NODE_LOGIC_PLAN_AGG
==
nodeType
(
pNode
->
pParent
))
{
return
!
scanPathOptHaveNormalCol
(((
SAggLogicNode
*
)
pNode
->
pParent
)
->
pGroupKeys
);
}
return
false
;
}
static
SNodeList
*
scanPathOptGetAllFuncs
(
SLogicNode
*
pNode
)
{
...
...
source/libs/qworker/CMakeLists.txt
浏览文件 @
d3cdd75b
source/libs/scalar/inc/sclInt.h
浏览文件 @
d3cdd75b
...
...
@@ -30,6 +30,7 @@ typedef struct SOperatorValueType {
typedef
struct
SScalarCtx
{
int32_t
code
;
bool
dual
;
SArray
*
pBlockList
;
/* element is SSDataBlock* */
SHashObj
*
pRes
;
/* element is SScalarParam */
void
*
param
;
// additional parameter (meta actually) for acquire value such as tbname/tags values
...
...
source/libs/scalar/src/scalar.c
浏览文件 @
d3cdd75b
...
...
@@ -1010,13 +1010,14 @@ int32_t sclExtendResRows(SScalarParam *pDst, SScalarParam *pSrc, SArray *pBlockL
return
TSDB_CODE_SUCCESS
;
}
int32_t
sc
alarCalculateConstants
(
SNode
*
pNode
,
SNode
**
pRes
)
{
int32_t
sc
lCalcConstants
(
SNode
*
pNode
,
bool
dual
,
SNode
**
pRes
)
{
if
(
NULL
==
pNode
)
{
SCL_ERR_RET
(
TSDB_CODE_QRY_INVALID_INPUT
);
}
int32_t
code
=
0
;
SScalarCtx
ctx
=
{
0
};
ctx
.
dual
=
dual
;
ctx
.
pRes
=
taosHashInit
(
SCL_DEFAULT_OP_NUM
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
false
,
HASH_NO_LOCK
);
if
(
NULL
==
ctx
.
pRes
)
{
sclError
(
"taosHashInit failed, num:%d"
,
SCL_DEFAULT_OP_NUM
);
...
...
@@ -1028,54 +1029,12 @@ int32_t scalarCalculateConstants(SNode *pNode, SNode **pRes) {
*
pRes
=
pNode
;
_return:
sclFreeRes
(
ctx
.
pRes
);
return
code
;
}
int32_t
scalarCalculate
(
SNode
*
pNode
,
SArray
*
pBlockList
,
SScalarParam
*
pDst
)
{
if
(
NULL
==
pNode
||
NULL
==
pBlockList
)
{
SCL_ERR_RET
(
TSDB_CODE_QRY_INVALID_INPUT
);
}
int32_t
code
=
0
;
SScalarCtx
ctx
=
{.
code
=
0
,
.
pBlockList
=
pBlockList
,
.
param
=
pDst
?
pDst
->
param
:
NULL
};
// TODO: OPT performance
ctx
.
pRes
=
taosHashInit
(
SCL_DEFAULT_OP_NUM
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
false
,
HASH_NO_LOCK
);
if
(
NULL
==
ctx
.
pRes
)
{
sclError
(
"taosHashInit failed, num:%d"
,
SCL_DEFAULT_OP_NUM
);
SCL_ERR_RET
(
TSDB_CODE_QRY_OUT_OF_MEMORY
);
}
nodesWalkExprPostOrder
(
pNode
,
sclCalcWalker
,
(
void
*
)
&
ctx
);
SCL_ERR_JRET
(
ctx
.
code
);
if
(
pDst
)
{
SScalarParam
*
res
=
(
SScalarParam
*
)
taosHashGet
(
ctx
.
pRes
,
(
void
*
)
&
pNode
,
POINTER_BYTES
);
if
(
NULL
==
res
)
{
sclError
(
"no valid res in hash, node:%p, type:%d"
,
pNode
,
nodeType
(
pNode
));
SCL_ERR_JRET
(
TSDB_CODE_QRY_APP_ERROR
);
}
if
(
1
==
res
->
numOfRows
)
{
SCL_ERR_JRET
(
sclExtendResRows
(
pDst
,
res
,
pBlockList
));
}
else
{
colInfoDataEnsureCapacity
(
pDst
->
columnData
,
res
->
numOfRows
);
colDataAssign
(
pDst
->
columnData
,
res
->
columnData
,
res
->
numOfRows
,
NULL
);
pDst
->
numOfRows
=
res
->
numOfRows
;
}
sclFreeParam
(
res
);
taosHashRemove
(
ctx
.
pRes
,
(
void
*
)
&
pNode
,
POINTER_BYTES
);
}
_return:
//nodesDestroyNode(pNode);
sclFreeRes
(
ctx
.
pRes
);
return
code
;
}
static
int32_t
getMinusOperatorResult
Type
(
SOperatorNode
*
pOp
)
{
static
int32_t
sclGetMinusOperatorRes
Type
(
SOperatorNode
*
pOp
)
{
if
(
!
IS_MATHABLE_TYPE
(((
SExprNode
*
)(
pOp
->
pLeft
))
->
resType
.
type
))
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
...
...
@@ -1084,7 +1043,7 @@ static int32_t getMinusOperatorResultType(SOperatorNode* pOp) {
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
getArithmeticOperatorResult
Type
(
SOperatorNode
*
pOp
)
{
static
int32_t
sclGetMathOperatorRes
Type
(
SOperatorNode
*
pOp
)
{
SDataType
ldt
=
((
SExprNode
*
)(
pOp
->
pLeft
))
->
resType
;
SDataType
rdt
=
((
SExprNode
*
)(
pOp
->
pRight
))
->
resType
;
if
((
TSDB_DATA_TYPE_TIMESTAMP
==
ldt
.
type
&&
TSDB_DATA_TYPE_TIMESTAMP
==
rdt
.
type
)
||
...
...
@@ -1106,7 +1065,7 @@ static int32_t getArithmeticOperatorResultType(SOperatorNode* pOp) {
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
getComparisonOperatorResult
Type
(
SOperatorNode
*
pOp
)
{
static
int32_t
sclGetCompOperatorRes
Type
(
SOperatorNode
*
pOp
)
{
SDataType
ldt
=
((
SExprNode
*
)(
pOp
->
pLeft
))
->
resType
;
if
(
OP_TYPE_IN
==
pOp
->
opType
||
OP_TYPE_NOT_IN
==
pOp
->
opType
)
{
((
SExprNode
*
)(
pOp
->
pRight
))
->
resType
=
ldt
;
...
...
@@ -1122,7 +1081,7 @@ static int32_t getComparisonOperatorResultType(SOperatorNode* pOp) {
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
getJsonOperatorResult
Type
(
SOperatorNode
*
pOp
)
{
static
int32_t
sclGetJsonOperatorRes
Type
(
SOperatorNode
*
pOp
)
{
SDataType
ldt
=
((
SExprNode
*
)(
pOp
->
pLeft
))
->
resType
;
SDataType
rdt
=
((
SExprNode
*
)(
pOp
->
pRight
))
->
resType
;
if
(
TSDB_DATA_TYPE_JSON
!=
ldt
.
type
||
!
IS_STR_DATA_TYPE
(
rdt
.
type
))
{
...
...
@@ -1137,12 +1096,64 @@ static int32_t getJsonOperatorResultType(SOperatorNode* pOp) {
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
getBitwiseOperatorResult
Type
(
SOperatorNode
*
pOp
)
{
static
int32_t
sclGetBitwiseOperatorRes
Type
(
SOperatorNode
*
pOp
)
{
pOp
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_BIGINT
;
pOp
->
node
.
resType
.
bytes
=
tDataTypes
[
TSDB_DATA_TYPE_BIGINT
].
bytes
;
return
TSDB_CODE_SUCCESS
;
}
int32_t
scalarCalculateConstants
(
SNode
*
pNode
,
SNode
**
pRes
)
{
return
sclCalcConstants
(
pNode
,
false
,
pRes
);
}
int32_t
scalarCalculateConstantsFromDual
(
SNode
*
pNode
,
SNode
**
pRes
)
{
return
sclCalcConstants
(
pNode
,
true
,
pRes
);
}
int32_t
scalarCalculate
(
SNode
*
pNode
,
SArray
*
pBlockList
,
SScalarParam
*
pDst
)
{
if
(
NULL
==
pNode
||
NULL
==
pBlockList
)
{
SCL_ERR_RET
(
TSDB_CODE_QRY_INVALID_INPUT
);
}
int32_t
code
=
0
;
SScalarCtx
ctx
=
{.
code
=
0
,
.
pBlockList
=
pBlockList
,
.
param
=
pDst
?
pDst
->
param
:
NULL
};
// TODO: OPT performance
ctx
.
pRes
=
taosHashInit
(
SCL_DEFAULT_OP_NUM
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
false
,
HASH_NO_LOCK
);
if
(
NULL
==
ctx
.
pRes
)
{
sclError
(
"taosHashInit failed, num:%d"
,
SCL_DEFAULT_OP_NUM
);
SCL_ERR_RET
(
TSDB_CODE_QRY_OUT_OF_MEMORY
);
}
nodesWalkExprPostOrder
(
pNode
,
sclCalcWalker
,
(
void
*
)
&
ctx
);
SCL_ERR_JRET
(
ctx
.
code
);
if
(
pDst
)
{
SScalarParam
*
res
=
(
SScalarParam
*
)
taosHashGet
(
ctx
.
pRes
,
(
void
*
)
&
pNode
,
POINTER_BYTES
);
if
(
NULL
==
res
)
{
sclError
(
"no valid res in hash, node:%p, type:%d"
,
pNode
,
nodeType
(
pNode
));
SCL_ERR_JRET
(
TSDB_CODE_QRY_APP_ERROR
);
}
if
(
1
==
res
->
numOfRows
)
{
SCL_ERR_JRET
(
sclExtendResRows
(
pDst
,
res
,
pBlockList
));
}
else
{
colInfoDataEnsureCapacity
(
pDst
->
columnData
,
res
->
numOfRows
);
colDataAssign
(
pDst
->
columnData
,
res
->
columnData
,
res
->
numOfRows
,
NULL
);
pDst
->
numOfRows
=
res
->
numOfRows
;
}
sclFreeParam
(
res
);
taosHashRemove
(
ctx
.
pRes
,
(
void
*
)
&
pNode
,
POINTER_BYTES
);
}
_return:
//nodesDestroyNode(pNode);
sclFreeRes
(
ctx
.
pRes
);
return
code
;
}
int32_t
scalarGetOperatorResultType
(
SOperatorNode
*
pOp
)
{
if
(
TSDB_DATA_TYPE_BLOB
==
((
SExprNode
*
)(
pOp
->
pLeft
))
->
resType
.
type
||
(
NULL
!=
pOp
->
pRight
&&
TSDB_DATA_TYPE_BLOB
==
((
SExprNode
*
)(
pOp
->
pRight
))
->
resType
.
type
))
{
...
...
@@ -1155,15 +1166,15 @@ int32_t scalarGetOperatorResultType(SOperatorNode* pOp) {
case
OP_TYPE_MULTI
:
case
OP_TYPE_DIV
:
case
OP_TYPE_REM
:
return
getArithmeticOperatorResult
Type
(
pOp
);
return
sclGetMathOperatorRes
Type
(
pOp
);
case
OP_TYPE_MINUS
:
return
getMinusOperatorResult
Type
(
pOp
);
return
sclGetMinusOperatorRes
Type
(
pOp
);
case
OP_TYPE_ASSIGN
:
pOp
->
node
.
resType
=
((
SExprNode
*
)(
pOp
->
pLeft
))
->
resType
;
break
;
case
OP_TYPE_BIT_AND
:
case
OP_TYPE_BIT_OR
:
return
getBitwiseOperatorResult
Type
(
pOp
);
return
sclGetBitwiseOperatorRes
Type
(
pOp
);
case
OP_TYPE_GREATER_THAN
:
case
OP_TYPE_GREATER_EQUAL
:
case
OP_TYPE_LOWER_THAN
:
...
...
@@ -1184,10 +1195,10 @@ int32_t scalarGetOperatorResultType(SOperatorNode* pOp) {
case
OP_TYPE_NMATCH
:
case
OP_TYPE_IN
:
case
OP_TYPE_NOT_IN
:
return
getComparisonOperatorResult
Type
(
pOp
);
return
sclGetCompOperatorRes
Type
(
pOp
);
case
OP_TYPE_JSON_GET_VALUE
:
case
OP_TYPE_JSON_CONTAINS
:
return
getJsonOperatorResult
Type
(
pOp
);
return
sclGetJsonOperatorRes
Type
(
pOp
);
default:
break
;
}
...
...
source/libs/scalar/src/sclvector.c
浏览文件 @
d3cdd75b
...
...
@@ -1055,7 +1055,7 @@ static void vectorMathAddHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRig
}
}
static
void
vectorMath
Bigint
AddHelper
(
SColumnInfoData
*
pLeftCol
,
SColumnInfoData
*
pRightCol
,
SColumnInfoData
*
pOutputCol
,
int32_t
numOfRows
,
int32_t
step
,
int32_t
i
)
{
static
void
vectorMath
Ts
AddHelper
(
SColumnInfoData
*
pLeftCol
,
SColumnInfoData
*
pRightCol
,
SColumnInfoData
*
pOutputCol
,
int32_t
numOfRows
,
int32_t
step
,
int32_t
i
)
{
_getBigintValue_fn_t
getVectorBigintValueFnLeft
=
getVectorBigintValueFn
(
pLeftCol
->
info
.
type
);
_getBigintValue_fn_t
getVectorBigintValueFnRight
=
getVectorBigintValueFn
(
pRightCol
->
info
.
type
);
...
...
@@ -1069,7 +1069,8 @@ static void vectorMathBigintAddHelper(SColumnInfoData* pLeftCol, SColumnInfoData
colDataAppendNULL
(
pOutputCol
,
i
);
continue
;
// TODO set null or ignore
}
*
output
=
getVectorBigintValueFnLeft
(
pLeftCol
->
pData
,
i
)
+
getVectorBigintValueFnRight
(
pRightCol
->
pData
,
0
);
*
output
=
taosTimeAdd
(
getVectorBigintValueFnLeft
(
pLeftCol
->
pData
,
i
),
getVectorBigintValueFnRight
(
pRightCol
->
pData
,
0
),
pRightCol
->
info
.
scale
,
pRightCol
->
info
.
precision
);
}
}
}
...
...
@@ -1116,7 +1117,17 @@ void vectorMathAdd(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut
_getBigintValue_fn_t
getVectorBigintValueFnLeft
=
getVectorBigintValueFn
(
pLeftCol
->
info
.
type
);
_getBigintValue_fn_t
getVectorBigintValueFnRight
=
getVectorBigintValueFn
(
pRightCol
->
info
.
type
);
if
(
pLeft
->
numOfRows
==
pRight
->
numOfRows
)
{
if
(
pLeft
->
numOfRows
==
1
&&
pRight
->
numOfRows
==
1
)
{
if
(
GET_PARAM_TYPE
(
pLeft
)
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
vectorMathTsAddHelper
(
pLeftCol
,
pRightCol
,
pOutputCol
,
pRight
->
numOfRows
,
step
,
i
);
}
else
{
vectorMathTsAddHelper
(
pRightCol
,
pLeftCol
,
pOutputCol
,
pRight
->
numOfRows
,
step
,
i
);
}
}
else
if
(
pLeft
->
numOfRows
==
1
)
{
vectorMathTsAddHelper
(
pRightCol
,
pLeftCol
,
pOutputCol
,
pRight
->
numOfRows
,
step
,
i
);
}
else
if
(
pRight
->
numOfRows
==
1
)
{
vectorMathTsAddHelper
(
pLeftCol
,
pRightCol
,
pOutputCol
,
pLeft
->
numOfRows
,
step
,
i
);
}
else
if
(
pLeft
->
numOfRows
==
pRight
->
numOfRows
)
{
for
(;
i
<
pRight
->
numOfRows
&&
i
>=
0
;
i
+=
step
,
output
+=
1
)
{
if
(
IS_NULL
)
{
colDataAppendNULL
(
pOutputCol
,
i
);
...
...
@@ -1124,10 +1135,6 @@ void vectorMathAdd(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut
}
*
output
=
getVectorBigintValueFnLeft
(
pLeftCol
->
pData
,
i
)
+
getVectorBigintValueFnRight
(
pRightCol
->
pData
,
i
);
}
}
else
if
(
pLeft
->
numOfRows
==
1
)
{
vectorMathBigintAddHelper
(
pRightCol
,
pLeftCol
,
pOutputCol
,
pRight
->
numOfRows
,
step
,
i
);
}
else
if
(
pRight
->
numOfRows
==
1
)
{
vectorMathBigintAddHelper
(
pLeftCol
,
pRightCol
,
pOutputCol
,
pLeft
->
numOfRows
,
step
,
i
);
}
}
else
{
double
*
output
=
(
double
*
)
pOutputCol
->
pData
;
...
...
@@ -1174,7 +1181,7 @@ static void vectorMathSubHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRig
}
}
static
void
vectorMath
Bigint
SubHelper
(
SColumnInfoData
*
pLeftCol
,
SColumnInfoData
*
pRightCol
,
SColumnInfoData
*
pOutputCol
,
int32_t
numOfRows
,
int32_t
step
,
int32_t
factor
,
int32_t
i
)
{
static
void
vectorMath
Ts
SubHelper
(
SColumnInfoData
*
pLeftCol
,
SColumnInfoData
*
pRightCol
,
SColumnInfoData
*
pOutputCol
,
int32_t
numOfRows
,
int32_t
step
,
int32_t
factor
,
int32_t
i
)
{
_getBigintValue_fn_t
getVectorBigintValueFnLeft
=
getVectorBigintValueFn
(
pLeftCol
->
info
.
type
);
_getBigintValue_fn_t
getVectorBigintValueFnRight
=
getVectorBigintValueFn
(
pRightCol
->
info
.
type
);
...
...
@@ -1188,7 +1195,9 @@ static void vectorMathBigintSubHelper(SColumnInfoData* pLeftCol, SColumnInfoData
colDataAppendNULL
(
pOutputCol
,
i
);
continue
;
// TODO set null or ignore
}
*
output
=
(
getVectorBigintValueFnLeft
(
pLeftCol
->
pData
,
i
)
-
getVectorBigintValueFnRight
(
pRightCol
->
pData
,
0
))
*
factor
;
*
output
=
taosTimeSub
(
getVectorBigintValueFnLeft
(
pLeftCol
->
pData
,
i
),
getVectorBigintValueFnRight
(
pRightCol
->
pData
,
0
),
pRightCol
->
info
.
scale
,
pRightCol
->
info
.
precision
);
}
}
}
...
...
@@ -1211,7 +1220,13 @@ void vectorMathSub(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut
_getBigintValue_fn_t
getVectorBigintValueFnLeft
=
getVectorBigintValueFn
(
pLeftCol
->
info
.
type
);
_getBigintValue_fn_t
getVectorBigintValueFnRight
=
getVectorBigintValueFn
(
pRightCol
->
info
.
type
);
if
(
pLeft
->
numOfRows
==
pRight
->
numOfRows
)
{
if
(
pLeft
->
numOfRows
==
1
&&
pRight
->
numOfRows
==
1
)
{
vectorMathTsSubHelper
(
pLeftCol
,
pRightCol
,
pOutputCol
,
pLeft
->
numOfRows
,
step
,
1
,
i
);
}
else
if
(
pLeft
->
numOfRows
==
1
)
{
vectorMathTsSubHelper
(
pRightCol
,
pLeftCol
,
pOutputCol
,
pRight
->
numOfRows
,
step
,
-
1
,
i
);
}
else
if
(
pRight
->
numOfRows
==
1
)
{
vectorMathTsSubHelper
(
pLeftCol
,
pRightCol
,
pOutputCol
,
pLeft
->
numOfRows
,
step
,
1
,
i
);
}
else
if
(
pLeft
->
numOfRows
==
pRight
->
numOfRows
)
{
for
(;
i
<
pRight
->
numOfRows
&&
i
>=
0
;
i
+=
step
,
output
+=
1
)
{
if
(
IS_NULL
)
{
colDataAppendNULL
(
pOutputCol
,
i
);
...
...
@@ -1219,10 +1234,6 @@ void vectorMathSub(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut
}
*
output
=
getVectorBigintValueFnLeft
(
pLeftCol
->
pData
,
i
)
-
getVectorBigintValueFnRight
(
pRightCol
->
pData
,
i
);
}
}
else
if
(
pLeft
->
numOfRows
==
1
)
{
vectorMathBigintSubHelper
(
pRightCol
,
pLeftCol
,
pOutputCol
,
pRight
->
numOfRows
,
step
,
-
1
,
i
);
}
else
if
(
pRight
->
numOfRows
==
1
)
{
vectorMathBigintSubHelper
(
pLeftCol
,
pRightCol
,
pOutputCol
,
pLeft
->
numOfRows
,
step
,
1
,
i
);
}
}
else
{
double
*
output
=
(
double
*
)
pOutputCol
->
pData
;
...
...
source/libs/stream/inc/streamInc.h
浏览文件 @
d3cdd75b
...
...
@@ -42,6 +42,9 @@ int32_t streamBroadcastToChildren(SStreamTask* pTask, const SSDataBlock* pBlock)
int32_t
tEncodeStreamRetrieveReq
(
SEncoder
*
pEncoder
,
const
SStreamRetrieveReq
*
pReq
);
int32_t
streamAppendQueueItem
(
SStreamQueueItem
*
dst
,
SStreamQueueItem
*
elem
);
void
streamFreeQitem
(
SStreamQueueItem
*
data
);
#ifdef __cplusplus
}
#endif
...
...
source/libs/stream/src/stream.c
浏览文件 @
d3cdd75b
...
...
@@ -97,7 +97,7 @@ int32_t streamLaunchByWrite(SStreamTask* pTask, int32_t vgId) {
.
pCont
=
pRunReq
,
.
contLen
=
sizeof
(
SStreamTaskRunReq
),
};
tmsgPutToQueue
(
pTask
->
pMsgCb
,
FETCH
_QUEUE
,
&
msg
);
tmsgPutToQueue
(
pTask
->
pMsgCb
,
STREAM
_QUEUE
,
&
msg
);
}
return
0
;
}
...
...
source/libs/stream/src/streamData.c
浏览文件 @
d3cdd75b
...
...
@@ -97,3 +97,29 @@ void streamDataSubmitRefDec(SStreamDataSubmit* pDataSubmit) {
taosMemoryFree
(
pDataSubmit
->
dataRef
);
}
}
int32_t
streamAppendQueueItem
(
SStreamQueueItem
*
dst
,
SStreamQueueItem
*
elem
)
{
ASSERT
(
elem
);
if
(
dst
->
type
==
elem
->
type
&&
dst
->
type
==
STREAM_INPUT__DATA_BLOCK
)
{
SStreamDataBlock
*
pBlock
=
(
SStreamDataBlock
*
)
dst
;
SStreamDataBlock
*
pBlockSrc
=
(
SStreamDataBlock
*
)
elem
;
taosArrayAddAll
(
pBlock
->
blocks
,
pBlockSrc
->
blocks
);
return
0
;
}
else
{
return
-
1
;
}
}
void
streamFreeQitem
(
SStreamQueueItem
*
data
)
{
int8_t
type
=
data
->
type
;
if
(
type
==
STREAM_INPUT__TRIGGER
)
{
blockDataDestroy
(((
SStreamTrigger
*
)
data
)
->
pBlock
);
taosFreeQitem
(
data
);
}
else
if
(
type
==
STREAM_INPUT__DATA_BLOCK
||
type
==
STREAM_INPUT__DATA_RETRIEVE
)
{
taosArrayDestroyEx
(((
SStreamDataBlock
*
)
data
)
->
blocks
,
(
FDelete
)
tDeleteSSDataBlock
);
taosFreeQitem
(
data
);
}
else
if
(
type
==
STREAM_INPUT__DATA_SUBMIT
)
{
streamDataSubmitRefDec
((
SStreamDataSubmit
*
)
data
);
taosFreeQitem
(
data
);
}
}
source/libs/stream/src/streamDispatch.c
浏览文件 @
d3cdd75b
...
...
@@ -251,7 +251,7 @@ int32_t streamBuildDispatchMsg(SStreamTask* pTask, const SStreamDataBlock* data,
ASSERT
(
vgId
>
0
||
vgId
==
SNODE_HANDLE
);
req
.
taskId
=
downstreamTaskId
;
q
Info
(
"dispatch from task %d (child id %d) to down stream task %d in vnode %d"
,
pTask
->
taskId
,
pTask
->
selfChildId
,
q
Debug
(
"dispatch from task %d (child id %d) to down stream task %d in vnode %d"
,
pTask
->
taskId
,
pTask
->
selfChildId
,
downstreamTaskId
,
vgId
);
// serialize
...
...
@@ -298,6 +298,7 @@ int32_t streamDispatch(SStreamTask* pTask, SMsgCb* pMsgCb) {
SStreamDataBlock
*
pBlock
=
streamQueueNextItem
(
pTask
->
outputQueue
);
if
(
pBlock
==
NULL
)
{
qDebug
(
"stream stop dispatching since no output: task %d"
,
pTask
->
taskId
);
atomic_store_8
(
&
pTask
->
outputStatus
,
TASK_OUTPUT_STATUS__NORMAL
);
return
0
;
}
...
...
source/libs/stream/src/streamExec.c
浏览文件 @
d3cdd75b
...
...
@@ -75,10 +75,35 @@ static int32_t streamTaskExecImpl(SStreamTask* pTask, void* data, SArray* pRes)
static
SArray
*
streamExecForQall
(
SStreamTask
*
pTask
,
SArray
*
pRes
)
{
while
(
1
)
{
void
*
data
=
streamQueueNextItem
(
pTask
->
inputQueue
);
int32_t
cnt
=
0
;
void
*
data
=
NULL
;
while
(
1
)
{
SStreamQueueItem
*
qItem
=
streamQueueNextItem
(
pTask
->
inputQueue
);
if
(
qItem
==
NULL
)
{
qDebug
(
"stream exec over, queue empty"
);
break
;
}
if
(
data
==
NULL
)
{
data
=
qItem
;
streamQueueProcessSuccess
(
pTask
->
inputQueue
);
continue
;
}
else
{
if
(
streamAppendQueueItem
(
data
,
qItem
)
<
0
)
{
streamQueueProcessFail
(
pTask
->
inputQueue
);
break
;
}
else
{
cnt
++
;
streamQueueProcessSuccess
(
pTask
->
inputQueue
);
taosArrayDestroy
(((
SStreamDataBlock
*
)
qItem
)
->
blocks
);
taosFreeQitem
(
qItem
);
}
}
}
if
(
data
==
NULL
)
break
;
qDebug
(
"stream task %d exec begin, batch msg: %d"
,
pTask
->
taskId
,
cnt
);
streamTaskExecImpl
(
pTask
,
data
,
pRes
);
qDebug
(
"stream task %d exec end"
,
pTask
->
taskId
);
if
(
pTask
->
taskStatus
==
TASK_STATUS__DROPPING
)
{
taosArrayDestroyEx
(
pRes
,
(
FDelete
)
tDeleteSSDataBlock
);
...
...
@@ -95,27 +120,16 @@ static SArray* streamExecForQall(SStreamTask* pTask, SArray* pRes) {
qRes
->
type
=
STREAM_INPUT__DATA_BLOCK
;
qRes
->
blocks
=
pRes
;
if
(
streamTaskOutput
(
pTask
,
qRes
)
<
0
)
{
streamQueueProcessFail
(
pTask
->
inputQueue
);
/*streamQueueProcessFail(pTask->inputQueue);*/
taosArrayDestroyEx
(
pRes
,
(
FDelete
)
tDeleteSSDataBlock
);
taosFreeQitem
(
qRes
);
return
NULL
;
}
streamQueueProcessSuccess
(
pTask
->
inputQueue
);
/*streamQueueProcessSuccess(pTask->inputQueue);*/
pRes
=
taosArrayInit
(
0
,
sizeof
(
SSDataBlock
));
}
int8_t
type
=
((
SStreamQueueItem
*
)
data
)
->
type
;
if
(
type
==
STREAM_INPUT__TRIGGER
)
{
blockDataDestroy
(((
SStreamTrigger
*
)
data
)
->
pBlock
);
taosFreeQitem
(
data
);
}
else
if
(
type
==
STREAM_INPUT__DATA_BLOCK
||
type
==
STREAM_INPUT__DATA_RETRIEVE
)
{
taosArrayDestroyEx
(((
SStreamDataBlock
*
)
data
)
->
blocks
,
(
FDelete
)
tDeleteSSDataBlock
);
taosFreeQitem
(
data
);
}
else
if
(
type
==
STREAM_INPUT__DATA_SUBMIT
)
{
ASSERT
(
pTask
->
isDataScan
);
streamDataSubmitRefDec
((
SStreamDataSubmit
*
)
data
);
taosFreeQitem
(
data
);
}
streamFreeQitem
(
data
);
}
return
pRes
;
}
...
...
@@ -129,6 +143,7 @@ int32_t streamExec(SStreamTask* pTask, SMsgCb* pMsgCb) {
atomic_val_compare_exchange_8
(
&
pTask
->
execStatus
,
TASK_EXEC_STATUS__IDLE
,
TASK_EXEC_STATUS__EXECUTING
);
if
(
execStatus
==
TASK_EXEC_STATUS__IDLE
)
{
// first run
qDebug
(
"stream exec, enter exec status"
);
pRes
=
streamExecForQall
(
pTask
,
pRes
);
if
(
pRes
==
NULL
)
goto
FAIL
;
...
...
@@ -136,11 +151,13 @@ int32_t streamExec(SStreamTask* pTask, SMsgCb* pMsgCb) {
atomic_store_8
(
&
pTask
->
execStatus
,
TASK_EXEC_STATUS__CLOSING
);
// second run, make sure inputQ and qall are cleared
qDebug
(
"stream exec, enter closing status"
);
pRes
=
streamExecForQall
(
pTask
,
pRes
);
if
(
pRes
==
NULL
)
goto
FAIL
;
taosArrayDestroyEx
(
pRes
,
(
FDelete
)
tDeleteSSDataBlock
);
atomic_store_8
(
&
pTask
->
execStatus
,
TASK_EXEC_STATUS__IDLE
);
qDebug
(
"stream exec, return result"
);
return
0
;
}
else
if
(
execStatus
==
TASK_EXEC_STATUS__CLOSING
)
{
continue
;
...
...
source/libs/sync/inc/syncRaftEntry.h
浏览文件 @
d3cdd75b
...
...
@@ -26,6 +26,7 @@ extern "C" {
#include "syncInt.h"
#include "syncMessage.h"
#include "taosdef.h"
#include "tskiplist.h"
typedef
struct
SSyncRaftEntry
{
uint32_t
bytes
;
...
...
@@ -58,29 +59,52 @@ void syncEntryLog(const SSyncRaftEntry* pObj);
void
syncEntryLog2
(
char
*
s
,
const
SSyncRaftEntry
*
pObj
);
//-----------------------------------
typedef
struct
SRaftEntryCache
{
typedef
struct
SRaftEntry
Hash
Cache
{
SHashObj
*
pEntryHash
;
int32_t
maxCount
;
int32_t
currentCount
;
TdThreadMutex
mutex
;
SSyncNode
*
pSyncNode
;
}
SRaftEntryHashCache
;
SRaftEntryHashCache
*
raftCacheCreate
(
SSyncNode
*
pSyncNode
,
int32_t
maxCount
);
void
raftCacheDestroy
(
SRaftEntryHashCache
*
pCache
);
int32_t
raftCachePutEntry
(
struct
SRaftEntryHashCache
*
pCache
,
SSyncRaftEntry
*
pEntry
);
int32_t
raftCacheGetEntry
(
struct
SRaftEntryHashCache
*
pCache
,
SyncIndex
index
,
SSyncRaftEntry
**
ppEntry
);
int32_t
raftCacheGetEntryP
(
struct
SRaftEntryHashCache
*
pCache
,
SyncIndex
index
,
SSyncRaftEntry
**
ppEntry
);
int32_t
raftCacheDelEntry
(
struct
SRaftEntryHashCache
*
pCache
,
SyncIndex
index
);
int32_t
raftCacheGetAndDel
(
struct
SRaftEntryHashCache
*
pCache
,
SyncIndex
index
,
SSyncRaftEntry
**
ppEntry
);
int32_t
raftCacheClear
(
struct
SRaftEntryHashCache
*
pCache
);
cJSON
*
raftCache2Json
(
SRaftEntryHashCache
*
pObj
);
char
*
raftCache2Str
(
SRaftEntryHashCache
*
pObj
);
void
raftCachePrint
(
SRaftEntryHashCache
*
pObj
);
void
raftCachePrint2
(
char
*
s
,
SRaftEntryHashCache
*
pObj
);
void
raftCacheLog
(
SRaftEntryHashCache
*
pObj
);
void
raftCacheLog2
(
char
*
s
,
SRaftEntryHashCache
*
pObj
);
//-----------------------------------
typedef
struct
SRaftEntryCache
{
SSkipList
*
pSkipList
;
int32_t
maxCount
;
int32_t
currentCount
;
TdThreadMutex
mutex
;
SSyncNode
*
pSyncNode
;
}
SRaftEntryCache
;
SRaftEntryCache
*
raftCacheCreate
(
SSyncNode
*
pSyncNode
,
int32_t
maxCount
);
void
raftCacheDestroy
(
SRaftEntryCache
*
pCache
);
int32_t
raftCachePutEntry
(
struct
SRaftEntryCache
*
pCache
,
SSyncRaftEntry
*
pEntry
);
int32_t
raftCacheGetEntry
(
struct
SRaftEntryCache
*
pCache
,
SyncIndex
index
,
SSyncRaftEntry
**
ppEntry
);
int32_t
raftCacheGetEntryP
(
struct
SRaftEntryCache
*
pCache
,
SyncIndex
index
,
SSyncRaftEntry
**
ppEntry
);
int32_t
raftCacheDelEntry
(
struct
SRaftEntryCache
*
pCache
,
SyncIndex
index
);
int32_t
raftCacheGetAndDel
(
struct
SRaftEntryCache
*
pCache
,
SyncIndex
index
,
SSyncRaftEntry
**
ppEntry
);
int32_t
raftCacheClear
(
struct
SRaftEntryCache
*
pCache
);
SRaftEntryCache
*
raftEntryCacheCreate
(
SSyncNode
*
pSyncNode
,
int32_t
maxCount
);
void
raftEntryCacheDestroy
(
SRaftEntryCache
*
pCache
);
int32_t
raftEntryCachePutEntry
(
struct
SRaftEntryCache
*
pCache
,
SSyncRaftEntry
*
pEntry
);
int32_t
raftEntryCacheGetEntry
(
struct
SRaftEntryCache
*
pCache
,
SyncIndex
index
,
SSyncRaftEntry
**
ppEntry
);
int32_t
raftEntryCacheGetEntryP
(
struct
SRaftEntryCache
*
pCache
,
SyncIndex
index
,
SSyncRaftEntry
**
ppEntry
);
int32_t
raftEntryCacheClear
(
struct
SRaftEntryCache
*
pCache
,
int32_t
count
);
cJSON
*
raftCache2Json
(
SRaftEntryCache
*
pObj
);
char
*
raftCache2Str
(
SRaftEntryCache
*
pObj
);
void
raftCachePrint
(
SRaftEntryCache
*
pObj
);
void
raftCachePrint2
(
char
*
s
,
SRaftEntryCache
*
pObj
);
void
raftCacheLog
(
SRaftEntryCache
*
pObj
);
void
raftCacheLog2
(
char
*
s
,
SRaftEntryCache
*
pObj
);
cJSON
*
raft
Entry
Cache2Json
(
SRaftEntryCache
*
pObj
);
char
*
raft
Entry
Cache2Str
(
SRaftEntryCache
*
pObj
);
void
raft
Entry
CachePrint
(
SRaftEntryCache
*
pObj
);
void
raft
Entry
CachePrint2
(
char
*
s
,
SRaftEntryCache
*
pObj
);
void
raft
Entry
CacheLog
(
SRaftEntryCache
*
pObj
);
void
raft
Entry
CacheLog2
(
char
*
s
,
SRaftEntryCache
*
pObj
);
#ifdef __cplusplus
}
...
...
source/libs/sync/src/syncMain.c
浏览文件 @
d3cdd75b
...
...
@@ -293,7 +293,7 @@ int32_t syncLeaderTransferTo(int64_t rid, SNodeInfo newLeader) {
int32_t
syncNodeLeaderTransfer
(
SSyncNode
*
pSyncNode
)
{
if
(
pSyncNode
->
peersNum
==
0
)
{
s
Error
(
"only one replica, cannot leader transfer"
);
s
Debug
(
"only one replica, cannot leader transfer"
);
terrno
=
TSDB_CODE_SYN_ONE_REPLICA
;
return
-
1
;
}
...
...
@@ -307,7 +307,7 @@ int32_t syncNodeLeaderTransferTo(SSyncNode* pSyncNode, SNodeInfo newLeader) {
int32_t
ret
=
0
;
if
(
pSyncNode
->
replicaNum
==
1
)
{
s
Error
(
"only one replica, cannot leader transfer"
);
s
Debug
(
"only one replica, cannot leader transfer"
);
terrno
=
TSDB_CODE_SYN_ONE_REPLICA
;
return
-
1
;
}
...
...
@@ -1055,19 +1055,12 @@ SSyncNode* syncNodeOpen(const SSyncInfo* pOldSyncInfo) {
}
// tools
pSyncNode
->
pSyncRespMgr
=
syncRespMgrCreate
(
pSyncNode
,
0
);
pSyncNode
->
pSyncRespMgr
=
syncRespMgrCreate
(
pSyncNode
,
SYNC_RESP_TTL_MS
);
ASSERT
(
pSyncNode
->
pSyncRespMgr
!=
NULL
);
// restore state
pSyncNode
->
restoreFinish
=
false
;
// pSyncNode->pSnapshot = NULL;
// if (pSyncNode->pFsm->FpGetSnapshotInfo != NULL) {
// pSyncNode->pSnapshot = taosMemoryMalloc(sizeof(SSnapshot));
// pSyncNode->pFsm->FpGetSnapshotInfo(pSyncNode->pFsm, pSyncNode->pSnapshot);
// }
// tsem_init(&(pSyncNode->restoreSem), 0, 0);
// snapshot senders
for
(
int
i
=
0
;
i
<
TSDB_MAX_REPLICA
;
++
i
)
{
SSyncSnapshotSender
*
pSender
=
snapshotSenderCreate
(
pSyncNode
,
i
);
...
...
source/libs/sync/src/syncRaftEntry.c
浏览文件 @
d3cdd75b
...
...
@@ -198,8 +198,8 @@ void syncEntryLog2(char* s, const SSyncRaftEntry* pObj) {
}
//-----------------------------------
SRaftEntryCache
*
raftCacheCreate
(
SSyncNode
*
pSyncNode
,
int32_t
maxCount
)
{
SRaftEntry
Cache
*
pCache
=
taosMemoryMalloc
(
sizeof
(
SRaftEntry
Cache
));
SRaftEntry
Hash
Cache
*
raftCacheCreate
(
SSyncNode
*
pSyncNode
,
int32_t
maxCount
)
{
SRaftEntry
HashCache
*
pCache
=
taosMemoryMalloc
(
sizeof
(
SRaftEntryHash
Cache
));
if
(
pCache
==
NULL
)
{
sError
(
"vgId:%d raft cache create error"
,
pSyncNode
->
vgId
);
return
NULL
;
...
...
@@ -220,7 +220,7 @@ SRaftEntryCache* raftCacheCreate(SSyncNode* pSyncNode, int32_t maxCount) {
return
pCache
;
}
void
raftCacheDestroy
(
SRaftEntryCache
*
pCache
)
{
void
raftCacheDestroy
(
SRaftEntry
Hash
Cache
*
pCache
)
{
if
(
pCache
!=
NULL
)
{
taosThreadMutexLock
(
&
(
pCache
->
mutex
));
taosHashCleanup
(
pCache
->
pEntryHash
);
...
...
@@ -233,7 +233,7 @@ void raftCacheDestroy(SRaftEntryCache* pCache) {
// success, return 1
// max count, return 0
// error, return -1
int32_t
raftCachePutEntry
(
struct
SRaftEntryCache
*
pCache
,
SSyncRaftEntry
*
pEntry
)
{
int32_t
raftCachePutEntry
(
struct
SRaftEntry
Hash
Cache
*
pCache
,
SSyncRaftEntry
*
pEntry
)
{
taosThreadMutexLock
(
&
(
pCache
->
mutex
));
if
(
pCache
->
currentCount
>=
pCache
->
maxCount
)
{
...
...
@@ -259,7 +259,7 @@ int32_t raftCachePutEntry(struct SRaftEntryCache* pCache, SSyncRaftEntry* pEntry
// success, return 0
// error, return -1
// not exist, return -1, terrno = TSDB_CODE_WAL_LOG_NOT_EXIST
int32_t
raftCacheGetEntry
(
struct
SRaftEntryCache
*
pCache
,
SyncIndex
index
,
SSyncRaftEntry
**
ppEntry
)
{
int32_t
raftCacheGetEntry
(
struct
SRaftEntry
Hash
Cache
*
pCache
,
SyncIndex
index
,
SSyncRaftEntry
**
ppEntry
)
{
if
(
ppEntry
==
NULL
)
{
return
-
1
;
}
...
...
@@ -292,7 +292,7 @@ int32_t raftCacheGetEntry(struct SRaftEntryCache* pCache, SyncIndex index, SSync
// success, return 0
// error, return -1
// not exist, return -1, terrno = TSDB_CODE_WAL_LOG_NOT_EXIST
int32_t
raftCacheGetEntryP
(
struct
SRaftEntryCache
*
pCache
,
SyncIndex
index
,
SSyncRaftEntry
**
ppEntry
)
{
int32_t
raftCacheGetEntryP
(
struct
SRaftEntry
Hash
Cache
*
pCache
,
SyncIndex
index
,
SSyncRaftEntry
**
ppEntry
)
{
if
(
ppEntry
==
NULL
)
{
return
-
1
;
}
...
...
@@ -321,7 +321,7 @@ int32_t raftCacheGetEntryP(struct SRaftEntryCache* pCache, SyncIndex index, SSyn
return
-
1
;
}
int32_t
raftCacheDelEntry
(
struct
SRaftEntryCache
*
pCache
,
SyncIndex
index
)
{
int32_t
raftCacheDelEntry
(
struct
SRaftEntry
Hash
Cache
*
pCache
,
SyncIndex
index
)
{
taosThreadMutexLock
(
&
(
pCache
->
mutex
));
taosHashRemove
(
pCache
->
pEntryHash
,
&
index
,
sizeof
(
index
));
--
(
pCache
->
currentCount
);
...
...
@@ -329,7 +329,7 @@ int32_t raftCacheDelEntry(struct SRaftEntryCache* pCache, SyncIndex index) {
return
0
;
}
int32_t
raftCacheGetAndDel
(
struct
SRaftEntryCache
*
pCache
,
SyncIndex
index
,
SSyncRaftEntry
**
ppEntry
)
{
int32_t
raftCacheGetAndDel
(
struct
SRaftEntry
Hash
Cache
*
pCache
,
SyncIndex
index
,
SSyncRaftEntry
**
ppEntry
)
{
if
(
ppEntry
==
NULL
)
{
return
-
1
;
}
...
...
@@ -362,7 +362,7 @@ int32_t raftCacheGetAndDel(struct SRaftEntryCache* pCache, SyncIndex index, SSyn
return
-
1
;
}
int32_t
raftCacheClear
(
struct
SRaftEntryCache
*
pCache
)
{
int32_t
raftCacheClear
(
struct
SRaftEntry
Hash
Cache
*
pCache
)
{
taosThreadMutexLock
(
&
(
pCache
->
mutex
));
taosHashClear
(
pCache
->
pEntryHash
);
pCache
->
currentCount
=
0
;
...
...
@@ -371,7 +371,7 @@ int32_t raftCacheClear(struct SRaftEntryCache* pCache) {
}
//-----------------------------------
cJSON
*
raftCache2Json
(
SRaftEntryCache
*
pCache
)
{
cJSON
*
raftCache2Json
(
SRaftEntry
Hash
Cache
*
pCache
)
{
char
u64buf
[
128
]
=
{
0
};
cJSON
*
pRoot
=
cJSON_CreateObject
();
...
...
@@ -402,41 +402,283 @@ cJSON* raftCache2Json(SRaftEntryCache* pCache) {
}
cJSON
*
pJson
=
cJSON_CreateObject
();
cJSON_AddItemToObject
(
pJson
,
"SRaftEntryCache"
,
pRoot
);
cJSON_AddItemToObject
(
pJson
,
"SRaftEntry
Hash
Cache"
,
pRoot
);
return
pJson
;
}
char
*
raftCache2Str
(
SRaftEntryCache
*
pCache
)
{
char
*
raftCache2Str
(
SRaftEntry
Hash
Cache
*
pCache
)
{
cJSON
*
pJson
=
raftCache2Json
(
pCache
);
char
*
serialized
=
cJSON_Print
(
pJson
);
cJSON_Delete
(
pJson
);
return
serialized
;
}
void
raftCachePrint
(
SRaftEntryCache
*
pCache
)
{
void
raftCachePrint
(
SRaftEntry
Hash
Cache
*
pCache
)
{
char
*
serialized
=
raftCache2Str
(
pCache
);
printf
(
"raftCachePrint | len:%"
PRIu64
" | %s
\n
"
,
strlen
(
serialized
),
serialized
);
fflush
(
NULL
);
taosMemoryFree
(
serialized
);
}
void
raftCachePrint2
(
char
*
s
,
SRaftEntryCache
*
pCache
)
{
void
raftCachePrint2
(
char
*
s
,
SRaftEntry
Hash
Cache
*
pCache
)
{
char
*
serialized
=
raftCache2Str
(
pCache
);
printf
(
"raftCachePrint2 | len:%"
PRIu64
" | %s | %s
\n
"
,
strlen
(
serialized
),
s
,
serialized
);
fflush
(
NULL
);
taosMemoryFree
(
serialized
);
}
void
raftCacheLog
(
SRaftEntryCache
*
pCache
)
{
void
raftCacheLog
(
SRaftEntry
Hash
Cache
*
pCache
)
{
char
*
serialized
=
raftCache2Str
(
pCache
);
sTrace
(
"raftCacheLog | len:%"
PRIu64
" | %s"
,
strlen
(
serialized
),
serialized
);
taosMemoryFree
(
serialized
);
}
void
raftCacheLog2
(
char
*
s
,
SRaftEntryCache
*
pCache
)
{
void
raftCacheLog2
(
char
*
s
,
SRaftEntry
Hash
Cache
*
pCache
)
{
if
(
gRaftDetailLog
)
{
char
*
serialized
=
raftCache2Str
(
pCache
);
sTraceLong
(
"raftCacheLog2 | len:%"
PRIu64
" | %s | %s"
,
strlen
(
serialized
),
s
,
serialized
);
taosMemoryFree
(
serialized
);
}
}
//-----------------------------------
static
char
*
keyFn
(
const
void
*
pData
)
{
SSyncRaftEntry
*
pEntry
=
(
SSyncRaftEntry
*
)
pData
;
return
(
char
*
)(
&
(
pEntry
->
index
));
}
static
int
cmpFn
(
const
void
*
p1
,
const
void
*
p2
)
{
return
memcmp
(
p1
,
p2
,
sizeof
(
SyncIndex
));
}
SRaftEntryCache
*
raftEntryCacheCreate
(
SSyncNode
*
pSyncNode
,
int32_t
maxCount
)
{
SRaftEntryCache
*
pCache
=
taosMemoryMalloc
(
sizeof
(
SRaftEntryCache
));
if
(
pCache
==
NULL
)
{
sError
(
"vgId:%d raft cache create error"
,
pSyncNode
->
vgId
);
return
NULL
;
}
pCache
->
pSkipList
=
tSkipListCreate
(
MAX_SKIP_LIST_LEVEL
,
TSDB_DATA_TYPE_BINARY
,
sizeof
(
SyncIndex
),
cmpFn
,
SL_ALLOW_DUP_KEY
,
keyFn
);
if
(
pCache
->
pSkipList
==
NULL
)
{
sError
(
"vgId:%d raft cache create hash error"
,
pSyncNode
->
vgId
);
return
NULL
;
}
taosThreadMutexInit
(
&
(
pCache
->
mutex
),
NULL
);
pCache
->
maxCount
=
maxCount
;
pCache
->
currentCount
=
0
;
pCache
->
pSyncNode
=
pSyncNode
;
return
pCache
;
}
void
raftEntryCacheDestroy
(
SRaftEntryCache
*
pCache
)
{
if
(
pCache
!=
NULL
)
{
taosThreadMutexLock
(
&
(
pCache
->
mutex
));
tSkipListDestroy
(
pCache
->
pSkipList
);
taosThreadMutexUnlock
(
&
(
pCache
->
mutex
));
taosThreadMutexDestroy
(
&
(
pCache
->
mutex
));
taosMemoryFree
(
pCache
);
}
}
// success, return 1
// max count, return 0
// error, return -1
int32_t
raftEntryCachePutEntry
(
struct
SRaftEntryCache
*
pCache
,
SSyncRaftEntry
*
pEntry
)
{
taosThreadMutexLock
(
&
(
pCache
->
mutex
));
if
(
pCache
->
currentCount
>=
pCache
->
maxCount
)
{
taosThreadMutexUnlock
(
&
(
pCache
->
mutex
));
return
0
;
}
SSkipListNode
*
pSkipListNode
=
tSkipListPut
(
pCache
->
pSkipList
,
pEntry
);
ASSERT
(
pSkipListNode
!=
NULL
);
++
(
pCache
->
currentCount
);
do
{
char
eventLog
[
128
];
snprintf
(
eventLog
,
sizeof
(
eventLog
),
"raft cache add, type:%s,%d, type2:%s,%d, index:%"
PRId64
", bytes:%d"
,
TMSG_INFO
(
pEntry
->
msgType
),
pEntry
->
msgType
,
TMSG_INFO
(
pEntry
->
originalRpcType
),
pEntry
->
originalRpcType
,
pEntry
->
index
,
pEntry
->
bytes
);
syncNodeEventLog
(
pCache
->
pSyncNode
,
eventLog
);
}
while
(
0
);
taosThreadMutexUnlock
(
&
(
pCache
->
mutex
));
return
1
;
}
// find one, return 1
// not found, return 0
// error, return -1
int32_t
raftEntryCacheGetEntry
(
struct
SRaftEntryCache
*
pCache
,
SyncIndex
index
,
SSyncRaftEntry
**
ppEntry
)
{
ASSERT
(
ppEntry
!=
NULL
);
SSyncRaftEntry
*
pEntry
=
NULL
;
int32_t
code
=
raftEntryCacheGetEntryP
(
pCache
,
index
,
&
pEntry
);
if
(
code
==
1
)
{
*
ppEntry
=
taosMemoryMalloc
(
pEntry
->
bytes
);
memcpy
(
*
ppEntry
,
pEntry
,
pEntry
->
bytes
);
}
else
{
*
ppEntry
=
NULL
;
}
return
code
;
}
// find one, return 1
// not found, return 0
// error, return -1
int32_t
raftEntryCacheGetEntryP
(
struct
SRaftEntryCache
*
pCache
,
SyncIndex
index
,
SSyncRaftEntry
**
ppEntry
)
{
taosThreadMutexLock
(
&
(
pCache
->
mutex
));
SyncIndex
index2
=
index
;
int32_t
code
=
0
;
SArray
*
entryPArray
=
tSkipListGet
(
pCache
->
pSkipList
,
(
char
*
)(
&
index2
));
int32_t
arraySize
=
taosArrayGetSize
(
entryPArray
);
if
(
arraySize
==
1
)
{
SSkipListNode
**
ppNode
=
(
SSkipListNode
**
)
taosArrayGet
(
entryPArray
,
0
);
ASSERT
(
*
ppNode
!=
NULL
);
*
ppEntry
=
(
SSyncRaftEntry
*
)
SL_GET_NODE_DATA
(
*
ppNode
);
code
=
1
;
}
else
if
(
arraySize
==
0
)
{
code
=
0
;
}
else
{
ASSERT
(
0
);
code
=
-
1
;
}
taosArrayDestroy
(
entryPArray
);
taosThreadMutexUnlock
(
&
(
pCache
->
mutex
));
return
code
;
}
// count = -1, clear all
// count >= 0, clear count
// return -1, error
// return delete count
int32_t
raftEntryCacheClear
(
struct
SRaftEntryCache
*
pCache
,
int32_t
count
)
{
taosThreadMutexLock
(
&
(
pCache
->
mutex
));
int32_t
returnCnt
=
0
;
if
(
count
==
-
1
)
{
// clear all
SSkipListIterator
*
pIter
=
tSkipListCreateIter
(
pCache
->
pSkipList
);
while
(
tSkipListIterNext
(
pIter
))
{
SSkipListNode
*
pNode
=
tSkipListIterGet
(
pIter
);
ASSERT
(
pNode
!=
NULL
);
SSyncRaftEntry
*
pEntry
=
(
SSyncRaftEntry
*
)
SL_GET_NODE_DATA
(
pNode
);
syncEntryDestory
(
pEntry
);
++
returnCnt
;
}
tSkipListDestroyIter
(
pIter
);
tSkipListDestroy
(
pCache
->
pSkipList
);
pCache
->
pSkipList
=
tSkipListCreate
(
MAX_SKIP_LIST_LEVEL
,
TSDB_DATA_TYPE_BINARY
,
sizeof
(
SyncIndex
),
cmpFn
,
SL_ALLOW_DUP_KEY
,
keyFn
);
ASSERT
(
pCache
->
pSkipList
!=
NULL
);
}
else
{
// clear count
int
i
=
0
;
SSkipListIterator
*
pIter
=
tSkipListCreateIter
(
pCache
->
pSkipList
);
SArray
*
delNodeArray
=
taosArrayInit
(
0
,
sizeof
(
SSkipListNode
*
));
// free entry
while
(
tSkipListIterNext
(
pIter
))
{
SSkipListNode
*
pNode
=
tSkipListIterGet
(
pIter
);
ASSERT
(
pNode
!=
NULL
);
if
(
i
++
>=
count
)
{
break
;
}
// sDebug("push pNode:%p", pNode);
taosArrayPush
(
delNodeArray
,
&
pNode
);
++
returnCnt
;
SSyncRaftEntry
*
pEntry
=
(
SSyncRaftEntry
*
)
SL_GET_NODE_DATA
(
pNode
);
syncEntryDestory
(
pEntry
);
}
tSkipListDestroyIter
(
pIter
);
// delete skiplist node
int32_t
arraySize
=
taosArrayGetSize
(
delNodeArray
);
for
(
int32_t
i
=
0
;
i
<
arraySize
;
++
i
)
{
SSkipListNode
**
ppNode
=
taosArrayGet
(
delNodeArray
,
i
);
// sDebug("get pNode:%p", *ppNode);
tSkipListRemoveNode
(
pCache
->
pSkipList
,
*
ppNode
);
}
taosArrayDestroy
(
delNodeArray
);
}
pCache
->
currentCount
-=
returnCnt
;
taosThreadMutexUnlock
(
&
(
pCache
->
mutex
));
return
returnCnt
;
}
cJSON
*
raftEntryCache2Json
(
SRaftEntryCache
*
pCache
)
{
char
u64buf
[
128
]
=
{
0
};
cJSON
*
pRoot
=
cJSON_CreateObject
();
if
(
pCache
!=
NULL
)
{
taosThreadMutexLock
(
&
(
pCache
->
mutex
));
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%p"
,
pCache
->
pSyncNode
);
cJSON_AddStringToObject
(
pRoot
,
"pSyncNode"
,
u64buf
);
cJSON_AddNumberToObject
(
pRoot
,
"currentCount"
,
pCache
->
currentCount
);
cJSON_AddNumberToObject
(
pRoot
,
"maxCount"
,
pCache
->
maxCount
);
cJSON
*
pEntries
=
cJSON_CreateArray
();
cJSON_AddItemToObject
(
pRoot
,
"entries"
,
pEntries
);
SSkipListIterator
*
pIter
=
tSkipListCreateIter
(
pCache
->
pSkipList
);
while
(
tSkipListIterNext
(
pIter
))
{
SSkipListNode
*
pNode
=
tSkipListIterGet
(
pIter
);
ASSERT
(
pNode
!=
NULL
);
SSyncRaftEntry
*
pEntry
=
(
SSyncRaftEntry
*
)
SL_GET_NODE_DATA
(
pNode
);
cJSON_AddItemToArray
(
pEntries
,
syncEntry2Json
(
pEntry
));
}
tSkipListDestroyIter
(
pIter
);
taosThreadMutexUnlock
(
&
(
pCache
->
mutex
));
}
cJSON
*
pJson
=
cJSON_CreateObject
();
cJSON_AddItemToObject
(
pJson
,
"SRaftEntryCache"
,
pRoot
);
return
pJson
;
}
char
*
raftEntryCache2Str
(
SRaftEntryCache
*
pObj
)
{
cJSON
*
pJson
=
raftEntryCache2Json
(
pObj
);
char
*
serialized
=
cJSON_Print
(
pJson
);
cJSON_Delete
(
pJson
);
return
serialized
;
}
void
raftEntryCachePrint
(
SRaftEntryCache
*
pObj
)
{
char
*
serialized
=
raftEntryCache2Str
(
pObj
);
printf
(
"raftEntryCachePrint | len:%"
PRIu64
" | %s
\n
"
,
strlen
(
serialized
),
serialized
);
fflush
(
NULL
);
taosMemoryFree
(
serialized
);
}
void
raftEntryCachePrint2
(
char
*
s
,
SRaftEntryCache
*
pObj
)
{
char
*
serialized
=
raftEntryCache2Str
(
pObj
);
printf
(
"raftEntryCachePrint2 | len:%"
PRIu64
" | %s | %s
\n
"
,
strlen
(
serialized
),
s
,
serialized
);
fflush
(
NULL
);
taosMemoryFree
(
serialized
);
}
void
raftEntryCacheLog
(
SRaftEntryCache
*
pObj
)
{
char
*
serialized
=
raftEntryCache2Str
(
pObj
);
sTrace
(
"raftEntryCacheLog | len:%"
PRIu64
" | %s"
,
strlen
(
serialized
),
serialized
);
taosMemoryFree
(
serialized
);
}
void
raftEntryCacheLog2
(
char
*
s
,
SRaftEntryCache
*
pObj
)
{
if
(
gRaftDetailLog
)
{
char
*
serialized
=
raftEntryCache2Str
(
pObj
);
sTraceLong
(
"raftEntryCacheLog2 | len:%"
PRIu64
" | %s | %s"
,
strlen
(
serialized
),
s
,
serialized
);
taosMemoryFree
(
serialized
);
}
}
\ No newline at end of file
source/libs/sync/src/syncRespMgr.c
浏览文件 @
d3cdd75b
...
...
@@ -122,54 +122,45 @@ void syncRespCleanByTTL(SSyncRespMgr *pObj, int64_t ttl) {
int
cnt
=
0
;
SSyncNode
*
pSyncNode
=
pObj
->
data
;
SArray
*
delIndexArray
=
taosArrayInit
(
0
,
sizeof
(
SyncIndex
));
SArray
*
delIndexArray
=
taosArrayInit
(
0
,
sizeof
(
uint64_t
));
ASSERT
(
delIndexArray
!=
NULL
);
while
(
pStub
)
{
size_t
len
;
void
*
key
=
taosHashGetKey
(
pStub
,
&
len
);
SyncIndex
*
pIndex
=
(
SyncIndex
*
)
key
;
uint64_t
*
pSeqNum
=
(
uint64_t
*
)
key
;
int64_t
nowMS
=
taosGetTimestampMs
();
if
(
nowMS
-
pStub
->
createTime
>
ttl
)
{
taosArrayPush
(
delIndexArray
,
p
Index
);
taosArrayPush
(
delIndexArray
,
p
SeqNum
);
cnt
++
;
SSyncRaftEntry
*
pEntry
=
NULL
;
int32_t
code
=
0
;
if
(
pSyncNode
->
pLogStore
!=
NULL
)
{
code
=
pSyncNode
->
pLogStore
->
syncLogGetEntry
(
pSyncNode
->
pLogStore
,
*
pIndex
,
&
pEntry
);
if
(
code
==
0
&&
pEntry
!=
NULL
)
{
SFsmCbMeta
cbMeta
=
{
0
};
cbMeta
.
index
=
pEntry
->
index
;
cbMeta
.
lastConfigIndex
=
syncNodeGetSnapshotConfigIndex
(
pSyncNode
,
cbMeta
.
index
)
;
cbMeta
.
isWeak
=
pEntry
->
isWeak
;
cbMeta
.
index
=
SYNC_INDEX_INVALID
;
cbMeta
.
lastConfigIndex
=
SYNC_INDEX_INVALID
;
cbMeta
.
isWeak
=
false
;
cbMeta
.
code
=
TSDB_CODE_SYN_TIMEOUT
;
cbMeta
.
state
=
pSyncNode
->
state
;
cbMeta
.
seqNum
=
pEntry
->
s
eqNum
;
cbMeta
.
term
=
pEntry
->
term
;
cbMeta
.
seqNum
=
*
pS
eqNum
;
cbMeta
.
term
=
SYNC_TERM_INVALID
;
cbMeta
.
currentTerm
=
pSyncNode
->
pRaftStore
->
currentTerm
;
cbMeta
.
flag
=
0
;
SRpcMsg
rpcMsg
=
pStub
->
rpcMsg
;
rpcMsg
.
pCont
=
rpcMallocCont
(
pEntry
->
dataLen
);
memcpy
(
rpcMsg
.
pCont
,
pEntry
->
data
,
pEntry
->
dataLen
);
pSyncNode
->
pFsm
->
FpCommitCb
(
pSyncNode
->
pFsm
,
&
rpcMsg
,
cbMeta
);
syncEntryDestory
(
pEntry
);
}
}
pStub
->
rpcMsg
.
pCont
=
NULL
;
pStub
->
rpcMsg
.
contLen
=
0
;
pSyncNode
->
pFsm
->
FpCommitCb
(
pSyncNode
->
pFsm
,
&
(
pStub
->
rpcMsg
),
cbMeta
);
}
pStub
=
(
SRespStub
*
)
taosHashIterate
(
pObj
->
pRespHash
,
pStub
);
}
int32_t
arraySize
=
taosArrayGetSize
(
delIndexArray
);
sDebug
(
"vgId:%d, resp clean by ttl, cnt:%d, array-size:%d"
,
pSyncNode
->
vgId
,
cnt
,
arraySize
);
sDebug
(
"vgId:%d, resp
mgr
clean by ttl, cnt:%d, array-size:%d"
,
pSyncNode
->
vgId
,
cnt
,
arraySize
);
for
(
int32_t
i
=
0
;
i
<
arraySize
;
++
i
)
{
SyncIndex
*
pIndex
=
taosArrayGet
(
delIndexArray
,
i
);
taosHashRemove
(
pObj
->
pRespHash
,
pIndex
,
sizeof
(
SyncIndex
));
uint64_t
*
pSeqNum
=
taosArrayGet
(
delIndexArray
,
i
);
taosHashRemove
(
pObj
->
pRespHash
,
pSeqNum
,
sizeof
(
uint64_t
));
sDebug
(
"vgId:%d, resp mgr clean by ttl, seq:%d"
,
pSyncNode
->
vgId
,
*
pSeqNum
);
}
taosArrayDestroy
(
delIndexArray
);
}
source/libs/sync/src/syncTimeout.c
浏览文件 @
d3cdd75b
...
...
@@ -16,9 +16,14 @@
#include "syncTimeout.h"
#include "syncElection.h"
#include "syncReplication.h"
#include "syncRespMgr.h"
int32_t
syncNodeTimerRoutine
(
SSyncNode
*
ths
)
{
syncNodeEventLog
(
ths
,
"timer routines ... "
);
if
(
ths
->
vgId
!=
1
)
{
syncRespClean
(
ths
->
pSyncRespMgr
);
}
return
0
;
}
...
...
source/libs/sync/test/CMakeLists.txt
浏览文件 @
d3cdd75b
...
...
@@ -18,6 +18,7 @@ add_executable(syncIndexMgrTest "")
add_executable
(
syncLogStoreTest
""
)
add_executable
(
syncEntryTest
""
)
add_executable
(
syncEntryCacheTest
""
)
add_executable
(
syncHashCacheTest
""
)
add_executable
(
syncRequestVoteTest
""
)
add_executable
(
syncRequestVoteReplyTest
""
)
add_executable
(
syncAppendEntriesTest
""
)
...
...
@@ -137,6 +138,10 @@ target_sources(syncEntryCacheTest
PRIVATE
"syncEntryCacheTest.cpp"
)
target_sources
(
syncHashCacheTest
PRIVATE
"syncHashCacheTest.cpp"
)
target_sources
(
syncRequestVoteTest
PRIVATE
"syncRequestVoteTest.cpp"
...
...
@@ -387,6 +392,11 @@ target_include_directories(syncEntryCacheTest
"
${
TD_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
target_include_directories
(
syncHashCacheTest
PUBLIC
"
${
TD_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
target_include_directories
(
syncRequestVoteTest
PUBLIC
"
${
TD_SOURCE_DIR
}
/include/libs/sync"
...
...
@@ -654,6 +664,10 @@ target_link_libraries(syncEntryCacheTest
sync
gtest_main
)
target_link_libraries
(
syncHashCacheTest
sync
gtest_main
)
target_link_libraries
(
syncRequestVoteTest
sync
gtest_main
...
...
source/libs/sync/test/syncEntryCacheTest.cpp
浏览文件 @
d3cdd75b
...
...
@@ -43,7 +43,7 @@ SRaftEntryCache* createCache(int maxCount) {
SSyncNode
*
pSyncNode
=
createFakeNode
();
ASSERT
(
pSyncNode
!=
NULL
);
SRaftEntryCache
*
pCache
=
raftCacheCreate
(
pSyncNode
,
maxCount
);
SRaftEntryCache
*
pCache
=
raft
Entry
CacheCreate
(
pSyncNode
,
maxCount
);
ASSERT
(
pCache
!=
NULL
);
return
pCache
;
...
...
@@ -52,213 +52,73 @@ SRaftEntryCache* createCache(int maxCount) {
void
test1
()
{
int32_t
code
=
0
;
SRaftEntryCache
*
pCache
=
createCache
(
5
);
for
(
int
i
=
0
;
i
<
5
;
++
i
)
{
for
(
int
i
=
0
;
i
<
10
;
++
i
)
{
SSyncRaftEntry
*
pEntry
=
createEntry
(
i
);
code
=
raftCachePutEntry
(
pCache
,
pEntry
);
ASSERT
(
code
==
1
);
syncEntryDestory
(
pEntry
);
code
=
raftEntryCachePutEntry
(
pCache
,
pEntry
);
sTrace
(
"put entry code:%d, pEntry:%p"
,
code
,
pEntry
);
}
raftCacheLog2
((
char
*
)
"==test1 write 5 entries=="
,
pCache
);
raft
Entry
CacheLog2
((
char
*
)
"==test1 write 5 entries=="
,
pCache
);
SyncIndex
index
;
index
=
1
;
code
=
raftCacheDelEntry
(
pCache
,
index
);
ASSERT
(
code
==
0
);
index
=
3
;
code
=
raftCacheDelEntry
(
pCache
,
index
);
ASSERT
(
code
==
0
);
raftCacheLog2
((
char
*
)
"==test1 delete 1,3=="
,
pCache
);
raftEntryCacheClear
(
pCache
,
3
);
raftEntryCacheLog2
((
char
*
)
"==test1 evict 3 entries=="
,
pCache
);
code
=
raftCacheClear
(
pCache
);
ASSERT
(
code
==
0
);
raftCacheLog2
((
char
*
)
"==clear all=="
,
pCache
);
raftEntryCacheClear
(
pCache
,
-
1
);
raftEntryCacheLog2
((
char
*
)
"==test1 evict -1(all) entries=="
,
pCache
);
}
void
test2
()
{
int32_t
code
=
0
;
SRaftEntryCache
*
pCache
=
createCache
(
5
);
for
(
int
i
=
0
;
i
<
5
;
++
i
)
{
for
(
int
i
=
0
;
i
<
10
;
++
i
)
{
SSyncRaftEntry
*
pEntry
=
createEntry
(
i
);
code
=
raftCachePutEntry
(
pCache
,
pEntry
);
ASSERT
(
code
==
1
);
syncEntryDestory
(
pEntry
);
code
=
raftEntryCachePutEntry
(
pCache
,
pEntry
);
sTrace
(
"put entry code:%d, pEntry:%p"
,
code
,
pEntry
);
}
raft
CacheLog2
((
char
*
)
"==test2
write 5 entries=="
,
pCache
);
raft
EntryCacheLog2
((
char
*
)
"==test1
write 5 entries=="
,
pCache
);
SyncIndex
index
;
index
=
1
;
SSyncRaftEntry
*
pEntry
;
code
=
raftCacheGetEntry
(
pCache
,
index
,
&
pEntry
);
ASSERT
(
code
==
0
);
syncEntryDestory
(
pEntry
);
syncEntryLog2
((
char
*
)
"==test2 get entry 1=="
,
pEntry
);
SyncIndex
index
=
2
;
SSyncRaftEntry
*
pEntry
=
NULL
;
index
=
2
;
code
=
raftCacheGetEntryP
(
pCache
,
index
,
&
pEntry
);
ASSERT
(
code
==
0
);
code
=
raftEntryCacheGetEntryP
(
pCache
,
index
,
&
pEntry
)
;
ASSERT
(
code
==
1
&&
index
==
pEntry
->
index
);
sTrace
(
"get entry:%p for %ld"
,
pEntry
,
index
);
syncEntryLog2
((
char
*
)
"==test2 get entry pointer 2=="
,
pEntry
);
code
=
raftEntryCacheGetEntry
(
pCache
,
index
,
&
pEntry
);
ASSERT
(
code
==
1
&&
index
==
pEntry
->
index
);
sTrace
(
"get entry:%p for %ld"
,
pEntry
,
index
);
syncEntryLog2
((
char
*
)
"==test2 get entry 2=="
,
pEntry
);
syncEntryDestory
(
pEntry
);
// not found
index
=
8
;
code
=
raftCacheGetEntry
(
pCache
,
index
,
&
pEntry
);
ASSERT
(
code
==
-
1
&&
terrno
==
TSDB_CODE_WAL_LOG_NOT_EXIST
);
code
=
raftEntryCacheGetEntry
(
pCache
,
index
,
&
pEntry
);
ASSERT
(
code
==
0
);
sTrace
(
"get entry:%p for %ld"
,
pEntry
,
index
);
sTrace
(
"==test2 get entry 8 not found=="
);
// not found
index
=
9
;
code
=
raftCacheGetEntryP
(
pCache
,
index
,
&
pEntry
);
ASSERT
(
code
==
-
1
&&
terrno
==
TSDB_CODE_WAL_LOG_NOT_EXIST
);
sTrace
(
"==test2 get entry pointer 9 not found=="
);
}
void
test3
()
{
int32_t
code
=
0
;
SRaftEntryCache
*
pCache
=
createCache
(
5
);
for
(
int
i
=
0
;
i
<
5
;
++
i
)
{
SSyncRaftEntry
*
pEntry
=
createEntry
(
i
);
code
=
raftCachePutEntry
(
pCache
,
pEntry
);
ASSERT
(
code
==
1
);
syncEntryDestory
(
pEntry
);
}
for
(
int
i
=
6
;
i
<
10
;
++
i
)
{
SSyncRaftEntry
*
pEntry
=
createEntry
(
i
);
code
=
raftCachePutEntry
(
pCache
,
pEntry
);
code
=
raftEntryCacheGetEntry
(
pCache
,
index
,
&
pEntry
);
ASSERT
(
code
==
0
);
syncEntryDestory
(
pEntry
);
}
raftCacheLog2
((
char
*
)
"==test3 write 10 entries, max count is 5=="
,
pCache
);
sTrace
(
"get entry:%p for %ld"
,
pEntry
,
index
);
sTrace
(
"==test2 get entry 9 not found=="
);
}
void
test
4
()
{
void
test
3
()
{
int32_t
code
=
0
;
SRaftEntryCache
*
pCache
=
createCache
(
5
);
for
(
int
i
=
0
;
i
<
5
;
++
i
)
{
SRaftEntryCache
*
pCache
=
createCache
(
20
);
for
(
int
i
=
0
;
i
<
=
4
;
++
i
)
{
SSyncRaftEntry
*
pEntry
=
createEntry
(
i
);
code
=
raftCachePutEntry
(
pCache
,
pEntry
);
ASSERT
(
code
==
1
);
syncEntryDestory
(
pEntry
);
}
raftCacheLog2
((
char
*
)
"==test4 write 5 entries=="
,
pCache
);
SyncIndex
index
;
index
=
3
;
SSyncRaftEntry
*
pEntry
;
code
=
raftCacheGetAndDel
(
pCache
,
index
,
&
pEntry
);
ASSERT
(
code
==
0
);
syncEntryLog2
((
char
*
)
"==test4 get-and-del entry 3=="
,
pEntry
);
raftCacheLog2
((
char
*
)
"==test4 after get-and-del entry 3=="
,
pCache
);
}
static
char
*
keyFn
(
const
void
*
pData
)
{
SSyncRaftEntry
*
pEntry
=
(
SSyncRaftEntry
*
)
pData
;
return
(
char
*
)(
&
(
pEntry
->
index
));
}
static
int
cmpFn
(
const
void
*
p1
,
const
void
*
p2
)
{
return
memcmp
(
p1
,
p2
,
sizeof
(
SyncIndex
));
}
void
printSkipList
(
SSkipList
*
pSkipList
)
{
ASSERT
(
pSkipList
!=
NULL
);
SSkipListIterator
*
pIter
=
tSkipListCreateIter
(
pSkipList
);
while
(
tSkipListIterNext
(
pIter
))
{
SSkipListNode
*
pNode
=
tSkipListIterGet
(
pIter
);
ASSERT
(
pNode
!=
NULL
);
SSyncRaftEntry
*
pEntry
=
(
SSyncRaftEntry
*
)
SL_GET_NODE_DATA
(
pNode
);
syncEntryPrint2
((
char
*
)
""
,
pEntry
);
code
=
raftEntryCachePutEntry
(
pCache
,
pEntry
);
sTrace
(
"put entry code:%d, pEntry:%p"
,
code
,
pEntry
);
}
}
void
delSkipListFirst
(
SSkipList
*
pSkipList
,
int
n
)
{
ASSERT
(
pSkipList
!=
NULL
);
sTrace
(
"delete first %d -------------"
,
n
);
SSkipListIterator
*
pIter
=
tSkipListCreateIter
(
pSkipList
);
for
(
int
i
=
0
;
i
<
n
;
++
i
)
{
tSkipListIterNext
(
pIter
);
SSkipListNode
*
pNode
=
tSkipListIterGet
(
pIter
);
tSkipListRemoveNode
(
pSkipList
,
pNode
);
}
}
SSyncRaftEntry
*
getLogEntry2
(
SSkipList
*
pSkipList
,
SyncIndex
index
)
{
SyncIndex
index2
=
index
;
SSyncRaftEntry
*
pEntry
=
NULL
;
int
arraySize
=
0
;
SArray
*
entryPArray
=
tSkipListGet
(
pSkipList
,
(
char
*
)(
&
index2
));
arraySize
=
taosArrayGetSize
(
entryPArray
);
if
(
arraySize
>
0
)
{
SSkipListNode
**
ppNode
=
(
SSkipListNode
**
)
taosArrayGet
(
entryPArray
,
0
);
ASSERT
(
*
ppNode
!=
NULL
);
pEntry
=
(
SSyncRaftEntry
*
)
SL_GET_NODE_DATA
(
*
ppNode
);
}
taosArrayDestroy
(
entryPArray
);
sTrace
(
"get index2: %ld, arraySize:%d -------------"
,
index
,
arraySize
);
syncEntryLog2
((
char
*
)
"getLogEntry2"
,
pEntry
);
return
pEntry
;
}
SSyncRaftEntry
*
getLogEntry
(
SSkipList
*
pSkipList
,
SyncIndex
index
)
{
sTrace
(
"get index: %ld -------------"
,
index
);
SyncIndex
index2
=
index
;
SSyncRaftEntry
*
pEntry
=
NULL
;
SSkipListIterator
*
pIter
=
tSkipListCreateIterFromVal
(
pSkipList
,
(
const
char
*
)
&
index2
,
TSDB_DATA_TYPE_BINARY
,
TSDB_ORDER_ASC
);
if
(
tSkipListIterNext
(
pIter
))
{
SSkipListNode
*
pNode
=
tSkipListIterGet
(
pIter
);
ASSERT
(
pNode
!=
NULL
);
pEntry
=
(
SSyncRaftEntry
*
)
SL_GET_NODE_DATA
(
pNode
);
}
syncEntryLog2
((
char
*
)
"getLogEntry"
,
pEntry
);
return
pEntry
;
}
void
test5
()
{
SSkipList
*
pSkipList
=
tSkipListCreate
(
MAX_SKIP_LIST_LEVEL
,
TSDB_DATA_TYPE_BINARY
,
sizeof
(
SyncIndex
),
cmpFn
,
SL_ALLOW_DUP_KEY
,
keyFn
);
ASSERT
(
pSkipList
!=
NULL
);
sTrace
(
"insert 9 - 5"
);
for
(
int
i
=
9
;
i
>=
5
;
--
i
)
{
SSyncRaftEntry
*
pEntry
=
createEntry
(
i
);
SSkipListNode
*
pSkipListNode
=
tSkipListPut
(
pSkipList
,
pEntry
);
}
sTrace
(
"insert 0 - 4"
);
for
(
int
i
=
0
;
i
<=
4
;
++
i
)
{
SSyncRaftEntry
*
pEntry
=
createEntry
(
i
);
SSkipListNode
*
pSkipListNode
=
tSkipListPut
(
pSkipList
,
pEntry
);
}
sTrace
(
"insert 7 7 7 7 7"
);
for
(
int
i
=
0
;
i
<=
4
;
++
i
)
{
SSyncRaftEntry
*
pEntry
=
createEntry
(
7
);
SSkipListNode
*
pSkipListNode
=
tSkipListPut
(
pSkipList
,
pEntry
);
code
=
raftEntryCachePutEntry
(
pCache
,
pEntry
);
sTrace
(
"put entry code:%d, pEntry:%p"
,
code
,
pEntry
);
}
sTrace
(
"print: -------------"
);
printSkipList
(
pSkipList
);
delSkipListFirst
(
pSkipList
,
3
);
sTrace
(
"print: -------------"
);
printSkipList
(
pSkipList
);
getLogEntry
(
pSkipList
,
2
);
getLogEntry
(
pSkipList
,
5
);
getLogEntry
(
pSkipList
,
7
);
getLogEntry
(
pSkipList
,
7
);
getLogEntry2
(
pSkipList
,
2
);
getLogEntry2
(
pSkipList
,
5
);
getLogEntry2
(
pSkipList
,
7
);
getLogEntry2
(
pSkipList
,
7
);
tSkipListDestroy
(
pSkipList
);
raftEntryCacheLog2
((
char
*
)
"==test3 write 10 entries=="
,
pCache
);
}
int
main
(
int
argc
,
char
**
argv
)
{
...
...
@@ -266,14 +126,9 @@ int main(int argc, char** argv) {
tsAsyncLog
=
0
;
sDebugFlag
=
DEBUG_TRACE
+
DEBUG_SCREEN
+
DEBUG_FILE
+
DEBUG_DEBUG
;
/*
test1
();
test2
();
test3
();
test4();
*/
test5
();
return
0
;
}
source/libs/sync/test/syncHashCacheTest.cpp
0 → 100644
浏览文件 @
d3cdd75b
#include <stdio.h>
#include "syncEnv.h"
#include "syncIO.h"
#include "syncInt.h"
#include "syncRaftLog.h"
#include "syncRaftStore.h"
#include "syncUtil.h"
#include "tskiplist.h"
void
logTest
()
{
sTrace
(
"--- sync log test: trace"
);
sDebug
(
"--- sync log test: debug"
);
sInfo
(
"--- sync log test: info"
);
sWarn
(
"--- sync log test: warn"
);
sError
(
"--- sync log test: error"
);
sFatal
(
"--- sync log test: fatal"
);
}
SSyncRaftEntry
*
createEntry
(
int
i
)
{
int32_t
dataLen
=
20
;
SSyncRaftEntry
*
pEntry
=
syncEntryBuild
(
dataLen
);
assert
(
pEntry
!=
NULL
);
pEntry
->
msgType
=
88
;
pEntry
->
originalRpcType
=
99
;
pEntry
->
seqNum
=
3
;
pEntry
->
isWeak
=
true
;
pEntry
->
term
=
100
+
i
;
pEntry
->
index
=
i
;
snprintf
(
pEntry
->
data
,
dataLen
,
"value%d"
,
i
);
return
pEntry
;
}
SSyncNode
*
createFakeNode
()
{
SSyncNode
*
pSyncNode
=
(
SSyncNode
*
)
taosMemoryMalloc
(
sizeof
(
SSyncNode
));
ASSERT
(
pSyncNode
!=
NULL
);
memset
(
pSyncNode
,
0
,
sizeof
(
SSyncNode
));
return
pSyncNode
;
}
SRaftEntryHashCache
*
createCache
(
int
maxCount
)
{
SSyncNode
*
pSyncNode
=
createFakeNode
();
ASSERT
(
pSyncNode
!=
NULL
);
SRaftEntryHashCache
*
pCache
=
raftCacheCreate
(
pSyncNode
,
maxCount
);
ASSERT
(
pCache
!=
NULL
);
return
pCache
;
}
void
test1
()
{
int32_t
code
=
0
;
SRaftEntryHashCache
*
pCache
=
createCache
(
5
);
for
(
int
i
=
0
;
i
<
5
;
++
i
)
{
SSyncRaftEntry
*
pEntry
=
createEntry
(
i
);
code
=
raftCachePutEntry
(
pCache
,
pEntry
);
ASSERT
(
code
==
1
);
syncEntryDestory
(
pEntry
);
}
raftCacheLog2
((
char
*
)
"==test1 write 5 entries=="
,
pCache
);
SyncIndex
index
;
index
=
1
;
code
=
raftCacheDelEntry
(
pCache
,
index
);
ASSERT
(
code
==
0
);
index
=
3
;
code
=
raftCacheDelEntry
(
pCache
,
index
);
ASSERT
(
code
==
0
);
raftCacheLog2
((
char
*
)
"==test1 delete 1,3=="
,
pCache
);
code
=
raftCacheClear
(
pCache
);
ASSERT
(
code
==
0
);
raftCacheLog2
((
char
*
)
"==clear all=="
,
pCache
);
}
void
test2
()
{
int32_t
code
=
0
;
SRaftEntryHashCache
*
pCache
=
createCache
(
5
);
for
(
int
i
=
0
;
i
<
5
;
++
i
)
{
SSyncRaftEntry
*
pEntry
=
createEntry
(
i
);
code
=
raftCachePutEntry
(
pCache
,
pEntry
);
ASSERT
(
code
==
1
);
syncEntryDestory
(
pEntry
);
}
raftCacheLog2
((
char
*
)
"==test2 write 5 entries=="
,
pCache
);
SyncIndex
index
;
index
=
1
;
SSyncRaftEntry
*
pEntry
;
code
=
raftCacheGetEntry
(
pCache
,
index
,
&
pEntry
);
ASSERT
(
code
==
0
);
syncEntryDestory
(
pEntry
);
syncEntryLog2
((
char
*
)
"==test2 get entry 1=="
,
pEntry
);
index
=
2
;
code
=
raftCacheGetEntryP
(
pCache
,
index
,
&
pEntry
);
ASSERT
(
code
==
0
);
syncEntryLog2
((
char
*
)
"==test2 get entry pointer 2=="
,
pEntry
);
// not found
index
=
8
;
code
=
raftCacheGetEntry
(
pCache
,
index
,
&
pEntry
);
ASSERT
(
code
==
-
1
&&
terrno
==
TSDB_CODE_WAL_LOG_NOT_EXIST
);
sTrace
(
"==test2 get entry 8 not found=="
);
// not found
index
=
9
;
code
=
raftCacheGetEntryP
(
pCache
,
index
,
&
pEntry
);
ASSERT
(
code
==
-
1
&&
terrno
==
TSDB_CODE_WAL_LOG_NOT_EXIST
);
sTrace
(
"==test2 get entry pointer 9 not found=="
);
}
void
test3
()
{
int32_t
code
=
0
;
SRaftEntryHashCache
*
pCache
=
createCache
(
5
);
for
(
int
i
=
0
;
i
<
5
;
++
i
)
{
SSyncRaftEntry
*
pEntry
=
createEntry
(
i
);
code
=
raftCachePutEntry
(
pCache
,
pEntry
);
ASSERT
(
code
==
1
);
syncEntryDestory
(
pEntry
);
}
for
(
int
i
=
6
;
i
<
10
;
++
i
)
{
SSyncRaftEntry
*
pEntry
=
createEntry
(
i
);
code
=
raftCachePutEntry
(
pCache
,
pEntry
);
ASSERT
(
code
==
0
);
syncEntryDestory
(
pEntry
);
}
raftCacheLog2
((
char
*
)
"==test3 write 10 entries, max count is 5=="
,
pCache
);
}
void
test4
()
{
int32_t
code
=
0
;
SRaftEntryHashCache
*
pCache
=
createCache
(
5
);
for
(
int
i
=
0
;
i
<
5
;
++
i
)
{
SSyncRaftEntry
*
pEntry
=
createEntry
(
i
);
code
=
raftCachePutEntry
(
pCache
,
pEntry
);
ASSERT
(
code
==
1
);
syncEntryDestory
(
pEntry
);
}
raftCacheLog2
((
char
*
)
"==test4 write 5 entries=="
,
pCache
);
SyncIndex
index
;
index
=
3
;
SSyncRaftEntry
*
pEntry
;
code
=
raftCacheGetAndDel
(
pCache
,
index
,
&
pEntry
);
ASSERT
(
code
==
0
);
syncEntryLog2
((
char
*
)
"==test4 get-and-del entry 3=="
,
pEntry
);
raftCacheLog2
((
char
*
)
"==test4 after get-and-del entry 3=="
,
pCache
);
}
static
char
*
keyFn
(
const
void
*
pData
)
{
SSyncRaftEntry
*
pEntry
=
(
SSyncRaftEntry
*
)
pData
;
return
(
char
*
)(
&
(
pEntry
->
index
));
}
static
int
cmpFn
(
const
void
*
p1
,
const
void
*
p2
)
{
return
memcmp
(
p1
,
p2
,
sizeof
(
SyncIndex
));
}
void
printSkipList
(
SSkipList
*
pSkipList
)
{
ASSERT
(
pSkipList
!=
NULL
);
SSkipListIterator
*
pIter
=
tSkipListCreateIter
(
pSkipList
);
while
(
tSkipListIterNext
(
pIter
))
{
SSkipListNode
*
pNode
=
tSkipListIterGet
(
pIter
);
ASSERT
(
pNode
!=
NULL
);
SSyncRaftEntry
*
pEntry
=
(
SSyncRaftEntry
*
)
SL_GET_NODE_DATA
(
pNode
);
syncEntryPrint2
((
char
*
)
""
,
pEntry
);
}
}
void
delSkipListFirst
(
SSkipList
*
pSkipList
,
int
n
)
{
ASSERT
(
pSkipList
!=
NULL
);
sTrace
(
"delete first %d -------------"
,
n
);
SSkipListIterator
*
pIter
=
tSkipListCreateIter
(
pSkipList
);
for
(
int
i
=
0
;
i
<
n
;
++
i
)
{
tSkipListIterNext
(
pIter
);
SSkipListNode
*
pNode
=
tSkipListIterGet
(
pIter
);
tSkipListRemoveNode
(
pSkipList
,
pNode
);
}
}
SSyncRaftEntry
*
getLogEntry2
(
SSkipList
*
pSkipList
,
SyncIndex
index
)
{
SyncIndex
index2
=
index
;
SSyncRaftEntry
*
pEntry
=
NULL
;
int
arraySize
=
0
;
SArray
*
entryPArray
=
tSkipListGet
(
pSkipList
,
(
char
*
)(
&
index2
));
arraySize
=
taosArrayGetSize
(
entryPArray
);
if
(
arraySize
>
0
)
{
SSkipListNode
**
ppNode
=
(
SSkipListNode
**
)
taosArrayGet
(
entryPArray
,
0
);
ASSERT
(
*
ppNode
!=
NULL
);
pEntry
=
(
SSyncRaftEntry
*
)
SL_GET_NODE_DATA
(
*
ppNode
);
}
taosArrayDestroy
(
entryPArray
);
sTrace
(
"get index2: %ld, arraySize:%d -------------"
,
index
,
arraySize
);
syncEntryLog2
((
char
*
)
"getLogEntry2"
,
pEntry
);
return
pEntry
;
}
SSyncRaftEntry
*
getLogEntry
(
SSkipList
*
pSkipList
,
SyncIndex
index
)
{
sTrace
(
"get index: %ld -------------"
,
index
);
SyncIndex
index2
=
index
;
SSyncRaftEntry
*
pEntry
=
NULL
;
SSkipListIterator
*
pIter
=
tSkipListCreateIterFromVal
(
pSkipList
,
(
const
char
*
)
&
index2
,
TSDB_DATA_TYPE_BINARY
,
TSDB_ORDER_ASC
);
if
(
tSkipListIterNext
(
pIter
))
{
SSkipListNode
*
pNode
=
tSkipListIterGet
(
pIter
);
ASSERT
(
pNode
!=
NULL
);
pEntry
=
(
SSyncRaftEntry
*
)
SL_GET_NODE_DATA
(
pNode
);
}
syncEntryLog2
((
char
*
)
"getLogEntry"
,
pEntry
);
return
pEntry
;
}
void
test5
()
{
SSkipList
*
pSkipList
=
tSkipListCreate
(
MAX_SKIP_LIST_LEVEL
,
TSDB_DATA_TYPE_BINARY
,
sizeof
(
SyncIndex
),
cmpFn
,
SL_ALLOW_DUP_KEY
,
keyFn
);
ASSERT
(
pSkipList
!=
NULL
);
sTrace
(
"insert 9 - 5"
);
for
(
int
i
=
9
;
i
>=
5
;
--
i
)
{
SSyncRaftEntry
*
pEntry
=
createEntry
(
i
);
SSkipListNode
*
pSkipListNode
=
tSkipListPut
(
pSkipList
,
pEntry
);
}
sTrace
(
"insert 0 - 4"
);
for
(
int
i
=
0
;
i
<=
4
;
++
i
)
{
SSyncRaftEntry
*
pEntry
=
createEntry
(
i
);
SSkipListNode
*
pSkipListNode
=
tSkipListPut
(
pSkipList
,
pEntry
);
}
sTrace
(
"insert 7 7 7 7 7"
);
for
(
int
i
=
0
;
i
<=
4
;
++
i
)
{
SSyncRaftEntry
*
pEntry
=
createEntry
(
7
);
SSkipListNode
*
pSkipListNode
=
tSkipListPut
(
pSkipList
,
pEntry
);
}
sTrace
(
"print: -------------"
);
printSkipList
(
pSkipList
);
delSkipListFirst
(
pSkipList
,
3
);
sTrace
(
"print: -------------"
);
printSkipList
(
pSkipList
);
getLogEntry
(
pSkipList
,
2
);
getLogEntry
(
pSkipList
,
5
);
getLogEntry
(
pSkipList
,
7
);
getLogEntry
(
pSkipList
,
7
);
getLogEntry2
(
pSkipList
,
2
);
getLogEntry2
(
pSkipList
,
5
);
getLogEntry2
(
pSkipList
,
7
);
getLogEntry2
(
pSkipList
,
7
);
tSkipListDestroy
(
pSkipList
);
}
int
main
(
int
argc
,
char
**
argv
)
{
gRaftDetailLog
=
true
;
tsAsyncLog
=
0
;
sDebugFlag
=
DEBUG_TRACE
+
DEBUG_SCREEN
+
DEBUG_FILE
+
DEBUG_DEBUG
;
/*
test1();
test2();
test3();
test4();
*/
test5
();
return
0
;
}
source/util/src/terror.c
浏览文件 @
d3cdd75b
...
...
@@ -561,6 +561,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_COL_JSON, "Only tag can be jso
TAOS_DEFINE_ERROR
(
TSDB_CODE_PAR_VALUE_TOO_LONG
,
"Value too long for column/tag"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_PAR_INVALID_DELETE_WHERE
,
"The DELETE statement must have a definite time window range"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_PAR_INVALID_REDISTRIBUTE_VG
,
"The REDISTRIBUTE VGROUP statement only support 1 to 3 dnodes"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_PAR_INVALID_SELECTED_EXPR
,
"Invalid SELECTed expression"
)
//planner
TAOS_DEFINE_ERROR
(
TSDB_CODE_PLAN_INTERNAL_ERROR
,
"Planner internal error"
)
...
...
tests/pytest/util/sqlset.py
浏览文件 @
d3cdd75b
...
...
@@ -41,7 +41,7 @@ class TDSetSql:
create_stb_sql
=
f
'create table
{
stbname
}
(
{
column_sql
[:
-
1
]
}
) tags(
{
tag_sql
[:
-
1
]
}
)'
return
create_stb_sql
def
set_insertsql
(
self
,
column_dict
,
tbname
,
binary_str
,
nchar_str
):
def
set_insertsql
(
self
,
column_dict
,
tbname
,
binary_str
=
None
,
nchar_str
=
None
):
sql
=
''
for
k
,
v
in
column_dict
.
items
():
if
v
.
lower
()
==
'timestamp'
or
v
.
lower
()
==
'tinyint'
or
v
.
lower
()
==
'smallint'
or
v
.
lower
()
==
'int'
or
v
.
lower
()
==
'bigint'
or
\
...
...
tests/script/general/cache/testSuite.sim
已删除
100644 → 0
浏览文件 @
8aa04f8e
run general/cache/new_metrics.sim
run general/cache/restart_table.sim
run general/cache/restart_metrics.sim
tests/script/general/column/testSuite.sim
已删除
100644 → 0
浏览文件 @
8aa04f8e
run general/column/commit.sim
run general/column/metrics.sim
run general/column/table.sim
tests/script/general/compress/testSuite.sim
已删除
100644 → 0
浏览文件 @
8aa04f8e
run general/compress/commitlog.sim
run general/compress/compress2.sim
run general/compress/compress.sim
run general/compress/uncompress.sim
tests/script/general/import/testSuite.sim
已删除
100644 → 0
浏览文件 @
8aa04f8e
run general/import/basic.sim
run general/import/commit.sim
run general/import/large.sim
run general/import/replica1.sim
tests/script/jenkins/basic.txt
浏览文件 @
d3cdd75b
#======================b1-start===============
# ---- alter
./test.sh -f tsim/alter/cached_schema_after_alter.sim
./test.sh -f tsim/alter/dnode.sim
#./test.sh -f tsim/alter/table.sim
# ---- user
./test.sh -f tsim/user/basic.sim
./test.sh -f tsim/user/password.sim
./test.sh -f tsim/user/privilege_db.sim
./test.sh -f tsim/user/privilege_sysinfo.sim
## ---- db
# ---- cache
./test.sh -f tsim/cache/new_metrics.sim
./test.sh -f tsim/cache/restart_table.sim
./test.sh -f tsim/cache/restart_metrics.sim
# ---- column
./test.sh -f tsim/column/commit.sim
./test.sh -f tsim/column/metrics.sim
./test.sh -f tsim/column/table.sim
# ---- compress
./test.sh -f tsim/compress/commitlog.sim
./test.sh -f tsim/compress/compress2.sim
./test.sh -f tsim/compress/compress.sim
./test.sh -f tsim/compress/uncompress.sim
# ---- db
./test.sh -f tsim/db/alter_option.sim
# ./test.sh -f tsim/db/alter_replica_13.sim
# ./test.sh -f tsim/db/alter_replica_31.sim
...
...
@@ -45,6 +66,12 @@
# ./test.sh -f tsim/dnode/redistribute_vgroup_replica3_v3.sim
# ./test.sh -f tsim/dnode/vnode_clean.sim
# ---- import
./test.sh -f tsim/import/basic.sim
./test.sh -f tsim/import/commit.sim
./test.sh -f tsim/import/large.sim
./test.sh -f tsim/import/replica1.sim
# ---- insert
./test.sh -f tsim/insert/basic0.sim
./test.sh -f tsim/insert/basic1.sim
...
...
@@ -197,5 +224,6 @@
# --- scalar
./test.sh -f tsim/scalar/in.sim
./test.sh -f tsim/scalar/scalar.sim
#======================b1-end===============
tests/script/
general
/alter/cached_schema_after_alter.sim
→
tests/script/
tsim
/alter/cached_schema_after_alter.sim
浏览文件 @
d3cdd75b
文件已移动
tests/script/
general
/alter/dnode.sim
→
tests/script/
tsim
/alter/dnode.sim
浏览文件 @
d3cdd75b
...
...
@@ -4,39 +4,34 @@ system sh/exec.sh -n dnode1 -s start
sql connect
print ======== step1
sql alter dnode 1 resetlog
sql alter dnode 1 monitor 1
sleep 3000
sql select * from log.dn
if $rows <= 0 then
return -1
endi
sql alter dnode 1 'resetlog'
sql alter dnode 1 'monitor' '1'
sql alter dnode 1 'monitor' '0'
sql alter dnode 1 'monitor 1'
sql alter dnode 1 'monitor 0'
print ======== step2
sql_error alter dnode 1 'resetquerycache'
sql alter dnode 1 'debugFlag 135'
sql alter dnode 1 'dDebugFlag 131'
sql alter dnode 1 'vDebugFlag 131'
sql alter dnode 1 'mDebugFlag 131'
sql alter dnode 1 'wDebugFlag 131'
sql alter dnode 1 'sDebugFlag 131'
sql alter dnode 1 'tsdbDebugFlag 131'
sql alter dnode 1 'tqDebugFlag 131'
sql alter dnode 1 'fsDebugFlag 131'
sql alter dnode 1 'udfDebugFlag 131'
sql alter dnode 1 'smaDebugFlag 131'
sql alter dnode 1 'idxDebugFlag 131'
sql alter dnode 1 'tmrDebugFlag 131'
sql alter dnode 1 'uDebugFlag 131'
sql alter dnode 1 'smaDebugFlag 131'
sql alter dnode 1 'rpcDebugFlag 131'
sql alter dnode 1 'qDebugFlag 131'
sql alter dnode 1 resetquerycache
sql alter dnode 1 debugFlag 135
sql alter dnode 1 debugFlag 131
sql alter dnode 1 monitor 0
sql alter dnode 1 debugFlag 135
sql alter dnode 1 monDebugFlag 135
sql alter dnode 1 vDebugFlag 135
sql alter dnode 1 mDebugFlag 135
sql alter dnode 1 cDebugFlag 135
sql alter dnode 1 httpDebugFlag 135
sql alter dnode 1 qDebugflag 135
sql alter dnode 1 sdbDebugFlag 135
sql alter dnode 1 uDebugFlag 135
sql alter dnode 1 tsdbDebugFlag 135
sql alter dnode 1 sDebugflag 135
sql alter dnode 1 rpcDebugFlag 135
sql alter dnode 1 dDebugFlag 135
sql alter dnode 1 mqttDebugFlag 135
sql alter dnode 1 wDebugFlag 135
sql alter dnode 1 tmrDebugFlag 135
sql_error alter dnode 2 wDebugFlag 135
sql_error alter dnode 2 tmrDebugFlag 135
sql_error alter dnode 2 'wDebugFlag 135'
sql_error alter dnode 2 'tmrDebugFlag 135'
print ======== step3
sql_error alter $hostname1 debugFlag 135
...
...
@@ -47,10 +42,10 @@ sql_error alter dnode $hostname2 debugFlag 135
sql_error alter dnode $hostname2 monDebugFlag 135
sql_error alter dnode $hostname2 vDebugFlag 135
sql_error alter dnode $hostname2 mDebugFlag 135
sql alter dnode $hostname1 debugFlag 135
sql alter dnode $hostname1 monDebugFlag 135
sql alter dnode $hostname1 vDebugFlag 135
sql alter dnode $hostname1 tmrDebugFlag 131
sql
_error
alter dnode $hostname1 debugFlag 135
sql
_error
alter dnode $hostname1 monDebugFlag 135
sql
_error
alter dnode $hostname1 vDebugFlag 135
sql
_error
alter dnode $hostname1 tmrDebugFlag 131
print ======== step4
sql_error sql alter dnode 1 balance 0
...
...
tests/script/
general
/alter/table.sim
→
tests/script/
tsim
/alter/table.sim
浏览文件 @
d3cdd75b
...
...
@@ -315,9 +315,7 @@ endi
print ======== step9
print ======== step10
system sh/exec.sh -n dnode1 -s stop -x SIGINT
sleep 3000
system sh/exec.sh -n dnode1 -s start
sleep 3000
sql use d1
sql describe tb
...
...
tests/script/
general
/cache/new_metrics.sim
→
tests/script/
tsim
/cache/new_metrics.sim
浏览文件 @
d3cdd75b
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c walLevel -v 1
system sh/exec.sh -n dnode1 -s start
sleep 2000
sql connect
$i = 0
...
...
@@ -38,7 +33,6 @@ while $i < 5
endw
print =============== step2
sql select * from $tb order by ts desc
print ===>rows $rows, data $data01
if $rows != 20 then
...
...
@@ -67,7 +61,6 @@ if $data00 != 100 then
endi
print =============== step3
sql show stables
if $rows != 1 then
return -1
...
...
@@ -75,12 +68,8 @@ endi
if $data00 != $mt then
return -1
endi
if $data04 != 5 then
return -1
endi
print =============== step4
while $i < 10
$tb = $tbPrefix . $i
sql create table $tb using $mt tags( 1 )
...
...
@@ -99,7 +88,6 @@ sql reset query cache
sleep 1000
print =============== step5
sql select * from $tb order by ts desc
print ===>rows $rows, data $data01
if $rows != 20 then
...
...
@@ -128,7 +116,6 @@ if $data00 != 200 then
endi
print =============== step6
sql show stables
if $rows != 1 then
return -1
...
...
@@ -136,8 +123,5 @@ endi
if $data00 != $mt then
return -1
endi
if $data04 != 10 then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
\ No newline at end of file
tests/script/
general
/cache/restart_metrics.sim
→
tests/script/
tsim
/cache/restart_metrics.sim
浏览文件 @
d3cdd75b
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c walLevel -v 1
system sh/exec.sh -n dnode1 -s start
sleep 2000
sql connect
print ======================== dnode1 start
print ======================== dnode1 start
$i = 0
$dbPrefix = ca_rm_db
$tbPrefix = ca_rm_tb
...
...
@@ -49,9 +44,7 @@ endi
print =============== step2
system sh/exec.sh -n dnode1 -s stop
sleep 3000
system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c walLevel -v 1
system sh/exec.sh -n dnode1 -s start
print =============== step3
...
...
tests/script/
general
/cache/restart_table.sim
→
tests/script/
tsim
/cache/restart_table.sim
浏览文件 @
d3cdd75b
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c walLevel -v 1
system sh/exec.sh -n dnode1 -s start
sleep 2000
sql connect
print ======================== dnode1 start
print ======================== dnode1 start
$i = 0
$dbPrefix = ca_rt_db
$tbPrefix = ca_rt_tb
...
...
@@ -33,9 +28,7 @@ endi
print =============== step2
system sh/exec.sh -n dnode1 -s stop
sleep 3000
system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c walLevel -v 1
system sh/exec.sh -n dnode1 -s start
print =============== step3
...
...
tests/script/
general
/column/commit.sim
→
tests/script/
tsim
/column/commit.sim
浏览文件 @
d3cdd75b
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c walLevel -v 1
system sh/exec.sh -n dnode1 -s start
sleep 2000
sql connect
print =============== step1
...
...
@@ -25,7 +20,6 @@ if $rows != 1 then
endi
print =============== step2
sql insert into d3.t1 values (now -300d,0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 );
sql insert into d3.t1 values (now-200d,1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 );
sql insert into d3.t1 values (now-150d,2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 );
...
...
@@ -38,7 +32,6 @@ sql insert into d3.t1 values (now,8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8
sql insert into d3.t1 values (now+1d,9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 );
print =============== step3
sql select * from d3.mt
if $rows != 10 then
return -1
...
...
@@ -89,12 +82,9 @@ endi
print =============== step4
system sh/exec.sh -n dnode1 -s stop -x SIGINT
sleep 3000
system sh/exec.sh -n dnode1 -s start
sleep 3000
print =============== step5
sql select * from d3.mt
if $rows != 10 then
return -1
...
...
tests/script/
general
/column/metrics.sim
→
tests/script/
tsim
/column/metrics.sim
浏览文件 @
d3cdd75b
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c walLevel -v 1
system sh/exec.sh -n dnode1 -s start
sleep 2000
sql connect
print =============== step1
...
...
@@ -26,7 +21,6 @@ if $rows != 1 then
endi
print =============== step2
sql insert into d2.t1 values (now,0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 )
sql insert into d2.t1 values (now+1m,1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 )
sql insert into d2.t1 values (now+2m,2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 )
...
...
@@ -58,7 +52,6 @@ sql insert into d2.t2 values (now+8m,8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 ,
sql insert into d2.t2 values (now+9m,9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 )
print =============== step3
sql select * from d2.mt
if $rows != 20 then
return -1
...
...
@@ -157,12 +150,9 @@ endi
print =============== step4
system sh/exec.sh -n dnode1 -s stop -x SIGINT
sleep 3000
system sh/exec.sh -n dnode1 -s start
sleep 3000
print =============== step5
sql select * from d2.mt
if $rows != 20 then
return -1
...
...
tests/script/
general
/column/table.sim
→
tests/script/
tsim
/column/table.sim
浏览文件 @
d3cdd75b
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c walLevel -v 1
system sh/exec.sh -n dnode1 -s start
sleep 2000
sql connect
print =============== step1
...
...
@@ -19,7 +14,6 @@ if $rows != 1 then
endi
print =============== step2
sql insert into d1.t1 values (now,0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 )
sql insert into d1.t1 values (now+1m,1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 )
sql insert into d1.t1 values (now+2m,2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 )
...
...
@@ -36,7 +30,6 @@ sql insert into d1.t1 values (now+8m,8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 ,
sql insert into d1.t1 values (now+9m,9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 )
print ======= step3
sql select * from d1.t1
print select * from d1.t1 => rows $rows
if $rows != 10 then
...
...
@@ -129,9 +122,7 @@ endi
print =============== step4
system sh/exec.sh -n dnode1 -s stop -x SIGINT
sleep 3000
system sh/exec.sh -n dnode1 -s start
sleep 3000
print ============== step5
...
...
tests/script/
general
/compress/commitlog.sim
→
tests/script/
tsim
/compress/commitlog.sim
浏览文件 @
d3cdd75b
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c walLevel -v 1
system sh/cfg.sh -n dnode1 -c comp -v 1
system sh/exec.sh -n dnode1 -s start
sleep 2000
sql connect
print ============================ dnode1 start
print ============================ dnode1 start
$i = 0
$dbPrefix = db
$tbPrefix = tb
...
...
@@ -18,7 +13,6 @@ $tb = $tbPrefix . $i
$N = 2000
print =============== step1
sql create database $db
sql use $db
sql create table $tb (ts timestamp, b bool, t tinyint, s smallint, i int, big bigint, str binary(256))
...
...
@@ -87,9 +81,7 @@ endi
print =============== step4
system sh/exec.sh -n dnode1 -s stop -x SIGINT
sleep 3000
system sh/exec.sh -n dnode1 -s start
sleep 3000
print =============== step5
...
...
tests/script/
general
/compress/compress.sim
→
tests/script/
tsim
/compress/compress.sim
浏览文件 @
d3cdd75b
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c walLevel -v 1
system sh/cfg.sh -n dnode1 -c comp -v 1
system sh/exec.sh -n dnode1 -s start
sleep 2000
sql connect
print ============================ dnode1 start
$i = 0
$dbPrefix = db
$tbPrefix = tb
...
...
@@ -19,7 +13,6 @@ $tb = $tbPrefix . $i
$N = 2000
print =============== step1
sql create database $db
sql use $db
sql create table $tb (ts timestamp, b bool, t tinyint, s smallint, i int, big bigint, str binary(256))
...
...
@@ -82,9 +75,7 @@ endi
print =============== step4
system sh/exec.sh -n dnode1 -s stop -x SIGINT
sleep 3000
system sh/exec.sh -n dnode1 -s start
sleep 3000
print =============== step5
...
...
tests/script/
general
/compress/compress2.sim
→
tests/script/
tsim
/compress/compress2.sim
浏览文件 @
d3cdd75b
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c walLevel -v 1
system sh/cfg.sh -n dnode1 -c comp -v 2
system sh/exec.sh -n dnode1 -s start
sleep 2000
sql connect
print ============================ dnode1 start
$i = 0
$dbPrefix = db
$tbPrefix = tb
...
...
@@ -82,9 +76,7 @@ endi
print =============== step4
system sh/exec.sh -n dnode1 -s stop -x SIGINT
sleep 3000
system sh/exec.sh -n dnode1 -s start
sleep 3000
print =============== step5
...
...
tests/script/
general
/compress/uncompress.sim
→
tests/script/
tsim
/compress/uncompress.sim
浏览文件 @
d3cdd75b
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c walLevel -v 1
system sh/cfg.sh -n dnode1 -c comp -v 1
system sh/exec.sh -n dnode1 -s start
sleep 2000
sql connect
print ============================ dnode1 start
print ============================ dnode1 start
$i = 0
$dbPrefix = cp_cp_db
$tbPrefix = cp_cp_tb
...
...
@@ -17,7 +13,6 @@ $tb = $tbPrefix . $i
$N = 2000
print =============== step1
sql create database $db
sql use $db
...
...
@@ -81,12 +76,9 @@ endi
print =============== step4
system sh/exec.sh -n dnode1 -s stop -x SIGINT
sleep 3000
system sh/exec.sh -n dnode1 -s start
sleep 2000
print =============== step5
$i = 0
$db = $dbPrefix . $i
$tb = $tbPrefix . $i
...
...
tests/script/
general
/import/basic.sim
→
tests/script/
tsim
/import/basic.sim
浏览文件 @
d3cdd75b
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/deploy.sh -n dnode2 -i 2
system sh/deploy.sh -n dnode3 -i 3
system sh/deploy.sh -n dnode4 -i 4
system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 10
system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 10
system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 10
system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 10
system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 2000
system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 2000
system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 2000
system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 2000
system sh/cfg.sh -n dnode1 -c walLevel -v 1
system sh/cfg.sh -n dnode2 -c walLevel -v 1
system sh/cfg.sh -n dnode3 -c walLevel -v 1
system sh/cfg.sh -n dnode4 -c walLevel -v 1
print ========= start dnode1
system sh/exec.sh -n dnode1 -s start
sleep 2000
sql connect
sql create database ibadb
...
...
tests/script/
general
/import/commit.sim
→
tests/script/
tsim
/import/commit.sim
浏览文件 @
d3cdd75b
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/deploy.sh -n dnode2 -i 2
system sh/deploy.sh -n dnode3 -i 3
system sh/deploy.sh -n dnode4 -i 4
system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 10
system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 10
system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 10
system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 10
system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 2000
system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 2000
system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 2000
system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 2000
system sh/cfg.sh -n dnode1 -c walLevel -v 1
system sh/cfg.sh -n dnode2 -c walLevel -v 1
system sh/cfg.sh -n dnode3 -c walLevel -v 1
system sh/cfg.sh -n dnode4 -c walLevel -v 1
print ========= start dnode1
system sh/exec.sh -n dnode1 -s start
sleep 2000
sql connect
print ========= step1
...
...
@@ -72,9 +46,7 @@ endi
print ========= step3
system sh/exec.sh -n dnode1 -s stop -x SIGINT
sleep 3000
system sh/exec.sh -n dnode1 -s start
sleep 3000
print ========= step4
sql select * from ic2db.tb;
...
...
tests/script/
general
/import/large.sim
→
tests/script/
tsim
/import/large.sim
浏览文件 @
d3cdd75b
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/deploy.sh -n dnode2 -i 2
system sh/deploy.sh -n dnode3 -i 3
system sh/deploy.sh -n dnode4 -i 4
system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 10
system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 10
system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 10
system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 10
system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 2000
system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 2000
system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 2000
system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 2000
system sh/cfg.sh -n dnode1 -c walLevel -v 1
system sh/cfg.sh -n dnode2 -c walLevel -v 1
system sh/cfg.sh -n dnode3 -c walLevel -v 1
system sh/cfg.sh -n dnode4 -c walLevel -v 1
print ========= start dnode1
system sh/exec.sh -n dnode1 -s start
sleep 2000
sql connect
sql create database db
...
...
tests/script/
general
/import/replica1.sim
→
tests/script/
tsim
/import/replica1.sim
浏览文件 @
d3cdd75b
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/deploy.sh -n dnode2 -i 2
system sh/deploy.sh -n dnode3 -i 3
system sh/deploy.sh -n dnode4 -i 4
system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 10
system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 10
system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 10
system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 10
system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 2000
system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 2000
system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 2000
system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 2000
system sh/cfg.sh -n dnode1 -c walLevel -v 2
system sh/cfg.sh -n dnode2 -c walLevel -v 2
system sh/cfg.sh -n dnode3 -c walLevel -v 2
system sh/cfg.sh -n dnode4 -c walLevel -v 2
print ========= start dnode1
system sh/exec.sh -n dnode1 -s start
sleep 2000
sql connect
sql create database ir1db duration 7
...
...
@@ -93,9 +66,7 @@ endi
print ================== dnode restart
system sh/exec.sh -n dnode1 -s stop -x SIGINT
sleep 3000
system sh/exec.sh -n dnode1 -s start
sleep 3000
sql use ir1db
sql select * from tb;
...
...
@@ -162,9 +133,7 @@ endi
print ================= step10
system sh/exec.sh -n dnode1 -s stop -x SIGINT
sleep 3000
system sh/exec.sh -n dnode1 -s start
sleep 3000
sql use ir1db
sql select * from tb;
...
...
tests/script/tsim/scalar/scalar.sim
0 → 100644
浏览文件 @
d3cdd75b
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
sql connect
print ======== step1
sql drop database if exists db1;
sql create database db1 vgroups 3;
sql use db1;
sql create stable st1 (fts timestamp, fbool bool, ftiny tinyint, fsmall smallint, fint int, fbig bigint, futiny tinyint unsigned, fusmall smallint unsigned, fuint int unsigned, fubig bigint unsigned, ffloat float, fdouble double, fbin binary(10), fnchar nchar(10)) tags(tts timestamp, tbool bool, ttiny tinyint, tsmall smallint, tint int, tbig bigint, tutiny tinyint unsigned, tusmall smallint unsigned, tuint int unsigned, tubig bigint unsigned, tfloat float, tdouble double, tbin binary(10), tnchar nchar(10));
sql create table tb1 using st1 tags('2022-07-10 16:31:00', true, 1, 1, 1, 1, 1, 1, 1, 1, 1.0, 1.0, 'a', 'a');
sql create table tb2 using st1 tags('2022-07-10 16:32:00', false, 2, 2, 2, 2, 2, 2, 2, 2, 2.0, 2.0, 'b', 'b');
sql create table tb3 using st1 tags('2022-07-10 16:33:00', true, 3, 3, 3, 3, 3, 3, 3, 3, 3.0, 3.0, 'c', 'c');
sql insert into tb1 values ('2022-07-10 16:31:01', false, 1, 1, 1, 1, 1, 1, 1, 1, 1.0, 1.0, 'a', 'a');
sql insert into tb1 values ('2022-07-10 16:31:02', true, 2, 2, 2, 2, 2, 2, 2, 2, 2.0, 2.0, 'b', 'b');
sql insert into tb1 values ('2022-07-10 16:31:03', false, 3, 3, 3, 3, 3, 3, 3, 3, 3.0, 3.0, 'c', 'c');
sql insert into tb1 values ('2022-07-10 16:31:04', true, 4, 4, 4, 4, 4, 4, 4, 4, 4.0, 4.0, 'd', 'd');
sql insert into tb1 values ('2022-07-10 16:31:05', false, 5, 5, 5, 5, 5, 5, 5, 5, 5.0, 5.0, 'e', 'e');
sql insert into tb2 values ('2022-07-10 16:32:01', false, 1, 1, 1, 1, 1, 1, 1, 1, 1.0, 1.0, 'a', 'a');
sql insert into tb2 values ('2022-07-10 16:32:02', true, 2, 2, 2, 2, 2, 2, 2, 2, 2.0, 2.0, 'b', 'b');
sql insert into tb2 values ('2022-07-10 16:32:03', false, 3, 3, 3, 3, 3, 3, 3, 3, 3.0, 3.0, 'c', 'c');
sql insert into tb2 values ('2022-07-10 16:32:04', true, 4, 4, 4, 4, 4, 4, 4, 4, 4.0, 4.0, 'd', 'd');
sql insert into tb2 values ('2022-07-10 16:32:05', false, 5, 5, 5, 5, 5, 5, 5, 5, 5.0, 5.0, 'e', 'e');
sql insert into tb3 values ('2022-07-10 16:33:01', false, 1, 1, 1, 1, 1, 1, 1, 1, 1.0, 1.0, 'a', 'a');
sql insert into tb3 values ('2022-07-10 16:33:02', true, 2, 2, 2, 2, 2, 2, 2, 2, 2.0, 2.0, 'b', 'b');
sql insert into tb3 values ('2022-07-10 16:33:03', false, 3, 3, 3, 3, 3, 3, 3, 3, 3.0, 3.0, 'c', 'c');
sql insert into tb3 values ('2022-07-10 16:33:04', true, 4, 4, 4, 4, 4, 4, 4, 4, 4.0, 4.0, 'd', 'd');
sql insert into tb3 values ('2022-07-10 16:33:05', false, 5, 5, 5, 5, 5, 5, 5, 5, 5.0, 5.0, 'e', 'e');
sql select 1+1n;
if $rows != 1 then
return -1
endi
if $data00 != 2.000000000 then
return -1
endi
sql select cast(1 as timestamp)+1n;
if $rows != 1 then
return -1
endi
if $data00 != @70-02-01 08:00:00.000@ then
return -1
endi
sql select 1-1n;
if $rows != 1 then
return -1
endi
sql select cast(1 as timestamp)-1y;
if $rows != 1 then
return -1
endi
if $data00 != @69-01-01 08:00:00.000@ then
return -1
endi
sql select 1n-now();
sql select 1n+now();
#sql select avg(4n);
system sh/exec.sh -n dnode1 -s stop -x SIGINT
tests/system-test/0-others/sysinfo.py
0 → 100644
浏览文件 @
d3cdd75b
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
import
subprocess
from
util.common
import
*
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
self
.
dbname
=
'db'
def
get_database_info
(
self
):
tdSql
.
query
(
'select database()'
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
execute
(
f
'create database if not exists
{
self
.
dbname
}
'
)
tdSql
.
execute
(
f
'use
{
self
.
dbname
}
'
)
tdSql
.
query
(
'select database()'
)
tdSql
.
checkData
(
0
,
0
,
self
.
dbname
)
tdSql
.
execute
(
f
'drop database
{
self
.
dbname
}
'
)
def
check_version
(
self
):
taos_list
=
[
'server'
,
'client'
]
for
i
in
taos_list
:
tdSql
.
query
(
f
'select
{
i
}
_version()'
)
version_info
=
str
(
subprocess
.
run
(
'cat ../../source/util/src/version.c |grep "char version"'
,
shell
=
True
,
capture_output
=
True
).
stdout
.
decode
(
'utf8'
)).
split
(
'"'
)[
1
]
tdSql
.
checkData
(
0
,
0
,
version_info
)
def
get_server_status
(
self
):
tdSql
.
query
(
'select server_status()'
)
tdSql
.
checkData
(
0
,
0
,
1
)
tdDnodes
.
stoptaosd
(
1
)
tdSql
.
query
(
'select server_status()'
)
print
(
tdSql
.
queryResult
)
def
run
(
self
):
self
.
get_database_info
()
self
.
check_version
()
# self.get_server_status()
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
\ No newline at end of file
tests/system-test/2-query/To_unixtimestamp.py
浏览文件 @
d3cdd75b
tests/system-test/2-query/arccos.py
浏览文件 @
d3cdd75b
tests/system-test/2-query/arcsin.py
浏览文件 @
d3cdd75b
tests/system-test/2-query/arctan.py
浏览文件 @
d3cdd75b
tests/system-test/2-query/count.py
浏览文件 @
d3cdd75b
from
util.log
import
*
from
util.sql
import
*
from
util.cases
import
*
from
util.sqlset
import
*
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
tdSql
.
init
(
conn
.
cursor
()
,
logSql
)
self
.
setsql
=
TDSetSql
()
self
.
rowNum
=
10
self
.
ts
=
1537146000000
def
run
(
self
):
self
.
ntbname
=
'ntb'
self
.
stbname
=
'stb'
self
.
column_dict
=
{
'ts'
:
'timestamp'
,
'c1'
:
'int'
,
'c2'
:
'float'
,
'c3'
:
'double'
,
'c4'
:
'timestamp'
}
self
.
tag_dict
=
{
't0'
:
'int'
}
# The number of tag_values should be same as tbnum
self
.
tbnum
=
2
self
.
tag_values
=
[
f
'10'
,
f
'100'
]
def
query_stb
(
self
,
k
,
stbname
,
tbnum
,
rownum
):
tdSql
.
query
(
f
'select count(
{
k
}
) from
{
stbname
}
'
)
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
0
][
0
],
tbnum
*
rownum
)
tdSql
.
query
(
f
'select count(
{
k
}
) from
{
stbname
}
where ts <=
{
self
.
ts
+
self
.
rowNum
-
1
}
'
)
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
0
][
0
],
tbnum
*
rownum
)
tdSql
.
query
(
f
'select count(
{
k
}
) from
{
stbname
}
where ts <=
{
self
.
ts
+
self
.
rowNum
-
2
}
'
)
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
0
][
0
],
tbnum
*
(
rownum
-
1
))
def
query_ctb
(
self
,
k
,
i
,
stbname
,
rownum
):
tdSql
.
query
(
f
'select count(
{
k
}
) from
{
stbname
}
_
{
i
}
'
)
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
0
][
0
],
rownum
)
tdSql
.
query
(
f
'select count(
{
k
}
) from
{
stbname
}
_
{
i
}
where ts <=
{
self
.
ts
+
self
.
rowNum
-
1
}
'
)
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
0
][
0
],
rownum
)
tdSql
.
query
(
f
'select count(
{
k
}
) from
{
stbname
}
_
{
i
}
where ts <=
{
self
.
ts
+
self
.
rowNum
-
2
}
'
)
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
0
][
0
],
rownum
-
1
)
def
query_ntb
(
self
,
k
,
ntbname
,
rownum
):
tdSql
.
query
(
f
'select count(
{
k
}
) from
{
ntbname
}
'
)
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
0
][
0
],
rownum
)
tdSql
.
query
(
f
'select count(
{
k
}
) from
{
ntbname
}
where ts <=
{
self
.
ts
+
self
.
rowNum
-
1
}
'
)
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
0
][
0
],
rownum
)
tdSql
.
query
(
f
'select count(
{
k
}
) from
{
ntbname
}
where ts <=
{
self
.
ts
+
self
.
rowNum
-
2
}
'
)
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
0
][
0
],
rownum
-
1
)
def
count_query_stb
(
self
,
column_dict
,
tag_dict
,
stbname
,
tbnum
,
rownum
):
tdSql
.
query
(
f
'select count(tbname) from
{
stbname
}
'
)
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
0
][
0
],
tbnum
*
rownum
)
tdSql
.
query
(
f
'SELECT count(*) from (select distinct tbname from
{
stbname
}
)'
)
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
0
][
0
],
tbnum
)
for
k
in
column_dict
.
keys
():
self
.
query_stb
(
k
,
stbname
,
tbnum
,
rownum
)
for
k
in
tag_dict
.
keys
():
self
.
query_stb
(
k
,
stbname
,
tbnum
,
rownum
)
def
count_query_ctb
(
self
,
column_dict
,
tag_dict
,
stbname
,
tbnum
,
rownum
):
for
i
in
range
(
tbnum
):
tdSql
.
query
(
f
'select count(tbname) from
{
stbname
}
_
{
i
}
'
)
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
0
][
0
],
rownum
)
for
k
in
column_dict
.
keys
():
self
.
query_ctb
(
k
,
i
,
stbname
,
rownum
)
for
k
in
tag_dict
.
keys
():
self
.
query_ctb
(
k
,
i
,
stbname
,
rownum
)
def
count_query_ntb
(
self
,
column_dict
,
ntbname
,
rownum
):
tdSql
.
query
(
f
'select count(tbname) from
{
ntbname
}
'
)
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
0
][
0
],
rownum
)
for
k
in
column_dict
.
keys
():
self
.
query_ntb
(
k
,
ntbname
,
rownum
)
def
insert_data
(
self
,
column_dict
,
tbname
,
row_num
):
insert_sql
=
self
.
setsql
.
set_insertsql
(
column_dict
,
tbname
)
for
i
in
range
(
row_num
):
insert_list
=
[]
self
.
setsql
.
insert_values
(
column_dict
,
i
,
insert_sql
,
insert_list
,
self
.
ts
)
def
check_ntb
(
self
):
tdSql
.
prepare
()
tdSql
.
execute
(
'''create table stb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned) tags(loc nchar(20))'''
)
tdSql
.
execute
(
"create table stb_1 using stb tags('beijing')"
)
tdSql
.
execute
(
"create table stb_2 using stb tags('shanghai')"
)
tdSql
.
execute
(
'''create table ntb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned)'''
)
for
i
in
range
(
self
.
rowNum
):
tdSql
.
execute
(
"insert into stb_1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)"
%
(
self
.
ts
+
i
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
0.1
,
i
+
0.1
,
i
%
2
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
))
tdSql
.
execute
(
"insert into stb_2 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)"
%
(
self
.
ts
+
i
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
0.1
,
i
+
0.1
,
i
%
2
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
))
for
i
in
range
(
self
.
rowNum
):
tdSql
.
execute
(
"insert into ntb values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)"
%
(
self
.
ts
+
i
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
0.1
,
i
+
0.1
,
i
%
2
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
))
tdSql
.
query
(
"select count(*) from stb"
)
tdSql
.
checkData
(
0
,
0
,
20
)
tdSql
.
query
(
"select count(*) from db.stb"
)
tdSql
.
checkData
(
0
,
0
,
20
)
tdSql
.
query
(
"select count(ts) from stb"
)
tdSql
.
checkData
(
0
,
0
,
20
)
tdSql
.
query
(
"select count(ts) from db.stb"
)
tdSql
.
checkData
(
0
,
0
,
20
)
tdSql
.
query
(
"select count(col1) from stb"
)
tdSql
.
checkData
(
0
,
0
,
20
)
tdSql
.
query
(
"select count(col1) from db.stb"
)
tdSql
.
checkData
(
0
,
0
,
20
)
tdSql
.
query
(
"select count(col2) from stb"
)
tdSql
.
checkData
(
0
,
0
,
20
)
tdSql
.
query
(
"select count(col2) from db.stb"
)
tdSql
.
checkData
(
0
,
0
,
20
)
tdSql
.
query
(
"select count(col3) from stb"
)
tdSql
.
checkData
(
0
,
0
,
20
)
tdSql
.
query
(
"select count(col3) from db.stb"
)
tdSql
.
checkData
(
0
,
0
,
20
)
tdSql
.
query
(
"select count(col4) from stb"
)
tdSql
.
checkData
(
0
,
0
,
20
)
tdSql
.
query
(
"select count(col4) from db.stb"
)
tdSql
.
checkData
(
0
,
0
,
20
)
tdSql
.
query
(
"select count(col5) from stb"
)
tdSql
.
checkData
(
0
,
0
,
20
)
tdSql
.
query
(
"select count(col5) from db.stb"
)
tdSql
.
checkData
(
0
,
0
,
20
)
tdSql
.
query
(
"select count(col6) from stb"
)
tdSql
.
checkData
(
0
,
0
,
20
)
tdSql
.
query
(
"select count(col6) from db.stb"
)
tdSql
.
checkData
(
0
,
0
,
20
)
tdSql
.
query
(
"select count(col7) from stb"
)
tdSql
.
checkData
(
0
,
0
,
20
)
tdSql
.
query
(
"select count(col7) from db.stb"
)
tdSql
.
checkData
(
0
,
0
,
20
)
tdSql
.
query
(
"select count(col8) from stb"
)
tdSql
.
checkData
(
0
,
0
,
20
)
tdSql
.
query
(
"select count(col8) from db.stb"
)
tdSql
.
checkData
(
0
,
0
,
20
)
tdSql
.
query
(
"select count(col9) from stb"
)
tdSql
.
checkData
(
0
,
0
,
20
)
tdSql
.
query
(
"select count(col9) from db.stb"
)
tdSql
.
checkData
(
0
,
0
,
20
)
tdSql
.
query
(
"select count(col11) from stb"
)
tdSql
.
checkData
(
0
,
0
,
20
)
tdSql
.
query
(
"select count(col11) from db.stb"
)
tdSql
.
checkData
(
0
,
0
,
20
)
tdSql
.
query
(
"select count(col12) from stb"
)
tdSql
.
checkData
(
0
,
0
,
20
)
tdSql
.
query
(
"select count(col12) from db.stb"
)
tdSql
.
checkData
(
0
,
0
,
20
)
tdSql
.
query
(
"select count(col13) from stb"
)
tdSql
.
checkData
(
0
,
0
,
20
)
tdSql
.
query
(
"select count(col13) from db.stb"
)
tdSql
.
checkData
(
0
,
0
,
20
)
tdSql
.
query
(
"select count(col14) from stb"
)
tdSql
.
checkData
(
0
,
0
,
20
)
tdSql
.
query
(
"select count(col14) from db.stb"
)
tdSql
.
checkData
(
0
,
0
,
20
)
tdSql
.
query
(
"select count(ts) from db.stb_1"
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select count(ts) from db.stb_1"
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select count(col1) from stb_1"
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select count(col1) from db.stb_1"
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select count(col2) from stb_1"
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select count(col2) from db.stb_1"
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select count(col3) from stb_1"
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select count(col3) from db.stb_1"
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select count(col4) from stb_1"
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select count(col4) from db.stb_1"
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select count(col5) from stb_1"
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select count(col5) from db.stb_1"
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select count(col6) from stb_1"
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select count(col6) from db.stb_1"
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select count(col7) from stb_1"
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select count(col7) from db.stb_1"
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select count(col8) from stb_1"
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select count(col8) from db.stb_1"
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select count(col9) from stb_1"
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select count(col9) from db.stb_1"
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select count(col11) from stb_1"
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select count(col11) from db.stb_1"
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select count(col12) from stb_1"
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select count(col12) from db.stb_1"
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select count(col13) from stb_1"
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select count(col13) from db.stb_1"
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select count(col14) from stb_1"
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select count(col14) from db.stb_1"
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select count(col1) from stb_1 group by col7"
)
tdSql
.
checkRows
(
2
)
tdSql
.
execute
(
"insert into stb_1 values(now,null,null,null,null,null,null,null,null,null,null,null,null,null)"
)
tdSql
.
query
(
"select count(col1) from stb_1"
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select count(col1),count(ts) from stb_1"
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
checkData
(
0
,
1
,
11
)
tdSql
.
query
(
"select count(col1) from db.stb_1"
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select count(col1),count(ts) from db.stb_1"
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
checkData
(
0
,
1
,
11
)
tdSql
.
query
(
"select count(col1) from stb"
)
tdSql
.
checkData
(
0
,
0
,
20
)
tdSql
.
query
(
"select count(col1),count(ts) from stb"
)
tdSql
.
checkData
(
0
,
0
,
20
)
tdSql
.
checkData
(
0
,
1
,
21
)
tdSql
.
query
(
"select count(col1) from db.stb"
)
tdSql
.
checkData
(
0
,
0
,
20
)
tdSql
.
query
(
"select count(col1),count(ts) from db.stb"
)
tdSql
.
checkData
(
0
,
0
,
20
)
tdSql
.
checkData
(
0
,
1
,
21
)
tdSql
.
query
(
"select count(col1) from stb_1 group by col7"
)
tdSql
.
checkRows
(
3
)
tdSql
.
query
(
"select count(col1) from stb_2 group by col7"
)
tdSql
.
checkRows
(
2
)
tdSql
.
query
(
"select count(col1) from stb group by col7"
)
tdSql
.
checkRows
(
3
)
tdSql
.
execute
(
self
.
setsql
.
set_create_normaltable_sql
(
self
.
ntbname
,
self
.
column_dict
))
tdSql
.
query
(
f
'select count(tbname) from
{
self
.
ntbname
}
'
)
tdSql
.
checkRows
(
0
)
tdSql
.
execute
(
'flush database db'
)
tdSql
.
query
(
f
'select count(tbname) from
{
self
.
ntbname
}
'
)
tdSql
.
checkRows
(
0
)
self
.
insert_data
(
self
.
column_dict
,
self
.
ntbname
,
self
.
rowNum
)
self
.
count_query_ntb
(
self
.
column_dict
,
self
.
ntbname
,
self
.
rowNum
)
tdSql
.
execute
(
'flush database db'
)
self
.
count_query_ntb
(
self
.
column_dict
,
self
.
ntbname
,
self
.
rowNum
)
tdSql
.
execute
(
'drop database db'
)
def
check_stb
(
self
):
tdSql
.
prepare
()
tdSql
.
execute
(
self
.
setsql
.
set_create_stable_sql
(
self
.
stbname
,
self
.
column_dict
,
self
.
tag_dict
))
for
i
in
range
(
self
.
tbnum
):
tdSql
.
execute
(
f
'create table
{
self
.
stbname
}
_
{
i
}
using
{
self
.
stbname
}
tags(
{
self
.
tag_values
[
i
]
}
)'
)
#!TODO
# tdSql.query(f'SELECT count(*) from (select distinct tbname from {self.stbname})')
# tdSql.checkEqual(tdSql.queryResult[0][0],self.tbnum)
tdSql
.
query
(
f
'select count(tbname) from
{
self
.
stbname
}
'
)
tdSql
.
checkRows
(
0
)
tdSql
.
execute
(
'flush database db'
)
tdSql
.
query
(
f
'select count(tbname) from
{
self
.
stbname
}
'
)
tdSql
.
checkRows
(
0
)
#!TODO
# tdSql.query(f'SELECT count(*) from (select distinct tbname from {self.stbname})')
# tdSql.checkEqual(tdSql.queryResult[0][0],self.tbnum)
for
i
in
range
(
self
.
tbnum
):
self
.
insert_data
(
self
.
column_dict
,
f
'
{
self
.
stbname
}
_
{
i
}
'
,
self
.
rowNum
)
self
.
count_query_stb
(
self
.
column_dict
,
self
.
tag_dict
,
self
.
stbname
,
self
.
tbnum
,
self
.
rowNum
)
self
.
count_query_ctb
(
self
.
column_dict
,
self
.
tag_dict
,
self
.
stbname
,
self
.
tbnum
,
self
.
rowNum
)
tdSql
.
execute
(
'flush database db'
)
self
.
count_query_stb
(
self
.
column_dict
,
self
.
tag_dict
,
self
.
stbname
,
self
.
tbnum
,
self
.
rowNum
)
self
.
count_query_ctb
(
self
.
column_dict
,
self
.
tag_dict
,
self
.
stbname
,
self
.
tbnum
,
self
.
rowNum
)
tdSql
.
execute
(
'drop database db'
)
def
run
(
self
):
self
.
check_stb
()
self
.
check_ntb
()
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
...
...
tests/system-test/2-query/diff.py
浏览文件 @
d3cdd75b
tests/system-test/2-query/elapsed.py
浏览文件 @
d3cdd75b
tests/system-test/2-query/nestedQuery_str.py
浏览文件 @
d3cdd75b
tests/system-test/2-query/queryQnode.py
浏览文件 @
d3cdd75b
tests/system-test/2-query/unique.py
浏览文件 @
d3cdd75b
tests/system-test/fulltest.sh
浏览文件 @
d3cdd75b
...
...
@@ -11,7 +11,7 @@ python3 ./test.py -f 0-others/udfTest.py
python3 ./test.py
-f
0-others/udf_create.py
python3 ./test.py
-f
0-others/udf_restart_taosd.py
python3 ./test.py
-f
0-others/cachelast.py
python3 ./test.py
-f
0-others/sysinfo.py
python3 ./test.py
-f
0-others/user_control.py
python3 ./test.py
-f
0-others/fsync.py
...
...
@@ -148,7 +148,7 @@ python3 ./test.py -f 7-tmq/subscribeDb2.py
python3 ./test.py
-f
7-tmq/subscribeDb3.py
#python3 ./test.py -f 7-tmq/subscribeDb4.py
python3 ./test.py
-f
7-tmq/subscribeStb.py
python3 ./test.py
-f
7-tmq/subscribeStb0.py
#
python3 ./test.py -f 7-tmq/subscribeStb0.py
python3 ./test.py
-f
7-tmq/subscribeStb1.py
python3 ./test.py
-f
7-tmq/subscribeStb2.py
python3 ./test.py
-f
7-tmq/subscribeStb3.py
...
...
@@ -179,7 +179,7 @@ python3 ./test.py -f 7-tmq/tmqConsFromTsdb1-mutilVg-mutilCtb.py
python3 ./test.py
-f
7-tmq/tmqAutoCreateTbl.py
#python3 ./test.py -f 7-tmq/tmqDnodeRestart.py
#python3 ./test.py -f 7-tmq/tmqUpdate-1ctb.py
#
python3 ./test.py -f 7-tmq/tmqUpdate-multiCtb.py
python3 ./test.py
-f
7-tmq/tmqUpdate-multiCtb.py
#------------querPolicy 2-----------
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录