Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
f249bae8
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
f249bae8
编写于
7月 02, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/3.0' into fix/tsim
上级
b490da0a
06514e13
变更
39
隐藏空白更改
内联
并排
Showing
39 changed file
with
734 addition
and
304 deletion
+734
-304
include/libs/qcom/query.h
include/libs/qcom/query.h
+0
-7
include/util/taoserror.h
include/util/taoserror.h
+1
-0
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+3
-0
source/dnode/mnode/impl/inc/mndDef.h
source/dnode/mnode/impl/inc/mndDef.h
+1
-1
source/dnode/mnode/impl/src/mndDef.c
source/dnode/mnode/impl/src/mndDef.c
+2
-2
source/dnode/mnode/impl/src/mndStream.c
source/dnode/mnode/impl/src/mndStream.c
+2
-1
source/dnode/vnode/CMakeLists.txt
source/dnode/vnode/CMakeLists.txt
+2
-0
source/dnode/vnode/src/inc/sma.h
source/dnode/vnode/src/inc/sma.h
+11
-11
source/dnode/vnode/src/inc/vnodeInt.h
source/dnode/vnode/src/inc/vnodeInt.h
+3
-0
source/dnode/vnode/src/sma/smaCommit.c
source/dnode/vnode/src/sma/smaCommit.c
+150
-0
source/dnode/vnode/src/sma/smaRollup.c
source/dnode/vnode/src/sma/smaRollup.c
+109
-73
source/dnode/vnode/src/sma/smaSnapshot.c
source/dnode/vnode/src/sma/smaSnapshot.c
+16
-0
source/dnode/vnode/src/sma/smaUtil.c
source/dnode/vnode/src/sma/smaUtil.c
+44
-33
source/dnode/vnode/src/tq/tq.c
source/dnode/vnode/src/tq/tq.c
+9
-8
source/dnode/vnode/src/tq/tqRead.c
source/dnode/vnode/src/tq/tqRead.c
+2
-0
source/dnode/vnode/src/vnd/vnodeCfg.c
source/dnode/vnode/src/vnd/vnodeCfg.c
+4
-4
source/dnode/vnode/src/vnd/vnodeCommit.c
source/dnode/vnode/src/vnd/vnodeCommit.c
+6
-0
source/dnode/vnode/src/vnd/vnodeSvr.c
source/dnode/vnode/src/vnd/vnodeSvr.c
+1
-0
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+1
-0
source/libs/executor/src/executor.c
source/libs/executor/src/executor.c
+3
-1
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+20
-17
source/libs/executor/src/scanoperator.c
source/libs/executor/src/scanoperator.c
+1
-0
source/libs/scheduler/inc/schedulerInt.h
source/libs/scheduler/inc/schedulerInt.h
+4
-3
source/libs/scheduler/src/schJob.c
source/libs/scheduler/src/schJob.c
+1
-1
source/libs/scheduler/src/schRemote.c
source/libs/scheduler/src/schRemote.c
+10
-8
source/util/src/terror.c
source/util/src/terror.c
+2
-0
tests/pytest/util/common.py
tests/pytest/util/common.py
+6
-0
tests/script/tsim/tmq/snapshot1.sim
tests/script/tsim/tmq/snapshot1.sim
+1
-1
tests/system-test/1-insert/insertWithMoreVgroup.py
tests/system-test/1-insert/insertWithMoreVgroup.py
+0
-34
tests/system-test/1-insert/test_stmt_insert_query_ex.py
tests/system-test/1-insert/test_stmt_insert_query_ex.py
+24
-24
tests/system-test/1-insert/test_stmt_muti_insert_query.py
tests/system-test/1-insert/test_stmt_muti_insert_query.py
+6
-6
tests/system-test/2-query/queryQnode.py
tests/system-test/2-query/queryQnode.py
+153
-8
tests/system-test/6-cluster/5dnode3mnodeSep1VnodeStopVnodeCreateDb.py
...-test/6-cluster/5dnode3mnodeSep1VnodeStopVnodeCreateDb.py
+2
-26
tests/system-test/6-cluster/clusterCommonCheck.py
tests/system-test/6-cluster/clusterCommonCheck.py
+2
-1
tests/system-test/6-cluster/clusterCommonCreate.py
tests/system-test/6-cluster/clusterCommonCreate.py
+0
-1
tests/system-test/7-tmq/stbFilter.py
tests/system-test/7-tmq/stbFilter.py
+3
-3
tests/system-test/7-tmq/tmqConsFromTsdb.py
tests/system-test/7-tmq/tmqConsFromTsdb.py
+99
-2
tests/system-test/fulltest.sh
tests/system-test/fulltest.sh
+1
-1
tests/test/c/tmqSim.c
tests/test/c/tmqSim.c
+29
-27
未找到文件。
include/libs/qcom/query.h
浏览文件 @
f249bae8
...
...
@@ -249,13 +249,6 @@ extern int32_t (*queryProcessMsgRsp[TDMT_MAX])(void* output, char* msg, int32_t
((_code) == TSDB_CODE_RPC_REDIRECT || (_code) == TSDB_CODE_NODE_NOT_DEPLOYED || \
(_code) == TSDB_CODE_SYN_NOT_LEADER || (_code) == TSDB_CODE_APP_NOT_READY)
#define NEED_SCHEDULER_RETRY_ERROR(_code) \
(NEED_SCHEDULER_REDIRECT_ERROR(_code) || (_code) == TSDB_CODE_RPC_NETWORK_UNAVAIL || \
(_code) == TSDB_CODE_SCH_TIMEOUT_ERROR || (_code) == TSDB_CODE_RPC_BROKEN_LINK)
#define REQUEST_TOTAL_EXEC_TIMES 2
#define qFatal(...) \
...
...
include/util/taoserror.h
浏览文件 @
f249bae8
...
...
@@ -623,6 +623,7 @@ int32_t* taosGetErrno();
#define TSDB_CODE_RSMA_INVALID_ENV TAOS_DEF_ERROR_CODE(0, 0x3150)
#define TSDB_CODE_RSMA_INVALID_STAT TAOS_DEF_ERROR_CODE(0, 0x3151)
#define TSDB_CODE_RSMA_QTASKINFO_CREATE TAOS_DEF_ERROR_CODE(0, 0x3152)
#define TSDB_CODE_RSMA_FILE_CORRUPTED TAOS_DEF_ERROR_CODE(0, 0x3153)
//index
#define TSDB_CODE_INDEX_REBUILDING TAOS_DEF_ERROR_CODE(0, 0x3200)
...
...
source/client/src/clientImpl.c
浏览文件 @
f249bae8
...
...
@@ -786,6 +786,7 @@ int32_t handleQueryExecRsp(SRequestObj* pRequest) {
void
schedulerExecCb
(
SQueryResult
*
pResult
,
void
*
param
,
int32_t
code
)
{
SRequestObj
*
pRequest
=
(
SRequestObj
*
)
param
;
pRequest
->
code
=
code
;
pRequest
->
body
.
resInfo
.
execRes
=
pResult
->
res
;
if
(
TDMT_VND_SUBMIT
==
pRequest
->
type
||
TDMT_VND_DELETE
==
pRequest
->
type
||
TDMT_VND_CREATE_TABLE
==
pRequest
->
type
)
{
...
...
@@ -797,6 +798,8 @@ void schedulerExecCb(SQueryResult* pResult, void* param, int32_t code) {
}
}
taosMemoryFree
(
pResult
);
tscDebug
(
"0x%"
PRIx64
" enter scheduler exec cb, code:%d - %s, reqId:0x%"
PRIx64
,
pRequest
->
self
,
code
,
tstrerror
(
code
),
pRequest
->
requestId
);
...
...
source/dnode/mnode/impl/inc/mndDef.h
浏览文件 @
f249bae8
...
...
@@ -556,7 +556,7 @@ typedef struct {
int64_t
uid
;
int8_t
status
;
// config
int8_t
dropPolicy
;
int8_t
igExpired
;
int8_t
trigger
;
int64_t
triggerParam
;
int64_t
watermark
;
...
...
source/dnode/mnode/impl/src/mndDef.c
浏览文件 @
f249bae8
...
...
@@ -28,7 +28,7 @@ int32_t tEncodeSStreamObj(SEncoder *pEncoder, const SStreamObj *pObj) {
if
(
tEncodeI64
(
pEncoder
,
pObj
->
uid
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pEncoder
,
pObj
->
status
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pEncoder
,
pObj
->
dropPolicy
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pEncoder
,
pObj
->
igExpired
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pEncoder
,
pObj
->
trigger
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
pEncoder
,
pObj
->
triggerParam
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
pEncoder
,
pObj
->
watermark
)
<
0
)
return
-
1
;
...
...
@@ -73,7 +73,7 @@ int32_t tDecodeSStreamObj(SDecoder *pDecoder, SStreamObj *pObj) {
if
(
tDecodeI64
(
pDecoder
,
&
pObj
->
uid
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pDecoder
,
&
pObj
->
status
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pDecoder
,
&
pObj
->
dropPolicy
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pDecoder
,
&
pObj
->
igExpired
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pDecoder
,
&
pObj
->
trigger
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
pDecoder
,
&
pObj
->
triggerParam
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
pDecoder
,
&
pObj
->
watermark
)
<
0
)
return
-
1
;
...
...
source/dnode/mnode/impl/src/mndStream.c
浏览文件 @
f249bae8
...
...
@@ -248,7 +248,7 @@ static int32_t mndBuildStreamObjFromCreateReq(SMnode *pMnode, SStreamObj *pObj,
pObj
->
status
=
0
;
// TODO
pObj
->
dropPolicy
=
0
;
pObj
->
igExpired
=
pCreate
->
igExpired
;
pObj
->
trigger
=
pCreate
->
triggerType
;
pObj
->
triggerParam
=
pCreate
->
maxDelay
;
pObj
->
watermark
=
pCreate
->
watermark
;
...
...
@@ -301,6 +301,7 @@ static int32_t mndBuildStreamObjFromCreateReq(SMnode *pMnode, SStreamObj *pObj,
.
streamQuery
=
true
,
.
triggerType
=
pObj
->
trigger
==
STREAM_TRIGGER_MAX_DELAY
?
STREAM_TRIGGER_WINDOW_CLOSE
:
pObj
->
trigger
,
.
watermark
=
pObj
->
watermark
,
.
igExpired
=
pObj
->
igExpired
,
};
// using ast and param to build physical plan
...
...
source/dnode/vnode/CMakeLists.txt
浏览文件 @
f249bae8
...
...
@@ -31,6 +31,8 @@ target_sources(
"src/sma/smaEnv.c"
"src/sma/smaUtil.c"
"src/sma/smaOpen.c"
"src/sma/smaCommit.c"
"src/sma/smaSnapshot.c"
"src/sma/smaRollup.c"
"src/sma/smaTimeRange.c"
...
...
source/dnode/vnode/src/inc/sma.h
浏览文件 @
f249bae8
...
...
@@ -92,8 +92,9 @@ enum {
TASK_TRIGGER_STAT_INIT
=
0
,
TASK_TRIGGER_STAT_ACTIVE
=
1
,
TASK_TRIGGER_STAT_INACTIVE
=
2
,
TASK_TRIGGER_STAT_CANCELLED
=
3
,
TASK_TRIGGER_STAT_FINISHED
=
4
,
TASK_TRIGGER_STAT_PAUSED
=
3
,
TASK_TRIGGER_STAT_CANCELLED
=
4
,
TASK_TRIGGER_STAT_FINISHED
=
5
,
};
void
tdDestroySmaEnv
(
SSmaEnv
*
pSmaEnv
);
void
*
tdFreeSmaEnv
(
SSmaEnv
*
pSmaEnv
);
...
...
@@ -214,25 +215,22 @@ struct STFInfo {
};
struct
STFile
{
uint8_t
state
;
STFInfo
info
;
STfsFile
f
;
char
*
fname
;
TdFilePtr
pFile
;
uint8_t
state
;
};
#define TD_TFILE_F(tf) (&((tf)->f))
#define TD_TFILE_PFILE(tf) ((tf)->pFile)
#define TD_TFILE_OPENED(tf) (TD_TFILE_PFILE(tf) != NULL)
#define TD_TFILE_FULL_NAME(tf) (TD_TFILE_F(tf)->aname)
#define TD_TFILE_REL_NAME(tf) (TD_TFILE_F(tf)->rname)
#define TD_TFILE_FULL_NAME(tf) ((tf)->fname)
#define TD_TFILE_OPENED(tf) (TD_TFILE_PFILE(tf) != NULL)
#define TD_TFILE_CLOSED(tf) (!TD_TFILE_OPENED(tf))
#define TD_TFILE_SET_CLOSED(f) (TD_TFILE_PFILE(f) = NULL)
#define TD_TFILE_SET_STATE(tf, s) ((tf)->state = (s))
#define TD_TFILE_DID(tf) (TD_TFILE_F(tf)->did)
int32_t
tdInitTFile
(
STFile
*
pTFile
,
STfs
*
pTfs
,
const
char
*
fname
);
int32_t
tdCreateTFile
(
STFile
*
pTFile
,
STfs
*
pTfs
,
bool
updateHeader
,
int8_t
fType
);
int32_t
tdInitTFile
(
STFile
*
pTFile
,
const
char
*
dname
,
const
char
*
fname
);
int32_t
tdCreateTFile
(
STFile
*
pTFile
,
bool
updateHeader
,
int8_t
fType
);
int32_t
tdOpenTFile
(
STFile
*
pTFile
,
int
flags
);
int64_t
tdReadTFile
(
STFile
*
pTFile
,
void
*
buf
,
int64_t
nbyte
);
int64_t
tdSeekTFile
(
STFile
*
pTFile
,
int64_t
offset
,
int
whence
);
...
...
@@ -244,8 +242,10 @@ int32_t tdLoadTFileHeader(STFile *pTFile, STFInfo *pInfo);
int32_t
tdUpdateTFileHeader
(
STFile
*
pTFile
);
void
tdUpdateTFileMagic
(
STFile
*
pTFile
,
void
*
pCksm
);
void
tdCloseTFile
(
STFile
*
pTFile
);
void
tdDestroyTFile
(
STFile
*
pTFile
);
void
tdGetVndFileName
(
int32_t
vgId
,
const
char
*
dname
,
const
char
*
fname
,
char
*
outputName
);
void
tdGetVndFileName
(
int32_t
vgId
,
const
char
*
dname
,
const
char
*
fname
,
int64_t
version
,
char
*
outputName
);
void
tdGetVndDirName
(
int32_t
vgId
,
const
char
*
dname
,
char
*
outputName
);
#ifdef __cplusplus
}
...
...
source/dnode/vnode/src/inc/vnodeInt.h
浏览文件 @
f249bae8
...
...
@@ -165,6 +165,9 @@ SSubmitReq* tdBlockToSubmit(const SArray* pBlocks, const STSchema* pSchema, bool
int32_t
smaOpen
(
SVnode
*
pVnode
);
int32_t
smaCloseEnv
(
SSma
*
pSma
);
int32_t
smaCloseEx
(
SSma
*
pSma
);
int32_t
smaPreCommit
(
SSma
*
pSma
);
int32_t
smaCommit
(
SSma
*
pSma
);
int32_t
smaPostCommit
(
SSma
*
pSma
);
int32_t
tdProcessTSmaCreate
(
SSma
*
pSma
,
int64_t
version
,
const
char
*
msg
);
int32_t
tdProcessTSmaInsert
(
SSma
*
pSma
,
int64_t
indexUid
,
const
char
*
msg
);
...
...
source/dnode/vnode/src/sma/smaCommit.c
0 → 100644
浏览文件 @
f249bae8
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "sma.h"
static
int32_t
tdProcessRSmaPreCommitImpl
(
SSma
*
pSma
);
static
int32_t
tdProcessRSmaCommitImpl
(
SSma
*
pSma
);
static
int32_t
tdProcessRSmaPostCommitImpl
(
SSma
*
pSma
);
/**
* @brief Only applicable to Rollup SMA
*
* @param pSma
* @return int32_t
*/
int32_t
smaPreCommit
(
SSma
*
pSma
)
{
return
tdProcessRSmaPreCommitImpl
(
pSma
);
}
/**
* @brief Only applicable to Rollup SMA
*
* @param pSma
* @return int32_t
*/
int32_t
smaCommit
(
SSma
*
pSma
)
{
return
tdProcessRSmaCommitImpl
(
pSma
);
}
/**
* @brief Only applicable to Rollup SMA
*
* @param pSma
* @return int32_t
*/
int32_t
smaPostCommit
(
SSma
*
pSma
)
{
return
tdProcessRSmaPostCommitImpl
(
pSma
);
}
/**
* @brief pre-commit for rollup sma.
* 1) set trigger stat of rsma timer TASK_TRIGGER_STAT_PAUSED.
* 2) perform persist task for qTaskInfo
* 3) wait all triggered fetch tasks finished
* 4) set trigger stat of rsma timer TASK_TRIGGER_STAT_ACTIVE.
* 5) finish
*
* @param pSma
* @return int32_t
*/
static
int32_t
tdProcessRSmaPreCommitImpl
(
SSma
*
pSma
)
{
SSmaEnv
*
pSmaEnv
=
SMA_RSMA_ENV
(
pSma
);
if
(
!
pSmaEnv
)
{
return
TSDB_CODE_SUCCESS
;
}
SSmaStat
*
pStat
=
SMA_ENV_STAT
(
pSmaEnv
);
SRSmaStat
*
pRSmaStat
=
SMA_RSMA_STAT
(
pStat
);
// step 1
atomic_store_8
(
RSMA_TRIGGER_STAT
(
pRSmaStat
),
TASK_TRIGGER_STAT_PAUSED
);
// step 2
return
TSDB_CODE_SUCCESS
;
}
/**
* @brief commit for rollup sma
*
* @param pSma
* @return int32_t
*/
static
int32_t
tdProcessRSmaCommitImpl
(
SSma
*
pSma
)
{
SSmaEnv
*
pSmaEnv
=
SMA_RSMA_ENV
(
pSma
);
if
(
!
pSmaEnv
)
{
return
TSDB_CODE_SUCCESS
;
}
return
TSDB_CODE_SUCCESS
;
}
/**
* @brief post-commit for rollup sma
* 1) clean up the outdated qtaskinfo files
*
* @param pSma
* @return int32_t
*/
static
int32_t
tdProcessRSmaPostCommitImpl
(
SSma
*
pSma
)
{
SVnode
*
pVnode
=
pSma
->
pVnode
;
if
(
!
VND_IS_RSMA
(
pVnode
))
{
return
TSDB_CODE_SUCCESS
;
}
int64_t
committed
=
pVnode
->
state
.
committed
;
TdDirPtr
pDir
=
NULL
;
TdDirEntryPtr
pDirEntry
=
NULL
;
char
dir
[
TSDB_FILENAME_LEN
];
char
bname
[
TSDB_FILENAME_LEN
];
const
char
*
pattern
=
"^v[0-9]+qtaskinfo
\\
.ver([0-9]+)?$"
;
regex_t
regex
;
tdGetVndDirName
(
TD_VID
(
pVnode
),
VNODE_RSMA_DIR
,
dir
);
// Resource allocation and init
regcomp
(
&
regex
,
pattern
,
REG_EXTENDED
);
if
((
pDir
=
taosOpenDir
(
dir
))
==
NULL
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
smaWarn
(
"rsma post-commit open dir %s failed since %s"
,
dir
,
terrstr
());
return
TSDB_CODE_FAILED
;
}
regmatch_t
regMatch
[
2
];
while
((
pDirEntry
=
taosReadDir
(
pDir
))
!=
NULL
)
{
char
*
entryName
=
taosGetDirEntryName
(
pDirEntry
);
if
(
!
entryName
)
{
continue
;
}
char
*
fileName
=
taosDirEntryBaseName
(
entryName
);
int
code
=
regexec
(
&
regex
,
bname
,
2
,
regMatch
,
0
);
if
(
code
==
0
)
{
// match
printf
(
"match 0 = %s
\n
"
,
(
char
*
)
POINTER_SHIFT
(
fileName
,
regMatch
[
0
].
rm_so
));
printf
(
"match 1 = %s
\n
"
,
(
char
*
)
POINTER_SHIFT
(
fileName
,
regMatch
[
1
].
rm_so
));
}
else
if
(
code
==
REG_NOMATCH
)
{
// not match
smaInfo
(
"rsma post-commit not match %s"
,
fileName
);
continue
;
}
else
{
// has other error
terrno
=
TAOS_SYSTEM_ERROR
(
code
);
smaWarn
(
"rsma post-commit regexec failed since %s"
,
terrstr
());
taosCloseDir
(
&
pDir
);
regfree
(
&
regex
);
return
TSDB_CODE_FAILED
;
}
}
taosCloseDir
(
&
pDir
);
return
TSDB_CODE_SUCCESS
;
}
source/dnode/vnode/src/sma/smaRollup.c
浏览文件 @
f249bae8
...
...
@@ -23,8 +23,7 @@ SSmaMgmt smaMgmt = {
.
smaRef
=
-
1
,
};
typedef
enum
{
TD_QTASK_TMP_F
=
0
,
TD_QTASK_CUR_F
}
TD_QTASK_FILE_T
;
static
const
char
*
tdQTaskInfoFname
[]
=
{
"qtaskinfo.t"
,
"qtaskinfo"
};
#define TD_QTASKINFO_FNAME_PREFIX "qtaskinfo.ver"
typedef
struct
SRSmaQTaskInfoItem
SRSmaQTaskInfoItem
;
typedef
struct
SRSmaQTaskInfoIter
SRSmaQTaskInfoIter
;
...
...
@@ -37,7 +36,7 @@ static int32_t tdExecuteRSmaImpl(SSma *pSma, const void *pMsg, int32_t inputType
static
void
tdRSmaFetchTrigger
(
void
*
param
,
void
*
tmrId
);
static
void
tdRSmaPersistTrigger
(
void
*
param
,
void
*
tmrId
);
static
void
*
tdRSmaPersistExec
(
void
*
param
);
static
void
tdRSmaQTaskInfoGetFName
(
int32_t
vid
,
int
8_t
ftype
,
char
*
outputName
);
static
void
tdRSmaQTaskInfoGetFName
(
int32_t
vid
,
int
64_t
version
,
char
*
outputName
);
static
int32_t
tdRSmaQTaskInfoIterInit
(
SRSmaQTaskInfoIter
*
pIter
,
STFile
*
pTFile
);
static
int32_t
tdRSmaQTaskInfoIterNextBlock
(
SRSmaQTaskInfoIter
*
pIter
,
bool
*
isFinish
);
...
...
@@ -88,8 +87,8 @@ struct SRSmaQTaskInfoIter {
int32_t
nBufPos
;
};
static
void
tdRSmaQTaskInfoGetFName
(
int32_t
vgId
,
int
8_t
ftype
,
char
*
outputName
)
{
tdGetVndFileName
(
vgId
,
VNODE_RSMA_DIR
,
tdQTaskInfoFname
[
ftype
]
,
outputName
);
static
void
tdRSmaQTaskInfoGetFName
(
int32_t
vgId
,
int
64_t
version
,
char
*
outputName
)
{
tdGetVndFileName
(
vgId
,
VNODE_RSMA_DIR
,
TD_QTASKINFO_FNAME_PREFIX
,
version
,
outputName
);
}
static
FORCE_INLINE
int32_t
tdRSmaQTaskInfoContLen
(
int32_t
lenWithHead
)
{
...
...
@@ -493,7 +492,6 @@ static int32_t tdProcessSubmitReq(STsdb *pTsdb, int64_t version, void *pReq) {
}
static
int32_t
tdFetchSubmitReqSuids
(
SSubmitReq
*
pMsg
,
STbUidStore
*
pStore
)
{
ASSERT
(
pMsg
!=
NULL
);
SSubmitMsgIter
msgIter
=
{
0
};
SSubmitBlk
*
pBlock
=
NULL
;
SSubmitBlkIter
blkIter
=
{
0
};
...
...
@@ -501,19 +499,26 @@ static int32_t tdFetchSubmitReqSuids(SSubmitReq *pMsg, STbUidStore *pStore) {
terrno
=
TSDB_CODE_SUCCESS
;
if
(
tInitSubmitMsgIter
(
pMsg
,
&
msgIter
)
<
0
)
return
-
1
;
if
(
tInitSubmitMsgIter
(
pMsg
,
&
msgIter
)
<
0
)
{
return
-
1
;
}
while
(
true
)
{
if
(
tGetSubmitMsgNext
(
&
msgIter
,
&
pBlock
)
<
0
)
return
-
1
;
if
(
tGetSubmitMsgNext
(
&
msgIter
,
&
pBlock
)
<
0
)
{
return
-
1
;
}
if
(
!
pBlock
)
break
;
tdUidStorePut
(
pStore
,
msgIter
.
suid
,
NULL
);
}
if
(
terrno
!=
TSDB_CODE_SUCCESS
)
return
-
1
;
if
(
terrno
!=
TSDB_CODE_SUCCESS
)
{
return
-
1
;
}
return
0
;
}
static
void
tdDestroySDataBlockArray
(
SArray
*
pArray
)
{
// TODO
#if 0
for (int32_t i = 0; i < taosArrayGetSize(pArray); ++i) {
SSDataBlock *pDataBlock = taosArrayGet(pArray, i);
...
...
@@ -598,33 +603,54 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) {
pSma
=
RSMA_INFO_SMA
(
pItem
->
pRsmaInfo
);
// if rsma trigger stat in
cancelled or finished, not start fetch task anymore
// if rsma trigger stat in
paused, cancelled or finished, not start fetch task
int8_t
rsmaTriggerStat
=
atomic_load_8
(
RSMA_TRIGGER_STAT
(
pStat
));
if
(
rsmaTriggerStat
==
TASK_TRIGGER_STAT_CANCELLED
||
rsmaTriggerStat
==
TASK_TRIGGER_STAT_FINISHED
)
{
taosReleaseRef
(
smaMgmt
.
smaRef
,
pItem
->
refId
);
smaDebug
(
"vgId:%d, not fetch rsma level %"
PRIi8
" data for table:%"
PRIi64
" since stat is cancelled"
,
SMA_VID
(
pSma
),
pItem
->
level
,
pItem
->
pRsmaInfo
->
suid
);
return
;
switch
(
rsmaTriggerStat
)
{
case
TASK_TRIGGER_STAT_PAUSED
:
case
TASK_TRIGGER_STAT_CANCELLED
:
case
TASK_TRIGGER_STAT_FINISHED
:
{
taosReleaseRef
(
smaMgmt
.
smaRef
,
pItem
->
refId
);
smaDebug
(
"vgId:%d, not fetch rsma level %"
PRIi8
" data for table:%"
PRIi64
" since stat is cancelled"
,
SMA_VID
(
pSma
),
pItem
->
level
,
pItem
->
pRsmaInfo
->
suid
);
return
;
}
default:
break
;
}
int8_t
fetchTriggerStat
=
atomic_val_compare_exchange_8
(
&
pItem
->
triggerStat
,
TASK_TRIGGER_STAT_ACTIVE
,
TASK_TRIGGER_STAT_INACTIVE
);
if
(
fetchTriggerStat
==
TASK_TRIGGER_STAT_ACTIVE
)
{
smaDebug
(
"vgId:%d, fetch rsma level %"
PRIi8
" data for table:%"
PRIi64
" since stat is active"
,
SMA_VID
(
pSma
),
pItem
->
level
,
pItem
->
pRsmaInfo
->
suid
);
tdRefSmaStat
(
pSma
,
(
SSmaStat
*
)
pStat
);
switch
(
fetchTriggerStat
)
{
case
TASK_TRIGGER_STAT_ACTIVE
:
{
smaDebug
(
"vgId:%d, fetch rsma level %"
PRIi8
" data for table:%"
PRIi64
" since stat is active"
,
SMA_VID
(
pSma
),
pItem
->
level
,
pItem
->
pRsmaInfo
->
suid
);
SSDataBlock
dataBlock
=
{.
info
.
type
=
STREAM_GET_ALL
};
qSetStreamInput
(
pItem
->
taskInfo
,
&
dataBlock
,
STREAM_INPUT__DATA_BLOCK
,
false
);
tdFetchAndSubmitRSmaResult
(
pItem
,
STREAM_INPUT__DATA_BLOCK
);
tdRefSmaStat
(
pSma
,
(
SSmaStat
*
)
pStat
);
tdUnRefSmaStat
(
pSma
,
(
SSmaStat
*
)
pStat
);
SSDataBlock
dataBlock
=
{.
info
.
type
=
STREAM_GET_ALL
};
qSetStreamInput
(
pItem
->
taskInfo
,
&
dataBlock
,
STREAM_INPUT__DATA_BLOCK
,
false
);
tdFetchAndSubmitRSmaResult
(
pItem
,
STREAM_INPUT__DATA_BLOCK
);
}
else
{
smaDebug
(
"vgId:%d, not fetch rsma level %"
PRIi8
" data for table:%"
PRIi64
" since stat is inactive"
,
SMA_VID
(
pSma
),
pItem
->
level
,
pItem
->
pRsmaInfo
->
suid
);
tdUnRefSmaStat
(
pSma
,
(
SSmaStat
*
)
pStat
);
}
break
;
case
TASK_TRIGGER_STAT_PAUSED
:
{
smaDebug
(
"vgId:%d, not fetch rsma level %"
PRIi8
" data for table:%"
PRIi64
" since stat is paused"
,
SMA_VID
(
pSma
),
pItem
->
level
,
pItem
->
pRsmaInfo
->
suid
);
}
break
;
case
TASK_TRIGGER_STAT_INACTIVE
:
{
smaDebug
(
"vgId:%d, not fetch rsma level %"
PRIi8
" data for table:%"
PRIi64
" since stat is inactive"
,
SMA_VID
(
pSma
),
pItem
->
level
,
pItem
->
pRsmaInfo
->
suid
);
}
break
;
case
TASK_TRIGGER_STAT_INIT
:
{
smaDebug
(
"vgId:%d, not fetch rsma level %"
PRIi8
" data for table:%"
PRIi64
" since stat is init"
,
SMA_VID
(
pSma
),
pItem
->
level
,
pItem
->
pRsmaInfo
->
suid
);
}
break
;
default:
{
smaWarn
(
"vgId:%d, not fetch rsma level %"
PRIi8
" data for table:%"
PRIi64
" since stat is unknown"
,
SMA_VID
(
pSma
),
pItem
->
level
,
pItem
->
pRsmaInfo
->
suid
);
}
break
;
}
_end:
taosReleaseRef
(
smaMgmt
.
smaRef
,
pItem
->
refId
);
}
...
...
@@ -780,10 +806,10 @@ _err:
static
int32_t
tdRSmaRestoreQTaskInfoReload
(
SSma
*
pSma
)
{
SVnode
*
pVnode
=
pSma
->
pVnode
;
STFile
tFile
=
{
0
};
char
qTaskInfoFName
[
TSDB_FILENAME_LEN
];
char
qTaskInfoFName
[
TSDB_FILENAME_LEN
]
=
{
0
}
;
tdRSmaQTaskInfoGetFName
(
TD_VID
(
pVnode
),
TD_QTASK_TMP_F
,
qTaskInfoFName
);
if
(
tdInitTFile
(
&
tFile
,
pVnode
->
pTfs
,
qTaskInfoFName
)
<
0
)
{
tdRSmaQTaskInfoGetFName
(
TD_VID
(
pVnode
),
pVnode
->
state
.
committed
,
qTaskInfoFName
);
if
(
tdInitTFile
(
&
tFile
,
tfsGetPrimaryPath
(
pVnode
->
pTfs
)
,
qTaskInfoFName
)
<
0
)
{
goto
_err
;
}
...
...
@@ -799,17 +825,20 @@ static int32_t tdRSmaRestoreQTaskInfoReload(SSma *pSma) {
if
(
tdRSmaQTaskInfoIterInit
(
&
fIter
,
&
tFile
)
<
0
)
{
tdRSmaQTaskInfoIterDestroy
(
&
fIter
);
tdCloseTFile
(
&
tFile
);
tdDestroyTFile
(
&
tFile
);
goto
_err
;
}
if
(
tdRSmaQTaskInfoRestore
(
pSma
,
&
fIter
)
<
0
)
{
tdRSmaQTaskInfoIterDestroy
(
&
fIter
);
tdCloseTFile
(
&
tFile
);
tdDestroyTFile
(
&
tFile
);
goto
_err
;
}
tdRSmaQTaskInfoIterDestroy
(
&
fIter
);
tdCloseTFile
(
&
tFile
);
tdDestroyTFile
(
&
tFile
);
return
TSDB_CODE_SUCCESS
;
_err:
smaError
(
"rsma restore, qtaskinfo reload failed since %s"
,
terrstr
());
...
...
@@ -931,19 +960,21 @@ static int32_t tdRSmaQTaskInfoIterNextBlock(SRSmaQTaskInfoIter *pIter, bool *isF
}
if
(
tdSeekTFile
(
pTFile
,
pIter
->
offset
,
SEEK_SET
)
<
0
)
{
ASSERT
(
0
);
return
TSDB_CODE_FAILED
;
}
if
(
tdReadTFile
(
pTFile
,
pIter
->
qBuf
,
nBytes
)
!=
nBytes
)
{
ASSERT
(
0
);
return
TSDB_CODE_FAILED
;
}
int32_t
infoLen
=
0
;
taosDecodeFixedI32
(
pIter
->
qBuf
,
&
infoLen
);
if
(
infoLen
>
nBytes
)
{
ASSERT
(
infoLen
>
RSMA_QTASKINFO_BUFSIZE
);
if
(
infoLen
<=
RSMA_QTASKINFO_BUFSIZE
)
{
terrno
=
TSDB_CODE_RSMA_FILE_CORRUPTED
;
smaError
(
"iterate rsma qtaskinfo file %s failed since %s"
,
TD_TFILE_FULL_NAME
(
pIter
->
pTFile
),
terrstr
());
return
TSDB_CODE_FAILED
;
}
pIter
->
nAlloc
=
infoLen
;
void
*
pBuf
=
taosMemoryRealloc
(
pIter
->
pBuf
,
infoLen
);
if
(
!
pBuf
)
{
...
...
@@ -955,12 +986,10 @@ static int32_t tdRSmaQTaskInfoIterNextBlock(SRSmaQTaskInfoIter *pIter, bool *isF
nBytes
=
infoLen
;
if
(
tdSeekTFile
(
pTFile
,
pIter
->
offset
,
SEEK_SET
))
{
ASSERT
(
0
);
return
TSDB_CODE_FAILED
;
}
if
(
tdReadTFile
(
pTFile
,
pIter
->
pBuf
,
nBytes
)
!=
nBytes
)
{
ASSERT
(
0
);
return
TSDB_CODE_FAILED
;
}
}
...
...
@@ -977,7 +1006,6 @@ static int32_t tdRSmaQTaskInfoRestore(SSma *pSma, SRSmaQTaskInfoIter *pIter) {
// block iter
bool
isFinish
=
false
;
if
(
tdRSmaQTaskInfoIterNextBlock
(
pIter
,
&
isFinish
)
<
0
)
{
ASSERT
(
0
);
return
TSDB_CODE_FAILED
;
}
if
(
isFinish
)
{
...
...
@@ -989,6 +1017,7 @@ static int32_t tdRSmaQTaskInfoRestore(SSma *pSma, SRSmaQTaskInfoIter *pIter) {
pIter
->
qBuf
=
taosDecodeFixedI32
(
pIter
->
qBuf
,
&
qTaskInfoLenWithHead
);
if
(
qTaskInfoLenWithHead
<
RSMA_QTASKINFO_HEAD_LEN
)
{
terrno
=
TSDB_CODE_TDB_FILE_CORRUPTED
;
smaError
(
"restore rsma qtaskinfo file %s failed since %s"
,
TD_TFILE_FULL_NAME
(
pIter
->
pTFile
),
terrstr
());
return
TSDB_CODE_FAILED
;
}
...
...
@@ -1025,22 +1054,16 @@ static int32_t tdRSmaQTaskInfoRestore(SSma *pSma, SRSmaQTaskInfoIter *pIter) {
return
TSDB_CODE_SUCCESS
;
}
static
void
*
tdRSmaPersistExec
(
void
*
param
)
{
setThreadName
(
"rsma-task-persist"
);
SRSmaStat
*
pRSmaStat
=
param
;
SSma
*
pSma
=
pRSmaStat
->
pSma
;
STfs
*
pTfs
=
pSma
->
pVnode
->
pTfs
;
int32_t
vid
=
SMA_VID
(
pSma
);
int64_t
toffset
=
0
;
bool
isFileCreated
=
false
;
if
(
TASK_TRIGGER_STAT_CANCELLED
==
atomic_load_8
(
RSMA_TRIGGER_STAT
(
pRSmaStat
)))
{
goto
_end
;
}
static
int32_t
tdRSmaPersistExecImpl
(
SRSmaStat
*
pRSmaStat
)
{
SSma
*
pSma
=
pRSmaStat
->
pSma
;
SVnode
*
pVnode
=
pSma
->
pVnode
;
int32_t
vid
=
SMA_VID
(
pSma
);
int64_t
toffset
=
0
;
bool
isFileCreated
=
false
;
void
*
infoHash
=
taosHashIterate
(
RSMA_INFO_HASH
(
pRSmaStat
),
NULL
);
if
(
!
infoHash
)
{
goto
_end
;
return
TSDB_CODE_SUCCESS
;
}
STFile
tFile
=
{
0
};
...
...
@@ -1074,9 +1097,13 @@ static void *tdRSmaPersistExec(void *param) {
if
(
!
isFileCreated
)
{
char
qTaskInfoFName
[
TSDB_FILENAME_LEN
];
tdRSmaQTaskInfoGetFName
(
vid
,
TD_QTASK_TMP_F
,
qTaskInfoFName
);
tdInitTFile
(
&
tFile
,
pTfs
,
qTaskInfoFName
);
tdCreateTFile
(
&
tFile
,
pTfs
,
true
,
-
1
);
tdRSmaQTaskInfoGetFName
(
vid
,
pSma
->
pVnode
->
state
.
applied
,
qTaskInfoFName
);
if
(
tdInitTFile
(
&
tFile
,
tfsGetPrimaryPath
(
pVnode
->
pTfs
),
qTaskInfoFName
)
<
0
)
{
goto
_err
;
}
if
(
tdCreateTFile
(
&
tFile
,
true
,
-
1
)
<
0
)
{
goto
_err
;
}
isFileCreated
=
true
;
}
...
...
@@ -1101,49 +1128,55 @@ static void *tdRSmaPersistExec(void *param) {
infoHash
=
taosHashIterate
(
RSMA_INFO_HASH
(
pRSmaStat
),
infoHash
);
}
_normal:
if
(
isFileCreated
)
{
if
(
tdUpdateTFileHeader
(
&
tFile
)
<
0
)
{
smaError
(
"vgId:%d, rsma, failed to update tfile %s header since %s"
,
vid
,
TD_TFILE_FULL_NAME
(
&
tFile
),
tstrerror
(
terrno
));
tdCloseTFile
(
&
tFile
);
tdRemoveTFile
(
&
tFile
);
goto
_err
;
}
else
{
smaDebug
(
"vgId:%d, rsma, succeed to update tfile %s header"
,
vid
,
TD_TFILE_FULL_NAME
(
&
tFile
));
}
tdCloseTFile
(
&
tFile
);
char
newFName
[
TSDB_FILENAME_LEN
];
strncpy
(
newFName
,
TD_TFILE_FULL_NAME
(
&
tFile
),
TSDB_FILENAME_LEN
);
char
*
pos
=
strstr
(
newFName
,
tdQTaskInfoFname
[
TD_QTASK_TMP_F
]);
strncpy
(
pos
,
tdQTaskInfoFname
[
TD_QTASK_TMP_F
],
TSDB_FILENAME_LEN
-
POINTER_DISTANCE
(
pos
,
newFName
));
if
(
taosRenameFile
(
TD_TFILE_FULL_NAME
(
&
tFile
),
newFName
)
!=
0
)
{
smaError
(
"vgId:%d, rsma, failed to rename %s to %s"
,
vid
,
TD_TFILE_FULL_NAME
(
&
tFile
),
newFName
);
goto
_err
;
}
else
{
smaDebug
(
"vgId:%d, rsma, succeed to rename %s to %s"
,
vid
,
TD_TFILE_FULL_NAME
(
&
tFile
),
newFName
);
}
tdDestroyTFile
(
&
tFile
);
}
goto
_end
;
return
TSDB_CODE_SUCCESS
;
_err:
if
(
isFileCreated
)
{
tdRemoveTFile
(
&
tFile
);
tdDestroyTFile
(
&
tFile
);
}
return
TSDB_CODE_FAILED
;
}
static
void
*
tdRSmaPersistExec
(
void
*
param
)
{
setThreadName
(
"rsma-task-persist"
);
SRSmaStat
*
pRSmaStat
=
param
;
SSma
*
pSma
=
pRSmaStat
->
pSma
;
int8_t
triggerStat
=
atomic_load_8
(
RSMA_TRIGGER_STAT
(
pRSmaStat
));
if
(
TASK_TRIGGER_STAT_CANCELLED
==
triggerStat
||
TASK_TRIGGER_STAT_PAUSED
==
triggerStat
)
{
goto
_end
;
}
// execution
tdRSmaPersistExecImpl
(
pRSmaStat
);
_end:
if
(
TASK_TRIGGER_STAT_INACTIVE
==
atomic_val_compare_exchange_8
(
RSMA_TRIGGER_STAT
(
pRSmaStat
),
TASK_TRIGGER_STAT_INACTIVE
,
TASK_TRIGGER_STAT_ACTIVE
))
{
smaDebug
(
"vgId:%d, rsma persist task is active again"
,
vid
);
smaDebug
(
"vgId:%d, rsma persist task is active again"
,
SMA_VID
(
pSma
)
);
}
else
if
(
TASK_TRIGGER_STAT_CANCELLED
==
atomic_val_compare_exchange_8
(
RSMA_TRIGGER_STAT
(
pRSmaStat
),
TASK_TRIGGER_STAT_CANCELLED
,
TASK_TRIGGER_STAT_FINISHED
))
{
smaDebug
(
"vgId:%d, rsma persist task is cancelled"
,
vid
);
smaDebug
(
"vgId:%d, rsma persist task is cancelled"
,
SMA_VID
(
pSma
)
);
}
else
{
smaWarn
(
"vgId:%d, rsma persist task in abnormal stat %"
PRIi8
,
vid
,
atomic_load_8
(
RSMA_TRIGGER_STAT
(
pRSmaStat
)));
ASSERT
(
0
);
smaWarn
(
"vgId:%d, rsma persist task in stat %"
PRIi8
,
SMA_VID
(
pSma
),
atomic_load_8
(
RSMA_TRIGGER_STAT
(
pRSmaStat
)));
}
atomic_store_8
(
RSMA_RUNNING_STAT
(
pRSmaStat
),
0
);
taosReleaseRef
(
smaMgmt
.
smaRef
,
pRSmaStat
->
refId
);
taosThreadExit
(
NULL
);
...
...
@@ -1166,8 +1199,8 @@ static void tdRSmaPersistTask(SRSmaStat *pRSmaStat) {
TASK_TRIGGER_STAT_FINISHED
))
{
smaDebug
(
"vgId:%d, persist task is cancelled and set finished"
,
SMA_VID
(
pRSmaStat
->
pSma
));
}
else
{
smaWarn
(
"vgId:%d, persist task in abnormal stat %"
PRIi8
,
atomic_load_8
(
RSMA_TRIGGER_STAT
(
pRSmaStat
)
),
SMA_VID
(
pRSmaStat
->
pSma
));
smaWarn
(
"vgId:%d, persist task in abnormal stat %"
PRIi8
,
SMA_VID
(
pRSmaStat
->
pSma
),
atomic_load_8
(
RSMA_TRIGGER_STAT
(
pRSmaStat
)
));
ASSERT
(
0
);
}
atomic_store_8
(
RSMA_RUNNING_STAT
(
pRSmaStat
),
0
);
...
...
@@ -1216,6 +1249,9 @@ static void tdRSmaPersistTrigger(void *param, void *tmrId) {
atomic_store_8
(
RSMA_TRIGGER_STAT
(
pRSmaStat
),
TASK_TRIGGER_STAT_FINISHED
);
smaDebug
(
"rsma persistence not start since cancelled and finished"
);
}
break
;
case
TASK_TRIGGER_STAT_PAUSED
:
{
smaDebug
(
"rsma persistence not start since paused"
);
}
break
;
case
TASK_TRIGGER_STAT_INACTIVE
:
{
smaDebug
(
"rsma persistence not start since inactive"
);
}
break
;
...
...
source/dnode/vnode/src/sma/smaSnapshot.c
0 → 100644
浏览文件 @
f249bae8
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "sma.h"
\ No newline at end of file
source/dnode/vnode/src/sma/smaUtil.c
浏览文件 @
f249bae8
...
...
@@ -179,72 +179,83 @@ void tdCloseTFile(STFile *pTFile) {
}
}
void
tdGetVndFileName
(
int32_t
vgId
,
const
char
*
dname
,
const
char
*
fname
,
char
*
outputName
)
{
snprintf
(
outputName
,
TSDB_FILENAME_LEN
,
"vnode/vnode%d/%s/%s"
,
vgId
,
dname
,
fname
);
void
tdDestroyTFile
(
STFile
*
pTFile
)
{
taosMemoryFreeClear
(
TD_TFILE_FULL_NAME
(
pTFile
));
}
void
tdGetVndFileName
(
int32_t
vgId
,
const
char
*
dname
,
const
char
*
fname
,
int64_t
version
,
char
*
outputName
)
{
if
(
version
<
0
)
{
snprintf
(
outputName
,
TSDB_FILENAME_LEN
,
"vnode/vnode%d/%s/v%d%s"
,
vgId
,
dname
,
vgId
,
fname
);
}
else
{
snprintf
(
outputName
,
TSDB_FILENAME_LEN
,
"vnode/vnode%d/%s/v%d%s%"
PRIi64
,
vgId
,
dname
,
vgId
,
fname
,
version
);
}
}
int32_t
tdInitTFile
(
STFile
*
pTFile
,
STfs
*
pTfs
,
const
char
*
fn
ame
)
{
char
fullname
[
TSDB_FILENAME_LEN
]
;
SDiskID
did
=
{
0
};
void
tdGetVndDirName
(
int32_t
vgId
,
const
char
*
dname
,
char
*
outputN
ame
)
{
snprintf
(
outputName
,
TSDB_FILENAME_LEN
,
"vnode/vnode%d/%s"
,
vgId
,
dname
)
;
}
int32_t
tdInitTFile
(
STFile
*
pTFile
,
const
char
*
dname
,
const
char
*
fname
)
{
TD_TFILE_SET_STATE
(
pTFile
,
TD_FILE_STATE_OK
);
TD_TFILE_SET_CLOSED
(
pTFile
);
memset
(
&
(
pTFile
->
info
),
0
,
sizeof
(
pTFile
->
info
));
pTFile
->
info
.
magic
=
TD_FILE_INIT_MAGIC
;
if
(
tfsAllocDisk
(
pTfs
,
0
,
&
did
)
<
0
)
{
terrno
=
TSDB_CODE_NO_AVAIL_DISK
;
char
tmpName
[
TSDB_FILENAME_LEN
*
2
+
32
]
=
{
0
};
snprintf
(
tmpName
,
TSDB_FILENAME_LEN
*
2
+
32
,
"%s%s%s"
,
dname
,
TD_DIRSEP
,
fname
);
int32_t
tmpNameLen
=
strlen
(
tmpName
)
+
1
;
pTFile
->
fname
=
taosMemoryMalloc
(
tmpNameLen
);
if
(
!
pTFile
->
fname
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
tfsInitFile
(
pTfs
,
&
(
pTFile
->
f
),
did
,
fname
);
tstrncpy
(
pTFile
->
fname
,
tmpName
,
tmpNameLen
);
return
0
;
}
int32_t
tdCreateTFile
(
STFile
*
pTFile
,
STfs
*
pTfs
,
bool
updateHeader
,
int8_t
fType
)
{
int32_t
tdCreateTFile
(
STFile
*
pTFile
,
bool
updateHeader
,
int8_t
fType
)
{
ASSERT
(
pTFile
->
info
.
fsize
==
0
&&
pTFile
->
info
.
magic
==
TD_FILE_INIT_MAGIC
);
pTFile
->
pFile
=
taosOpenFile
(
TD_TFILE_FULL_NAME
(
pTFile
),
TD_FILE_CREATE
|
TD_FILE_WRITE
|
TD_FILE_TRUNC
);
if
(
pTFile
->
pFile
==
NULL
)
{
if
(
errno
==
ENOENT
)
{
// Try to create directory recursively
char
*
s
=
strdup
(
TD_TFILE_REL_NAME
(
pTFile
));
if
(
tfsMkdirRecurAt
(
pTfs
,
taosDirName
(
s
),
TD_TFILE_DID
(
pTFile
))
<
0
)
{
taosMemoryFreeClear
(
s
);
return
-
1
;
}
taosMemoryFreeClear
(
s
);
pTFile
->
pFile
=
taosOpenFile
(
TD_TFILE_FULL_NAME
(
pTFile
),
TD_FILE_CREATE
|
TD_FILE_WRITE
|
TD_FILE_TRUNC
);
if
(
pTFile
->
pFile
==
NULL
)
{
if
(
taosMulMkDir
(
taosDirName
(
TD_TFILE_FULL_NAME
(
pTFile
)))
!=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
}
else
{
pTFile
->
pFile
=
taosOpenFile
(
TD_TFILE_FULL_NAME
(
pTFile
),
TD_FILE_CREATE
|
TD_FILE_WRITE
|
TD_FILE_TRUNC
);
if
(
pTFile
->
pFile
==
NULL
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
}
}
}
else
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
}
}
if
(
!
updateHeader
)
{
return
0
;
}
if
(
!
updateHeader
)
{
return
0
;
}
pTFile
->
info
.
fsize
+=
TD_FILE_HEAD_SIZE
;
pTFile
->
info
.
fver
=
0
;
pTFile
->
info
.
fsize
+=
TD_FILE_HEAD_SIZE
;
pTFile
->
info
.
fver
=
0
;
if
(
tdUpdateTFileHeader
(
pTFile
)
<
0
)
{
tdCloseTFile
(
pTFile
);
tdRemoveTFile
(
pTFile
);
return
-
1
;
if
(
tdUpdateTFileHeader
(
pTFile
)
<
0
)
{
tdCloseTFile
(
pTFile
);
tdRemoveTFile
(
pTFile
);
return
-
1
;
}
}
return
0
;
}
int32_t
tdRemoveTFile
(
STFile
*
pTFile
)
{
return
tfsRemoveFile
(
TD_TFILE_F
(
pTFile
));
}
int32_t
tdRemoveTFile
(
STFile
*
pTFile
)
{
if
(
taosRemoveFile
(
TD_TFILE_FULL_NAME
(
pTFile
))
!=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
};
return
0
;
}
// smaXXXUtil ================
// ...
\ No newline at end of file
source/dnode/vnode/src/tq/tq.c
浏览文件 @
f249bae8
...
...
@@ -183,13 +183,15 @@ int32_t tqProcessOffsetCommitReq(STQ* pTq, char* msg, int32_t msgLen) {
}
else
{
ASSERT
(
0
);
}
STqOffset
*
pOffset
=
tqOffsetRead
(
pTq
->
pOffsetStore
,
offset
.
subKey
);
if
(
pOffset
==
NULL
||
pOffset
->
val
.
version
<
offset
.
val
.
version
)
{
if
(
tqOffsetWrite
(
pTq
->
pOffsetStore
,
&
offset
)
<
0
)
{
ASSERT
(
0
);
return
-
1
;
}
/*STqOffset* pOffset = tqOffsetRead(pTq->pOffsetStore, offset.subKey);*/
/*if (pOffset != NULL) {*/
/*if (pOffset->val.type == TMQ_OFFSET__LOG && pOffset->val.version < offset.val.version) {*/
if
(
tqOffsetWrite
(
pTq
->
pOffsetStore
,
&
offset
)
<
0
)
{
ASSERT
(
0
)
;
return
-
1
;
}
/*}*/
/*}*/
return
0
;
}
...
...
@@ -375,8 +377,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
taosMemoryFree
(
pCkHead
);
}
else
if
(
fetchOffsetNew
.
type
==
TMQ_OFFSET__SNAPSHOT_DATA
)
{
tqInfo
(
"retrieve using snapshot req offset: uid %ld ts %ld, actual offset: uid %ld ts %ld"
,
dataRsp
.
reqOffset
.
uid
,
dataRsp
.
reqOffset
.
ts
,
fetchOffsetNew
.
uid
,
fetchOffsetNew
.
ts
);
tqInfo
(
"retrieve using snapshot actual offset: uid %ld ts %ld"
,
fetchOffsetNew
.
uid
,
fetchOffsetNew
.
ts
);
if
(
tqScanSnapshot
(
pTq
,
&
pHandle
->
execHandle
,
&
dataRsp
,
fetchOffsetNew
,
workerId
)
<
0
)
{
ASSERT
(
0
);
}
...
...
source/dnode/vnode/src/tq/tqRead.c
浏览文件 @
f249bae8
...
...
@@ -120,7 +120,9 @@ bool tqNextDataBlock(SStreamReader* pHandle) {
return
true
;
}
void
*
ret
=
taosHashGet
(
pHandle
->
tbIdHash
,
&
pHandle
->
msgIter
.
uid
,
sizeof
(
int64_t
));
/*tqDebug("search uid %ld", pHandle->msgIter.uid);*/
if
(
ret
!=
NULL
)
{
/*tqDebug("find uid %ld", pHandle->msgIter.uid);*/
return
true
;
}
}
...
...
source/dnode/vnode/src/vnd/vnodeCfg.c
浏览文件 @
f249bae8
...
...
@@ -28,12 +28,12 @@ const SVnodeCfg vnodeCfgDefault = {
.
update
=
1
,
.
compression
=
2
,
.
slLevel
=
5
,
.
days
=
10
,
.
days
=
1
440
0
,
.
minRows
=
100
,
.
maxRows
=
4096
,
.
keep2
=
365
0
,
.
keep0
=
365
0
,
.
keep1
=
365
0
},
.
keep2
=
525600
0
,
.
keep0
=
525600
0
,
.
keep1
=
525600
0
},
.
walCfg
=
{.
vgId
=
-
1
,
.
fsyncPeriod
=
0
,
.
retentionPeriod
=
0
,
.
rollPeriod
=
0
,
.
segSize
=
0
,
.
level
=
TAOS_WAL_WRITE
},
.
hashBegin
=
0
,
...
...
source/dnode/vnode/src/vnd/vnodeCommit.c
浏览文件 @
f249bae8
...
...
@@ -229,6 +229,9 @@ int vnodeCommit(SVnode *pVnode) {
return
-
1
;
}
// preCommit
// TODO
// commit each sub-system
if
(
metaCommit
(
pVnode
->
pMeta
)
<
0
)
{
ASSERT
(
0
);
...
...
@@ -269,6 +272,9 @@ int vnodeCommit(SVnode *pVnode) {
pVnode
->
state
.
committed
=
info
.
state
.
committed
;
// postCommit
smaPostCommit
(
pVnode
->
pSma
);
// apply the commit (TODO)
vnodeBufPoolReset
(
pVnode
->
onCommit
);
pVnode
->
onCommit
->
next
=
pVnode
->
pPool
;
...
...
source/dnode/vnode/src/vnd/vnodeSvr.c
浏览文件 @
f249bae8
...
...
@@ -779,6 +779,7 @@ _exit:
taosArrayDestroy
(
submitRsp
.
pArray
);
// TODO: the partial success scenario and the error case
// => If partial success, extract the success submitted rows and reconstruct a new submit msg, and push to level 1/level 2.
// TODO: refactor
if
((
terrno
==
TSDB_CODE_SUCCESS
)
&&
(
pRsp
->
code
==
TSDB_CODE_SUCCESS
))
{
tdProcessRSmaSubmit
(
pVnode
->
pSma
,
pReq
,
STREAM_INPUT__DATA_SUBMIT
);
...
...
source/libs/executor/inc/executorimpl.h
浏览文件 @
f249bae8
...
...
@@ -356,6 +356,7 @@ typedef struct SStreamBlockScanInfo {
SUpdateInfo
*
pUpdateInfo
;
EStreamScanMode
scanMode
;
SOperatorInfo
*
pStreamScanOp
;
SOperatorInfo
*
pSnapshotReadOp
;
SArray
*
childIds
;
SessionWindowSupporter
sessionSup
;
...
...
source/libs/executor/src/executor.c
浏览文件 @
f249bae8
...
...
@@ -145,10 +145,12 @@ static SArray* filterQualifiedChildTables(const SStreamBlockScanInfo* pScanInfo,
continue
;
}
// TODO handle ntb case
if
(
mr
.
me
.
type
!=
TSDB_CHILD_TABLE
||
mr
.
me
.
ctbEntry
.
suid
!=
pScanInfo
->
tableUid
)
{
continue
;
}
// TODO handle ntb case
/*pScanInfo->pStreamScanOp->pTaskInfo->tableqinfoList.*/
// handle multiple partition
taosArrayPush
(
qa
,
id
);
}
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
f249bae8
...
...
@@ -2027,8 +2027,9 @@ static int32_t doSendFetchDataRequest(SExchangeInfo* pExchangeInfo, SExecTaskInf
ASSERT
(
pDataInfo
->
status
==
EX_SOURCE_DATA_NOT_READY
);
qDebug
(
"%s build fetch msg and send to vgId:%d, ep:%s, taskId:0x%"
PRIx64
", execId:%d, %d/%"
PRIzu
,
GET_TASKID
(
pTaskInfo
),
pSource
->
addr
.
nodeId
,
pSource
->
addr
.
epSet
.
eps
[
0
].
fqdn
,
pSource
->
taskId
,
pSource
->
execId
,
sourceIndex
,
totalSources
);
qDebug
(
"%s build fetch msg and send to vgId:%d, ep:%s, taskId:0x%"
PRIx64
", execId:%d, %d/%"
PRIzu
,
GET_TASKID
(
pTaskInfo
),
pSource
->
addr
.
nodeId
,
pSource
->
addr
.
epSet
.
eps
[
0
].
fqdn
,
pSource
->
taskId
,
pSource
->
execId
,
sourceIndex
,
totalSources
);
pMsg
->
header
.
vgId
=
htonl
(
pSource
->
addr
.
nodeId
);
pMsg
->
sId
=
htobe64
(
pSource
->
schedId
);
...
...
@@ -2163,8 +2164,8 @@ static SSDataBlock* concurrentlyLoadRemoteDataImpl(SOperatorInfo* pOperator, SEx
SSDataBlock
*
pRes
=
pExchangeInfo
->
pResult
;
SLoadRemoteDataInfo
*
pLoadInfo
=
&
pExchangeInfo
->
loadInfo
;
if
(
pRsp
->
numOfRows
==
0
)
{
qDebug
(
"%s vgId:%d, taskId:0x%"
PRIx64
" execId:%d index:%d completed, rowsOfSource:%"
PRIu64
", totalRows:%"
PRIu64
", completed:%d try next %d/%"
PRIzu
,
qDebug
(
"%s vgId:%d, taskId:0x%"
PRIx64
" execId:%d index:%d completed, rowsOfSource:%"
PRIu64
",
totalRows:%"
PRIu64
",
completed:%d try next %d/%"
PRIzu
,
GET_TASKID
(
pTaskInfo
),
pSource
->
addr
.
nodeId
,
pSource
->
taskId
,
pSource
->
execId
,
i
,
pDataInfo
->
totalRows
,
pExchangeInfo
->
loadInfo
.
totalRows
,
completed
+
1
,
i
+
1
,
totalSources
);
pDataInfo
->
status
=
EX_SOURCE_DATA_EXHAUSTED
;
...
...
@@ -2183,18 +2184,19 @@ static SSDataBlock* concurrentlyLoadRemoteDataImpl(SOperatorInfo* pOperator, SEx
}
if
(
pRsp
->
completed
==
1
)
{
qDebug
(
"%s fetch msg rsp from vgId:%d, taskId:0x%"
PRIx64
" execId:%d"
qDebug
(
"%s fetch msg rsp from vgId:%d, taskId:0x%"
PRIx64
" execId:%d"
" index:%d completed, numOfRows:%d, rowsOfSource:%"
PRIu64
", totalRows:%"
PRIu64
", totalBytes:%"
PRIu64
", completed:%d try next %d/%"
PRIzu
,
GET_TASKID
(
pTaskInfo
),
pSource
->
addr
.
nodeId
,
pSource
->
taskId
,
pSource
->
execId
,
i
,
pRes
->
info
.
rows
,
pDataInfo
->
totalRows
,
pLoadInfo
->
totalRows
,
pLoadInfo
->
totalSize
,
completed
+
1
,
i
+
1
,
totalSources
);
GET_TASKID
(
pTaskInfo
),
pSource
->
addr
.
nodeId
,
pSource
->
taskId
,
pSource
->
execId
,
i
,
pRes
->
info
.
rows
,
p
DataInfo
->
totalRows
,
p
LoadInfo
->
totalRows
,
pLoadInfo
->
totalSize
,
completed
+
1
,
i
+
1
,
totalSources
);
completed
+=
1
;
pDataInfo
->
status
=
EX_SOURCE_DATA_EXHAUSTED
;
}
else
{
qDebug
(
"%s fetch msg rsp from vgId:%d, taskId:0x%"
PRIx64
" execId:%d numOfRows:%d, totalRows:%"
PRIu64
", totalBytes:%"
PRIu64
,
GET_TASKID
(
pTaskInfo
),
pSource
->
addr
.
nodeId
,
pSource
->
taskId
,
pSource
->
execId
,
pRes
->
info
.
rows
,
pLoadInfo
->
totalRows
,
pLoadInfo
->
totalSize
);
GET_TASKID
(
pTaskInfo
),
pSource
->
addr
.
nodeId
,
pSource
->
taskId
,
pSource
->
execId
,
pRes
->
info
.
rows
,
pLoadInfo
->
total
Rows
,
pLoadInfo
->
total
Size
);
}
taosMemoryFreeClear
(
pDataInfo
->
pRsp
);
...
...
@@ -2267,8 +2269,8 @@ static SSDataBlock* seqLoadRemoteData(SOperatorInfo* pOperator) {
SDownstreamSourceNode
*
pSource
=
taosArrayGet
(
pExchangeInfo
->
pSources
,
pExchangeInfo
->
current
);
if
(
pDataInfo
->
code
!=
TSDB_CODE_SUCCESS
)
{
qError
(
"%s vgId:%d, taskID:0x%"
PRIx64
" execId:%d error happens, code:%s"
,
GET_TASKID
(
pTaskInfo
),
pSource
->
addr
.
nodeId
,
pSource
->
taskId
,
pSource
->
execId
,
tstrerror
(
pDataInfo
->
code
));
qError
(
"%s vgId:%d, taskID:0x%"
PRIx64
" execId:%d error happens, code:%s"
,
GET_TASKID
(
pTaskInfo
),
pSource
->
addr
.
nodeId
,
pSource
->
taskId
,
pSource
->
execId
,
tstrerror
(
pDataInfo
->
code
));
pOperator
->
pTaskInfo
->
code
=
pDataInfo
->
code
;
return
NULL
;
}
...
...
@@ -2276,8 +2278,8 @@ static SSDataBlock* seqLoadRemoteData(SOperatorInfo* pOperator) {
SRetrieveTableRsp
*
pRsp
=
pDataInfo
->
pRsp
;
SLoadRemoteDataInfo
*
pLoadInfo
=
&
pExchangeInfo
->
loadInfo
;
if
(
pRsp
->
numOfRows
==
0
)
{
qDebug
(
"%s vgId:%d, taskID:0x%"
PRIx64
" execId:%d %d of total completed, rowsOfSource:%"
PRIu64
", totalRows:%"
PRIu64
" try next"
,
qDebug
(
"%s vgId:%d, taskID:0x%"
PRIx64
" execId:%d %d of total completed, rowsOfSource:%"
PRIu64
"
, totalRows:%"
PRIu64
"
try next"
,
GET_TASKID
(
pTaskInfo
),
pSource
->
addr
.
nodeId
,
pSource
->
taskId
,
pSource
->
execId
,
pExchangeInfo
->
current
+
1
,
pDataInfo
->
totalRows
,
pLoadInfo
->
totalRows
);
...
...
@@ -2296,16 +2298,17 @@ static SSDataBlock* seqLoadRemoteData(SOperatorInfo* pOperator) {
if
(
pRsp
->
completed
==
1
)
{
qDebug
(
"%s fetch msg rsp from vgId:%d, taskId:0x%"
PRIx64
" execId:%d numOfRows:%d, rowsOfSource:%"
PRIu64
", totalRows:%"
PRIu64
", totalBytes:%"
PRIu64
" try next %d/%"
PRIzu
,
GET_TASKID
(
pTaskInfo
),
pSource
->
addr
.
nodeId
,
pSource
->
taskId
,
pSource
->
execId
,
pRes
->
info
.
rows
,
pDataInfo
->
totalRows
,
pLoadInfo
->
totalRows
,
pLoadInfo
->
totalSize
,
pExchangeInfo
->
current
+
1
,
totalSources
);
GET_TASKID
(
pTaskInfo
),
pSource
->
addr
.
nodeId
,
pSource
->
taskId
,
pSource
->
execId
,
pRes
->
info
.
rows
,
pDataInfo
->
totalRows
,
pLoadInfo
->
totalRows
,
pLoadInfo
->
totalSize
,
pExchangeInfo
->
current
+
1
,
totalSources
);
pDataInfo
->
status
=
EX_SOURCE_DATA_EXHAUSTED
;
pExchangeInfo
->
current
+=
1
;
}
else
{
qDebug
(
"%s fetch msg rsp from vgId:%d, taskId:0x%"
PRIx64
" execId:%d numOfRows:%d, totalRows:%"
PRIu64
", totalBytes:%"
PRIu64
,
GET_TASKID
(
pTaskInfo
),
pSource
->
addr
.
nodeId
,
pSource
->
taskId
,
pSource
->
execId
,
pRes
->
info
.
rows
,
pLoadInfo
->
totalRows
,
pLoadInfo
->
totalSize
);
GET_TASKID
(
pTaskInfo
),
pSource
->
addr
.
nodeId
,
pSource
->
taskId
,
pSource
->
execId
,
pRes
->
info
.
rows
,
pLoadInfo
->
total
Rows
,
pLoadInfo
->
total
Size
);
}
pOperator
->
resultInfo
.
totalRows
+=
pRes
->
info
.
rows
;
...
...
source/libs/executor/src/scanoperator.c
浏览文件 @
f249bae8
...
...
@@ -1274,6 +1274,7 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys
pInfo
->
sessionSup
=
(
SessionWindowSupporter
){.
pStreamAggSup
=
NULL
,
.
gap
=
-
1
};
pInfo
->
groupId
=
0
;
pInfo
->
pPullDataRes
=
createPullDataBlock
();
pInfo
->
pStreamScanOp
=
pOperator
;
pOperator
->
name
=
"StreamBlockScanOperator"
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN
;
...
...
source/libs/scheduler/inc/schedulerInt.h
浏览文件 @
f249bae8
...
...
@@ -276,8 +276,6 @@ extern SSchedulerMgmt schMgmt;
#define SCH_TASK_ID(_task) ((_task) ? (_task)->taskId : -1)
#define SCH_TASK_EID(_task) ((_task) ? (_task)->execId : -1)
#define SCH_SET_TASK_LASTMSG_TYPE(_task, _type) do { if(_task) { atomic_store_32(&(_task)->lastMsgType, _type); } } while (0)
#define SCH_GET_TASK_LASTMSG_TYPE(_task) ((_task) ? atomic_load_32(&(_task)->lastMsgType) : -1)
#define SCH_IS_DATA_SRC_QRY_TASK(task) ((task)->plan->subplanType == SUBPLAN_TYPE_SCAN)
#define SCH_IS_DATA_SRC_TASK(task) (((task)->plan->subplanType == SUBPLAN_TYPE_SCAN) || ((task)->plan->subplanType == SUBPLAN_TYPE_MODIFY))
...
...
@@ -309,7 +307,10 @@ extern SSchedulerMgmt schMgmt;
#define SCH_IS_NEED_DROP_JOB(_job) (SCH_IS_QUERY_JOB(_job))
#define SCH_IS_EXPLAIN_JOB(_job) (EXPLAIN_MODE_ANALYZE == (_job)->attr.explainMode)
#define SCH_NETWORK_ERR(_code) ((_code) == TSDB_CODE_RPC_BROKEN_LINK || (_code) == TSDB_CODE_RPC_NETWORK_UNAVAIL)
#define SCH_SUB_TASK_NETWORK_ERR(_code, _len) (((_code) == TSDB_CODE_RPC_NETWORK_UNAVAIL || (_code) == TSDB_CODE_RPC_BROKEN_LINK) && ((_len) > 0))
#define SCH_SUB_TASK_NETWORK_ERR(_code, _len) (SCH_NETWORK_ERR(_code) && ((_len) > 0))
#define SCH_NEED_REDIRECT_MSGTYPE(_msgType) ((_msgType) == TDMT_SCH_QUERY || (_msgType) == TDMT_SCH_MERGE_QUERY || (_msgType) == TDMT_SCH_FETCH)
#define SCH_NEED_REDIRECT(_msgType, _code, _rspLen) (SCH_NEED_REDIRECT_MSGTYPE(_msgType) && (NEED_SCHEDULER_REDIRECT_ERROR(_code) || SCH_SUB_TASK_NETWORK_ERR(_code, _rspLen)))
#define SCH_NEED_RETRY(_msgType, _code) ((SCH_NETWORK_ERR(_code) && SCH_NEED_REDIRECT_MSGTYPE(_msgType)) || (_code) == TSDB_CODE_SCH_TIMEOUT_ERROR)
#define SCH_IS_LEVEL_UNFINISHED(_level) ((_level)->taskLaunchedNum < (_level)->taskNum)
#define SCH_GET_CUR_EP(_addr) (&(_addr)->epSet.eps[(_addr)->epSet.inUse])
...
...
source/libs/scheduler/src/schJob.c
浏览文件 @
f249bae8
...
...
@@ -835,7 +835,7 @@ int32_t schTaskCheckSetRetry(SSchJob *pJob, SSchTask *pTask, int32_t errCode, bo
return
TSDB_CODE_SUCCESS
;
}
if
(
!
NEED_SCHEDULER_RETRY_ERROR
(
errCode
))
{
if
(
!
SCH_NEED_RETRY
(
pTask
->
lastMsgType
,
errCode
))
{
*
needRetry
=
false
;
SCH_TASK_DLOG
(
"task no more retry cause of errCode, errCode:%x - %s"
,
errCode
,
tstrerror
(
errCode
));
return
TSDB_CODE_SUCCESS
;
...
...
source/libs/scheduler/src/schRemote.c
浏览文件 @
f249bae8
...
...
@@ -23,7 +23,7 @@
int32_t
schValidateReceivedMsgType
(
SSchJob
*
pJob
,
SSchTask
*
pTask
,
int32_t
msgType
)
{
int32_t
lastMsgType
=
SCH_GET_TASK_LASTMSG_TYPE
(
pTask
)
;
int32_t
lastMsgType
=
pTask
->
lastMsgType
;
int32_t
taskStatus
=
SCH_GET_TASK_STATUS
(
pTask
);
int32_t
reqMsgType
=
msgType
-
1
;
switch
(
msgType
)
{
...
...
@@ -42,7 +42,7 @@ int32_t schValidateReceivedMsgType(SSchJob *pJob, SSchTask *pTask, int32_t msgTy
TMSG_INFO
(
msgType
));
}
SCH_SET_TASK_LASTMSG_TYPE
(
pTask
,
-
1
);
//
SCH_SET_TASK_LASTMSG_TYPE(pTask, -1);
return
TSDB_CODE_SUCCESS
;
case
TDMT_SCH_FETCH_RSP
:
if
(
lastMsgType
!=
reqMsgType
&&
-
1
!=
lastMsgType
)
{
...
...
@@ -57,7 +57,7 @@ int32_t schValidateReceivedMsgType(SSchJob *pJob, SSchTask *pTask, int32_t msgTy
SCH_ERR_RET
(
TSDB_CODE_SCH_STATUS_ERROR
);
}
SCH_SET_TASK_LASTMSG_TYPE
(
pTask
,
-
1
);
//
SCH_SET_TASK_LASTMSG_TYPE(pTask, -1);
return
TSDB_CODE_SUCCESS
;
case
TDMT_VND_CREATE_TABLE_RSP
:
case
TDMT_VND_DROP_TABLE_RSP
:
...
...
@@ -82,7 +82,7 @@ int32_t schValidateReceivedMsgType(SSchJob *pJob, SSchTask *pTask, int32_t msgTy
SCH_ERR_RET
(
TSDB_CODE_SCH_STATUS_ERROR
);
}
SCH_SET_TASK_LASTMSG_TYPE
(
pTask
,
-
1
);
//
SCH_SET_TASK_LASTMSG_TYPE(pTask, -1);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -396,7 +396,8 @@ int32_t schHandleCallback(void *param, SDataBuf *pMsg, int32_t rspCode) {
SCH_ERR_JRET
(
schValidateReceivedMsgType
(
pJob
,
pTask
,
msgType
));
if
(
NEED_SCHEDULER_REDIRECT_ERROR
(
rspCode
)
||
SCH_SUB_TASK_NETWORK_ERR
(
rspCode
,
pMsg
->
len
>
0
))
{
int32_t
reqType
=
IsReq
(
pMsg
)
?
pMsg
->
msgType
:
(
pMsg
->
msgType
-
1
);
if
(
SCH_NEED_REDIRECT
(
reqType
,
rspCode
,
pMsg
->
len
))
{
code
=
schHandleRedirect
(
pJob
,
pTask
,
(
SDataBuf
*
)
pMsg
,
rspCode
);
goto
_return
;
}
...
...
@@ -855,6 +856,9 @@ int32_t schAsyncSendMsg(SSchJob *pJob, SSchTask *pTask, SSchTrans *trans, SQuery
addr
->
nodeId
,
epSet
->
eps
[
epSet
->
inUse
].
fqdn
,
epSet
->
eps
[
epSet
->
inUse
].
port
,
trans
->
pTrans
,
trans
->
pHandle
);
if
(
pTask
)
{
pTask
->
lastMsgType
=
msgType
;
}
int64_t
transporterId
=
0
;
code
=
asyncSendMsgToServerExt
(
trans
->
pTrans
,
epSet
,
&
transporterId
,
pMsgSendInfo
,
persistHandle
,
ctx
);
...
...
@@ -1098,8 +1102,6 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr,
break
;
}
SCH_SET_TASK_LASTMSG_TYPE
(
pTask
,
msgType
);
SSchTrans
trans
=
{.
pTrans
=
pJob
->
conn
.
pTrans
,
.
pHandle
=
SCH_GET_TASK_HANDLE
(
pTask
)};
SCH_ERR_JRET
(
schAsyncSendMsg
(
pJob
,
pTask
,
&
trans
,
addr
,
msgType
,
msg
,
msgSize
,
persistHandle
,
(
rpcCtx
.
args
?
&
rpcCtx
:
NULL
)));
...
...
@@ -1112,7 +1114,7 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr,
_return:
SCH_SET_TASK_LASTMSG_TYPE
(
pTask
,
-
1
)
;
pTask
->
lastMsgType
=
-
1
;
schFreeRpcCtx
(
&
rpcCtx
);
taosMemoryFreeClear
(
msg
);
...
...
source/util/src/terror.c
浏览文件 @
f249bae8
...
...
@@ -590,6 +590,8 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TSMA_NO_INDEX_IN_CACHE, "No tsma index in ca
TAOS_DEFINE_ERROR
(
TSDB_CODE_RSMA_INVALID_ENV
,
"Invalid rsma env"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_RSMA_INVALID_STAT
,
"Invalid rsma state"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_RSMA_QTASKINFO_CREATE
,
"Rsma qtaskinfo creation error"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_RSMA_FILE_CORRUPTED
,
"Rsma file corrupted"
)
//tq
TAOS_DEFINE_ERROR
(
TSDB_CODE_TQ_NO_COMMITTED_OFFSET
,
"No committed offset"
)
...
...
tests/pytest/util/common.py
浏览文件 @
f249bae8
...
...
@@ -662,6 +662,12 @@ class TDCom:
return
res_list
else
:
tdLog
.
exit
(
f
"getOneRow out of range: row_index=
{
location
}
row_count=
{
self
.
query_row
}
"
)
def
killProcessor
(
self
,
processorName
):
if
(
platform
.
system
().
lower
()
==
'windows'
):
os
.
system
(
"TASKKILL /F /IM %s.exe"
%
processorName
)
else
:
os
.
system
(
'pkill %s'
%
processorName
)
def
is_json
(
msg
):
...
...
tests/script/tsim/tmq/snapshot1.sim
浏览文件 @
f249bae8
...
...
@@ -25,7 +25,7 @@ $rowsPerCtb = 10
$tstart = 1640966400000 # 2022-01-01 00:00:00.000
#---- global parameters end ----#
$pullDelay =
5
$pullDelay =
2
$ifcheckdata = 1
$ifmanualcommit = 1
$showMsg = 1
...
...
tests/system-test/1-insert/insertWithMoreVgroup.py
浏览文件 @
f249bae8
...
...
@@ -355,40 +355,6 @@ class TDTestCase:
return
def
test_case4
(
self
):
self
.
taosBenchCreate
(
"127.0.0.1"
,
"no"
,
"db1"
,
"stb1"
,
1
,
2
,
1
*
10
)
tdSql
.
execute
(
"use db1;"
)
tdSql
.
query
(
"show dnodes;"
)
dnodeId
=
tdSql
.
getData
(
0
,
0
)
print
(
dnodeId
)
tdSql
.
execute
(
"create qnode on dnode %s"
%
dnodeId
)
tdSql
.
query
(
"select max(c1) from stb10;"
)
maxQnode
=
tdSql
.
getData
(
0
,
0
)
tdSql
.
query
(
"select min(c1) from stb11;"
)
minQnode
=
tdSql
.
getData
(
0
,
0
)
tdSql
.
query
(
"select c0,c1 from stb11_1 where (c0>1000) union select c0,c1 from stb11_1 where c0>2000;"
)
unionQnode
=
tdSql
.
queryResult
tdSql
.
query
(
"select c0,c1 from stb11_1 where (c0>1000) union all select c0,c1 from stb11_1 where c0>2000;"
)
unionallQnode
=
tdSql
.
queryResult
# tdSql.query("show qnodes;")
# qnodeId=tdSql.getData(0,0)
tdSql
.
execute
(
"drop qnode on dnode %s"
%
dnodeId
)
tdSql
.
execute
(
"reset query cache"
)
tdSql
.
query
(
"select max(c1) from stb10;"
)
tdSql
.
checkData
(
0
,
0
,
"%s"
%
maxQnode
)
tdSql
.
query
(
"select min(c1) from stb11;"
)
tdSql
.
checkData
(
0
,
0
,
"%s"
%
minQnode
)
tdSql
.
query
(
"select c0,c1 from stb11_1 where (c0>1000) union select c0,c1 from stb11_1 where c0>2000;"
)
unionVnode
=
tdSql
.
queryResult
assert
unionQnode
==
unionVnode
tdSql
.
query
(
"select c0,c1 from stb11_1 where (c0>1000) union all select c0,c1 from stb11_1 where c0>2000;"
)
unionallVnode
=
tdSql
.
queryResult
assert
unionallQnode
==
unionallVnode
# tdSql.execute("create qnode on dnode %s"%dnodeId)
# run case
def
run
(
self
):
...
...
tests/system-test/1-insert/test_stmt_insert_query_ex.py
浏览文件 @
f249bae8
...
...
@@ -82,7 +82,7 @@ class TDTestCase:
return
con
def
test_stmt_set_tbname_tag
(
self
,
conn
):
dbname
=
"stmt_
set_tbname_
tag"
dbname
=
"stmt_tag"
try
:
conn
.
execute
(
"drop database if exists %s"
%
dbname
)
...
...
@@ -196,31 +196,31 @@ class TDTestCase:
assert
rows9
[
0
][
0
]
==
12
,
'fourth case is failed'
assert
rows9
[
1
][
0
]
==
12
,
'fourth case is failed'
#
#
query: conversion Functions
#query: conversion Functions
#
querystmt4=conn.statement("select cast( ? as bigint) from log ")
#
queryparam4=new_bind_params(1)
#
print(type(queryparam4))
#
queryparam4[0].binary('1232a')
#
querystmt4.bind_param(queryparam4)
#
querystmt4.execute()
#
result4=querystmt4.use_result()
#
rows4=result4.fetch_all()
#
print("5",rows4)
#
assert rows4[0][0] == 1232
#
assert rows4[1][0] == 1232
querystmt4
=
conn
.
statement
(
"select cast( ? as bigint) from log "
)
queryparam4
=
new_bind_params
(
1
)
print
(
type
(
queryparam4
))
queryparam4
[
0
].
binary
(
'1232a'
)
querystmt4
.
bind_param
(
queryparam4
)
querystmt4
.
execute
()
result4
=
querystmt4
.
use_result
()
rows4
=
result4
.
fetch_all
()
print
(
"5"
,
rows4
)
assert
rows4
[
0
][
0
]
==
1232
assert
rows4
[
1
][
0
]
==
1232
#
querystmt4=conn.statement("select cast( ? as binary(10)) from log ")
#
queryparam4=new_bind_params(1)
#
print(type(queryparam4))
#
queryparam4[0].int(123)
#
querystmt4.bind_param(queryparam4)
#
querystmt4.execute()
#
result4=querystmt4.use_result()
#
rows4=result4.fetch_all()
#
print("6",rows4)
#
assert rows4[0][0] == '123'
#
assert rows4[1][0] == '123'
querystmt4
=
conn
.
statement
(
"select cast( ? as binary(10)) from log "
)
queryparam4
=
new_bind_params
(
1
)
print
(
type
(
queryparam4
))
queryparam4
[
0
].
int
(
123
)
querystmt4
.
bind_param
(
queryparam4
)
querystmt4
.
execute
()
result4
=
querystmt4
.
use_result
()
rows4
=
result4
.
fetch_all
()
print
(
"6"
,
rows4
)
assert
rows4
[
0
][
0
]
==
'123'
assert
rows4
[
1
][
0
]
==
'123'
# #query: datatime Functions
...
...
tests/system-test/1-insert/test_stmt_muti_insert_query.py
浏览文件 @
f249bae8
...
...
@@ -84,21 +84,21 @@ class TDTestCase:
def
test_stmt_insert_multi
(
self
,
conn
):
# type: (TaosConnection) -> None
dbname
=
"
pytest_taos_stmt_multi
"
dbname
=
"
db_stmt
"
try
:
conn
.
execute
(
"drop database if exists %s"
%
dbname
)
conn
.
execute
(
"create database if not exists %s"
%
dbname
)
conn
.
select_db
(
dbname
)
conn
.
execute
(
"create table if not exists
log
(ts timestamp, bo bool, nil tinyint, ti tinyint, si smallint, ii int,
\
"create table if not exists
stb1
(ts timestamp, bo bool, nil tinyint, ti tinyint, si smallint, ii int,
\
bi bigint, tu tinyint unsigned, su smallint unsigned, iu int unsigned, bu bigint unsigned,
\
ff float, dd double, bb binary(100), nn nchar(100), tt timestamp)"
,
)
# conn.load_table_info("log")
start
=
datetime
.
now
()
stmt
=
conn
.
statement
(
"insert into
log
values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
)
stmt
=
conn
.
statement
(
"insert into
stb1
values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
)
params
=
new_multi_binds
(
16
)
params
[
0
].
timestamp
((
1626861392589
,
1626861392590
,
1626861392591
))
...
...
@@ -125,7 +125,7 @@ class TDTestCase:
assert
stmt
.
affected_rows
==
3
#query 1
querystmt
=
conn
.
statement
(
"select ?,bu from
log
"
)
querystmt
=
conn
.
statement
(
"select ?,bu from
stb1
"
)
queryparam
=
new_bind_params
(
1
)
print
(
type
(
queryparam
))
queryparam
[
0
].
binary
(
"ts"
)
...
...
@@ -135,7 +135,7 @@ class TDTestCase:
# rows=result.fetch_all()
# print( querystmt.use_result())
# result = conn.query("select * from
log
")
# result = conn.query("select * from
stb1
")
rows
=
result
.
fetch_all
()
# rows=result.fetch_all()
print
(
rows
)
...
...
@@ -144,7 +144,7 @@ class TDTestCase:
assert
rows
[
2
][
1
]
==
None
#query 2
querystmt1
=
conn
.
statement
(
"select * from
log
where bu < ?"
)
querystmt1
=
conn
.
statement
(
"select * from
stb1
where bu < ?"
)
queryparam1
=
new_bind_params
(
1
)
print
(
type
(
queryparam1
))
queryparam1
[
0
].
int
(
4
)
...
...
tests/system-test/2-query/queryQnode.py
浏览文件 @
f249bae8
...
...
@@ -17,6 +17,8 @@ import threading as thd
import
multiprocessing
as
mp
from
numpy.lib.function_base
import
insert
import
taos
from
util.dnodes
import
TDDnode
from
util.dnodes
import
*
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
...
...
@@ -30,9 +32,9 @@ class TDTestCase:
#
# --------------- main frame -------------------
#
clientCfgDict
=
{
'query
prox
y'
:
'1'
,
'debugFlag'
:
135
}
clientCfgDict
[
"query
proxy"
]
=
'2
'
clientCfgDict
[
"debugFlag"
]
=
1
43
clientCfgDict
=
{
'query
Polic
y'
:
'1'
,
'debugFlag'
:
135
}
clientCfgDict
[
"query
Policy"
]
=
'1
'
clientCfgDict
[
"debugFlag"
]
=
1
31
updatecfgDict
=
{
'clientCfg'
:
{}}
updatecfgDict
=
{
'debugFlag'
:
143
}
...
...
@@ -62,7 +64,7 @@ class TDTestCase:
return
buildPath
# init
def
init
(
self
,
conn
,
logSql
):
def
init
(
self
,
conn
,
logSql
=
True
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
# tdSql.prepare()
...
...
@@ -292,12 +294,13 @@ class TDTestCase:
tdLog
.
debug
(
"-----create database and muti-thread create tables test------- "
)
def
test_case
4
(
self
):
def
test_case
1
(
self
):
self
.
taosBenchCreate
(
"127.0.0.1"
,
"no"
,
"db1"
,
"stb1"
,
1
,
2
,
1
*
10
)
tdSql
.
execute
(
"use db1;"
)
tdSql
.
query
(
"show dnodes;"
)
dnodeId
=
tdSql
.
getData
(
0
,
0
)
print
(
dnodeId
)
tdLog
.
debug
(
"create qnode on dnode %s"
%
dnodeId
)
tdSql
.
execute
(
"create qnode on dnode %s"
%
dnodeId
)
tdSql
.
query
(
"select max(c1) from stb10;"
)
maxQnode
=
tdSql
.
getData
(
0
,
0
)
...
...
@@ -310,6 +313,7 @@ class TDTestCase:
# tdSql.query("show qnodes;")
# qnodeId=tdSql.getData(0,0)
tdLog
.
debug
(
"drop qnode on dnode %s"
%
dnodeId
)
tdSql
.
execute
(
"drop qnode on dnode %s"
%
dnodeId
)
tdSql
.
execute
(
"reset query cache"
)
tdSql
.
query
(
"select max(c1) from stb10;"
)
...
...
@@ -323,15 +327,156 @@ class TDTestCase:
unionallVnode
=
tdSql
.
queryResult
assert
unionallQnode
==
unionallVnode
queryPolicy
=
2
simClientCfg
=
"%s/taos.cfg"
%
tdDnodes
.
getSimCfgPath
()
cmd
=
'sed -i "s/^queryPolicy.*/queryPolicy 2/g" %s'
%
simClientCfg
os
.
system
(
cmd
)
# tdDnodes.stop(1)
# tdDnodes.start(1)
tdSql
.
execute
(
"reset query cache"
)
tdSql
.
execute
(
'alter local "queryPolicy" "%d"'
%
queryPolicy
)
tdSql
.
query
(
"show local variables;"
)
for
i
in
range
(
tdSql
.
queryRows
):
if
tdSql
.
queryResult
[
i
][
0
]
==
"queryPolicy"
:
if
int
(
tdSql
.
queryResult
[
i
][
1
])
==
int
(
queryPolicy
):
tdLog
.
success
(
'alter queryPolicy to %d successfully'
%
queryPolicy
)
else
:
tdLog
.
debug
(
tdSql
.
queryResult
)
tdLog
.
exit
(
"alter queryPolicy to %d failed"
%
queryPolicy
)
tdSql
.
execute
(
"reset query cache"
)
tdSql
.
execute
(
"use db1;"
)
tdSql
.
query
(
"show dnodes;"
)
dnodeId
=
tdSql
.
getData
(
0
,
0
)
tdLog
.
debug
(
"create qnode on dnode %s"
%
dnodeId
)
tdSql
.
execute
(
"create qnode on dnode %s"
%
dnodeId
)
tdSql
.
query
(
"select max(c1) from stb10;"
)
assert
maxQnode
==
tdSql
.
getData
(
0
,
0
)
tdSql
.
query
(
"select min(c1) from stb11;"
)
assert
minQnode
==
tdSql
.
getData
(
0
,
0
)
tdSql
.
query
(
"select c0,c1 from stb11_1 where (c0>1000) union select c0,c1 from stb11_1 where c0>2000;"
)
assert
unionQnode
==
tdSql
.
queryResult
tdSql
.
query
(
"select c0,c1 from stb11_1 where (c0>1000) union all select c0,c1 from stb11_1 where c0>2000;"
)
assert
unionallQnode
==
tdSql
.
queryResult
# tdSql.query("show qnodes;")
# qnodeId=tdSql.getData(0,0)
tdLog
.
debug
(
"drop qnode on dnode %s"
%
dnodeId
)
tdSql
.
execute
(
"drop qnode on dnode %s"
%
dnodeId
)
tdSql
.
execute
(
"reset query cache"
)
tdSql
.
query
(
"select max(c1) from stb10;"
)
assert
maxQnode
==
tdSql
.
getData
(
0
,
0
)
tdSql
.
query
(
"select min(c1) from stb11;"
)
assert
minQnode
==
tdSql
.
getData
(
0
,
0
)
tdSql
.
error
(
"select c0,c1 from stb11_1 where (c0>1000) union select c0,c1 from stb11_1 where c0>2000;"
)
tdSql
.
error
(
"select c0,c1 from stb11_1 where (c0>1000) union all select c0,c1 from stb11_1 where c0>2000;"
)
# tdSql.execute("create qnode on dnode %s"%dnodeId)
queryPolicy
=
3
simClientCfg
=
"%s/taos.cfg"
%
tdDnodes
.
getSimCfgPath
()
cmd
=
'sed -i "s/^queryPolicy.*/queryPolicy 2/g" %s'
%
simClientCfg
os
.
system
(
cmd
)
# tdDnodes.stop(1)
# tdDnodes.start(1)
tdSql
.
execute
(
"reset query cache"
)
tdSql
.
execute
(
'alter local "queryPolicy" "%d"'
%
queryPolicy
)
tdSql
.
query
(
"show local variables;"
)
for
i
in
range
(
tdSql
.
queryRows
):
if
tdSql
.
queryResult
[
i
][
0
]
==
"queryPolicy"
:
if
int
(
tdSql
.
queryResult
[
i
][
1
])
==
int
(
queryPolicy
):
tdLog
.
success
(
'alter queryPolicy to %d successfully'
%
queryPolicy
)
else
:
tdLog
.
debug
(
tdSql
.
queryResult
)
tdLog
.
exit
(
"alter queryPolicy to %d failed"
%
queryPolicy
)
tdSql
.
execute
(
"reset query cache"
)
tdSql
.
execute
(
"use db1;"
)
tdSql
.
query
(
"show dnodes;"
)
dnodeId
=
tdSql
.
getData
(
0
,
0
)
tdLog
.
debug
(
"create qnode on dnode %s"
%
dnodeId
)
tdSql
.
execute
(
"create qnode on dnode %s"
%
dnodeId
)
tdSql
.
query
(
"select max(c1) from stb10;"
)
assert
maxQnode
==
tdSql
.
getData
(
0
,
0
)
tdSql
.
query
(
"select min(c1) from stb11;"
)
assert
minQnode
==
tdSql
.
getData
(
0
,
0
)
tdSql
.
query
(
"select c0,c1 from stb11_1 where (c0>1000) union select c0,c1 from stb11_1 where c0>2000;"
)
assert
unionQnode
==
tdSql
.
queryResult
tdSql
.
query
(
"select c0,c1 from stb11_1 where (c0>1000) union all select c0,c1 from stb11_1 where c0>2000;"
)
assert
unionallQnode
==
tdSql
.
queryResult
def
test_case2
(
self
):
self
.
taosBenchCreate
(
"127.0.0.1"
,
"no"
,
"db1"
,
"stb1"
,
10
,
2
,
1
*
10
)
tdSql
.
query
(
"show qnodes"
)
if
tdSql
.
queryRows
==
1
:
tdLog
.
debug
(
"drop qnode on dnode 1"
)
tdSql
.
execute
(
"drop qnode on dnode 1"
)
queryPolicy
=
2
simClientCfg
=
"%s/taos.cfg"
%
tdDnodes
.
getSimCfgPath
()
cmd
=
'sed -i "s/^queryPolicy.*/queryPolicy 2/g" %s'
%
simClientCfg
os
.
system
(
cmd
)
# tdDnodes.stop(1)
# tdDnodes.start(1)
tdSql
.
execute
(
"reset query cache"
)
tdSql
.
execute
(
'alter local "queryPolicy" "%d"'
%
queryPolicy
)
tdSql
.
query
(
"show local variables;"
)
for
i
in
range
(
tdSql
.
queryRows
):
if
tdSql
.
queryResult
[
i
][
0
]
==
"queryPolicy"
:
if
int
(
tdSql
.
queryResult
[
i
][
1
])
==
int
(
queryPolicy
):
tdLog
.
success
(
'alter queryPolicy to %d successfully'
%
queryPolicy
)
else
:
tdLog
.
debug
(
tdSql
.
queryResult
)
tdLog
.
exit
(
"alter queryPolicy to %d failed"
%
queryPolicy
)
tdSql
.
execute
(
"use db1;"
)
tdSql
.
error
(
"select max(c1) from stb10;"
)
tdSql
.
error
(
"select min(c1) from stb11;"
)
tdSql
.
error
(
"select c0,c1 from stb11_1 where (c0>1000) union select c0,c1 from stb11_1 where c0>2000;"
)
tdSql
.
error
(
"select c0,c1 from stb11_1 where (c0>1000) union all select c0,c1 from stb11_1 where c0>2000;"
)
tdSql
.
query
(
"select max(c1) from stb10_0;"
)
tdSql
.
query
(
"select min(c1) from stb11_0;"
)
def
test_case3
(
self
):
tdSql
.
execute
(
'alter local "queryPolicy" "3"'
)
tdLog
.
debug
(
"create qnode on dnode 1"
)
tdSql
.
execute
(
"create qnode on dnode 1"
)
tdSql
.
execute
(
"use db1;"
)
tdSql
.
query
(
"show dnodes;"
)
dnodeId
=
tdSql
.
getData
(
0
,
0
)
print
(
dnodeId
)
tdSql
.
query
(
"select max(c1) from stb10;"
)
maxQnode
=
tdSql
.
getData
(
0
,
0
)
tdSql
.
query
(
"select min(c1) from stb11;"
)
minQnode
=
tdSql
.
getData
(
0
,
0
)
tdSql
.
query
(
"select c0,c1 from stb11_1 where (c0>1000) union select c0,c1 from stb11_1 where c0>2000;"
)
unionQnode
=
tdSql
.
queryResult
tdSql
.
query
(
"select c0,c1 from stb11_1 where (c0>1000) union all select c0,c1 from stb11_1 where c0>2000;"
)
unionallQnode
=
tdSql
.
queryResult
# tdSql.query("show qnodes;")
# qnodeId=tdSql.getData(0,0)
tdLog
.
debug
(
"drop qnode on dnode %s"
%
dnodeId
)
tdSql
.
execute
(
"drop qnode on dnode %s"
%
dnodeId
)
tdSql
.
execute
(
"reset query cache"
)
tdSql
.
error
(
"select max(c1) from stb10;"
)
tdSql
.
error
(
"select min(c1) from stb11;"
)
tdSql
.
error
(
"select c0,c1 from stb11_1 where (c0>1000) union select c0,c1 from stb11_1 where c0>2000;"
)
tdSql
.
error
(
"select c0,c1 from stb11_1 where (c0>1000) union all select c0,c1 from stb11_1 where c0>2000;"
)
# run case
def
run
(
self
):
# test qnode
self
.
test_case4
()
tdLog
.
debug
(
" LIMIT test_case3 ............ [OK]"
)
self
.
test_case1
()
self
.
test_case2
()
self
.
test_case3
()
# tdLog.debug(" LIMIT test_case3 ............ [OK]")
return
...
...
tests/system-test/6-cluster/5dnode3mnodeSep1VnodeStopVnodeCreateDb.py
浏览文件 @
f249bae8
...
...
@@ -65,31 +65,6 @@ class TDTestCase:
self
.
_async_raise
(
thread
.
ident
,
SystemExit
)
def
insertData
(
self
,
countstart
,
countstop
):
# fisrt add data : db\stable\childtable\general table
for
couti
in
range
(
countstart
,
countstop
):
tdLog
.
debug
(
"drop database if exists db%d"
%
couti
)
tdSql
.
execute
(
"drop database if exists db%d"
%
couti
)
print
(
"create database if not exists db%d replica 1 duration 300"
%
couti
)
tdSql
.
execute
(
"create database if not exists db%d replica 1 duration 300"
%
couti
)
tdSql
.
execute
(
"use db%d"
%
couti
)
tdSql
.
execute
(
'''create table stb1
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
tags (t1 int)
'''
)
tdSql
.
execute
(
'''
create table t1
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
'''
)
for
i
in
range
(
4
):
tdSql
.
execute
(
f
'create table ct
{
i
+
1
}
using stb1 tags (
{
i
+
1
}
)'
)
def
fiveDnodeThreeMnode
(
self
,
dnodeNumbers
,
mnodeNums
,
restartNumbers
,
stopRole
):
tdLog
.
printNoPrefix
(
"======== test case 1: "
)
paraDict
=
{
'dbName'
:
'db'
,
...
...
@@ -143,7 +118,8 @@ class TDTestCase:
threads
=
[]
for
i
in
range
(
restartNumbers
):
dbNameIndex
=
'%s%d'
%
(
paraDict
[
"dbName"
],
i
)
threads
.
append
(
threading
.
Thread
(
target
=
clusterComCreate
.
create_databases
,
args
=
(
tdSql
,
dbNameIndex
,
paraDict
[
"dbNumbers"
],
paraDict
[
"dropFlag"
],
paraDict
[
"vgroups"
],
paraDict
[
'replica'
])))
newTdSql
=
tdCom
.
newTdSql
()
threads
.
append
(
threading
.
Thread
(
target
=
clusterComCreate
.
create_databases
,
args
=
(
newTdSql
,
dbNameIndex
,
paraDict
[
"dbNumbers"
],
paraDict
[
"dropFlag"
],
paraDict
[
"vgroups"
],
paraDict
[
'replica'
])))
for
tr
in
threads
:
tr
.
start
()
...
...
tests/system-test/6-cluster/clusterCommonCheck.py
浏览文件 @
f249bae8
...
...
@@ -39,6 +39,7 @@ class ClusterComCheck:
def
checkDnodes
(
self
,
dnodeNumbers
):
count
=
0
# print(tdSql)
while
count
<
5
:
tdSql
.
query
(
"show dnodes"
)
# tdLog.debug(tdSql.queryResult)
...
...
@@ -85,7 +86,7 @@ class ClusterComCheck:
tdLog
.
debug
(
"check %s_%d that status is ready "
%
(
dbNameIndex
,
j
))
else
:
continue
print
(
query_status
)
#
print(query_status)
count
+=
1
if
query_status
==
dbNumbers
:
tdLog
.
success
(
"we find cluster with %d dnode and check all databases are ready within 5s! "
%
dbNumbers
)
...
...
tests/system-test/6-cluster/clusterCommonCreate.py
浏览文件 @
f249bae8
...
...
@@ -125,7 +125,6 @@ class ClusterComCreate:
def
create_databases
(
self
,
tsql
,
dbNameIndex
,
dbNumbers
,
dropFlag
=
1
,
vgroups
=
4
,
replica
=
1
):
for
i
in
range
(
dbNumbers
):
print
(
dbNumbers
)
if
dropFlag
==
1
:
tsql
.
execute
(
"drop database if exists %s_%d"
%
(
dbNameIndex
,
i
))
tsql
.
execute
(
"create database if not exists %s_%d vgroups %d replica %d"
%
(
dbNameIndex
,
i
,
vgroups
,
replica
))
...
...
tests/system-test/7-tmq/stbFilter.py
浏览文件 @
f249bae8
...
...
@@ -122,9 +122,9 @@ class TDTestCase:
tdLog
.
info
(
"wait the consume result"
)
expectRows
=
1
resultList
=
tmqCom
.
selectConsumeResult
(
expectRows
)
#
if expectRowsList[2] != resultList[0]:
#
tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectRowsList[2], resultList[0]))
#
tdLog.exit("2 tmq consume rows error!")
if
expectRowsList
[
2
]
!=
resultList
[
0
]:
tdLog
.
info
(
"expect consume rows: %d, act consume rows: %d"
%
(
expectRowsList
[
2
],
resultList
[
0
]))
tdLog
.
exit
(
"2 tmq consume rows error!"
)
time
.
sleep
(
10
)
for
i
in
range
(
len
(
topicNameList
)):
...
...
tests/system-test/7-tmq/tmqConsFromTsdb.py
浏览文件 @
f249bae8
...
...
@@ -16,7 +16,7 @@ sys.path.append("./7-tmq")
from
tmqCommon
import
*
class
TDTestCase
:
def
__int__
(
self
):
def
__in
i
t__
(
self
):
self
.
vgroups
=
1
self
.
ctbNum
=
10
self
.
rowsPerTbl
=
10000
...
...
@@ -216,7 +216,7 @@ class TDTestCase:
'rowsPerTbl'
:
10000
,
'batchNum'
:
10
,
'startTs'
:
1640966400000
,
# 2022-01-01 00:00:00.000
'pollDelay'
:
-
1
,
'pollDelay'
:
10
,
'showMsg'
:
1
,
'showRow'
:
1
,
'snapshot'
:
1
}
...
...
@@ -281,10 +281,107 @@ class TDTestCase:
tdLog
.
printNoPrefix
(
"======== test case 3 end ...... "
)
def
tmqCase4
(
self
):
tdLog
.
printNoPrefix
(
"======== test case 4: "
)
paraDict
=
{
'dbName'
:
'dbt'
,
'dropFlag'
:
1
,
'event'
:
''
,
'vgroups'
:
1
,
'stbName'
:
'stb'
,
'colPrefix'
:
'c'
,
'tagPrefix'
:
't'
,
'colSchema'
:
[{
'type'
:
'INT'
,
'count'
:
1
},
{
'type'
:
'binary'
,
'len'
:
20
,
'count'
:
1
}],
'tagSchema'
:
[{
'type'
:
'INT'
,
'count'
:
1
},
{
'type'
:
'binary'
,
'len'
:
20
,
'count'
:
1
}],
'ctbPrefix'
:
'ctb'
,
'ctbNum'
:
1
,
'rowsPerTbl'
:
10000
,
'batchNum'
:
10
,
'startTs'
:
1640966400000
,
# 2022-01-01 00:00:00.000
'pollDelay'
:
10
,
'showMsg'
:
1
,
'showRow'
:
1
,
'snapshot'
:
1
}
paraDict
[
'vgroups'
]
=
self
.
vgroups
paraDict
[
'ctbNum'
]
=
self
.
ctbNum
paraDict
[
'rowsPerTbl'
]
=
self
.
rowsPerTbl
topicNameList
=
[
'topic1'
]
expectRowsList
=
[]
tmqCom
.
initConsumerTable
()
# tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1)
# tdLog.info("create stb")
# tdCom.create_stable(tdSql, dbname=paraDict["dbName"],stbname=paraDict["stbName"], column_elm_list=paraDict['colSchema'], tag_elm_list=paraDict['tagSchema'])
# tdLog.info("create ctb")
# tdCom.create_ctable(tdSql, dbname=paraDict["dbName"],stbname=paraDict["stbName"],tag_elm_list=paraDict['tagSchema'],count=paraDict["ctbNum"], default_ctbname_prefix=paraDict['ctbPrefix'])
# tdLog.info("insert data")
# tmqCom.insert_data(tdSql,paraDict["dbName"],paraDict["ctbPrefix"],paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"],paraDict["startTs"])
# tdDnodes.stop(1)
# tdDnodes.start(1)
tdLog
.
info
(
"create topics from stb with filter"
)
queryString
=
"select * from %s.%s"
%
(
paraDict
[
'dbName'
],
paraDict
[
'stbName'
])
# sqlString = "create topic %s as stable %s" %(topicNameList[0], paraDict['stbName'])
sqlString
=
"create topic %s as %s"
%
(
topicNameList
[
0
],
queryString
)
tdLog
.
info
(
"create topic sql: %s"
%
sqlString
)
tdSql
.
execute
(
sqlString
)
tdSql
.
query
(
queryString
)
expectRowsList
.
append
(
tdSql
.
getRows
())
totalRowsInserted
=
expectRowsList
[
0
]
# init consume info, and start tmq_sim, then check consume result
tdLog
.
info
(
"insert consume info to consume processor"
)
consumerId
=
5
expectrowcnt
=
math
.
ceil
(
paraDict
[
"rowsPerTbl"
]
*
paraDict
[
"ctbNum"
])
topicList
=
topicNameList
[
0
]
ifcheckdata
=
1
ifManualCommit
=
1
keyList
=
'group.id:cgrp1, enable.auto.commit:true, auto.commit.interval.ms:1000, auto.offset.reset:earliest'
tmqCom
.
insertConsumerInfo
(
consumerId
,
expectrowcnt
,
topicList
,
keyList
,
ifcheckdata
,
ifManualCommit
)
tdLog
.
info
(
"start consume processor 0"
)
tmqCom
.
startTmqSimProcess
(
pollDelay
=
paraDict
[
'pollDelay'
],
dbName
=
paraDict
[
"dbName"
],
showMsg
=
paraDict
[
'showMsg'
],
showRow
=
paraDict
[
'showRow'
],
snapshot
=
paraDict
[
'snapshot'
])
tdLog
.
info
(
"wait commit notify"
)
tmqCom
.
getStartCommitNotifyFromTmqsim
()
tdLog
.
info
(
"pkill consume processor"
)
tdCom
.
killProcessor
(
"tmq_sim"
)
# time.sleep(10)
# reinit consume info, and start tmq_sim, then check consume result
tmqCom
.
initConsumerTable
()
consumerId
=
6
tmqCom
.
insertConsumerInfo
(
consumerId
,
expectrowcnt
,
topicList
,
keyList
,
ifcheckdata
,
ifManualCommit
)
tdLog
.
info
(
"start consume processor 1"
)
tmqCom
.
startTmqSimProcess
(
pollDelay
=
paraDict
[
'pollDelay'
],
dbName
=
paraDict
[
"dbName"
],
showMsg
=
paraDict
[
'showMsg'
],
showRow
=
paraDict
[
'showRow'
],
snapshot
=
paraDict
[
'snapshot'
])
tdLog
.
info
(
"wait the consume result"
)
expectRows
=
1
resultList
=
tmqCom
.
selectConsumeResult
(
expectRows
)
actConsumeTotalRows
=
resultList
[
0
]
if
not
(
actConsumeTotalRows
>
0
and
actConsumeTotalRows
<
totalRowsInserted
):
tdLog
.
info
(
"act consume rows: %d"
%
(
actConsumeTotalRows
))
tdLog
.
info
(
"and second consume rows should be between 0 and %d"
%
(
totalRowsInserted
))
tdLog
.
exit
(
"%d tmq consume rows error!"
%
consumerId
)
time
.
sleep
(
10
)
for
i
in
range
(
len
(
topicNameList
)):
tdSql
.
query
(
"drop topic %s"
%
topicNameList
[
i
])
tdLog
.
printNoPrefix
(
"======== test case 4 end ...... "
)
def
run
(
self
):
tdSql
.
prepare
()
self
.
tmqCase1
()
self
.
tmqCase2
()
self
.
tmqCase3
()
self
.
tmqCase4
()
def
stop
(
self
):
tdSql
.
close
()
...
...
tests/system-test/fulltest.sh
浏览文件 @
f249bae8
...
...
@@ -121,7 +121,7 @@ python3 ./test.py -f 6-cluster/5dnode3mnodeStop.py -N 5 -M 3
python3 ./test.py
-f
6-cluster/5dnode3mnodeStopLoop.py
-N
5
-M
3
# BUG python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopDnodeCreateDb.py -N 5 -M 3
# BUG python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopMnodeCreateDb.py -N 5 -M 3
#
python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopVnodeCreateDb.py -N 5 -M 3
python3 ./test.py
-f
6-cluster/5dnode3mnodeSep1VnodeStopVnodeCreateDb.py
-N
5
-M
3
# BUG python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopDnodeCreateStb.py -N 5 -M 3
# BUG python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopMnodeCreateStb.py -N 5 -M 3
# python3 ./test.py -f 6-cluster/5dnode3mnodeSep1VnodeStopVnodeCreateStb.py -N 5 -M 3
...
...
tests/test/c/tmqSim.c
浏览文件 @
f249bae8
...
...
@@ -36,6 +36,7 @@
#define MAX_CONSUMER_THREAD_CNT (16)
#define MAX_VGROUP_CNT (32)
int64_t
now
;
typedef
enum
{
NOTIFY_CMD_START_CONSUM
,
NOTIFY_CMD_START_COMMIT
,
...
...
@@ -525,15 +526,15 @@ int32_t notifyMainScript(SThreadInfo* pInfo, int32_t cmdId) {
static
int32_t
g_once_commit_flag
=
0
;
static
void
tmq_commit_cb_print
(
tmq_t
*
tmq
,
int32_t
code
,
void
*
param
)
{
pError
(
"tmq_commit_cb_print() commit %d
\n
"
,
code
);
pError
(
"tmq_commit_cb_print() commit %d
\n
"
,
code
);
if
(
0
==
g_once_commit_flag
)
{
g_once_commit_flag
=
1
;
notifyMainScript
((
SThreadInfo
*
)
param
,
(
int32_t
)
NOTIFY_CMD_START_COMMIT
);
if
(
0
==
g_once_commit_flag
)
{
g_once_commit_flag
=
1
;
notifyMainScript
((
SThreadInfo
*
)
param
,
(
int32_t
)
NOTIFY_CMD_START_COMMIT
);
}
char
tmpString
[
128
];
taosFprintfFile
(
g_fp
,
"%s tmq_commit_cb_print() be called
\n
"
,
getCurrentTimeString
(
tmpString
));
char
tmpString
[
128
];
taosFprintfFile
(
g_fp
,
"%s tmq_commit_cb_print() be called
\n
"
,
getCurrentTimeString
(
tmpString
));
}
void
build_consumer
(
SThreadInfo
*
pInfo
)
{
...
...
@@ -588,12 +589,10 @@ void build_topic_list(SThreadInfo* pInfo) {
int32_t
saveConsumeResult
(
SThreadInfo
*
pInfo
)
{
char
sqlStr
[
1024
]
=
{
0
};
int64_t
now
=
taosGetTimestampMs
();
// schema: ts timestamp, consumerid int, consummsgcnt bigint, checkresult int
sprintf
(
sqlStr
,
"insert into %s.consumeresult values (%"
PRId64
", %d, %"
PRId64
", %"
PRId64
", %d)"
,
g_stConfInfo
.
cdbName
,
now
,
pInfo
->
consumerId
,
pInfo
->
consumeMsgCnt
,
pInfo
->
consumeRowCnt
,
pInfo
->
checkresult
);
g_stConfInfo
.
cdbName
,
atomic_fetch_add_64
(
&
now
,
1
),
pInfo
->
consumerId
,
pInfo
->
consumeMsgCnt
,
pInfo
->
consumeRowCnt
,
pInfo
->
checkresult
);
char
tmpString
[
128
];
taosFprintfFile
(
g_fp
,
"%s, consume id %d result: %s
\n
"
,
getCurrentTimeString
(
tmpString
),
pInfo
->
consumerId
,
sqlStr
);
...
...
@@ -637,9 +636,9 @@ void loop_consume(SThreadInfo* pInfo) {
}
}
int64_t
lastTotalMsgs
=
0
;
uint64_t
lastPrintTime
=
taosGetTimestampMs
();
uint64_t
startTs
=
taosGetTimestampMs
();
int64_t
lastTotalMsgs
=
0
;
uint64_t
lastPrintTime
=
taosGetTimestampMs
();
uint64_t
startTs
=
taosGetTimestampMs
();
int32_t
consumeDelay
=
g_stConfInfo
.
consumeDelay
==
-
1
?
-
1
:
(
g_stConfInfo
.
consumeDelay
*
1000
);
while
(
running
)
{
...
...
@@ -652,16 +651,16 @@ void loop_consume(SThreadInfo* pInfo) {
taos_free_result
(
tmqMsg
);
totalMsgs
++
;
int64_t
currentPrintTime
=
taosGetTimestampMs
();
if
(
currentPrintTime
-
lastPrintTime
>
10
*
1000
)
{
taosFprintfFile
(
g_fp
,
"consumer id %d has currently poll total msgs: %"
PRId64
", period rate: %.3f msgs/second
\n
"
,
pInfo
->
consumerId
,
totalMsgs
,
(
totalMsgs
-
lastTotalMsgs
)
*
1000
.
0
/
(
currentPrintTime
-
lastPrintTime
));
lastPrintTime
=
currentPrintTime
;
lastTotalMsgs
=
totalMsgs
;
}
int64_t
currentPrintTime
=
taosGetTimestampMs
();
if
(
currentPrintTime
-
lastPrintTime
>
10
*
1000
)
{
taosFprintfFile
(
g_fp
,
"consumer id %d has currently poll total msgs: %"
PRId64
", period rate: %.3f msgs/second
\n
"
,
pInfo
->
consumerId
,
totalMsgs
,
(
totalMsgs
-
lastTotalMsgs
)
*
1000
.
0
/
(
currentPrintTime
-
lastPrintTime
));
lastPrintTime
=
currentPrintTime
;
lastTotalMsgs
=
totalMsgs
;
}
if
(
0
==
once_flag
)
{
once_flag
=
1
;
notifyMainScript
(
pInfo
,
NOTIFY_CMD_START_CONSUM
);
...
...
@@ -678,7 +677,7 @@ void loop_consume(SThreadInfo* pInfo) {
break
;
}
}
if
(
0
==
running
)
{
taosFprintfFile
(
g_fp
,
"receive stop signal and not continue consume
\n
"
);
}
...
...
@@ -696,6 +695,7 @@ void* consumeThreadFunc(void* param) {
pInfo
->
taos
=
taos_connect
(
NULL
,
"root"
,
"taosdata"
,
NULL
,
0
);
if
(
pInfo
->
taos
==
NULL
)
{
taosFprintfFile
(
g_fp
,
"taos_connect() fail, can not notify and save consume result to main scripte
\n
"
);
ASSERT
(
0
);
return
NULL
;
}
...
...
@@ -855,6 +855,8 @@ int32_t getConsumeInfo() {
}
int
main
(
int32_t
argc
,
char
*
argv
[])
{
now
=
taosGetTimestampMs
();
parseArgument
(
argc
,
argv
);
getConsumeInfo
();
saveConfigToLogFile
();
...
...
@@ -888,11 +890,11 @@ int main(int32_t argc, char* argv[]) {
int64_t
t
=
end
-
start
;
if
(
0
==
t
)
t
=
1
;
double
tInMs
=
(
double
)
t
/
1000000
.
0
;
taosFprintfFile
(
g_fp
,
"Spent %.3f seconds to poll msgs: %"
PRIu64
" with %d thread(s), throughput: %.3f msgs/second
\n\n
"
,
tInMs
,
totalMsgs
,
g_stConfInfo
.
numOfThread
,
(
double
)(
totalMsgs
/
tInMs
));
"Spent %.3f seconds to poll msgs: %"
PRIu64
" with %d thread(s), throughput: %.3f msgs/second
\n\n
"
,
tInMs
,
totalMsgs
,
g_stConfInfo
.
numOfThread
,
(
double
)(
totalMsgs
/
tInMs
));
taosFprintfFile
(
g_fp
,
"==== close tmqlog ====
\n
"
);
taosCloseFile
(
&
g_fp
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录