Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
33525deb
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
33525deb
编写于
7月 02, 2022
作者:
P
plum-lihui
浏览文件
操作
浏览文件
下载
差异文件
Merge branch '3.0' into test3.0/lihui
上级
86622ddd
cee7f41b
变更
52
展开全部
隐藏空白更改
内联
并排
Showing
52 changed file
with
1672 addition
and
812 deletion
+1672
-812
include/os/osMath.h
include/os/osMath.h
+6
-0
include/os/osString.h
include/os/osString.h
+1
-1
include/util/taoserror.h
include/util/taoserror.h
+1
-0
source/dnode/mgmt/mgmt_vnode/src/vmInt.c
source/dnode/mgmt/mgmt_vnode/src/vmInt.c
+4
-2
source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
+3
-3
source/dnode/mnode/impl/inc/mndDef.h
source/dnode/mnode/impl/inc/mndDef.h
+1
-1
source/dnode/mnode/impl/inc/mndStream.h
source/dnode/mnode/impl/inc/mndStream.h
+2
-0
source/dnode/mnode/impl/src/mndDb.c
source/dnode/mnode/impl/src/mndDb.c
+2
-1
source/dnode/mnode/impl/src/mndDef.c
source/dnode/mnode/impl/src/mndDef.c
+2
-2
source/dnode/mnode/impl/src/mndSma.c
source/dnode/mnode/impl/src/mndSma.c
+10
-19
source/dnode/mnode/impl/src/mndStream.c
source/dnode/mnode/impl/src/mndStream.c
+9
-6
source/dnode/mnode/impl/src/mndTrans.c
source/dnode/mnode/impl/src/mndTrans.c
+5
-4
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/tq/tqSink.c
source/dnode/vnode/src/tq/tqSink.c
+3
-1
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
+5
-4
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
+5
-2
source/libs/executor/src/timewindowoperator.c
source/libs/executor/src/timewindowoperator.c
+19
-14
source/libs/function/src/builtins.c
source/libs/function/src/builtins.c
+210
-147
source/libs/index/CMakeLists.txt
source/libs/index/CMakeLists.txt
+3
-3
source/os/src/osString.c
source/os/src/osString.c
+1
-1
source/util/src/terror.c
source/util/src/terror.c
+2
-0
tests/script/jenkins/basic.txt
tests/script/jenkins/basic.txt
+2
-0
tests/script/sh/deploy.sh
tests/script/sh/deploy.sh
+1
-1
tests/script/tsim/sma/drop_sma.sim
tests/script/tsim/sma/drop_sma.sim
+52
-5
tests/script/tsim/stream/distributeInterval0.sim
tests/script/tsim/stream/distributeInterval0.sim
+1
-1
tests/script/tsim/stream/distributeSession0.sim
tests/script/tsim/stream/distributeSession0.sim
+24
-0
tests/script/tsim/stream/drop_stream.sim
tests/script/tsim/stream/drop_stream.sim
+222
-0
tests/script/tsim/stream/ignoreExpiredData.sim
tests/script/tsim/stream/ignoreExpiredData.sim
+161
-0
tests/script/tsim/tmq/snapshot1.sim
tests/script/tsim/tmq/snapshot1.sim
+1
-1
tests/system-test/2-query/Timediff.py
tests/system-test/2-query/Timediff.py
+21
-21
tests/system-test/2-query/elapsed.py
tests/system-test/2-query/elapsed.py
+105
-106
tests/system-test/2-query/function_stateduration.py
tests/system-test/2-query/function_stateduration.py
+33
-34
tests/system-test/2-query/json_tag.py
tests/system-test/2-query/json_tag.py
+1
-1
tests/system-test/2-query/statecount.py
tests/system-test/2-query/statecount.py
+43
-44
tests/system-test/2-query/timetruncate.py
tests/system-test/2-query/timetruncate.py
+12
-12
tests/system-test/7-tmq/tmqConsFromTsdb.py
tests/system-test/7-tmq/tmqConsFromTsdb.py
+48
-200
tests/system-test/7-tmq/tmqConsFromTsdb1.py
tests/system-test/7-tmq/tmqConsFromTsdb1.py
+241
-0
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/os/osMath.h
浏览文件 @
33525deb
...
@@ -20,6 +20,12 @@
...
@@ -20,6 +20,12 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
// If the error is in a third-party library, place this header file under the third-party library header file.
// When you want to use this feature, you should find or add the same function in the following sectio
#ifndef ALLOW_FORBID_FUNC
#define qsort QSORT_FUNC_TAOS_FORBID
#endif
#define TPOW2(x) ((x) * (x))
#define TPOW2(x) ((x) * (x))
#define TABS(x) ((x) > 0 ? (x) : -(x))
#define TABS(x) ((x) > 0 ? (x) : -(x))
...
...
include/os/osString.h
浏览文件 @
33525deb
...
@@ -67,7 +67,7 @@ bool taosMbsToUcs4(const char *mbs, size_t mbs_len, TdUcs4 *ucs4, int32_t ucs
...
@@ -67,7 +67,7 @@ bool taosMbsToUcs4(const char *mbs, size_t mbs_len, TdUcs4 *ucs4, int32_t ucs
int32_t
tasoUcs4Compare
(
TdUcs4
*
f1_ucs4
,
TdUcs4
*
f2_ucs4
,
int32_t
bytes
);
int32_t
tasoUcs4Compare
(
TdUcs4
*
f1_ucs4
,
TdUcs4
*
f2_ucs4
,
int32_t
bytes
);
TdUcs4
*
tasoUcs4Copy
(
TdUcs4
*
target_ucs4
,
TdUcs4
*
source_ucs4
,
int32_t
len_ucs4
);
TdUcs4
*
tasoUcs4Copy
(
TdUcs4
*
target_ucs4
,
TdUcs4
*
source_ucs4
,
int32_t
len_ucs4
);
bool
taosValidateEncodec
(
const
char
*
encodec
);
bool
taosValidateEncodec
(
const
char
*
encodec
);
int32_t
taosHexEncode
(
const
char
*
src
,
char
*
dst
,
int32_t
len
);
int32_t
taosHexEncode
(
const
unsigned
char
*
src
,
char
*
dst
,
int32_t
len
);
int32_t
taosHexDecode
(
const
char
*
src
,
char
*
dst
,
int32_t
len
);
int32_t
taosHexDecode
(
const
char
*
src
,
char
*
dst
,
int32_t
len
);
int32_t
taosWcharWidth
(
TdWchar
wchar
);
int32_t
taosWcharWidth
(
TdWchar
wchar
);
...
...
include/util/taoserror.h
浏览文件 @
33525deb
...
@@ -623,6 +623,7 @@ int32_t* taosGetErrno();
...
@@ -623,6 +623,7 @@ int32_t* taosGetErrno();
#define TSDB_CODE_RSMA_INVALID_ENV TAOS_DEF_ERROR_CODE(0, 0x3150)
#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_INVALID_STAT TAOS_DEF_ERROR_CODE(0, 0x3151)
#define TSDB_CODE_RSMA_QTASKINFO_CREATE TAOS_DEF_ERROR_CODE(0, 0x3152)
#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
//index
#define TSDB_CODE_INDEX_REBUILDING TAOS_DEF_ERROR_CODE(0, 0x3200)
#define TSDB_CODE_INDEX_REBUILDING TAOS_DEF_ERROR_CODE(0, 0x3200)
...
...
source/dnode/mgmt/mgmt_vnode/src/vmInt.c
浏览文件 @
33525deb
...
@@ -21,7 +21,7 @@ SVnodeObj *vmAcquireVnode(SVnodeMgmt *pMgmt, int32_t vgId) {
...
@@ -21,7 +21,7 @@ SVnodeObj *vmAcquireVnode(SVnodeMgmt *pMgmt, int32_t vgId) {
taosThreadRwlockRdlock
(
&
pMgmt
->
lock
);
taosThreadRwlockRdlock
(
&
pMgmt
->
lock
);
taosHashGetDup
(
pMgmt
->
hash
,
&
vgId
,
sizeof
(
int32_t
),
(
void
*
)
&
pVnode
);
taosHashGetDup
(
pMgmt
->
hash
,
&
vgId
,
sizeof
(
int32_t
),
(
void
*
)
&
pVnode
);
if
(
pVnode
==
NULL
)
{
if
(
pVnode
==
NULL
||
pVnode
->
dropped
)
{
terrno
=
TSDB_CODE_VND_INVALID_VGROUP_ID
;
terrno
=
TSDB_CODE_VND_INVALID_VGROUP_ID
;
}
else
{
}
else
{
int32_t
refCount
=
atomic_add_fetch_32
(
&
pVnode
->
refCount
,
1
);
int32_t
refCount
=
atomic_add_fetch_32
(
&
pVnode
->
refCount
,
1
);
...
@@ -81,16 +81,18 @@ void vmCloseVnode(SVnodeMgmt *pMgmt, SVnodeObj *pVnode) {
...
@@ -81,16 +81,18 @@ void vmCloseVnode(SVnodeMgmt *pMgmt, SVnodeObj *pVnode) {
vmReleaseVnode
(
pMgmt
,
pVnode
);
vmReleaseVnode
(
pMgmt
,
pVnode
);
while
(
pVnode
->
refCount
>
0
)
taosMsleep
(
10
);
while
(
pVnode
->
refCount
>
0
)
taosMsleep
(
10
);
dTrace
(
"vgId:%d, wait for vnode queue is empty"
,
pVnode
->
vgId
);
while
(
!
taosQueueEmpty
(
pVnode
->
pWriteQ
))
taosMsleep
(
10
);
while
(
!
taosQueueEmpty
(
pVnode
->
pWriteQ
))
taosMsleep
(
10
);
while
(
!
taosQueueEmpty
(
pVnode
->
pSyncQ
))
taosMsleep
(
10
);
while
(
!
taosQueueEmpty
(
pVnode
->
pSyncQ
))
taosMsleep
(
10
);
while
(
!
taosQueueEmpty
(
pVnode
->
pApplyQ
))
taosMsleep
(
10
);
while
(
!
taosQueueEmpty
(
pVnode
->
pApplyQ
))
taosMsleep
(
10
);
while
(
!
taosQueueEmpty
(
pVnode
->
pQueryQ
))
taosMsleep
(
10
);
while
(
!
taosQueueEmpty
(
pVnode
->
pQueryQ
))
taosMsleep
(
10
);
while
(
!
taosQueueEmpty
(
pVnode
->
pFetchQ
))
taosMsleep
(
10
);
while
(
!
taosQueueEmpty
(
pVnode
->
pFetchQ
))
taosMsleep
(
10
);
dTrace
(
"vgId:%d, vnode-fetch queue is empty"
,
pVnode
->
vgId
);
vmFreeQueue
(
pMgmt
,
pVnode
);
vmFreeQueue
(
pMgmt
,
pVnode
);
vnodeClose
(
pVnode
->
pImpl
);
vnodeClose
(
pVnode
->
pImpl
);
pVnode
->
pImpl
=
NULL
;
pVnode
->
pImpl
=
NULL
;
dDebug
(
"vgId:%d, vnode is closed"
,
pVnode
->
vgId
);
dDebug
(
"vgId:%d, vnode is closed"
,
pVnode
->
vgId
);
if
(
pVnode
->
dropped
)
{
if
(
pVnode
->
dropped
)
{
...
...
source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
浏览文件 @
33525deb
...
@@ -107,7 +107,7 @@ static void vmProcessSyncQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numOf
...
@@ -107,7 +107,7 @@ static void vmProcessSyncQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numOf
const
STraceId
*
trace
=
&
pMsg
->
info
.
traceId
;
const
STraceId
*
trace
=
&
pMsg
->
info
.
traceId
;
dGTrace
(
"vgId:%d, msg:%p get from vnode-sync queue"
,
pVnode
->
vgId
,
pMsg
);
dGTrace
(
"vgId:%d, msg:%p get from vnode-sync queue"
,
pVnode
->
vgId
,
pMsg
);
int32_t
code
=
vnodeProcessSyncReq
(
pVnode
->
pImpl
,
pMsg
,
NULL
);
// no response here
int32_t
code
=
vnodeProcessSyncReq
(
pVnode
->
pImpl
,
pMsg
,
NULL
);
// no response here
dGTrace
(
"vgId:%d, msg:%p is freed, code:0x%x"
,
pVnode
->
vgId
,
pMsg
,
code
);
dGTrace
(
"vgId:%d, msg:%p is freed, code:0x%x"
,
pVnode
->
vgId
,
pMsg
,
code
);
rpcFreeCont
(
pMsg
->
pCont
);
rpcFreeCont
(
pMsg
->
pCont
);
taosFreeQitem
(
pMsg
);
taosFreeQitem
(
pMsg
);
...
@@ -146,8 +146,8 @@ static int32_t vmPutMsgToQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg, EQueueType qtyp
...
@@ -146,8 +146,8 @@ static int32_t vmPutMsgToQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg, EQueueType qtyp
SVnodeObj
*
pVnode
=
vmAcquireVnode
(
pMgmt
,
pHead
->
vgId
);
SVnodeObj
*
pVnode
=
vmAcquireVnode
(
pMgmt
,
pHead
->
vgId
);
if
(
pVnode
==
NULL
)
{
if
(
pVnode
==
NULL
)
{
dGError
(
"vgId:%d, msg:%p failed to put into vnode queue since %s,
type:%s"
,
pHead
->
vgId
,
pMsg
,
terrstr
()
,
dGError
(
"vgId:%d, msg:%p failed to put into vnode queue since %s,
msgtype:%s qtype:%d"
,
pHead
->
vgId
,
pMsg
,
TMSG_INFO
(
pMsg
->
msgType
)
);
terrstr
(),
TMSG_INFO
(
pMsg
->
msgType
),
qtype
);
return
terrno
!=
0
?
terrno
:
-
1
;
return
terrno
!=
0
?
terrno
:
-
1
;
}
}
...
...
source/dnode/mnode/impl/inc/mndDef.h
浏览文件 @
33525deb
...
@@ -556,7 +556,7 @@ typedef struct {
...
@@ -556,7 +556,7 @@ typedef struct {
int64_t
uid
;
int64_t
uid
;
int8_t
status
;
int8_t
status
;
// config
// config
int8_t
dropPolicy
;
int8_t
igExpired
;
int8_t
trigger
;
int8_t
trigger
;
int64_t
triggerParam
;
int64_t
triggerParam
;
int64_t
watermark
;
int64_t
watermark
;
...
...
source/dnode/mnode/impl/inc/mndStream.h
浏览文件 @
33525deb
...
@@ -38,6 +38,8 @@ int32_t mndPersistStream(SMnode *pMnode, STrans *pTrans, SStreamObj *pStream);
...
@@ -38,6 +38,8 @@ int32_t mndPersistStream(SMnode *pMnode, STrans *pTrans, SStreamObj *pStream);
int32_t
mndDropStreamTasks
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SStreamObj
*
pStream
);
int32_t
mndDropStreamTasks
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SStreamObj
*
pStream
);
int32_t
mndPersistDropStreamLog
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SStreamObj
*
pStream
);
int32_t
mndPersistDropStreamLog
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SStreamObj
*
pStream
);
int32_t
mndDropStreamByDb
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pDb
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
source/dnode/mnode/impl/src/mndDb.c
浏览文件 @
33525deb
...
@@ -21,6 +21,7 @@
...
@@ -21,6 +21,7 @@
#include "mndShow.h"
#include "mndShow.h"
#include "mndSma.h"
#include "mndSma.h"
#include "mndStb.h"
#include "mndStb.h"
#include "mndStream.h"
#include "mndSubscribe.h"
#include "mndSubscribe.h"
#include "mndTopic.h"
#include "mndTopic.h"
#include "mndTrans.h"
#include "mndTrans.h"
...
@@ -927,6 +928,7 @@ static int32_t mndDropDb(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb) {
...
@@ -927,6 +928,7 @@ static int32_t mndDropDb(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb) {
if
(
mndDropOffsetByDB
(
pMnode
,
pTrans
,
pDb
)
!=
0
)
goto
_OVER
;
if
(
mndDropOffsetByDB
(
pMnode
,
pTrans
,
pDb
)
!=
0
)
goto
_OVER
;
if
(
mndDropSubByDB
(
pMnode
,
pTrans
,
pDb
)
!=
0
)
goto
_OVER
;
if
(
mndDropSubByDB
(
pMnode
,
pTrans
,
pDb
)
!=
0
)
goto
_OVER
;
if
(
mndDropTopicByDB
(
pMnode
,
pTrans
,
pDb
)
!=
0
)
goto
_OVER
;
if
(
mndDropTopicByDB
(
pMnode
,
pTrans
,
pDb
)
!=
0
)
goto
_OVER
;
if
(
mndDropStreamByDb
(
pMnode
,
pTrans
,
pDb
)
!=
0
)
goto
_OVER
;
if
(
mndDropSmasByDb
(
pMnode
,
pTrans
,
pDb
)
!=
0
)
goto
_OVER
;
if
(
mndDropSmasByDb
(
pMnode
,
pTrans
,
pDb
)
!=
0
)
goto
_OVER
;
if
(
mndSetDropDbRedoActions
(
pMnode
,
pTrans
,
pDb
)
!=
0
)
goto
_OVER
;
if
(
mndSetDropDbRedoActions
(
pMnode
,
pTrans
,
pDb
)
!=
0
)
goto
_OVER
;
...
@@ -947,7 +949,6 @@ static int32_t mndDropDb(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb) {
...
@@ -947,7 +949,6 @@ static int32_t mndDropDb(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb) {
mndTransSetRpcRsp
(
pTrans
,
pRsp
,
rspLen
);
mndTransSetRpcRsp
(
pTrans
,
pRsp
,
rspLen
);
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
goto
_OVER
;
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
goto
_OVER
;
code
=
0
;
code
=
0
;
_OVER:
_OVER:
...
...
source/dnode/mnode/impl/src/mndDef.c
浏览文件 @
33525deb
...
@@ -28,7 +28,7 @@ int32_t tEncodeSStreamObj(SEncoder *pEncoder, const SStreamObj *pObj) {
...
@@ -28,7 +28,7 @@ int32_t tEncodeSStreamObj(SEncoder *pEncoder, const SStreamObj *pObj) {
if
(
tEncodeI64
(
pEncoder
,
pObj
->
uid
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
pEncoder
,
pObj
->
uid
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pEncoder
,
pObj
->
status
)
<
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
(
tEncodeI8
(
pEncoder
,
pObj
->
trigger
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
pEncoder
,
pObj
->
triggerParam
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
pEncoder
,
pObj
->
triggerParam
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
pEncoder
,
pObj
->
watermark
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
pEncoder
,
pObj
->
watermark
)
<
0
)
return
-
1
;
...
@@ -73,7 +73,7 @@ int32_t tDecodeSStreamObj(SDecoder *pDecoder, SStreamObj *pObj) {
...
@@ -73,7 +73,7 @@ int32_t tDecodeSStreamObj(SDecoder *pDecoder, SStreamObj *pObj) {
if
(
tDecodeI64
(
pDecoder
,
&
pObj
->
uid
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
pDecoder
,
&
pObj
->
uid
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pDecoder
,
&
pObj
->
status
)
<
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
(
tDecodeI8
(
pDecoder
,
&
pObj
->
trigger
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
pDecoder
,
&
pObj
->
triggerParam
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
pDecoder
,
&
pObj
->
triggerParam
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
pDecoder
,
&
pObj
->
watermark
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
pDecoder
,
&
pObj
->
watermark
)
<
0
)
return
-
1
;
...
...
source/dnode/mnode/impl/src/mndSma.c
浏览文件 @
33525deb
...
@@ -523,6 +523,7 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea
...
@@ -523,6 +523,7 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea
streamObj
.
updateTime
=
streamObj
.
createTime
;
streamObj
.
updateTime
=
streamObj
.
createTime
;
streamObj
.
uid
=
mndGenerateUid
(
pCreate
->
name
,
strlen
(
pCreate
->
name
));
streamObj
.
uid
=
mndGenerateUid
(
pCreate
->
name
,
strlen
(
pCreate
->
name
));
streamObj
.
sourceDbUid
=
pDb
->
uid
;
streamObj
.
sourceDbUid
=
pDb
->
uid
;
streamObj
.
targetDbUid
=
pDb
->
uid
;
streamObj
.
version
=
1
;
streamObj
.
version
=
1
;
streamObj
.
sql
=
pCreate
->
sql
;
streamObj
.
sql
=
pCreate
->
sql
;
streamObj
.
smaId
=
smaObj
.
uid
;
streamObj
.
smaId
=
smaObj
.
uid
;
...
@@ -853,36 +854,26 @@ _OVER:
...
@@ -853,36 +854,26 @@ _OVER:
}
}
int32_t
mndDropSmasByDb
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pDb
)
{
int32_t
mndDropSmasByDb
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pDb
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SSmaObj
*
pSma
=
NULL
;
void
*
pIter
=
NULL
;
void
*
pIter
=
NULL
;
SVgObj
*
pVgroup
=
NULL
;
int32_t
code
=
-
1
;
while
(
1
)
{
while
(
1
)
{
SSmaObj
*
pSma
=
NULL
;
pIter
=
sdbFetch
(
pSdb
,
SDB_SMA
,
pIter
,
(
void
**
)
&
pSma
);
pIter
=
sdbFetch
(
pSdb
,
SDB_SMA
,
pIter
,
(
void
**
)
&
pSma
);
if
(
pIter
==
NULL
)
break
;
if
(
pIter
==
NULL
)
break
;
if
(
pSma
->
dbUid
==
pDb
->
uid
)
{
if
(
pSma
->
dbUid
==
pDb
->
uid
)
{
pVgroup
=
mndAcquireVgroup
(
pMnode
,
pSma
->
dstVgId
);
if
(
mndSetDropSmaCommitLogs
(
pMnode
,
pTrans
,
pSma
)
!=
0
)
{
if
(
pVgroup
==
NULL
)
goto
_OVER
;
sdbRelease
(
pSdb
,
pSma
);
if
(
mndSetDropSmaVgroupCommitLogs
(
pMnode
,
pTrans
,
pVgroup
)
!=
0
)
goto
_OVER
;
sdbCancelFetch
(
pSdb
,
pSma
);
if
(
mndSetDropSmaVgroupRedoActions
(
pMnode
,
pTrans
,
pDb
,
pVgroup
)
!=
0
)
goto
_OVER
;
return
-
1
;
if
(
mndSetDropSmaCommitLogs
(
pMnode
,
pTrans
,
pSma
)
!=
0
)
goto
_OVER
;
}
mndReleaseVgroup
(
pMnode
,
pVgroup
);
pVgroup
=
NULL
;
}
}
sdbRelease
(
pSdb
,
pSma
);
sdbRelease
(
pSdb
,
pSma
);
}
}
code
=
0
;
return
0
;
_OVER:
sdbCancelFetch
(
pSdb
,
pIter
);
sdbRelease
(
pSdb
,
pSma
);
mndReleaseVgroup
(
pMnode
,
pVgroup
);
return
code
;
}
}
static
int32_t
mndProcessDropSmaReq
(
SRpcMsg
*
pReq
)
{
static
int32_t
mndProcessDropSmaReq
(
SRpcMsg
*
pReq
)
{
...
...
source/dnode/mnode/impl/src/mndStream.c
浏览文件 @
33525deb
...
@@ -248,7 +248,7 @@ static int32_t mndBuildStreamObjFromCreateReq(SMnode *pMnode, SStreamObj *pObj,
...
@@ -248,7 +248,7 @@ static int32_t mndBuildStreamObjFromCreateReq(SMnode *pMnode, SStreamObj *pObj,
pObj
->
status
=
0
;
pObj
->
status
=
0
;
// TODO
// TODO
pObj
->
dropPolicy
=
0
;
pObj
->
igExpired
=
pCreate
->
igExpired
;
pObj
->
trigger
=
pCreate
->
triggerType
;
pObj
->
trigger
=
pCreate
->
triggerType
;
pObj
->
triggerParam
=
pCreate
->
maxDelay
;
pObj
->
triggerParam
=
pCreate
->
maxDelay
;
pObj
->
watermark
=
pCreate
->
watermark
;
pObj
->
watermark
=
pCreate
->
watermark
;
...
@@ -301,6 +301,7 @@ static int32_t mndBuildStreamObjFromCreateReq(SMnode *pMnode, SStreamObj *pObj,
...
@@ -301,6 +301,7 @@ static int32_t mndBuildStreamObjFromCreateReq(SMnode *pMnode, SStreamObj *pObj,
.
streamQuery
=
true
,
.
streamQuery
=
true
,
.
triggerType
=
pObj
->
trigger
==
STREAM_TRIGGER_MAX_DELAY
?
STREAM_TRIGGER_WINDOW_CLOSE
:
pObj
->
trigger
,
.
triggerType
=
pObj
->
trigger
==
STREAM_TRIGGER_MAX_DELAY
?
STREAM_TRIGGER_WINDOW_CLOSE
:
pObj
->
trigger
,
.
watermark
=
pObj
->
watermark
,
.
watermark
=
pObj
->
watermark
,
.
igExpired
=
pObj
->
igExpired
,
};
};
// using ast and param to build physical plan
// using ast and param to build physical plan
...
@@ -673,27 +674,29 @@ static int32_t mndProcessDropStreamReq(SRpcMsg *pReq) {
...
@@ -673,27 +674,29 @@ static int32_t mndProcessDropStreamReq(SRpcMsg *pReq) {
int32_t
mndDropStreamByDb
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pDb
)
{
int32_t
mndDropStreamByDb
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pDb
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
void
*
pIter
=
NULL
;
void
*
pIter
=
NULL
;
SStreamObj
*
pStream
=
NULL
;
while
(
1
)
{
while
(
1
)
{
SStreamObj
*
pStream
=
NULL
;
pIter
=
sdbFetch
(
pSdb
,
SDB_STREAM
,
pIter
,
(
void
**
)
&
pStream
);
pIter
=
sdbFetch
(
pSdb
,
SDB_STREAM
,
pIter
,
(
void
**
)
&
pStream
);
if
(
pIter
==
NULL
)
break
;
if
(
pIter
==
NULL
)
break
;
if
(
pStream
->
sourceDbUid
==
pDb
->
uid
||
pStream
->
targetDbUid
==
pDb
->
uid
)
{
if
(
pStream
->
sourceDbUid
==
pDb
->
uid
||
pStream
->
targetDbUid
==
pDb
->
uid
)
{
if
(
pStream
->
sourceDbUid
!=
pStream
->
targetDbUid
)
{
if
(
pStream
->
sourceDbUid
!=
pStream
->
targetDbUid
)
{
sdbRelease
(
pSdb
,
pStream
);
sdbRelease
(
pSdb
,
pStream
);
sdbCancelFetch
(
pSdb
,
pIter
);
mError
(
"db:%s, failed to drop stream:%s since sourceDbUid:%"
PRId64
" not match with targetDbUid:%"
PRId64
,
pDb
->
name
,
pStream
->
name
,
pStream
->
sourceDbUid
,
pStream
->
targetDbUid
);
terrno
=
TSDB_CODE_MND_STREAM_ALREADY_EXIST
;
return
-
1
;
return
-
1
;
}
else
{
}
else
{
// TODO drop all task on snode
// TODO drop all task on snode
if
(
mndPersistDropStreamLog
(
pMnode
,
pTrans
,
pStream
)
<
0
)
{
if
(
mndPersistDropStreamLog
(
pMnode
,
pTrans
,
pStream
)
<
0
)
{
sdbRelease
(
pSdb
,
pStream
);
sdbRelease
(
pSdb
,
pStream
);
sdbCancelFetch
(
pSdb
,
pIter
);
return
-
1
;
return
-
1
;
}
}
}
}
}
else
{
sdbRelease
(
pSdb
,
pStream
);
continue
;
}
}
#if 0
#if 0
...
...
source/dnode/mnode/impl/src/mndTrans.c
浏览文件 @
33525deb
...
@@ -90,7 +90,7 @@ static int32_t mndTransGetActionsSize(SArray *pArray) {
...
@@ -90,7 +90,7 @@ static int32_t mndTransGetActionsSize(SArray *pArray) {
for
(
int32_t
i
=
0
;
i
<
actionNum
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
actionNum
;
++
i
)
{
STransAction
*
pAction
=
taosArrayGet
(
pArray
,
i
);
STransAction
*
pAction
=
taosArrayGet
(
pArray
,
i
);
if
(
pAction
->
actionType
==
TRANS_ACTION_RAW
)
{
if
(
pAction
->
actionType
==
TRANS_ACTION_RAW
)
{
rawDataLen
+=
(
s
dbGetRawTotalSize
(
pAction
->
pRaw
)
+
sizeof
(
int32_t
));
rawDataLen
+=
(
s
izeof
(
STransAction
)
+
sdbGetRawTotalSize
(
pAction
->
pRaw
));
}
else
if
(
pAction
->
actionType
==
TRANS_ACTION_MSG
)
{
}
else
if
(
pAction
->
actionType
==
TRANS_ACTION_MSG
)
{
rawDataLen
+=
(
sizeof
(
STransAction
)
+
pAction
->
contLen
);
rawDataLen
+=
(
sizeof
(
STransAction
)
+
pAction
->
contLen
);
}
else
{
}
else
{
...
@@ -105,7 +105,7 @@ static int32_t mndTransGetActionsSize(SArray *pArray) {
...
@@ -105,7 +105,7 @@ static int32_t mndTransGetActionsSize(SArray *pArray) {
static
SSdbRaw
*
mndTransActionEncode
(
STrans
*
pTrans
)
{
static
SSdbRaw
*
mndTransActionEncode
(
STrans
*
pTrans
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
int32_t
rawDataLen
=
sizeof
(
STrans
)
+
TRANS_RESERVE_SIZE
;
int32_t
rawDataLen
=
sizeof
(
STrans
)
+
TRANS_RESERVE_SIZE
+
pTrans
->
paramLen
;
rawDataLen
+=
mndTransGetActionsSize
(
pTrans
->
redoActions
);
rawDataLen
+=
mndTransGetActionsSize
(
pTrans
->
redoActions
);
rawDataLen
+=
mndTransGetActionsSize
(
pTrans
->
undoActions
);
rawDataLen
+=
mndTransGetActionsSize
(
pTrans
->
undoActions
);
rawDataLen
+=
mndTransGetActionsSize
(
pTrans
->
commitActions
);
rawDataLen
+=
mndTransGetActionsSize
(
pTrans
->
commitActions
);
...
@@ -226,7 +226,8 @@ static SSdbRaw *mndTransActionEncode(STrans *pTrans) {
...
@@ -226,7 +226,8 @@ static SSdbRaw *mndTransActionEncode(STrans *pTrans) {
_OVER:
_OVER:
if
(
terrno
!=
0
)
{
if
(
terrno
!=
0
)
{
mError
(
"trans:%d, failed to encode to raw:%p len:%d since %s"
,
pTrans
->
id
,
pRaw
,
dataPos
,
terrstr
());
mError
(
"trans:%d, failed to encode to raw:%p maxlen:%d len:%d since %s"
,
pTrans
->
id
,
pRaw
,
sdbGetRawTotalSize
(
pRaw
),
dataPos
,
terrstr
());
sdbFreeRaw
(
pRaw
);
sdbFreeRaw
(
pRaw
);
return
NULL
;
return
NULL
;
}
}
...
@@ -1025,7 +1026,7 @@ static int32_t mndTransExecNullMsg(SMnode *pMnode, STrans *pTrans, STransAction
...
@@ -1025,7 +1026,7 @@ static int32_t mndTransExecNullMsg(SMnode *pMnode, STrans *pTrans, STransAction
pTrans
->
lastAction
=
pAction
->
id
;
pTrans
->
lastAction
=
pAction
->
id
;
pTrans
->
lastMsgType
=
pAction
->
msgType
;
pTrans
->
lastMsgType
=
pAction
->
msgType
;
pTrans
->
lastEpset
=
pAction
->
epSet
;
pTrans
->
lastEpset
=
pAction
->
epSet
;
pTrans
->
lastErrorNo
=
=
0
;
pTrans
->
lastErrorNo
=
0
;
return
0
;
return
0
;
}
}
...
...
source/dnode/vnode/CMakeLists.txt
浏览文件 @
33525deb
...
@@ -31,6 +31,8 @@ target_sources(
...
@@ -31,6 +31,8 @@ target_sources(
"src/sma/smaEnv.c"
"src/sma/smaEnv.c"
"src/sma/smaUtil.c"
"src/sma/smaUtil.c"
"src/sma/smaOpen.c"
"src/sma/smaOpen.c"
"src/sma/smaCommit.c"
"src/sma/smaSnapshot.c"
"src/sma/smaRollup.c"
"src/sma/smaRollup.c"
"src/sma/smaTimeRange.c"
"src/sma/smaTimeRange.c"
...
...
source/dnode/vnode/src/inc/sma.h
浏览文件 @
33525deb
...
@@ -92,8 +92,9 @@ enum {
...
@@ -92,8 +92,9 @@ enum {
TASK_TRIGGER_STAT_INIT
=
0
,
TASK_TRIGGER_STAT_INIT
=
0
,
TASK_TRIGGER_STAT_ACTIVE
=
1
,
TASK_TRIGGER_STAT_ACTIVE
=
1
,
TASK_TRIGGER_STAT_INACTIVE
=
2
,
TASK_TRIGGER_STAT_INACTIVE
=
2
,
TASK_TRIGGER_STAT_CANCELLED
=
3
,
TASK_TRIGGER_STAT_PAUSED
=
3
,
TASK_TRIGGER_STAT_FINISHED
=
4
,
TASK_TRIGGER_STAT_CANCELLED
=
4
,
TASK_TRIGGER_STAT_FINISHED
=
5
,
};
};
void
tdDestroySmaEnv
(
SSmaEnv
*
pSmaEnv
);
void
tdDestroySmaEnv
(
SSmaEnv
*
pSmaEnv
);
void
*
tdFreeSmaEnv
(
SSmaEnv
*
pSmaEnv
);
void
*
tdFreeSmaEnv
(
SSmaEnv
*
pSmaEnv
);
...
@@ -214,25 +215,22 @@ struct STFInfo {
...
@@ -214,25 +215,22 @@ struct STFInfo {
};
};
struct
STFile
{
struct
STFile
{
uint8_t
state
;
STFInfo
info
;
STFInfo
info
;
STfsFile
f
;
char
*
fname
;
TdFilePtr
pFile
;
TdFilePtr
pFile
;
uint8_t
state
;
};
};
#define TD_TFILE_F(tf) (&((tf)->f))
#define TD_TFILE_PFILE(tf) ((tf)->pFile)
#define TD_TFILE_PFILE(tf) ((tf)->pFile)
#define TD_TFILE_OPENED(tf) (TD_TFILE_PFILE(tf) != NULL)
#define TD_TFILE_OPENED(tf) (TD_TFILE_PFILE(tf) != NULL)
#define TD_TFILE_FULL_NAME(tf) (TD_TFILE_F(tf)->aname)
#define TD_TFILE_FULL_NAME(tf) ((tf)->fname)
#define TD_TFILE_REL_NAME(tf) (TD_TFILE_F(tf)->rname)
#define TD_TFILE_OPENED(tf) (TD_TFILE_PFILE(tf) != NULL)
#define TD_TFILE_OPENED(tf) (TD_TFILE_PFILE(tf) != NULL)
#define TD_TFILE_CLOSED(tf) (!TD_TFILE_OPENED(tf))
#define TD_TFILE_CLOSED(tf) (!TD_TFILE_OPENED(tf))
#define TD_TFILE_SET_CLOSED(f) (TD_TFILE_PFILE(f) = NULL)
#define TD_TFILE_SET_CLOSED(f) (TD_TFILE_PFILE(f) = NULL)
#define TD_TFILE_SET_STATE(tf, s) ((tf)->state = (s))
#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
tdInitTFile
(
STFile
*
pTFile
,
const
char
*
dname
,
const
char
*
fname
);
int32_t
tdCreateTFile
(
STFile
*
pTFile
,
STfs
*
pTfs
,
bool
updateHeader
,
int8_t
fType
);
int32_t
tdCreateTFile
(
STFile
*
pTFile
,
bool
updateHeader
,
int8_t
fType
);
int32_t
tdOpenTFile
(
STFile
*
pTFile
,
int
flags
);
int32_t
tdOpenTFile
(
STFile
*
pTFile
,
int
flags
);
int64_t
tdReadTFile
(
STFile
*
pTFile
,
void
*
buf
,
int64_t
nbyte
);
int64_t
tdReadTFile
(
STFile
*
pTFile
,
void
*
buf
,
int64_t
nbyte
);
int64_t
tdSeekTFile
(
STFile
*
pTFile
,
int64_t
offset
,
int
whence
);
int64_t
tdSeekTFile
(
STFile
*
pTFile
,
int64_t
offset
,
int
whence
);
...
@@ -244,8 +242,10 @@ int32_t tdLoadTFileHeader(STFile *pTFile, STFInfo *pInfo);
...
@@ -244,8 +242,10 @@ int32_t tdLoadTFileHeader(STFile *pTFile, STFInfo *pInfo);
int32_t
tdUpdateTFileHeader
(
STFile
*
pTFile
);
int32_t
tdUpdateTFileHeader
(
STFile
*
pTFile
);
void
tdUpdateTFileMagic
(
STFile
*
pTFile
,
void
*
pCksm
);
void
tdUpdateTFileMagic
(
STFile
*
pTFile
,
void
*
pCksm
);
void
tdCloseTFile
(
STFile
*
pTFile
);
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
#ifdef __cplusplus
}
}
...
...
source/dnode/vnode/src/inc/vnodeInt.h
浏览文件 @
33525deb
...
@@ -165,6 +165,9 @@ SSubmitReq* tdBlockToSubmit(const SArray* pBlocks, const STSchema* pSchema, bool
...
@@ -165,6 +165,9 @@ SSubmitReq* tdBlockToSubmit(const SArray* pBlocks, const STSchema* pSchema, bool
int32_t
smaOpen
(
SVnode
*
pVnode
);
int32_t
smaOpen
(
SVnode
*
pVnode
);
int32_t
smaCloseEnv
(
SSma
*
pSma
);
int32_t
smaCloseEnv
(
SSma
*
pSma
);
int32_t
smaCloseEx
(
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
tdProcessTSmaCreate
(
SSma
*
pSma
,
int64_t
version
,
const
char
*
msg
);
int32_t
tdProcessTSmaInsert
(
SSma
*
pSma
,
int64_t
indexUid
,
const
char
*
msg
);
int32_t
tdProcessTSmaInsert
(
SSma
*
pSma
,
int64_t
indexUid
,
const
char
*
msg
);
...
...
source/dnode/vnode/src/sma/smaCommit.c
0 → 100644
浏览文件 @
33525deb
/*
* 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
浏览文件 @
33525deb
...
@@ -23,8 +23,7 @@ SSmaMgmt smaMgmt = {
...
@@ -23,8 +23,7 @@ SSmaMgmt smaMgmt = {
.
smaRef
=
-
1
,
.
smaRef
=
-
1
,
};
};
typedef
enum
{
TD_QTASK_TMP_F
=
0
,
TD_QTASK_CUR_F
}
TD_QTASK_FILE_T
;
#define TD_QTASKINFO_FNAME_PREFIX "qtaskinfo.ver"
static
const
char
*
tdQTaskInfoFname
[]
=
{
"qtaskinfo.t"
,
"qtaskinfo"
};
typedef
struct
SRSmaQTaskInfoItem
SRSmaQTaskInfoItem
;
typedef
struct
SRSmaQTaskInfoItem
SRSmaQTaskInfoItem
;
typedef
struct
SRSmaQTaskInfoIter
SRSmaQTaskInfoIter
;
typedef
struct
SRSmaQTaskInfoIter
SRSmaQTaskInfoIter
;
...
@@ -37,7 +36,7 @@ static int32_t tdExecuteRSmaImpl(SSma *pSma, const void *pMsg, int32_t inputType
...
@@ -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
tdRSmaFetchTrigger
(
void
*
param
,
void
*
tmrId
);
static
void
tdRSmaPersistTrigger
(
void
*
param
,
void
*
tmrId
);
static
void
tdRSmaPersistTrigger
(
void
*
param
,
void
*
tmrId
);
static
void
*
tdRSmaPersistExec
(
void
*
param
);
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
tdRSmaQTaskInfoIterInit
(
SRSmaQTaskInfoIter
*
pIter
,
STFile
*
pTFile
);
static
int32_t
tdRSmaQTaskInfoIterNextBlock
(
SRSmaQTaskInfoIter
*
pIter
,
bool
*
isFinish
);
static
int32_t
tdRSmaQTaskInfoIterNextBlock
(
SRSmaQTaskInfoIter
*
pIter
,
bool
*
isFinish
);
...
@@ -88,8 +87,8 @@ struct SRSmaQTaskInfoIter {
...
@@ -88,8 +87,8 @@ struct SRSmaQTaskInfoIter {
int32_t
nBufPos
;
int32_t
nBufPos
;
};
};
static
void
tdRSmaQTaskInfoGetFName
(
int32_t
vgId
,
int
8_t
ftype
,
char
*
outputName
)
{
static
void
tdRSmaQTaskInfoGetFName
(
int32_t
vgId
,
int
64_t
version
,
char
*
outputName
)
{
tdGetVndFileName
(
vgId
,
VNODE_RSMA_DIR
,
tdQTaskInfoFname
[
ftype
]
,
outputName
);
tdGetVndFileName
(
vgId
,
VNODE_RSMA_DIR
,
TD_QTASKINFO_FNAME_PREFIX
,
version
,
outputName
);
}
}
static
FORCE_INLINE
int32_t
tdRSmaQTaskInfoContLen
(
int32_t
lenWithHead
)
{
static
FORCE_INLINE
int32_t
tdRSmaQTaskInfoContLen
(
int32_t
lenWithHead
)
{
...
@@ -493,7 +492,6 @@ static int32_t tdProcessSubmitReq(STsdb *pTsdb, int64_t version, void *pReq) {
...
@@ -493,7 +492,6 @@ static int32_t tdProcessSubmitReq(STsdb *pTsdb, int64_t version, void *pReq) {
}
}
static
int32_t
tdFetchSubmitReqSuids
(
SSubmitReq
*
pMsg
,
STbUidStore
*
pStore
)
{
static
int32_t
tdFetchSubmitReqSuids
(
SSubmitReq
*
pMsg
,
STbUidStore
*
pStore
)
{
ASSERT
(
pMsg
!=
NULL
);
SSubmitMsgIter
msgIter
=
{
0
};
SSubmitMsgIter
msgIter
=
{
0
};
SSubmitBlk
*
pBlock
=
NULL
;
SSubmitBlk
*
pBlock
=
NULL
;
SSubmitBlkIter
blkIter
=
{
0
};
SSubmitBlkIter
blkIter
=
{
0
};
...
@@ -501,19 +499,26 @@ static int32_t tdFetchSubmitReqSuids(SSubmitReq *pMsg, STbUidStore *pStore) {
...
@@ -501,19 +499,26 @@ static int32_t tdFetchSubmitReqSuids(SSubmitReq *pMsg, STbUidStore *pStore) {
terrno
=
TSDB_CODE_SUCCESS
;
terrno
=
TSDB_CODE_SUCCESS
;
if
(
tInitSubmitMsgIter
(
pMsg
,
&
msgIter
)
<
0
)
return
-
1
;
if
(
tInitSubmitMsgIter
(
pMsg
,
&
msgIter
)
<
0
)
{
return
-
1
;
}
while
(
true
)
{
while
(
true
)
{
if
(
tGetSubmitMsgNext
(
&
msgIter
,
&
pBlock
)
<
0
)
return
-
1
;
if
(
tGetSubmitMsgNext
(
&
msgIter
,
&
pBlock
)
<
0
)
{
return
-
1
;
}
if
(
!
pBlock
)
break
;
if
(
!
pBlock
)
break
;
tdUidStorePut
(
pStore
,
msgIter
.
suid
,
NULL
);
tdUidStorePut
(
pStore
,
msgIter
.
suid
,
NULL
);
}
}
if
(
terrno
!=
TSDB_CODE_SUCCESS
)
return
-
1
;
if
(
terrno
!=
TSDB_CODE_SUCCESS
)
{
return
-
1
;
}
return
0
;
return
0
;
}
}
static
void
tdDestroySDataBlockArray
(
SArray
*
pArray
)
{
static
void
tdDestroySDataBlockArray
(
SArray
*
pArray
)
{
// TODO
#if 0
#if 0
for (int32_t i = 0; i < taosArrayGetSize(pArray); ++i) {
for (int32_t i = 0; i < taosArrayGetSize(pArray); ++i) {
SSDataBlock *pDataBlock = taosArrayGet(pArray, i);
SSDataBlock *pDataBlock = taosArrayGet(pArray, i);
...
@@ -598,33 +603,54 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) {
...
@@ -598,33 +603,54 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) {
pSma
=
RSMA_INFO_SMA
(
pItem
->
pRsmaInfo
);
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
));
int8_t
rsmaTriggerStat
=
atomic_load_8
(
RSMA_TRIGGER_STAT
(
pStat
));
if
(
rsmaTriggerStat
==
TASK_TRIGGER_STAT_CANCELLED
||
rsmaTriggerStat
==
TASK_TRIGGER_STAT_FINISHED
)
{
switch
(
rsmaTriggerStat
)
{
taosReleaseRef
(
smaMgmt
.
smaRef
,
pItem
->
refId
);
case
TASK_TRIGGER_STAT_PAUSED
:
smaDebug
(
"vgId:%d, not fetch rsma level %"
PRIi8
" data for table:%"
PRIi64
" since stat is cancelled"
,
case
TASK_TRIGGER_STAT_CANCELLED
:
SMA_VID
(
pSma
),
pItem
->
level
,
pItem
->
pRsmaInfo
->
suid
);
case
TASK_TRIGGER_STAT_FINISHED
:
{
return
;
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
=
int8_t
fetchTriggerStat
=
atomic_val_compare_exchange_8
(
&
pItem
->
triggerStat
,
TASK_TRIGGER_STAT_ACTIVE
,
TASK_TRIGGER_STAT_INACTIVE
);
atomic_val_compare_exchange_8
(
&
pItem
->
triggerStat
,
TASK_TRIGGER_STAT_ACTIVE
,
TASK_TRIGGER_STAT_INACTIVE
);
if
(
fetchTriggerStat
==
TASK_TRIGGER_STAT_ACTIVE
)
{
switch
(
fetchTriggerStat
)
{
smaDebug
(
"vgId:%d, fetch rsma level %"
PRIi8
" data for table:%"
PRIi64
" since stat is active"
,
SMA_VID
(
pSma
),
case
TASK_TRIGGER_STAT_ACTIVE
:
{
pItem
->
level
,
pItem
->
pRsmaInfo
->
suid
);
smaDebug
(
"vgId:%d, fetch rsma level %"
PRIi8
" data for table:%"
PRIi64
" since stat is active"
,
SMA_VID
(
pSma
),
pItem
->
level
,
pItem
->
pRsmaInfo
->
suid
);
tdRefSmaStat
(
pSma
,
(
SSmaStat
*
)
pStat
);
SSDataBlock
dataBlock
=
{.
info
.
type
=
STREAM_GET_ALL
};
tdRefSmaStat
(
pSma
,
(
SSmaStat
*
)
pStat
);
qSetStreamInput
(
pItem
->
taskInfo
,
&
dataBlock
,
STREAM_INPUT__DATA_BLOCK
,
false
);
tdFetchAndSubmitRSmaResult
(
pItem
,
STREAM_INPUT__DATA_BLOCK
);
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
{
tdUnRefSmaStat
(
pSma
,
(
SSmaStat
*
)
pStat
);
smaDebug
(
"vgId:%d, not fetch rsma level %"
PRIi8
" data for table:%"
PRIi64
" since stat is inactive"
,
}
break
;
SMA_VID
(
pSma
),
pItem
->
level
,
pItem
->
pRsmaInfo
->
suid
);
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:
_end:
taosReleaseRef
(
smaMgmt
.
smaRef
,
pItem
->
refId
);
taosReleaseRef
(
smaMgmt
.
smaRef
,
pItem
->
refId
);
}
}
...
@@ -780,10 +806,10 @@ _err:
...
@@ -780,10 +806,10 @@ _err:
static
int32_t
tdRSmaRestoreQTaskInfoReload
(
SSma
*
pSma
)
{
static
int32_t
tdRSmaRestoreQTaskInfoReload
(
SSma
*
pSma
)
{
SVnode
*
pVnode
=
pSma
->
pVnode
;
SVnode
*
pVnode
=
pSma
->
pVnode
;
STFile
tFile
=
{
0
};
STFile
tFile
=
{
0
};
char
qTaskInfoFName
[
TSDB_FILENAME_LEN
];
char
qTaskInfoFName
[
TSDB_FILENAME_LEN
]
=
{
0
}
;
tdRSmaQTaskInfoGetFName
(
TD_VID
(
pVnode
),
TD_QTASK_TMP_F
,
qTaskInfoFName
);
tdRSmaQTaskInfoGetFName
(
TD_VID
(
pVnode
),
pVnode
->
state
.
committed
,
qTaskInfoFName
);
if
(
tdInitTFile
(
&
tFile
,
pVnode
->
pTfs
,
qTaskInfoFName
)
<
0
)
{
if
(
tdInitTFile
(
&
tFile
,
tfsGetPrimaryPath
(
pVnode
->
pTfs
)
,
qTaskInfoFName
)
<
0
)
{
goto
_err
;
goto
_err
;
}
}
...
@@ -799,17 +825,20 @@ static int32_t tdRSmaRestoreQTaskInfoReload(SSma *pSma) {
...
@@ -799,17 +825,20 @@ static int32_t tdRSmaRestoreQTaskInfoReload(SSma *pSma) {
if
(
tdRSmaQTaskInfoIterInit
(
&
fIter
,
&
tFile
)
<
0
)
{
if
(
tdRSmaQTaskInfoIterInit
(
&
fIter
,
&
tFile
)
<
0
)
{
tdRSmaQTaskInfoIterDestroy
(
&
fIter
);
tdRSmaQTaskInfoIterDestroy
(
&
fIter
);
tdCloseTFile
(
&
tFile
);
tdCloseTFile
(
&
tFile
);
tdDestroyTFile
(
&
tFile
);
goto
_err
;
goto
_err
;
}
}
if
(
tdRSmaQTaskInfoRestore
(
pSma
,
&
fIter
)
<
0
)
{
if
(
tdRSmaQTaskInfoRestore
(
pSma
,
&
fIter
)
<
0
)
{
tdRSmaQTaskInfoIterDestroy
(
&
fIter
);
tdRSmaQTaskInfoIterDestroy
(
&
fIter
);
tdCloseTFile
(
&
tFile
);
tdCloseTFile
(
&
tFile
);
tdDestroyTFile
(
&
tFile
);
goto
_err
;
goto
_err
;
}
}
tdRSmaQTaskInfoIterDestroy
(
&
fIter
);
tdRSmaQTaskInfoIterDestroy
(
&
fIter
);
tdCloseTFile
(
&
tFile
);
tdCloseTFile
(
&
tFile
);
tdDestroyTFile
(
&
tFile
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
_err:
_err:
smaError
(
"rsma restore, qtaskinfo reload failed since %s"
,
terrstr
());
smaError
(
"rsma restore, qtaskinfo reload failed since %s"
,
terrstr
());
...
@@ -931,19 +960,21 @@ static int32_t tdRSmaQTaskInfoIterNextBlock(SRSmaQTaskInfoIter *pIter, bool *isF
...
@@ -931,19 +960,21 @@ static int32_t tdRSmaQTaskInfoIterNextBlock(SRSmaQTaskInfoIter *pIter, bool *isF
}
}
if
(
tdSeekTFile
(
pTFile
,
pIter
->
offset
,
SEEK_SET
)
<
0
)
{
if
(
tdSeekTFile
(
pTFile
,
pIter
->
offset
,
SEEK_SET
)
<
0
)
{
ASSERT
(
0
);
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
if
(
tdReadTFile
(
pTFile
,
pIter
->
qBuf
,
nBytes
)
!=
nBytes
)
{
if
(
tdReadTFile
(
pTFile
,
pIter
->
qBuf
,
nBytes
)
!=
nBytes
)
{
ASSERT
(
0
);
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
int32_t
infoLen
=
0
;
int32_t
infoLen
=
0
;
taosDecodeFixedI32
(
pIter
->
qBuf
,
&
infoLen
);
taosDecodeFixedI32
(
pIter
->
qBuf
,
&
infoLen
);
if
(
infoLen
>
nBytes
)
{
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
;
pIter
->
nAlloc
=
infoLen
;
void
*
pBuf
=
taosMemoryRealloc
(
pIter
->
pBuf
,
infoLen
);
void
*
pBuf
=
taosMemoryRealloc
(
pIter
->
pBuf
,
infoLen
);
if
(
!
pBuf
)
{
if
(
!
pBuf
)
{
...
@@ -955,12 +986,10 @@ static int32_t tdRSmaQTaskInfoIterNextBlock(SRSmaQTaskInfoIter *pIter, bool *isF
...
@@ -955,12 +986,10 @@ static int32_t tdRSmaQTaskInfoIterNextBlock(SRSmaQTaskInfoIter *pIter, bool *isF
nBytes
=
infoLen
;
nBytes
=
infoLen
;
if
(
tdSeekTFile
(
pTFile
,
pIter
->
offset
,
SEEK_SET
))
{
if
(
tdSeekTFile
(
pTFile
,
pIter
->
offset
,
SEEK_SET
))
{
ASSERT
(
0
);
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
if
(
tdReadTFile
(
pTFile
,
pIter
->
pBuf
,
nBytes
)
!=
nBytes
)
{
if
(
tdReadTFile
(
pTFile
,
pIter
->
pBuf
,
nBytes
)
!=
nBytes
)
{
ASSERT
(
0
);
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
}
}
...
@@ -977,7 +1006,6 @@ static int32_t tdRSmaQTaskInfoRestore(SSma *pSma, SRSmaQTaskInfoIter *pIter) {
...
@@ -977,7 +1006,6 @@ static int32_t tdRSmaQTaskInfoRestore(SSma *pSma, SRSmaQTaskInfoIter *pIter) {
// block iter
// block iter
bool
isFinish
=
false
;
bool
isFinish
=
false
;
if
(
tdRSmaQTaskInfoIterNextBlock
(
pIter
,
&
isFinish
)
<
0
)
{
if
(
tdRSmaQTaskInfoIterNextBlock
(
pIter
,
&
isFinish
)
<
0
)
{
ASSERT
(
0
);
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
if
(
isFinish
)
{
if
(
isFinish
)
{
...
@@ -989,6 +1017,7 @@ static int32_t tdRSmaQTaskInfoRestore(SSma *pSma, SRSmaQTaskInfoIter *pIter) {
...
@@ -989,6 +1017,7 @@ static int32_t tdRSmaQTaskInfoRestore(SSma *pSma, SRSmaQTaskInfoIter *pIter) {
pIter
->
qBuf
=
taosDecodeFixedI32
(
pIter
->
qBuf
,
&
qTaskInfoLenWithHead
);
pIter
->
qBuf
=
taosDecodeFixedI32
(
pIter
->
qBuf
,
&
qTaskInfoLenWithHead
);
if
(
qTaskInfoLenWithHead
<
RSMA_QTASKINFO_HEAD_LEN
)
{
if
(
qTaskInfoLenWithHead
<
RSMA_QTASKINFO_HEAD_LEN
)
{
terrno
=
TSDB_CODE_TDB_FILE_CORRUPTED
;
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
;
return
TSDB_CODE_FAILED
;
}
}
...
@@ -1025,22 +1054,16 @@ static int32_t tdRSmaQTaskInfoRestore(SSma *pSma, SRSmaQTaskInfoIter *pIter) {
...
@@ -1025,22 +1054,16 @@ static int32_t tdRSmaQTaskInfoRestore(SSma *pSma, SRSmaQTaskInfoIter *pIter) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
void
*
tdRSmaPersistExec
(
void
*
param
)
{
static
int32_t
tdRSmaPersistExecImpl
(
SRSmaStat
*
pRSmaStat
)
{
setThreadName
(
"rsma-task-persist"
);
SSma
*
pSma
=
pRSmaStat
->
pSma
;
SRSmaStat
*
pRSmaStat
=
param
;
SVnode
*
pVnode
=
pSma
->
pVnode
;
SSma
*
pSma
=
pRSmaStat
->
pSma
;
int32_t
vid
=
SMA_VID
(
pSma
);
STfs
*
pTfs
=
pSma
->
pVnode
->
pTfs
;
int64_t
toffset
=
0
;
int32_t
vid
=
SMA_VID
(
pSma
);
bool
isFileCreated
=
false
;
int64_t
toffset
=
0
;
bool
isFileCreated
=
false
;
if
(
TASK_TRIGGER_STAT_CANCELLED
==
atomic_load_8
(
RSMA_TRIGGER_STAT
(
pRSmaStat
)))
{
goto
_end
;
}
void
*
infoHash
=
taosHashIterate
(
RSMA_INFO_HASH
(
pRSmaStat
),
NULL
);
void
*
infoHash
=
taosHashIterate
(
RSMA_INFO_HASH
(
pRSmaStat
),
NULL
);
if
(
!
infoHash
)
{
if
(
!
infoHash
)
{
goto
_end
;
return
TSDB_CODE_SUCCESS
;
}
}
STFile
tFile
=
{
0
};
STFile
tFile
=
{
0
};
...
@@ -1074,9 +1097,13 @@ static void *tdRSmaPersistExec(void *param) {
...
@@ -1074,9 +1097,13 @@ static void *tdRSmaPersistExec(void *param) {
if
(
!
isFileCreated
)
{
if
(
!
isFileCreated
)
{
char
qTaskInfoFName
[
TSDB_FILENAME_LEN
];
char
qTaskInfoFName
[
TSDB_FILENAME_LEN
];
tdRSmaQTaskInfoGetFName
(
vid
,
TD_QTASK_TMP_F
,
qTaskInfoFName
);
tdRSmaQTaskInfoGetFName
(
vid
,
pSma
->
pVnode
->
state
.
applied
,
qTaskInfoFName
);
tdInitTFile
(
&
tFile
,
pTfs
,
qTaskInfoFName
);
if
(
tdInitTFile
(
&
tFile
,
tfsGetPrimaryPath
(
pVnode
->
pTfs
),
qTaskInfoFName
)
<
0
)
{
tdCreateTFile
(
&
tFile
,
pTfs
,
true
,
-
1
);
goto
_err
;
}
if
(
tdCreateTFile
(
&
tFile
,
true
,
-
1
)
<
0
)
{
goto
_err
;
}
isFileCreated
=
true
;
isFileCreated
=
true
;
}
}
...
@@ -1101,49 +1128,55 @@ static void *tdRSmaPersistExec(void *param) {
...
@@ -1101,49 +1128,55 @@ static void *tdRSmaPersistExec(void *param) {
infoHash
=
taosHashIterate
(
RSMA_INFO_HASH
(
pRSmaStat
),
infoHash
);
infoHash
=
taosHashIterate
(
RSMA_INFO_HASH
(
pRSmaStat
),
infoHash
);
}
}
_normal:
if
(
isFileCreated
)
{
if
(
isFileCreated
)
{
if
(
tdUpdateTFileHeader
(
&
tFile
)
<
0
)
{
if
(
tdUpdateTFileHeader
(
&
tFile
)
<
0
)
{
smaError
(
"vgId:%d, rsma, failed to update tfile %s header since %s"
,
vid
,
TD_TFILE_FULL_NAME
(
&
tFile
),
smaError
(
"vgId:%d, rsma, failed to update tfile %s header since %s"
,
vid
,
TD_TFILE_FULL_NAME
(
&
tFile
),
tstrerror
(
terrno
));
tstrerror
(
terrno
));
tdCloseTFile
(
&
tFile
);
tdRemoveTFile
(
&
tFile
);
goto
_err
;
goto
_err
;
}
else
{
}
else
{
smaDebug
(
"vgId:%d, rsma, succeed to update tfile %s header"
,
vid
,
TD_TFILE_FULL_NAME
(
&
tFile
));
smaDebug
(
"vgId:%d, rsma, succeed to update tfile %s header"
,
vid
,
TD_TFILE_FULL_NAME
(
&
tFile
));
}
}
tdCloseTFile
(
&
tFile
);
tdCloseTFile
(
&
tFile
);
tdDestroyTFile
(
&
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
);
}
}
}
goto
_end
;
return
TSDB_CODE_SUCCESS
;
_err:
_err:
if
(
isFileCreated
)
{
if
(
isFileCreated
)
{
tdRemoveTFile
(
&
tFile
);
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:
_end:
if
(
TASK_TRIGGER_STAT_INACTIVE
==
atomic_val_compare_exchange_8
(
RSMA_TRIGGER_STAT
(
pRSmaStat
),
if
(
TASK_TRIGGER_STAT_INACTIVE
==
atomic_val_compare_exchange_8
(
RSMA_TRIGGER_STAT
(
pRSmaStat
),
TASK_TRIGGER_STAT_INACTIVE
,
TASK_TRIGGER_STAT_INACTIVE
,
TASK_TRIGGER_STAT_ACTIVE
))
{
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
),
}
else
if
(
TASK_TRIGGER_STAT_CANCELLED
==
atomic_val_compare_exchange_8
(
RSMA_TRIGGER_STAT
(
pRSmaStat
),
TASK_TRIGGER_STAT_CANCELLED
,
TASK_TRIGGER_STAT_CANCELLED
,
TASK_TRIGGER_STAT_FINISHED
))
{
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
{
}
else
{
smaWarn
(
"vgId:%d, rsma persist task in abnormal stat %"
PRIi8
,
vid
,
atomic_load_8
(
RSMA_TRIGGER_STAT
(
pRSmaStat
)));
smaWarn
(
"vgId:%d, rsma persist task in stat %"
PRIi8
,
SMA_VID
(
pSma
),
atomic_load_8
(
RSMA_TRIGGER_STAT
(
pRSmaStat
)));
ASSERT
(
0
);
}
}
atomic_store_8
(
RSMA_RUNNING_STAT
(
pRSmaStat
),
0
);
atomic_store_8
(
RSMA_RUNNING_STAT
(
pRSmaStat
),
0
);
taosReleaseRef
(
smaMgmt
.
smaRef
,
pRSmaStat
->
refId
);
taosReleaseRef
(
smaMgmt
.
smaRef
,
pRSmaStat
->
refId
);
taosThreadExit
(
NULL
);
taosThreadExit
(
NULL
);
...
@@ -1166,8 +1199,8 @@ static void tdRSmaPersistTask(SRSmaStat *pRSmaStat) {
...
@@ -1166,8 +1199,8 @@ static void tdRSmaPersistTask(SRSmaStat *pRSmaStat) {
TASK_TRIGGER_STAT_FINISHED
))
{
TASK_TRIGGER_STAT_FINISHED
))
{
smaDebug
(
"vgId:%d, persist task is cancelled and set finished"
,
SMA_VID
(
pRSmaStat
->
pSma
));
smaDebug
(
"vgId:%d, persist task is cancelled and set finished"
,
SMA_VID
(
pRSmaStat
->
pSma
));
}
else
{
}
else
{
smaWarn
(
"vgId:%d, persist task in abnormal stat %"
PRIi8
,
atomic_load_8
(
RSMA_TRIGGER_STAT
(
pRSmaStat
)
),
smaWarn
(
"vgId:%d, persist task in abnormal stat %"
PRIi8
,
SMA_VID
(
pRSmaStat
->
pSma
),
SMA_VID
(
pRSmaStat
->
pSma
));
atomic_load_8
(
RSMA_TRIGGER_STAT
(
pRSmaStat
)
));
ASSERT
(
0
);
ASSERT
(
0
);
}
}
atomic_store_8
(
RSMA_RUNNING_STAT
(
pRSmaStat
),
0
);
atomic_store_8
(
RSMA_RUNNING_STAT
(
pRSmaStat
),
0
);
...
@@ -1216,6 +1249,9 @@ static void tdRSmaPersistTrigger(void *param, void *tmrId) {
...
@@ -1216,6 +1249,9 @@ static void tdRSmaPersistTrigger(void *param, void *tmrId) {
atomic_store_8
(
RSMA_TRIGGER_STAT
(
pRSmaStat
),
TASK_TRIGGER_STAT_FINISHED
);
atomic_store_8
(
RSMA_TRIGGER_STAT
(
pRSmaStat
),
TASK_TRIGGER_STAT_FINISHED
);
smaDebug
(
"rsma persistence not start since cancelled and finished"
);
smaDebug
(
"rsma persistence not start since cancelled and finished"
);
}
break
;
}
break
;
case
TASK_TRIGGER_STAT_PAUSED
:
{
smaDebug
(
"rsma persistence not start since paused"
);
}
break
;
case
TASK_TRIGGER_STAT_INACTIVE
:
{
case
TASK_TRIGGER_STAT_INACTIVE
:
{
smaDebug
(
"rsma persistence not start since inactive"
);
smaDebug
(
"rsma persistence not start since inactive"
);
}
break
;
}
break
;
...
...
source/dnode/vnode/src/sma/smaSnapshot.c
0 → 100644
浏览文件 @
33525deb
/*
* 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
浏览文件 @
33525deb
...
@@ -179,72 +179,83 @@ void tdCloseTFile(STFile *pTFile) {
...
@@ -179,72 +179,83 @@ void tdCloseTFile(STFile *pTFile) {
}
}
}
}
void
tdGetVndFileName
(
int32_t
vgId
,
const
char
*
dname
,
const
char
*
fname
,
char
*
outputName
)
{
void
tdDestroyTFile
(
STFile
*
pTFile
)
{
taosMemoryFreeClear
(
TD_TFILE_FULL_NAME
(
pTFile
));
}
snprintf
(
outputName
,
TSDB_FILENAME_LEN
,
"vnode/vnode%d/%s/%s"
,
vgId
,
dname
,
fname
);
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
)
{
void
tdGetVndDirName
(
int32_t
vgId
,
const
char
*
dname
,
char
*
outputN
ame
)
{
char
fullname
[
TSDB_FILENAME_LEN
]
;
snprintf
(
outputName
,
TSDB_FILENAME_LEN
,
"vnode/vnode%d/%s"
,
vgId
,
dname
)
;
SDiskID
did
=
{
0
};
}
int32_t
tdInitTFile
(
STFile
*
pTFile
,
const
char
*
dname
,
const
char
*
fname
)
{
TD_TFILE_SET_STATE
(
pTFile
,
TD_FILE_STATE_OK
);
TD_TFILE_SET_STATE
(
pTFile
,
TD_FILE_STATE_OK
);
TD_TFILE_SET_CLOSED
(
pTFile
);
TD_TFILE_SET_CLOSED
(
pTFile
);
memset
(
&
(
pTFile
->
info
),
0
,
sizeof
(
pTFile
->
info
));
memset
(
&
(
pTFile
->
info
),
0
,
sizeof
(
pTFile
->
info
));
pTFile
->
info
.
magic
=
TD_FILE_INIT_MAGIC
;
pTFile
->
info
.
magic
=
TD_FILE_INIT_MAGIC
;
if
(
tfsAllocDisk
(
pTfs
,
0
,
&
did
)
<
0
)
{
char
tmpName
[
TSDB_FILENAME_LEN
*
2
+
32
]
=
{
0
};
terrno
=
TSDB_CODE_NO_AVAIL_DISK
;
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
;
return
-
1
;
}
}
tstrncpy
(
pTFile
->
fname
,
tmpName
,
tmpNameLen
);
tfsInitFile
(
pTfs
,
&
(
pTFile
->
f
),
did
,
fname
);
return
0
;
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
);
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
);
pTFile
->
pFile
=
taosOpenFile
(
TD_TFILE_FULL_NAME
(
pTFile
),
TD_FILE_CREATE
|
TD_FILE_WRITE
|
TD_FILE_TRUNC
);
if
(
pTFile
->
pFile
==
NULL
)
{
if
(
pTFile
->
pFile
==
NULL
)
{
if
(
errno
==
ENOENT
)
{
if
(
errno
==
ENOENT
)
{
// Try to create directory recursively
// Try to create directory recursively
char
*
s
=
strdup
(
TD_TFILE_REL_NAME
(
pTFile
));
if
(
taosMulMkDir
(
taosDirName
(
TD_TFILE_FULL_NAME
(
pTFile
)))
!=
0
)
{
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
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
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
)
{
if
(
!
updateHeader
)
{
return
0
;
return
0
;
}
}
pTFile
->
info
.
fsize
+=
TD_FILE_HEAD_SIZE
;
pTFile
->
info
.
fsize
+=
TD_FILE_HEAD_SIZE
;
pTFile
->
info
.
fver
=
0
;
pTFile
->
info
.
fver
=
0
;
if
(
tdUpdateTFileHeader
(
pTFile
)
<
0
)
{
if
(
tdUpdateTFileHeader
(
pTFile
)
<
0
)
{
tdCloseTFile
(
pTFile
);
tdCloseTFile
(
pTFile
);
tdRemoveTFile
(
pTFile
);
tdRemoveTFile
(
pTFile
);
return
-
1
;
return
-
1
;
}
}
}
return
0
;
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 ================
// smaXXXUtil ================
// ...
// ...
\ No newline at end of file
source/dnode/vnode/src/tq/tq.c
浏览文件 @
33525deb
...
@@ -183,13 +183,15 @@ int32_t tqProcessOffsetCommitReq(STQ* pTq, char* msg, int32_t msgLen) {
...
@@ -183,13 +183,15 @@ int32_t tqProcessOffsetCommitReq(STQ* pTq, char* msg, int32_t msgLen) {
}
else
{
}
else
{
ASSERT
(
0
);
ASSERT
(
0
);
}
}
STqOffset
*
pOffset
=
tqOffsetRead
(
pTq
->
pOffsetStore
,
offset
.
subKey
);
/*STqOffset* pOffset = tqOffsetRead(pTq->pOffsetStore, offset.subKey);*/
if
(
pOffset
==
NULL
||
pOffset
->
val
.
version
<
offset
.
val
.
version
)
{
/*if (pOffset != NULL) {*/
if
(
tqOffsetWrite
(
pTq
->
pOffsetStore
,
&
offset
)
<
0
)
{
/*if (pOffset->val.type == TMQ_OFFSET__LOG && pOffset->val.version < offset.val.version) {*/
ASSERT
(
0
);
if
(
tqOffsetWrite
(
pTq
->
pOffsetStore
,
&
offset
)
<
0
)
{
return
-
1
;
ASSERT
(
0
)
;
}
return
-
1
;
}
}
/*}*/
/*}*/
return
0
;
return
0
;
}
}
...
@@ -375,8 +377,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
...
@@ -375,8 +377,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
taosMemoryFree
(
pCkHead
);
taosMemoryFree
(
pCkHead
);
}
else
if
(
fetchOffsetNew
.
type
==
TMQ_OFFSET__SNAPSHOT_DATA
)
{
}
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
,
tqInfo
(
"retrieve using snapshot actual offset: uid %ld ts %ld"
,
fetchOffsetNew
.
uid
,
fetchOffsetNew
.
ts
);
dataRsp
.
reqOffset
.
ts
,
fetchOffsetNew
.
uid
,
fetchOffsetNew
.
ts
);
if
(
tqScanSnapshot
(
pTq
,
&
pHandle
->
execHandle
,
&
dataRsp
,
fetchOffsetNew
,
workerId
)
<
0
)
{
if
(
tqScanSnapshot
(
pTq
,
&
pHandle
->
execHandle
,
&
dataRsp
,
fetchOffsetNew
,
workerId
)
<
0
)
{
ASSERT
(
0
);
ASSERT
(
0
);
}
}
...
...
source/dnode/vnode/src/tq/tqRead.c
浏览文件 @
33525deb
...
@@ -120,7 +120,9 @@ bool tqNextDataBlock(SStreamReader* pHandle) {
...
@@ -120,7 +120,9 @@ bool tqNextDataBlock(SStreamReader* pHandle) {
return
true
;
return
true
;
}
}
void
*
ret
=
taosHashGet
(
pHandle
->
tbIdHash
,
&
pHandle
->
msgIter
.
uid
,
sizeof
(
int64_t
));
void
*
ret
=
taosHashGet
(
pHandle
->
tbIdHash
,
&
pHandle
->
msgIter
.
uid
,
sizeof
(
int64_t
));
/*tqDebug("search uid %ld", pHandle->msgIter.uid);*/
if
(
ret
!=
NULL
)
{
if
(
ret
!=
NULL
)
{
/*tqDebug("find uid %ld", pHandle->msgIter.uid);*/
return
true
;
return
true
;
}
}
}
}
...
...
source/dnode/vnode/src/tq/tqSink.c
浏览文件 @
33525deb
...
@@ -185,5 +185,7 @@ void tqTableSink(SStreamTask* pTask, void* vnode, int64_t ver, void* data) {
...
@@ -185,5 +185,7 @@ void tqTableSink(SStreamTask* pTask, void* vnode, int64_t ver, void* data) {
.
contLen
=
ntohl
(
pReq
->
length
),
.
contLen
=
ntohl
(
pReq
->
length
),
};
};
ASSERT
(
tmsgPutToQueue
(
&
pVnode
->
msgCb
,
WRITE_QUEUE
,
&
msg
)
==
0
);
if
(
tmsgPutToQueue
(
&
pVnode
->
msgCb
,
WRITE_QUEUE
,
&
msg
)
!=
0
)
{
tqDebug
(
"failed to put into write-queue since %s"
,
terrstr
());
}
}
}
source/dnode/vnode/src/vnd/vnodeCfg.c
浏览文件 @
33525deb
...
@@ -28,12 +28,12 @@ const SVnodeCfg vnodeCfgDefault = {
...
@@ -28,12 +28,12 @@ const SVnodeCfg vnodeCfgDefault = {
.
update
=
1
,
.
update
=
1
,
.
compression
=
2
,
.
compression
=
2
,
.
slLevel
=
5
,
.
slLevel
=
5
,
.
days
=
10
,
.
days
=
1
440
0
,
.
minRows
=
100
,
.
minRows
=
100
,
.
maxRows
=
4096
,
.
maxRows
=
4096
,
.
keep2
=
365
0
,
.
keep2
=
525600
0
,
.
keep0
=
365
0
,
.
keep0
=
525600
0
,
.
keep1
=
365
0
},
.
keep1
=
525600
0
},
.
walCfg
=
.
walCfg
=
{.
vgId
=
-
1
,
.
fsyncPeriod
=
0
,
.
retentionPeriod
=
0
,
.
rollPeriod
=
0
,
.
segSize
=
0
,
.
level
=
TAOS_WAL_WRITE
},
{.
vgId
=
-
1
,
.
fsyncPeriod
=
0
,
.
retentionPeriod
=
0
,
.
rollPeriod
=
0
,
.
segSize
=
0
,
.
level
=
TAOS_WAL_WRITE
},
.
hashBegin
=
0
,
.
hashBegin
=
0
,
...
...
source/dnode/vnode/src/vnd/vnodeCommit.c
浏览文件 @
33525deb
...
@@ -229,6 +229,9 @@ int vnodeCommit(SVnode *pVnode) {
...
@@ -229,6 +229,9 @@ int vnodeCommit(SVnode *pVnode) {
return
-
1
;
return
-
1
;
}
}
// preCommit
// TODO
// commit each sub-system
// commit each sub-system
if
(
metaCommit
(
pVnode
->
pMeta
)
<
0
)
{
if
(
metaCommit
(
pVnode
->
pMeta
)
<
0
)
{
ASSERT
(
0
);
ASSERT
(
0
);
...
@@ -269,6 +272,9 @@ int vnodeCommit(SVnode *pVnode) {
...
@@ -269,6 +272,9 @@ int vnodeCommit(SVnode *pVnode) {
pVnode
->
state
.
committed
=
info
.
state
.
committed
;
pVnode
->
state
.
committed
=
info
.
state
.
committed
;
// postCommit
smaPostCommit
(
pVnode
->
pSma
);
// apply the commit (TODO)
// apply the commit (TODO)
vnodeBufPoolReset
(
pVnode
->
onCommit
);
vnodeBufPoolReset
(
pVnode
->
onCommit
);
pVnode
->
onCommit
->
next
=
pVnode
->
pPool
;
pVnode
->
onCommit
->
next
=
pVnode
->
pPool
;
...
...
source/dnode/vnode/src/vnd/vnodeSvr.c
浏览文件 @
33525deb
...
@@ -779,6 +779,7 @@ _exit:
...
@@ -779,6 +779,7 @@ _exit:
taosArrayDestroy
(
submitRsp
.
pArray
);
taosArrayDestroy
(
submitRsp
.
pArray
);
// TODO: the partial success scenario and the error case
// 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
// TODO: refactor
if
((
terrno
==
TSDB_CODE_SUCCESS
)
&&
(
pRsp
->
code
==
TSDB_CODE_SUCCESS
))
{
if
((
terrno
==
TSDB_CODE_SUCCESS
)
&&
(
pRsp
->
code
==
TSDB_CODE_SUCCESS
))
{
tdProcessRSmaSubmit
(
pVnode
->
pSma
,
pReq
,
STREAM_INPUT__DATA_SUBMIT
);
tdProcessRSmaSubmit
(
pVnode
->
pSma
,
pReq
,
STREAM_INPUT__DATA_SUBMIT
);
...
...
source/libs/executor/inc/executorimpl.h
浏览文件 @
33525deb
...
@@ -356,6 +356,7 @@ typedef struct SStreamBlockScanInfo {
...
@@ -356,6 +356,7 @@ typedef struct SStreamBlockScanInfo {
SUpdateInfo
*
pUpdateInfo
;
SUpdateInfo
*
pUpdateInfo
;
EStreamScanMode
scanMode
;
EStreamScanMode
scanMode
;
SOperatorInfo
*
pStreamScanOp
;
SOperatorInfo
*
pSnapshotReadOp
;
SOperatorInfo
*
pSnapshotReadOp
;
SArray
*
childIds
;
SArray
*
childIds
;
SessionWindowSupporter
sessionSup
;
SessionWindowSupporter
sessionSup
;
...
@@ -427,7 +428,7 @@ typedef struct SIntervalAggOperatorInfo {
...
@@ -427,7 +428,7 @@ typedef struct SIntervalAggOperatorInfo {
STimeWindowAggSupp
twAggSup
;
STimeWindowAggSupp
twAggSup
;
bool
invertible
;
bool
invertible
;
SArray
*
pPrevValues
;
// SArray<SGroupKeys> used to keep the previous not null value for interpolation.
SArray
*
pPrevValues
;
// SArray<SGroupKeys> used to keep the previous not null value for interpolation.
bool
ignore
CloseWindow
;
bool
ignore
ExpiredData
;
}
SIntervalAggOperatorInfo
;
}
SIntervalAggOperatorInfo
;
typedef
struct
SStreamFinalIntervalOperatorInfo
{
typedef
struct
SStreamFinalIntervalOperatorInfo
{
...
@@ -449,7 +450,7 @@ typedef struct SStreamFinalIntervalOperatorInfo {
...
@@ -449,7 +450,7 @@ typedef struct SStreamFinalIntervalOperatorInfo {
SArray
*
pPullWins
;
// SPullWindowInfo
SArray
*
pPullWins
;
// SPullWindowInfo
int32_t
pullIndex
;
int32_t
pullIndex
;
SSDataBlock
*
pPullDataRes
;
SSDataBlock
*
pPullDataRes
;
bool
ignore
CloseWindow
;
bool
ignore
ExpiredData
;
}
SStreamFinalIntervalOperatorInfo
;
}
SStreamFinalIntervalOperatorInfo
;
typedef
struct
SAggOperatorInfo
{
typedef
struct
SAggOperatorInfo
{
...
@@ -587,7 +588,7 @@ typedef struct SStreamSessionAggOperatorInfo {
...
@@ -587,7 +588,7 @@ typedef struct SStreamSessionAggOperatorInfo {
SArray
*
pChildren
;
// cache for children's result; final stream operator
SArray
*
pChildren
;
// cache for children's result; final stream operator
SPhysiNode
*
pPhyNode
;
// create new child
SPhysiNode
*
pPhyNode
;
// create new child
bool
isFinal
;
bool
isFinal
;
bool
ignore
CloseWindow
;
bool
ignore
ExpiredData
;
}
SStreamSessionAggOperatorInfo
;
}
SStreamSessionAggOperatorInfo
;
typedef
struct
STimeSliceOperatorInfo
{
typedef
struct
STimeSliceOperatorInfo
{
...
@@ -631,7 +632,7 @@ typedef struct SStreamStateAggOperatorInfo {
...
@@ -631,7 +632,7 @@ typedef struct SStreamStateAggOperatorInfo {
void
*
pDelIterator
;
void
*
pDelIterator
;
SArray
*
pScanWindow
;
SArray
*
pScanWindow
;
SArray
*
pChildren
;
// cache for children's result;
SArray
*
pChildren
;
// cache for children's result;
bool
ignore
CloseWindow
;
bool
ignore
ExpiredData
;
}
SStreamStateAggOperatorInfo
;
}
SStreamStateAggOperatorInfo
;
typedef
struct
SSortedMergeOperatorInfo
{
typedef
struct
SSortedMergeOperatorInfo
{
...
...
source/libs/executor/src/executor.c
浏览文件 @
33525deb
...
@@ -145,10 +145,12 @@ static SArray* filterQualifiedChildTables(const SStreamBlockScanInfo* pScanInfo,
...
@@ -145,10 +145,12 @@ static SArray* filterQualifiedChildTables(const SStreamBlockScanInfo* pScanInfo,
continue
;
continue
;
}
}
// TODO handle ntb case
if
(
mr
.
me
.
type
!=
TSDB_CHILD_TABLE
||
mr
.
me
.
ctbEntry
.
suid
!=
pScanInfo
->
tableUid
)
{
if
(
mr
.
me
.
type
!=
TSDB_CHILD_TABLE
||
mr
.
me
.
ctbEntry
.
suid
!=
pScanInfo
->
tableUid
)
{
continue
;
continue
;
}
}
// TODO handle ntb case
/*pScanInfo->pStreamScanOp->pTaskInfo->tableqinfoList.*/
// handle multiple partition
taosArrayPush
(
qa
,
id
);
taosArrayPush
(
qa
,
id
);
}
}
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
33525deb
...
@@ -2027,8 +2027,9 @@ static int32_t doSendFetchDataRequest(SExchangeInfo* pExchangeInfo, SExecTaskInf
...
@@ -2027,8 +2027,9 @@ static int32_t doSendFetchDataRequest(SExchangeInfo* pExchangeInfo, SExecTaskInf
ASSERT
(
pDataInfo
->
status
==
EX_SOURCE_DATA_NOT_READY
);
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
),
qDebug
(
"%s build fetch msg and send to vgId:%d, ep:%s, taskId:0x%"
PRIx64
", execId:%d, %d/%"
PRIzu
,
pSource
->
addr
.
nodeId
,
pSource
->
addr
.
epSet
.
eps
[
0
].
fqdn
,
pSource
->
taskId
,
pSource
->
execId
,
sourceIndex
,
totalSources
);
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
->
header
.
vgId
=
htonl
(
pSource
->
addr
.
nodeId
);
pMsg
->
sId
=
htobe64
(
pSource
->
schedId
);
pMsg
->
sId
=
htobe64
(
pSource
->
schedId
);
...
@@ -2163,8 +2164,8 @@ static SSDataBlock* concurrentlyLoadRemoteDataImpl(SOperatorInfo* pOperator, SEx
...
@@ -2163,8 +2164,8 @@ static SSDataBlock* concurrentlyLoadRemoteDataImpl(SOperatorInfo* pOperator, SEx
SSDataBlock
*
pRes
=
pExchangeInfo
->
pResult
;
SSDataBlock
*
pRes
=
pExchangeInfo
->
pResult
;
SLoadRemoteDataInfo
*
pLoadInfo
=
&
pExchangeInfo
->
loadInfo
;
SLoadRemoteDataInfo
*
pLoadInfo
=
&
pExchangeInfo
->
loadInfo
;
if
(
pRsp
->
numOfRows
==
0
)
{
if
(
pRsp
->
numOfRows
==
0
)
{
qDebug
(
"%s vgId:%d, taskId:0x%"
PRIx64
" execId:%d index:%d completed, rowsOfSource:%"
PRIu64
", totalRows:%"
PRIu64
qDebug
(
"%s vgId:%d, taskId:0x%"
PRIx64
" execId:%d index:%d completed, rowsOfSource:%"
PRIu64
", completed:%d try next %d/%"
PRIzu
,
",
totalRows:%"
PRIu64
",
completed:%d try next %d/%"
PRIzu
,
GET_TASKID
(
pTaskInfo
),
pSource
->
addr
.
nodeId
,
pSource
->
taskId
,
pSource
->
execId
,
i
,
pDataInfo
->
totalRows
,
GET_TASKID
(
pTaskInfo
),
pSource
->
addr
.
nodeId
,
pSource
->
taskId
,
pSource
->
execId
,
i
,
pDataInfo
->
totalRows
,
pExchangeInfo
->
loadInfo
.
totalRows
,
completed
+
1
,
i
+
1
,
totalSources
);
pExchangeInfo
->
loadInfo
.
totalRows
,
completed
+
1
,
i
+
1
,
totalSources
);
pDataInfo
->
status
=
EX_SOURCE_DATA_EXHAUSTED
;
pDataInfo
->
status
=
EX_SOURCE_DATA_EXHAUSTED
;
...
@@ -2183,18 +2184,19 @@ static SSDataBlock* concurrentlyLoadRemoteDataImpl(SOperatorInfo* pOperator, SEx
...
@@ -2183,18 +2184,19 @@ static SSDataBlock* concurrentlyLoadRemoteDataImpl(SOperatorInfo* pOperator, SEx
}
}
if
(
pRsp
->
completed
==
1
)
{
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
" index:%d completed, numOfRows:%d, rowsOfSource:%"
PRIu64
", totalRows:%"
PRIu64
", totalBytes:%"
PRIu64
", completed:%d try next %d/%"
PRIzu
,
", completed:%d try next %d/%"
PRIzu
,
GET_TASKID
(
pTaskInfo
),
pSource
->
addr
.
nodeId
,
pSource
->
taskId
,
pSource
->
execId
,
i
,
pRes
->
info
.
rows
,
pDataInfo
->
totalRows
,
GET_TASKID
(
pTaskInfo
),
pSource
->
addr
.
nodeId
,
pSource
->
taskId
,
pSource
->
execId
,
i
,
pRes
->
info
.
rows
,
pLoadInfo
->
totalRows
,
pLoadInfo
->
totalSize
,
completed
+
1
,
i
+
1
,
totalSources
);
p
DataInfo
->
totalRows
,
p
LoadInfo
->
totalRows
,
pLoadInfo
->
totalSize
,
completed
+
1
,
i
+
1
,
totalSources
);
completed
+=
1
;
completed
+=
1
;
pDataInfo
->
status
=
EX_SOURCE_DATA_EXHAUSTED
;
pDataInfo
->
status
=
EX_SOURCE_DATA_EXHAUSTED
;
}
else
{
}
else
{
qDebug
(
"%s fetch msg rsp from vgId:%d, taskId:0x%"
PRIx64
" execId:%d numOfRows:%d, totalRows:%"
PRIu64
qDebug
(
"%s fetch msg rsp from vgId:%d, taskId:0x%"
PRIx64
" execId:%d numOfRows:%d, totalRows:%"
PRIu64
", totalBytes:%"
PRIu64
,
", totalBytes:%"
PRIu64
,
GET_TASKID
(
pTaskInfo
),
pSource
->
addr
.
nodeId
,
pSource
->
taskId
,
pSource
->
execId
,
pRes
->
info
.
rows
,
pLoadInfo
->
totalRows
,
GET_TASKID
(
pTaskInfo
),
pSource
->
addr
.
nodeId
,
pSource
->
taskId
,
pSource
->
execId
,
pRes
->
info
.
rows
,
pLoadInfo
->
totalSize
);
pLoadInfo
->
total
Rows
,
pLoadInfo
->
total
Size
);
}
}
taosMemoryFreeClear
(
pDataInfo
->
pRsp
);
taosMemoryFreeClear
(
pDataInfo
->
pRsp
);
...
@@ -2267,8 +2269,8 @@ static SSDataBlock* seqLoadRemoteData(SOperatorInfo* pOperator) {
...
@@ -2267,8 +2269,8 @@ static SSDataBlock* seqLoadRemoteData(SOperatorInfo* pOperator) {
SDownstreamSourceNode
*
pSource
=
taosArrayGet
(
pExchangeInfo
->
pSources
,
pExchangeInfo
->
current
);
SDownstreamSourceNode
*
pSource
=
taosArrayGet
(
pExchangeInfo
->
pSources
,
pExchangeInfo
->
current
);
if
(
pDataInfo
->
code
!=
TSDB_CODE_SUCCESS
)
{
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
,
qError
(
"%s vgId:%d, taskID:0x%"
PRIx64
" execId:%d error happens, code:%s"
,
GET_TASKID
(
pTaskInfo
),
pSource
->
taskId
,
pSource
->
execId
,
tstrerror
(
pDataInfo
->
code
));
pSource
->
addr
.
nodeId
,
pSource
->
taskId
,
pSource
->
execId
,
tstrerror
(
pDataInfo
->
code
));
pOperator
->
pTaskInfo
->
code
=
pDataInfo
->
code
;
pOperator
->
pTaskInfo
->
code
=
pDataInfo
->
code
;
return
NULL
;
return
NULL
;
}
}
...
@@ -2276,8 +2278,8 @@ static SSDataBlock* seqLoadRemoteData(SOperatorInfo* pOperator) {
...
@@ -2276,8 +2278,8 @@ static SSDataBlock* seqLoadRemoteData(SOperatorInfo* pOperator) {
SRetrieveTableRsp
*
pRsp
=
pDataInfo
->
pRsp
;
SRetrieveTableRsp
*
pRsp
=
pDataInfo
->
pRsp
;
SLoadRemoteDataInfo
*
pLoadInfo
=
&
pExchangeInfo
->
loadInfo
;
SLoadRemoteDataInfo
*
pLoadInfo
=
&
pExchangeInfo
->
loadInfo
;
if
(
pRsp
->
numOfRows
==
0
)
{
if
(
pRsp
->
numOfRows
==
0
)
{
qDebug
(
"%s vgId:%d, taskID:0x%"
PRIx64
" execId:%d %d of total completed, rowsOfSource:%"
PRIu64
", totalRows:%"
PRIu64
qDebug
(
"%s vgId:%d, taskID:0x%"
PRIx64
" execId:%d %d of total completed, rowsOfSource:%"
PRIu64
" try next"
,
"
, totalRows:%"
PRIu64
"
try next"
,
GET_TASKID
(
pTaskInfo
),
pSource
->
addr
.
nodeId
,
pSource
->
taskId
,
pSource
->
execId
,
pExchangeInfo
->
current
+
1
,
GET_TASKID
(
pTaskInfo
),
pSource
->
addr
.
nodeId
,
pSource
->
taskId
,
pSource
->
execId
,
pExchangeInfo
->
current
+
1
,
pDataInfo
->
totalRows
,
pLoadInfo
->
totalRows
);
pDataInfo
->
totalRows
,
pLoadInfo
->
totalRows
);
...
@@ -2296,16 +2298,17 @@ static SSDataBlock* seqLoadRemoteData(SOperatorInfo* pOperator) {
...
@@ -2296,16 +2298,17 @@ static SSDataBlock* seqLoadRemoteData(SOperatorInfo* pOperator) {
if
(
pRsp
->
completed
==
1
)
{
if
(
pRsp
->
completed
==
1
)
{
qDebug
(
"%s fetch msg rsp from vgId:%d, taskId:0x%"
PRIx64
" execId:%d numOfRows:%d, rowsOfSource:%"
PRIu64
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
,
", totalRows:%"
PRIu64
", totalBytes:%"
PRIu64
" try next %d/%"
PRIzu
,
GET_TASKID
(
pTaskInfo
),
pSource
->
addr
.
nodeId
,
pSource
->
taskId
,
pSource
->
execId
,
pRes
->
info
.
rows
,
pDataInfo
->
totalRows
,
GET_TASKID
(
pTaskInfo
),
pSource
->
addr
.
nodeId
,
pSource
->
taskId
,
pSource
->
execId
,
pRes
->
info
.
rows
,
pLoadInfo
->
totalRows
,
pLoadInfo
->
totalSize
,
pExchangeInfo
->
current
+
1
,
totalSources
);
pDataInfo
->
totalRows
,
pLoadInfo
->
totalRows
,
pLoadInfo
->
totalSize
,
pExchangeInfo
->
current
+
1
,
totalSources
);
pDataInfo
->
status
=
EX_SOURCE_DATA_EXHAUSTED
;
pDataInfo
->
status
=
EX_SOURCE_DATA_EXHAUSTED
;
pExchangeInfo
->
current
+=
1
;
pExchangeInfo
->
current
+=
1
;
}
else
{
}
else
{
qDebug
(
"%s fetch msg rsp from vgId:%d, taskId:0x%"
PRIx64
" execId:%d numOfRows:%d, totalRows:%"
PRIu64
qDebug
(
"%s fetch msg rsp from vgId:%d, taskId:0x%"
PRIx64
" execId:%d numOfRows:%d, totalRows:%"
PRIu64
", totalBytes:%"
PRIu64
,
", totalBytes:%"
PRIu64
,
GET_TASKID
(
pTaskInfo
),
pSource
->
addr
.
nodeId
,
pSource
->
taskId
,
pSource
->
execId
,
pRes
->
info
.
rows
,
pLoadInfo
->
totalRows
,
GET_TASKID
(
pTaskInfo
),
pSource
->
addr
.
nodeId
,
pSource
->
taskId
,
pSource
->
execId
,
pRes
->
info
.
rows
,
pLoadInfo
->
totalSize
);
pLoadInfo
->
total
Rows
,
pLoadInfo
->
total
Size
);
}
}
pOperator
->
resultInfo
.
totalRows
+=
pRes
->
info
.
rows
;
pOperator
->
resultInfo
.
totalRows
+=
pRes
->
info
.
rows
;
...
...
source/libs/executor/src/scanoperator.c
浏览文件 @
33525deb
...
@@ -1031,10 +1031,12 @@ static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator) {
...
@@ -1031,10 +1031,12 @@ static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator) {
}
}
pInfo
->
scanMode
=
STREAM_SCAN_FROM_DATAREADER
;
pInfo
->
scanMode
=
STREAM_SCAN_FROM_DATAREADER
;
}
else
{
}
else
{
if
(
isStateWindow
(
pInfo
)
&&
taosArrayGetSize
(
pInfo
->
sessionSup
.
pStreamAggSup
->
pScanWindow
)
>
0
)
{
if
(
isStateWindow
(
pInfo
))
{
pInfo
->
scanMode
=
STREAM_SCAN_FROM_DATAREADER
;
pInfo
->
scanMode
=
STREAM_SCAN_FROM_DATAREADER
;
pInfo
->
updateResIndex
=
pInfo
->
pUpdateRes
->
info
.
rows
;
pInfo
->
updateResIndex
=
pInfo
->
pUpdateRes
->
info
.
rows
;
prepareDataScan
(
pInfo
,
pInfo
->
pUpdateRes
,
pInfo
->
primaryTsIndex
,
&
pInfo
->
updateResIndex
);
if
(
!
prepareDataScan
(
pInfo
,
pInfo
->
pUpdateRes
,
pInfo
->
primaryTsIndex
,
&
pInfo
->
updateResIndex
))
{
pInfo
->
scanMode
=
STREAM_SCAN_FROM_READERHANDLE
;
}
}
}
if
(
pInfo
->
scanMode
==
STREAM_SCAN_FROM_DATAREADER
)
{
if
(
pInfo
->
scanMode
==
STREAM_SCAN_FROM_DATAREADER
)
{
SSDataBlock
*
pSDB
=
doDataScan
(
pInfo
,
pInfo
->
pUpdateRes
,
pInfo
->
primaryTsIndex
,
&
pInfo
->
updateResIndex
);
SSDataBlock
*
pSDB
=
doDataScan
(
pInfo
,
pInfo
->
pUpdateRes
,
pInfo
->
primaryTsIndex
,
&
pInfo
->
updateResIndex
);
...
@@ -1274,6 +1276,7 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys
...
@@ -1274,6 +1276,7 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys
pInfo
->
sessionSup
=
(
SessionWindowSupporter
){.
pStreamAggSup
=
NULL
,
.
gap
=
-
1
};
pInfo
->
sessionSup
=
(
SessionWindowSupporter
){.
pStreamAggSup
=
NULL
,
.
gap
=
-
1
};
pInfo
->
groupId
=
0
;
pInfo
->
groupId
=
0
;
pInfo
->
pPullDataRes
=
createPullDataBlock
();
pInfo
->
pPullDataRes
=
createPullDataBlock
();
pInfo
->
pStreamScanOp
=
pOperator
;
pOperator
->
name
=
"StreamBlockScanOperator"
;
pOperator
->
name
=
"StreamBlockScanOperator"
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN
;
...
...
source/libs/executor/src/timewindowoperator.c
浏览文件 @
33525deb
...
@@ -838,7 +838,7 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
...
@@ -838,7 +838,7 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
STimeWindow
win
=
getActiveTimeWindow
(
pInfo
->
aggSup
.
pResultBuf
,
pResultRowInfo
,
ts
,
&
pInfo
->
interval
,
STimeWindow
win
=
getActiveTimeWindow
(
pInfo
->
aggSup
.
pResultBuf
,
pResultRowInfo
,
ts
,
&
pInfo
->
interval
,
pInfo
->
interval
.
precision
,
&
pInfo
->
win
);
pInfo
->
interval
.
precision
,
&
pInfo
->
win
);
int32_t
ret
=
TSDB_CODE_SUCCESS
;
int32_t
ret
=
TSDB_CODE_SUCCESS
;
if
(
!
pInfo
->
ignore
CloseWindow
||
!
isCloseWindow
(
&
win
,
&
pInfo
->
twAggSup
))
{
if
(
!
pInfo
->
ignore
ExpiredData
||
!
isCloseWindow
(
&
win
,
&
pInfo
->
twAggSup
))
{
ret
=
setTimeWindowOutputBuf
(
pResultRowInfo
,
&
win
,
(
scanFlag
==
MAIN_SCAN
),
&
pResult
,
tableGroupId
,
pSup
->
pCtx
,
ret
=
setTimeWindowOutputBuf
(
pResultRowInfo
,
&
win
,
(
scanFlag
==
MAIN_SCAN
),
&
pResult
,
tableGroupId
,
pSup
->
pCtx
,
numOfOutput
,
pSup
->
rowEntryInfoOffset
,
&
pInfo
->
aggSup
,
pTaskInfo
);
numOfOutput
,
pSup
->
rowEntryInfoOffset
,
&
pInfo
->
aggSup
,
pTaskInfo
);
if
(
ret
!=
TSDB_CODE_SUCCESS
||
pResult
==
NULL
)
{
if
(
ret
!=
TSDB_CODE_SUCCESS
||
pResult
==
NULL
)
{
...
@@ -871,7 +871,7 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
...
@@ -871,7 +871,7 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
doWindowBorderInterpolation
(
pInfo
,
pBlock
,
pResult
,
&
win
,
startPos
,
forwardRows
,
pSup
);
doWindowBorderInterpolation
(
pInfo
,
pBlock
,
pResult
,
&
win
,
startPos
,
forwardRows
,
pSup
);
}
}
if
(
!
pInfo
->
ignore
CloseWindow
||
!
isCloseWindow
(
&
win
,
&
pInfo
->
twAggSup
))
{
if
(
!
pInfo
->
ignore
ExpiredData
||
!
isCloseWindow
(
&
win
,
&
pInfo
->
twAggSup
))
{
updateTimeWindowInfo
(
&
pInfo
->
twAggSup
.
timeWindowData
,
&
win
,
true
);
updateTimeWindowInfo
(
&
pInfo
->
twAggSup
.
timeWindowData
,
&
win
,
true
);
doApplyFunctions
(
pTaskInfo
,
pSup
->
pCtx
,
&
win
,
&
pInfo
->
twAggSup
.
timeWindowData
,
startPos
,
forwardRows
,
tsCols
,
doApplyFunctions
(
pTaskInfo
,
pSup
->
pCtx
,
&
win
,
&
pInfo
->
twAggSup
.
timeWindowData
,
startPos
,
forwardRows
,
tsCols
,
pBlock
->
info
.
rows
,
numOfOutput
,
pInfo
->
order
);
pBlock
->
info
.
rows
,
numOfOutput
,
pInfo
->
order
);
...
@@ -886,7 +886,7 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
...
@@ -886,7 +886,7 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
if
(
startPos
<
0
)
{
if
(
startPos
<
0
)
{
break
;
break
;
}
}
if
(
pInfo
->
ignore
CloseWindow
&&
isCloseWindow
(
&
nextWin
,
&
pInfo
->
twAggSup
))
{
if
(
pInfo
->
ignore
ExpiredData
&&
isCloseWindow
(
&
nextWin
,
&
pInfo
->
twAggSup
))
{
ekey
=
ascScan
?
nextWin
.
ekey
:
nextWin
.
skey
;
ekey
=
ascScan
?
nextWin
.
ekey
:
nextWin
.
skey
;
forwardRows
=
forwardRows
=
getNumOfRowsInTimeWindow
(
&
pBlock
->
info
,
tsCols
,
startPos
,
ekey
,
binarySearchForKey
,
NULL
,
pInfo
->
order
);
getNumOfRowsInTimeWindow
(
&
pBlock
->
info
,
tsCols
,
startPos
,
ekey
,
binarySearchForKey
,
NULL
,
pInfo
->
order
);
...
@@ -1535,7 +1535,7 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo*
...
@@ -1535,7 +1535,7 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo*
pInfo
->
interval
=
*
pInterval
;
pInfo
->
interval
=
*
pInterval
;
pInfo
->
execModel
=
pTaskInfo
->
execModel
;
pInfo
->
execModel
=
pTaskInfo
->
execModel
;
pInfo
->
twAggSup
=
*
pTwAggSupp
;
pInfo
->
twAggSup
=
*
pTwAggSupp
;
pInfo
->
ignore
CloseWindow
=
false
;
pInfo
->
ignore
ExpiredData
=
pPhyNode
->
window
.
igExpired
;
if
(
pPhyNode
->
window
.
pExprs
!=
NULL
)
{
if
(
pPhyNode
->
window
.
pExprs
!=
NULL
)
{
int32_t
numOfScalar
=
0
;
int32_t
numOfScalar
=
0
;
...
@@ -2292,7 +2292,7 @@ static void doHashInterval(SOperatorInfo* pOperatorInfo, SSDataBlock* pSDataBloc
...
@@ -2292,7 +2292,7 @@ static void doHashInterval(SOperatorInfo* pOperatorInfo, SSDataBlock* pSDataBloc
pInfo
->
interval
.
precision
,
NULL
);
pInfo
->
interval
.
precision
,
NULL
);
while
(
1
)
{
while
(
1
)
{
bool
isClosed
=
isCloseWindow
(
&
nextWin
,
&
pInfo
->
twAggSup
);
bool
isClosed
=
isCloseWindow
(
&
nextWin
,
&
pInfo
->
twAggSup
);
if
(
pInfo
->
ignore
CloseWindow
&&
isClosed
)
{
if
(
pInfo
->
ignore
ExpiredData
&&
isClosed
)
{
startPos
=
getNexWindowPos
(
&
pInfo
->
interval
,
&
pSDataBlock
->
info
,
tsCols
,
startPos
,
nextWin
.
ekey
,
&
nextWin
);
startPos
=
getNexWindowPos
(
&
pInfo
->
interval
,
&
pSDataBlock
->
info
,
tsCols
,
startPos
,
nextWin
.
ekey
,
&
nextWin
);
if
(
startPos
<
0
)
{
if
(
startPos
<
0
)
{
break
;
break
;
...
@@ -2710,7 +2710,7 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream,
...
@@ -2710,7 +2710,7 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream,
_hash_fn_t
hashFn
=
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
);
_hash_fn_t
hashFn
=
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
);
pInfo
->
pPullDataMap
=
taosHashInit
(
64
,
hashFn
,
false
,
HASH_NO_LOCK
);
pInfo
->
pPullDataMap
=
taosHashInit
(
64
,
hashFn
,
false
,
HASH_NO_LOCK
);
pInfo
->
pPullDataRes
=
createPullDataBlock
();
pInfo
->
pPullDataRes
=
createPullDataBlock
();
pInfo
->
ignore
CloseWindow
=
false
;
pInfo
->
ignore
ExpiredData
=
pIntervalPhyNode
->
window
.
igExpired
;
pOperator
->
operatorType
=
pPhyNode
->
type
;
pOperator
->
operatorType
=
pPhyNode
->
type
;
pOperator
->
blocking
=
true
;
pOperator
->
blocking
=
true
;
...
@@ -2857,7 +2857,7 @@ SOperatorInfo* createStreamSessionAggOperatorInfo(SOperatorInfo* downstream, SPh
...
@@ -2857,7 +2857,7 @@ SOperatorInfo* createStreamSessionAggOperatorInfo(SOperatorInfo* downstream, SPh
pInfo
->
pChildren
=
NULL
;
pInfo
->
pChildren
=
NULL
;
pInfo
->
isFinal
=
false
;
pInfo
->
isFinal
=
false
;
pInfo
->
pPhyNode
=
pPhyNode
;
pInfo
->
pPhyNode
=
pPhyNode
;
pInfo
->
ignore
CloseWindow
=
false
;
pInfo
->
ignore
ExpiredData
=
pSessionNode
->
window
.
igExpired
;
pOperator
->
name
=
"StreamSessionWindowAggOperator"
;
pOperator
->
name
=
"StreamSessionWindowAggOperator"
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION
;
...
@@ -3133,7 +3133,7 @@ static void doStreamSessionAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSData
...
@@ -3133,7 +3133,7 @@ static void doStreamSessionAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSData
SStreamAggSupporter
*
pAggSup
=
&
pInfo
->
streamAggSup
;
SStreamAggSupporter
*
pAggSup
=
&
pInfo
->
streamAggSup
;
for
(
int32_t
i
=
0
;
i
<
pSDataBlock
->
info
.
rows
;)
{
for
(
int32_t
i
=
0
;
i
<
pSDataBlock
->
info
.
rows
;)
{
if
(
pInfo
->
ignore
CloseWindow
&&
isOverdue
(
endTsCols
[
i
],
&
pInfo
->
twAggSup
))
{
if
(
pInfo
->
ignore
ExpiredData
&&
isOverdue
(
endTsCols
[
i
],
&
pInfo
->
twAggSup
))
{
i
++
;
i
++
;
continue
;
continue
;
}
}
...
@@ -3413,8 +3413,8 @@ static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) {
...
@@ -3413,8 +3413,8 @@ static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) {
pOperator
->
status
=
OP_RES_TO_RETURN
;
pOperator
->
status
=
OP_RES_TO_RETURN
;
closeSessionWindow
(
pInfo
->
streamAggSup
.
pResultRows
,
&
pInfo
->
twAggSup
,
pUpdated
,
closeSessionWindow
(
pInfo
->
streamAggSup
.
pResultRows
,
&
pInfo
->
twAggSup
,
pUpdated
,
getResWinForSession
,
pInfo
->
ignore
CloseWindow
);
getResWinForSession
,
pInfo
->
ignore
ExpiredData
);
closeChildSessionWindow
(
pInfo
->
pChildren
,
pInfo
->
twAggSup
.
maxTs
,
pInfo
->
ignore
CloseWindow
);
closeChildSessionWindow
(
pInfo
->
pChildren
,
pInfo
->
twAggSup
.
maxTs
,
pInfo
->
ignore
ExpiredData
);
copyUpdateResult
(
pStUpdated
,
pUpdated
);
copyUpdateResult
(
pStUpdated
,
pUpdated
);
taosHashCleanup
(
pStUpdated
);
taosHashCleanup
(
pStUpdated
);
...
@@ -3822,7 +3822,7 @@ static void doStreamStateAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSDataBl
...
@@ -3822,7 +3822,7 @@ static void doStreamStateAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSDataBl
SStreamAggSupporter
*
pAggSup
=
&
pInfo
->
streamAggSup
;
SStreamAggSupporter
*
pAggSup
=
&
pInfo
->
streamAggSup
;
SColumnInfoData
*
pKeyColInfo
=
taosArrayGet
(
pSDataBlock
->
pDataBlock
,
pInfo
->
stateCol
.
slotId
);
SColumnInfoData
*
pKeyColInfo
=
taosArrayGet
(
pSDataBlock
->
pDataBlock
,
pInfo
->
stateCol
.
slotId
);
for
(
int32_t
i
=
0
;
i
<
pSDataBlock
->
info
.
rows
;
i
+=
winRows
)
{
for
(
int32_t
i
=
0
;
i
<
pSDataBlock
->
info
.
rows
;
i
+=
winRows
)
{
if
(
pInfo
->
ignore
CloseWindow
&&
isOverdue
(
tsCols
[
i
],
&
pInfo
->
twAggSup
))
{
if
(
pInfo
->
ignore
ExpiredData
&&
isOverdue
(
tsCols
[
i
],
&
pInfo
->
twAggSup
))
{
i
++
;
i
++
;
continue
;
continue
;
}
}
...
@@ -3866,12 +3866,14 @@ static SSDataBlock* doStreamStateAgg(SOperatorInfo* pOperator) {
...
@@ -3866,12 +3866,14 @@ static SSDataBlock* doStreamStateAgg(SOperatorInfo* pOperator) {
if
(
pOperator
->
status
==
OP_RES_TO_RETURN
)
{
if
(
pOperator
->
status
==
OP_RES_TO_RETURN
)
{
doBuildDeleteDataBlock
(
pInfo
->
pSeDeleted
,
pInfo
->
pDelRes
,
&
pInfo
->
pDelIterator
);
doBuildDeleteDataBlock
(
pInfo
->
pSeDeleted
,
pInfo
->
pDelRes
,
&
pInfo
->
pDelIterator
);
if
(
pInfo
->
pDelRes
->
info
.
rows
>
0
)
{
if
(
pInfo
->
pDelRes
->
info
.
rows
>
0
)
{
printDataBlock
(
pInfo
->
pDelRes
,
"single state"
);
return
pInfo
->
pDelRes
;
return
pInfo
->
pDelRes
;
}
}
doBuildResultDatablock
(
pOperator
,
pBInfo
,
&
pInfo
->
groupResInfo
,
pInfo
->
streamAggSup
.
pResultBuf
);
doBuildResultDatablock
(
pOperator
,
pBInfo
,
&
pInfo
->
groupResInfo
,
pInfo
->
streamAggSup
.
pResultBuf
);
if
(
pBInfo
->
pRes
->
info
.
rows
==
0
||
!
hasDataInGroupInfo
(
&
pInfo
->
groupResInfo
))
{
if
(
pBInfo
->
pRes
->
info
.
rows
==
0
||
!
hasDataInGroupInfo
(
&
pInfo
->
groupResInfo
))
{
doSetOperatorCompleted
(
pOperator
);
doSetOperatorCompleted
(
pOperator
);
}
}
printDataBlock
(
pBInfo
->
pRes
,
"single state"
);
return
pBInfo
->
pRes
->
info
.
rows
==
0
?
NULL
:
pBInfo
->
pRes
;
return
pBInfo
->
pRes
->
info
.
rows
==
0
?
NULL
:
pBInfo
->
pRes
;
}
}
...
@@ -3884,6 +3886,7 @@ static SSDataBlock* doStreamStateAgg(SOperatorInfo* pOperator) {
...
@@ -3884,6 +3886,7 @@ static SSDataBlock* doStreamStateAgg(SOperatorInfo* pOperator) {
if
(
pBlock
==
NULL
)
{
if
(
pBlock
==
NULL
)
{
break
;
break
;
}
}
printDataBlock
(
pBlock
,
"single state recv"
);
if
(
pBlock
->
info
.
type
==
STREAM_CLEAR
)
{
if
(
pBlock
->
info
.
type
==
STREAM_CLEAR
)
{
doClearStateWindows
(
&
pInfo
->
streamAggSup
,
pBlock
,
pInfo
->
primaryTsIndex
,
&
pInfo
->
stateCol
,
pInfo
->
stateCol
.
slotId
,
doClearStateWindows
(
&
pInfo
->
streamAggSup
,
pBlock
,
pInfo
->
primaryTsIndex
,
&
pInfo
->
stateCol
,
pInfo
->
stateCol
.
slotId
,
...
@@ -3903,8 +3906,8 @@ static SSDataBlock* doStreamStateAgg(SOperatorInfo* pOperator) {
...
@@ -3903,8 +3906,8 @@ static SSDataBlock* doStreamStateAgg(SOperatorInfo* pOperator) {
pOperator
->
status
=
OP_RES_TO_RETURN
;
pOperator
->
status
=
OP_RES_TO_RETURN
;
closeSessionWindow
(
pInfo
->
streamAggSup
.
pResultRows
,
&
pInfo
->
twAggSup
,
pUpdated
,
closeSessionWindow
(
pInfo
->
streamAggSup
.
pResultRows
,
&
pInfo
->
twAggSup
,
pUpdated
,
getResWinForState
,
pInfo
->
ignore
CloseWindow
);
getResWinForState
,
pInfo
->
ignore
ExpiredData
);
closeChildSessionWindow
(
pInfo
->
pChildren
,
pInfo
->
twAggSup
.
maxTs
,
pInfo
->
ignore
CloseWindow
);
closeChildSessionWindow
(
pInfo
->
pChildren
,
pInfo
->
twAggSup
.
maxTs
,
pInfo
->
ignore
ExpiredData
);
copyUpdateResult
(
pSeUpdated
,
pUpdated
);
copyUpdateResult
(
pSeUpdated
,
pUpdated
);
taosHashCleanup
(
pSeUpdated
);
taosHashCleanup
(
pSeUpdated
);
...
@@ -3914,9 +3917,11 @@ static SSDataBlock* doStreamStateAgg(SOperatorInfo* pOperator) {
...
@@ -3914,9 +3917,11 @@ static SSDataBlock* doStreamStateAgg(SOperatorInfo* pOperator) {
blockDataEnsureCapacity
(
pInfo
->
binfo
.
pRes
,
pOperator
->
resultInfo
.
capacity
);
blockDataEnsureCapacity
(
pInfo
->
binfo
.
pRes
,
pOperator
->
resultInfo
.
capacity
);
doBuildDeleteDataBlock
(
pInfo
->
pSeDeleted
,
pInfo
->
pDelRes
,
&
pInfo
->
pDelIterator
);
doBuildDeleteDataBlock
(
pInfo
->
pSeDeleted
,
pInfo
->
pDelRes
,
&
pInfo
->
pDelIterator
);
if
(
pInfo
->
pDelRes
->
info
.
rows
>
0
)
{
if
(
pInfo
->
pDelRes
->
info
.
rows
>
0
)
{
printDataBlock
(
pInfo
->
pDelRes
,
"single state"
);
return
pInfo
->
pDelRes
;
return
pInfo
->
pDelRes
;
}
}
doBuildResultDatablock
(
pOperator
,
&
pInfo
->
binfo
,
&
pInfo
->
groupResInfo
,
pInfo
->
streamAggSup
.
pResultBuf
);
doBuildResultDatablock
(
pOperator
,
&
pInfo
->
binfo
,
&
pInfo
->
groupResInfo
,
pInfo
->
streamAggSup
.
pResultBuf
);
printDataBlock
(
pBInfo
->
pRes
,
"single state"
);
return
pBInfo
->
pRes
->
info
.
rows
==
0
?
NULL
:
pBInfo
->
pRes
;
return
pBInfo
->
pRes
->
info
.
rows
==
0
?
NULL
:
pBInfo
->
pRes
;
}
}
...
@@ -3978,7 +3983,7 @@ SOperatorInfo* createStreamStateAggOperatorInfo(SOperatorInfo* downstream, SPhys
...
@@ -3978,7 +3983,7 @@ SOperatorInfo* createStreamStateAggOperatorInfo(SOperatorInfo* downstream, SPhys
pInfo
->
pDelRes
->
info
.
type
=
STREAM_DELETE
;
pInfo
->
pDelRes
->
info
.
type
=
STREAM_DELETE
;
blockDataEnsureCapacity
(
pInfo
->
pDelRes
,
64
);
blockDataEnsureCapacity
(
pInfo
->
pDelRes
,
64
);
pInfo
->
pChildren
=
NULL
;
pInfo
->
pChildren
=
NULL
;
pInfo
->
ignore
CloseWindow
=
false
;
pInfo
->
ignore
ExpiredData
=
pStateNode
->
window
.
igExpired
;
pOperator
->
name
=
"StreamStateAggOperator"
;
pOperator
->
name
=
"StreamStateAggOperator"
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE
;
...
...
source/libs/function/src/builtins.c
浏览文件 @
33525deb
...
@@ -39,6 +39,174 @@ static int32_t invaildFuncParaValueErrMsg(char* pErrBuf, int32_t len, const char
...
@@ -39,6 +39,174 @@ static int32_t invaildFuncParaValueErrMsg(char* pErrBuf, int32_t len, const char
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_PARA_VALUE
,
"Invalid parameter value : %s"
,
pFuncName
);
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_PARA_VALUE
,
"Invalid parameter value : %s"
,
pFuncName
);
}
}
#define TIME_UNIT_INVALID 1
#define TIME_UNIT_TOO_SMALL 2
static
int32_t
validateTimeUnitParam
(
uint8_t
dbPrec
,
const
SValueNode
*
pVal
)
{
if
(
!
pVal
->
isDuration
)
{
return
TIME_UNIT_INVALID
;
}
if
(
TSDB_TIME_PRECISION_MILLI
==
dbPrec
&&
0
==
strcasecmp
(
pVal
->
literal
,
"1u"
))
{
return
TIME_UNIT_TOO_SMALL
;
}
if
(
pVal
->
literal
[
0
]
!=
'1'
||
(
pVal
->
literal
[
1
]
!=
'u'
&&
pVal
->
literal
[
1
]
!=
'a'
&&
pVal
->
literal
[
1
]
!=
's'
&&
pVal
->
literal
[
1
]
!=
'm'
&&
pVal
->
literal
[
1
]
!=
'h'
&&
pVal
->
literal
[
1
]
!=
'd'
&&
pVal
->
literal
[
1
]
!=
'w'
))
{
return
TIME_UNIT_INVALID
;
}
return
TSDB_CODE_SUCCESS
;
}
/* Following are valid ISO-8601 timezone format:
* 1 z/Z
* 2 ±hh:mm
* 3 ±hhmm
* 4 ±hh
*
*/
static
bool
validateHourRange
(
int8_t
hour
)
{
if
(
hour
<
0
||
hour
>
12
)
{
return
false
;
}
return
true
;
}
static
bool
validateMinuteRange
(
int8_t
hour
,
int8_t
minute
,
char
sign
)
{
if
(
minute
==
0
||
(
minute
==
30
&&
(
hour
==
3
||
hour
==
5
)
&&
sign
==
'+'
))
{
return
true
;
}
return
false
;
}
static
bool
validateTimestampDigits
(
const
SValueNode
*
pVal
)
{
if
(
!
IS_INTEGER_TYPE
(
pVal
->
node
.
resType
.
type
))
{
return
false
;
}
int64_t
tsVal
=
pVal
->
datum
.
i
;
char
fraction
[
20
]
=
{
0
};
NUM_TO_STRING
(
pVal
->
node
.
resType
.
type
,
&
tsVal
,
sizeof
(
fraction
),
fraction
);
int32_t
tsDigits
=
(
int32_t
)
strlen
(
fraction
);
if
(
tsDigits
>
TSDB_TIME_PRECISION_SEC_DIGITS
)
{
if
(
tsDigits
==
TSDB_TIME_PRECISION_MILLI_DIGITS
||
tsDigits
==
TSDB_TIME_PRECISION_MICRO_DIGITS
||
tsDigits
==
TSDB_TIME_PRECISION_NANO_DIGITS
)
{
return
true
;
}
else
{
return
false
;
}
}
return
true
;
}
static
bool
validateTimezoneFormat
(
const
SValueNode
*
pVal
)
{
if
(
TSDB_DATA_TYPE_BINARY
!=
pVal
->
node
.
resType
.
type
)
{
return
false
;
}
char
*
tz
=
varDataVal
(
pVal
->
datum
.
p
);
int32_t
len
=
varDataLen
(
pVal
->
datum
.
p
);
char
buf
[
3
]
=
{
0
};
int8_t
hour
=
-
1
,
minute
=
-
1
;
if
(
len
==
0
)
{
return
false
;
}
else
if
(
len
==
1
&&
(
tz
[
0
]
==
'z'
||
tz
[
0
]
==
'Z'
))
{
return
true
;
}
else
if
((
tz
[
0
]
==
'+'
||
tz
[
0
]
==
'-'
))
{
switch
(
len
)
{
case
3
:
case
5
:
{
for
(
int32_t
i
=
1
;
i
<
len
;
++
i
)
{
if
(
!
isdigit
(
tz
[
i
]))
{
return
false
;
}
if
(
i
==
2
)
{
memcpy
(
buf
,
&
tz
[
i
-
1
],
2
);
hour
=
taosStr2Int8
(
buf
,
NULL
,
10
);
if
(
!
validateHourRange
(
hour
))
{
return
false
;
}
}
else
if
(
i
==
4
)
{
memcpy
(
buf
,
&
tz
[
i
-
1
],
2
);
minute
=
taosStr2Int8
(
buf
,
NULL
,
10
);
if
(
!
validateMinuteRange
(
hour
,
minute
,
tz
[
0
]))
{
return
false
;
}
}
}
break
;
}
case
6
:
{
for
(
int32_t
i
=
1
;
i
<
len
;
++
i
)
{
if
(
i
==
3
)
{
if
(
tz
[
i
]
!=
':'
)
{
return
false
;
}
continue
;
}
if
(
!
isdigit
(
tz
[
i
]))
{
return
false
;
}
if
(
i
==
2
)
{
memcpy
(
buf
,
&
tz
[
i
-
1
],
2
);
hour
=
taosStr2Int8
(
buf
,
NULL
,
10
);
if
(
!
validateHourRange
(
hour
))
{
return
false
;
}
}
else
if
(
i
==
5
)
{
memcpy
(
buf
,
&
tz
[
i
-
1
],
2
);
minute
=
taosStr2Int8
(
buf
,
NULL
,
10
);
if
(
!
validateMinuteRange
(
hour
,
minute
,
tz
[
0
]))
{
return
false
;
}
}
}
break
;
}
default:
{
return
false
;
}
}
}
else
{
return
false
;
}
return
true
;
}
void
static
addTimezoneParam
(
SNodeList
*
pList
)
{
char
buf
[
6
]
=
{
0
};
time_t
t
=
taosTime
(
NULL
);
struct
tm
*
tmInfo
=
taosLocalTime
(
&
t
,
NULL
);
strftime
(
buf
,
sizeof
(
buf
),
"%z"
,
tmInfo
);
int32_t
len
=
(
int32_t
)
strlen
(
buf
);
SValueNode
*
pVal
=
(
SValueNode
*
)
nodesMakeNode
(
QUERY_NODE_VALUE
);
pVal
->
literal
=
strndup
(
buf
,
len
);
pVal
->
isDuration
=
false
;
pVal
->
translate
=
true
;
pVal
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_BINARY
;
pVal
->
node
.
resType
.
bytes
=
len
+
VARSTR_HEADER_SIZE
;
pVal
->
node
.
resType
.
precision
=
TSDB_TIME_PRECISION_MILLI
;
pVal
->
datum
.
p
=
taosMemoryCalloc
(
1
,
len
+
VARSTR_HEADER_SIZE
+
1
);
varDataSetLen
(
pVal
->
datum
.
p
,
len
);
strncpy
(
varDataVal
(
pVal
->
datum
.
p
),
pVal
->
literal
,
len
);
nodesListAppend
(
pList
,
(
SNode
*
)
pVal
);
}
void
static
addDbPrecisonParam
(
SNodeList
**
pList
,
uint8_t
precision
)
{
void
static
addDbPrecisonParam
(
SNodeList
**
pList
,
uint8_t
precision
)
{
SValueNode
*
pVal
=
(
SValueNode
*
)
nodesMakeNode
(
QUERY_NODE_VALUE
);
SValueNode
*
pVal
=
(
SValueNode
*
)
nodesMakeNode
(
QUERY_NODE_VALUE
);
pVal
->
literal
=
NULL
;
pVal
->
literal
=
NULL
;
...
@@ -525,9 +693,15 @@ static int32_t translateElapsed(SFunctionNode* pFunc, char* pErrBuf, int32_t len
...
@@ -525,9 +693,15 @@ static int32_t translateElapsed(SFunctionNode* pFunc, char* pErrBuf, int32_t len
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
}
if
(
pValue
->
datum
.
i
==
0
)
{
uint8_t
dbPrec
=
pFunc
->
node
.
resType
.
precision
;
int32_t
ret
=
validateTimeUnitParam
(
dbPrec
,
(
SValueNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
1
));
if
(
ret
==
TIME_UNIT_TOO_SMALL
)
{
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
"ELAPSED function time unit parameter should be greater than db precision"
);
"ELAPSED function time unit parameter should be greater than db precision"
);
}
else
if
(
ret
==
TIME_UNIT_INVALID
)
{
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
"ELAPSED function time unit parameter should be one of the following: [1u, 1a, 1s, 1m, 1h, 1d, 1w]"
);
}
}
}
}
...
@@ -843,6 +1017,19 @@ static int32_t translateStateDuration(SFunctionNode* pFunc, char* pErrBuf, int32
...
@@ -843,6 +1017,19 @@ static int32_t translateStateDuration(SFunctionNode* pFunc, char* pErrBuf, int32
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
}
if
(
numOfParams
==
4
)
{
uint8_t
dbPrec
=
pFunc
->
node
.
resType
.
precision
;
int32_t
ret
=
validateTimeUnitParam
(
dbPrec
,
(
SValueNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
3
));
if
(
ret
==
TIME_UNIT_TOO_SMALL
)
{
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
"STATEDURATION function time unit parameter should be greater than db precision"
);
}
else
if
(
ret
==
TIME_UNIT_INVALID
)
{
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
"STATEDURATION function time unit parameter should be one of the following: [1u, 1a, 1s, 1m, 1h, 1d, 1w]"
);
}
}
// set result type
// set result type
pFunc
->
node
.
resType
=
(
SDataType
){.
bytes
=
tDataTypes
[
TSDB_DATA_TYPE_BIGINT
].
bytes
,
.
type
=
TSDB_DATA_TYPE_BIGINT
};
pFunc
->
node
.
resType
=
(
SDataType
){.
bytes
=
tDataTypes
[
TSDB_DATA_TYPE_BIGINT
].
bytes
,
.
type
=
TSDB_DATA_TYPE_BIGINT
};
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -1284,152 +1471,6 @@ static int32_t translateCast(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
...
@@ -1284,152 +1471,6 @@ static int32_t translateCast(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
/* Following are valid ISO-8601 timezone format:
* 1 z/Z
* 2 ±hh:mm
* 3 ±hhmm
* 4 ±hh
*
*/
static
bool
validateHourRange
(
int8_t
hour
)
{
if
(
hour
<
0
||
hour
>
12
)
{
return
false
;
}
return
true
;
}
static
bool
validateMinuteRange
(
int8_t
hour
,
int8_t
minute
,
char
sign
)
{
if
(
minute
==
0
||
(
minute
==
30
&&
(
hour
==
3
||
hour
==
5
)
&&
sign
==
'+'
))
{
return
true
;
}
return
false
;
}
static
bool
validateTimestampDigits
(
const
SValueNode
*
pVal
)
{
if
(
!
IS_INTEGER_TYPE
(
pVal
->
node
.
resType
.
type
))
{
return
false
;
}
int64_t
tsVal
=
pVal
->
datum
.
i
;
char
fraction
[
20
]
=
{
0
};
NUM_TO_STRING
(
pVal
->
node
.
resType
.
type
,
&
tsVal
,
sizeof
(
fraction
),
fraction
);
int32_t
tsDigits
=
(
int32_t
)
strlen
(
fraction
);
if
(
tsDigits
>
TSDB_TIME_PRECISION_SEC_DIGITS
)
{
if
(
tsDigits
==
TSDB_TIME_PRECISION_MILLI_DIGITS
||
tsDigits
==
TSDB_TIME_PRECISION_MICRO_DIGITS
||
tsDigits
==
TSDB_TIME_PRECISION_NANO_DIGITS
)
{
return
true
;
}
else
{
return
false
;
}
}
return
true
;
}
static
bool
validateTimezoneFormat
(
const
SValueNode
*
pVal
)
{
if
(
TSDB_DATA_TYPE_BINARY
!=
pVal
->
node
.
resType
.
type
)
{
return
false
;
}
char
*
tz
=
varDataVal
(
pVal
->
datum
.
p
);
int32_t
len
=
varDataLen
(
pVal
->
datum
.
p
);
char
buf
[
3
]
=
{
0
};
int8_t
hour
=
-
1
,
minute
=
-
1
;
if
(
len
==
0
)
{
return
false
;
}
else
if
(
len
==
1
&&
(
tz
[
0
]
==
'z'
||
tz
[
0
]
==
'Z'
))
{
return
true
;
}
else
if
((
tz
[
0
]
==
'+'
||
tz
[
0
]
==
'-'
))
{
switch
(
len
)
{
case
3
:
case
5
:
{
for
(
int32_t
i
=
1
;
i
<
len
;
++
i
)
{
if
(
!
isdigit
(
tz
[
i
]))
{
return
false
;
}
if
(
i
==
2
)
{
memcpy
(
buf
,
&
tz
[
i
-
1
],
2
);
hour
=
taosStr2Int8
(
buf
,
NULL
,
10
);
if
(
!
validateHourRange
(
hour
))
{
return
false
;
}
}
else
if
(
i
==
4
)
{
memcpy
(
buf
,
&
tz
[
i
-
1
],
2
);
minute
=
taosStr2Int8
(
buf
,
NULL
,
10
);
if
(
!
validateMinuteRange
(
hour
,
minute
,
tz
[
0
]))
{
return
false
;
}
}
}
break
;
}
case
6
:
{
for
(
int32_t
i
=
1
;
i
<
len
;
++
i
)
{
if
(
i
==
3
)
{
if
(
tz
[
i
]
!=
':'
)
{
return
false
;
}
continue
;
}
if
(
!
isdigit
(
tz
[
i
]))
{
return
false
;
}
if
(
i
==
2
)
{
memcpy
(
buf
,
&
tz
[
i
-
1
],
2
);
hour
=
taosStr2Int8
(
buf
,
NULL
,
10
);
if
(
!
validateHourRange
(
hour
))
{
return
false
;
}
}
else
if
(
i
==
5
)
{
memcpy
(
buf
,
&
tz
[
i
-
1
],
2
);
minute
=
taosStr2Int8
(
buf
,
NULL
,
10
);
if
(
!
validateMinuteRange
(
hour
,
minute
,
tz
[
0
]))
{
return
false
;
}
}
}
break
;
}
default:
{
return
false
;
}
}
}
else
{
return
false
;
}
return
true
;
}
void
static
addTimezoneParam
(
SNodeList
*
pList
)
{
char
buf
[
6
]
=
{
0
};
time_t
t
=
taosTime
(
NULL
);
struct
tm
*
tmInfo
=
taosLocalTime
(
&
t
,
NULL
);
strftime
(
buf
,
sizeof
(
buf
),
"%z"
,
tmInfo
);
int32_t
len
=
(
int32_t
)
strlen
(
buf
);
SValueNode
*
pVal
=
(
SValueNode
*
)
nodesMakeNode
(
QUERY_NODE_VALUE
);
pVal
->
literal
=
strndup
(
buf
,
len
);
pVal
->
isDuration
=
false
;
pVal
->
translate
=
true
;
pVal
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_BINARY
;
pVal
->
node
.
resType
.
bytes
=
len
+
VARSTR_HEADER_SIZE
;
pVal
->
node
.
resType
.
precision
=
TSDB_TIME_PRECISION_MILLI
;
pVal
->
datum
.
p
=
taosMemoryCalloc
(
1
,
len
+
VARSTR_HEADER_SIZE
+
1
);
varDataSetLen
(
pVal
->
datum
.
p
,
len
);
strncpy
(
varDataVal
(
pVal
->
datum
.
p
),
pVal
->
literal
,
len
);
nodesListAppend
(
pList
,
(
SNode
*
)
pVal
);
}
static
int32_t
translateToIso8601
(
SFunctionNode
*
pFunc
,
char
*
pErrBuf
,
int32_t
len
)
{
static
int32_t
translateToIso8601
(
SFunctionNode
*
pFunc
,
char
*
pErrBuf
,
int32_t
len
)
{
int32_t
numOfParams
=
LIST_LENGTH
(
pFunc
->
pParameterList
);
int32_t
numOfParams
=
LIST_LENGTH
(
pFunc
->
pParameterList
);
if
(
1
!=
numOfParams
&&
2
!=
numOfParams
)
{
if
(
1
!=
numOfParams
&&
2
!=
numOfParams
)
{
...
@@ -1498,6 +1539,16 @@ static int32_t translateTimeTruncate(SFunctionNode* pFunc, char* pErrBuf, int32_
...
@@ -1498,6 +1539,16 @@ static int32_t translateTimeTruncate(SFunctionNode* pFunc, char* pErrBuf, int32_
// add database precision as param
// add database precision as param
uint8_t
dbPrec
=
pFunc
->
node
.
resType
.
precision
;
uint8_t
dbPrec
=
pFunc
->
node
.
resType
.
precision
;
int32_t
ret
=
validateTimeUnitParam
(
dbPrec
,
(
SValueNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
1
));
if
(
ret
==
TIME_UNIT_TOO_SMALL
)
{
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
"TIMETRUNCATE function time unit parameter should be greater than db precision"
);
}
else
if
(
ret
==
TIME_UNIT_INVALID
)
{
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
"TIMETRUNCATE function time unit parameter should be one of the following: [1u, 1a, 1s, 1m, 1h, 1d, 1w]"
);
}
addDbPrecisonParam
(
&
pFunc
->
pParameterList
,
dbPrec
);
addDbPrecisonParam
(
&
pFunc
->
pParameterList
,
dbPrec
);
pFunc
->
node
.
resType
=
pFunc
->
node
.
resType
=
...
@@ -1526,6 +1577,18 @@ static int32_t translateTimeDiff(SFunctionNode* pFunc, char* pErrBuf, int32_t le
...
@@ -1526,6 +1577,18 @@ static int32_t translateTimeDiff(SFunctionNode* pFunc, char* pErrBuf, int32_t le
// add database precision as param
// add database precision as param
uint8_t
dbPrec
=
pFunc
->
node
.
resType
.
precision
;
uint8_t
dbPrec
=
pFunc
->
node
.
resType
.
precision
;
if
(
3
==
numOfParams
)
{
int32_t
ret
=
validateTimeUnitParam
(
dbPrec
,
(
SValueNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
2
));
if
(
ret
==
TIME_UNIT_TOO_SMALL
)
{
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
"TIMEDIFF function time unit parameter should be greater than db precision"
);
}
else
if
(
ret
==
TIME_UNIT_INVALID
)
{
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
"TIMEDIFF function time unit parameter should be one of the following: [1u, 1a, 1s, 1m, 1h, 1d, 1w]"
);
}
}
addDbPrecisonParam
(
&
pFunc
->
pParameterList
,
dbPrec
);
addDbPrecisonParam
(
&
pFunc
->
pParameterList
,
dbPrec
);
pFunc
->
node
.
resType
=
(
SDataType
){.
bytes
=
tDataTypes
[
TSDB_DATA_TYPE_BIGINT
].
bytes
,
.
type
=
TSDB_DATA_TYPE_BIGINT
};
pFunc
->
node
.
resType
=
(
SDataType
){.
bytes
=
tDataTypes
[
TSDB_DATA_TYPE_BIGINT
].
bytes
,
.
type
=
TSDB_DATA_TYPE_BIGINT
};
...
...
source/libs/index/CMakeLists.txt
浏览文件 @
33525deb
...
@@ -35,7 +35,7 @@ if (${BUILD_WITH_INVERTEDINDEX})
...
@@ -35,7 +35,7 @@ if (${BUILD_WITH_INVERTEDINDEX})
endif
(
${
BUILD_WITH_INVERTEDINDEX
}
)
endif
(
${
BUILD_WITH_INVERTEDINDEX
}
)
if
(
${
BUILD_TEST
}
)
#
if (${BUILD_TEST})
add_subdirectory
(
test
)
#
add_subdirectory(test)
endif
(
${
BUILD_TEST
}
)
#
endif(${BUILD_TEST})
source/os/src/osString.c
浏览文件 @
33525deb
...
@@ -196,7 +196,7 @@ int32_t taosUcs4len(TdUcs4 *ucs4) {
...
@@ -196,7 +196,7 @@ int32_t taosUcs4len(TdUcs4 *ucs4) {
}
}
//dst buffer size should be at least 2*len + 1
//dst buffer size should be at least 2*len + 1
int32_t
taosHexEncode
(
const
char
*
src
,
char
*
dst
,
int32_t
len
)
{
int32_t
taosHexEncode
(
const
unsigned
char
*
src
,
char
*
dst
,
int32_t
len
)
{
if
(
!
dst
)
{
if
(
!
dst
)
{
return
-
1
;
return
-
1
;
}
}
...
...
source/util/src/terror.c
浏览文件 @
33525deb
...
@@ -590,6 +590,8 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TSMA_NO_INDEX_IN_CACHE, "No tsma index in ca
...
@@ -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_ENV
,
"Invalid rsma env"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_RSMA_INVALID_STAT
,
"Invalid rsma state"
)
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_QTASKINFO_CREATE
,
"Rsma qtaskinfo creation error"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_RSMA_FILE_CORRUPTED
,
"Rsma file corrupted"
)
//tq
//tq
TAOS_DEFINE_ERROR
(
TSDB_CODE_TQ_NO_COMMITTED_OFFSET
,
"No committed offset"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_TQ_NO_COMMITTED_OFFSET
,
"No committed offset"
)
...
...
tests/script/jenkins/basic.txt
浏览文件 @
33525deb
...
@@ -93,6 +93,7 @@
...
@@ -93,6 +93,7 @@
./test.sh -f tsim/stream/basic0.sim
./test.sh -f tsim/stream/basic0.sim
./test.sh -f tsim/stream/basic1.sim
./test.sh -f tsim/stream/basic1.sim
./test.sh -f tsim/stream/basic2.sim
./test.sh -f tsim/stream/basic2.sim
./test.sh -f tsim/stream/drop_stream.sim
./test.sh -f tsim/stream/distributeInterval0.sim
./test.sh -f tsim/stream/distributeInterval0.sim
# ./test.sh -f tsim/stream/distributeIntervalRetrive0.sim
# ./test.sh -f tsim/stream/distributeIntervalRetrive0.sim
# ./test.sh -f tsim/stream/distributesession0.sim
# ./test.sh -f tsim/stream/distributesession0.sim
...
@@ -159,6 +160,7 @@
...
@@ -159,6 +160,7 @@
#./test.sh -f tsim/mnode/basic1.sim -m
#./test.sh -f tsim/mnode/basic1.sim -m
# --- sma
# --- sma
./test.sh -f tsim/sma/drop_sma.sim
./test.sh -f tsim/sma/tsmaCreateInsertQuery.sim
./test.sh -f tsim/sma/tsmaCreateInsertQuery.sim
./test.sh -f tsim/sma/rsmaCreateInsertQuery.sim
./test.sh -f tsim/sma/rsmaCreateInsertQuery.sim
...
...
tests/script/sh/deploy.sh
浏览文件 @
33525deb
...
@@ -135,7 +135,7 @@ echo "jniDebugFlag 143" >> $TAOS_CFG
...
@@ -135,7 +135,7 @@ echo "jniDebugFlag 143" >> $TAOS_CFG
echo
"qDebugFlag 143"
>>
$TAOS_CFG
echo
"qDebugFlag 143"
>>
$TAOS_CFG
echo
"rpcDebugFlag 143"
>>
$TAOS_CFG
echo
"rpcDebugFlag 143"
>>
$TAOS_CFG
echo
"tmrDebugFlag 131"
>>
$TAOS_CFG
echo
"tmrDebugFlag 131"
>>
$TAOS_CFG
echo
"uDebugFlag 1
43
"
>>
$TAOS_CFG
echo
"uDebugFlag 1
31
"
>>
$TAOS_CFG
echo
"sDebugFlag 143"
>>
$TAOS_CFG
echo
"sDebugFlag 143"
>>
$TAOS_CFG
echo
"wDebugFlag 143"
>>
$TAOS_CFG
echo
"wDebugFlag 143"
>>
$TAOS_CFG
echo
"numOfLogLines 20000000"
>>
$TAOS_CFG
echo
"numOfLogLines 20000000"
>>
$TAOS_CFG
...
...
tests/script/tsim/sma/drop_sma.sim
浏览文件 @
33525deb
...
@@ -64,12 +64,59 @@ sql create sma index sma_index_name1 on stb function(max(c1),max(c2),min(c1)) in
...
@@ -64,12 +64,59 @@ sql create sma index sma_index_name1 on stb function(max(c1),max(c2),min(c1)) in
print --> drop stb
print --> drop stb
sql drop table stb;
sql drop table stb;
print ========== step5
sql drop database if exists db;
sql create database db duration 300;
sql use db;
sql create table stb1(ts timestamp, c_int int, c_bint bigint, c_sint smallint, c_tint tinyint, c_float float, c_double double, c_bool bool, c_binary binary(16), c_nchar nchar(32), c_ts timestamp, c_tint_un tinyint unsigned, c_sint_un smallint unsigned, c_int_un int unsigned, c_bint_un bigint unsigned) tags (t_int int);
sql CREATE SMA INDEX sma_index_1 ON stb1 function(min(c_int), max(c_int)) interval(6m, 10s) sliding(6m) watermark 5s;
print ========== step6 repeat
sql drop database if exists db;
sql create database db duration 300;
sql use db;
sql create table stb1(ts timestamp, c_int int, c_bint bigint ) tags (t_int int);
sql CREATE SMA INDEX sma_index_1 ON stb1 function(min(c_int), max(c_int)) interval(6m, 10s) sliding(6m) watermark 5s;
print ========== step7
sql drop database if exists db;
sql create database db duration 300;
sql use db;
sql create table stb1(ts timestamp, c_int int, c_bint bigint, c_sint smallint, c_tint tinyint,c_float float, c_double double, c_bool bool,c_binary binary(16), c_nchar nchar(32), c_ts timestamp,c_tint_un tinyint unsigned, c_sint_un smallint unsigned,c_int_un int unsigned, c_bint_un bigint unsigned) tags (t_int int);
sql create table ct1 using stb1 tags ( 1 );
sql create table ct2 using stb1 tags ( 2 );
sql create table ct3 using stb1 tags ( 3 );
sql create table ct4 using stb1 tags ( 4 );
sql CREATE SMA INDEX sma_index_1 ON stb1 function(min(c_int), max(c_int)) interval(6m, 10s) sliding(6m) watermark 5s;
sql CREATE SMA INDEX sma_index_2 ON stb1 function(min(c_int), max(c_int)) interval(6m, 10s) sliding(6m) max_delay 6m;
sql CREATE SMA INDEX sma_index_3 ON stb1 function(min(c_int), max(c_int)) interval(6m, 10s) watermark 5s max_delay 6m;
sql DROP INDEX sma_index_1 ;
sql DROP INDEX sma_index_2 ;
sql DROP INDEX sma_index_3 ;
print ========== step8
sql drop database if exists db;
sql create database db duration 300;
sql use db;
sql create table stb1(ts timestamp, c_int int, c_bint bigint, c_sint smallint, c_tint tinyint,c_float float, c_double double, c_bool bool,c_binary binary(16), c_nchar nchar(32), c_ts timestamp,c_tint_un tinyint unsigned, c_sint_un smallint unsigned,c_int_un int unsigned, c_bint_un bigint unsigned) tags (t_int int);
sql create table ct1 using stb1 tags ( 1 );
sql create table ct2 using stb1 tags ( 2 );
sql create table ct3 using stb1 tags ( 3 );
sql create table ct4 using stb1 tags ( 4 );
sql CREATE SMA INDEX sma_index_1 ON stb1 function(min(c_int), max(c_int)) interval(6m, 10s) sliding(6m) watermark 5s;
sql CREATE SMA INDEX sma_index_2 ON stb1 function(min(c_int), max(c_int)) interval(6m, 10s) sliding(6m) max_delay 6m;
sql CREATE SMA INDEX sma_index_3 ON stb1 function(min(c_int), max(c_int)) interval(6m, 10s) watermark 5s max_delay 6m;
sql DROP INDEX sma_index_1 ;
sql DROP INDEX sma_index_2 ;
sql DROP INDEX sma_index_3 ;
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode2 -s stop -x SIGINT
system sh/exec.sh -n dnode2 -s stop -x SIGINT
system sh/exec.sh -n dnode3 -s stop -x SIGINT
system sh/exec.sh -n dnode3 -s stop -x SIGINT
system sh/exec.sh -n dnode4 -s stop -x SIGINT
system sh/exec.sh -n dnode4 -s stop -x SIGINT
system sh/exec.sh -n dnode5 -s stop -x SIGINT
\ No newline at end of file
system sh/exec.sh -n dnode6 -s stop -x SIGINT
system sh/exec.sh -n dnode7 -s stop -x SIGINT
system sh/exec.sh -n dnode8 -s stop -x SIGINT
\ No newline at end of file
tests/script/tsim/stream/distributeInterval0.sim
浏览文件 @
33525deb
...
@@ -83,9 +83,9 @@ sql insert into ts3 values(1648791243006,4,2,3,3.1) (1648791213001,1,52,13,1.0)
...
@@ -83,9 +83,9 @@ sql insert into ts3 values(1648791243006,4,2,3,3.1) (1648791213001,1,52,13,1.0)
$loop_count = 0
$loop_count = 0
loop1:
loop1:
sleep 300
sql select * from streamtST1;
sql select * from streamtST1;
sleep 300
$loop_count = $loop_count + 1
$loop_count = $loop_count + 1
if $loop_count == 10 then
if $loop_count == 10 then
return -1
return -1
...
...
tests/script/tsim/stream/distributeSession0.sim
浏览文件 @
33525deb
...
@@ -10,6 +10,30 @@ sql create dnode $hostname2 port 7200
...
@@ -10,6 +10,30 @@ sql create dnode $hostname2 port 7200
system sh/exec.sh -n dnode2 -s start
system sh/exec.sh -n dnode2 -s start
print ===== step1
$x = 0
step1:
$x = $x + 1
sleep 1000
if $x == 10 then
print ====> dnode not ready!
return -1
endi
sql show dnodes
print ===> $data00 $data01 $data02 $data03 $data04 $data05
print ===> $data10 $data11 $data12 $data13 $data14 $data15
if $rows != 2 then
return -1
endi
if $data(1)[4] != ready then
goto step1
endi
if $data(2)[4] != ready then
goto step1
endi
print ===== step2
sql create database test vgroups 4;
sql create database test vgroups 4;
sql use test;
sql use test;
sql create stable st(ts timestamp,a int,b int,c int) tags(ta int,tb int,tc int);
sql create stable st(ts timestamp,a int,b int,c int) tags(ta int,tb int,tc int);
...
...
tests/script/tsim/stream/drop_stream.sim
0 → 100644
浏览文件 @
33525deb
此差异已折叠。
点击以展开。
tests/script/tsim/stream/ignoreExpiredData.sim
0 → 100644
浏览文件 @
33525deb
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/deploy.sh -n dnode2 -i 2
system sh/exec.sh -n dnode1 -s start
sleep 50
sql connect
sql create dnode $hostname2 port 7200
system sh/exec.sh -n dnode2 -s start
print ===== step1
$x = 0
step1:
$x = $x + 1
sleep 1000
if $x == 10 then
print ====> dnode not ready!
return -1
endi
sql show dnodes
print ===> $data00 $data01 $data02 $data03 $data04 $data05
print ===> $data10 $data11 $data12 $data13 $data14 $data15
if $rows != 2 then
return -1
endi
if $data(1)[4] != ready then
goto step1
endi
if $data(2)[4] != ready then
goto step1
endi
print ===== step2
print =============== create database
sql create database test vgroups 1
sql show databases
if $rows != 3 then
return -1
endi
print $data00 $data01 $data02
sql use test
sql create table t1(ts timestamp, a int, b int , c int, d double);
sql create stream streams1 trigger at_once IGNORE EXPIRED into streamt1 as select _wstartts, count(*) c1, sum(a) c3 from t1 interval(10s);
sql create stream streams2 trigger at_once IGNORE EXPIRED into streamt2 as select _wstartts, count(*) c1, sum(a) c3 from t1 session(ts,10s);
sql create stream streams3 trigger at_once IGNORE EXPIRED into streamt3 as select _wstartts, count(*) c1, sum(a) c3 from t1 state_window(a);
sql insert into t1 values(1648791213000,1,2,3,1.0);
sql insert into t1 values(1648791223001,1,2,3,1.1);
sql insert into t1 values(1648791233002,2,2,3,2.1);
sql insert into t1 values(1648791243003,2,2,3,3.1);
sql insert into t1 values(1648791200000,4,2,3,4.1);
$loop_count = 0
loop1:
sleep 300
sql select * from streamt1;
$loop_count = $loop_count + 1
if $loop_count == 10 then
return -1
endi
if $rows != 4 then
print =====rows=$rows
goto loop1
endi
$loop_count = 0
loop2:
sleep 300
sql select * from streamt2;
$loop_count = $loop_count + 1
if $loop_count == 10 then
return -1
endi
if $rows != 4 then
print =====rows=$rows
goto loop2
endi
$loop_count = 0
loop3:
sleep 300
sql select * from streamt3;
$loop_count = $loop_count + 1
if $loop_count == 10 then
return -1
endi
if $rows != 2 then
print =====rows=$rows
goto loop3
endi
print =============== create database
sql create database test1 vgroups 4
sql show databases
print ======database=$rows
sql use test1
sql create stable st(ts timestamp,a int,b int,c int) tags(ta int,tb int,tc int);
sql create table ts1 using st tags(1,1,1);
sql create table ts2 using st tags(2,2,2);
sql create stream stream_t1 trigger at_once IGNORE EXPIRED into streamtST1 as select _wstartts, count(*) c1, count(a) c2 , sum(a) c3 , max(b) c5, min(c) c6 from st interval(10s) ;
sql create stream stream_t2 trigger at_once IGNORE EXPIRED into streamtST2 as select _wstartts, count(*) c1, count(a) c2 , sum(a) c3 , max(b) c5, min(c) c6 from st session(ts, 10s) ;
sql insert into ts1 values(1648791211000,1,2,3);
sql insert into ts1 values(1648791222001,2,2,3);
sql insert into ts2 values(1648791211000,1,2,3);
sql insert into ts2 values(1648791222001,2,2,3);
$loop_count = 0
loop4:
sleep 300
sql select * from streamtST1;
$loop_count = $loop_count + 1
if $loop_count == 10 then
return -1
endi
if $data01 != 1 then
print =====data01=$data01
goto loop4
endi
if $data02 != 1 then
print =====data02=$data02
goto loop4
endi
$loop_count = 0
loop5:
sleep 300
sql select * from streamtST2;
$loop_count = $loop_count + 1
if $loop_count == 10 then
return -1
endi
if $data01 != 1 then
print =====data01=$data01
goto loop5
endi
if $data02 != 1 then
print =====data02=$data02
goto loop5
endi
system sh/stop_dnodes.sh
\ No newline at end of file
tests/script/tsim/tmq/snapshot1.sim
浏览文件 @
33525deb
...
@@ -25,7 +25,7 @@ $rowsPerCtb = 10
...
@@ -25,7 +25,7 @@ $rowsPerCtb = 10
$tstart = 1640966400000 # 2022-01-01 00:00:00.000
$tstart = 1640966400000 # 2022-01-01 00:00:00.000
#---- global parameters end ----#
#---- global parameters end ----#
$pullDelay =
5
$pullDelay =
2
$ifcheckdata = 1
$ifcheckdata = 1
$ifmanualcommit = 1
$ifmanualcommit = 1
$showMsg = 1
$showMsg = 1
...
...
tests/system-test/2-query/Timediff.py
浏览文件 @
33525deb
...
@@ -3,7 +3,7 @@ from util.sql import *
...
@@ -3,7 +3,7 @@ from util.sql import *
from
util.cases
import
*
from
util.cases
import
*
class
TDTestCase
:
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
f
"start to excute
{
__file__
}
"
)
tdLog
.
debug
(
f
"start to excute
{
__file__
}
"
)
tdSql
.
init
(
conn
.
cursor
())
tdSql
.
init
(
conn
.
cursor
())
...
@@ -33,7 +33,7 @@ class TDTestCase:
...
@@ -33,7 +33,7 @@ class TDTestCase:
'insert into ntb values(now,1,1.55,100.555555,today())("2020-1-1 00:00:00",10,11.11,99.999999,now())(today(),3,3.333,333.333333,now())'
)
'insert into ntb values(now,1,1.55,100.555555,today())("2020-1-1 00:00:00",10,11.11,99.999999,now())(today(),3,3.333,333.333333,now())'
)
tdSql
.
execute
(
tdSql
.
execute
(
'insert into stb_1 values(now,1,1.55,100.555555,today())("2020-1-1 00:00:00",10,11.11,99.999999,now())(today(),3,3.333,333.333333,now())'
)
'insert into stb_1 values(now,1,1.55,100.555555,today())("2020-1-1 00:00:00",10,11.11,99.999999,now())(today(),3,3.333,333.333333,now())'
)
tdSql
.
query
(
"select timediff('2020-1-1 00:00:00','2020-1-2 00:00:00') from ntb"
)
tdSql
.
query
(
"select timediff('2020-1-1 00:00:00','2020-1-2 00:00:00') from ntb"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkRows
(
3
)
tdSql
.
query
(
"select timediff(1,0,1d) from ntb"
)
tdSql
.
query
(
"select timediff(1,0,1d) from ntb"
)
...
@@ -72,12 +72,12 @@ class TDTestCase:
...
@@ -72,12 +72,12 @@ class TDTestCase:
tdSql
.
query
(
"select timediff(1,0,1a) from db.ntb"
)
tdSql
.
query
(
"select timediff(1,0,1a) from db.ntb"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkData
(
0
,
0
,
1000
)
tdSql
.
checkData
(
0
,
0
,
1000
)
tdSql
.
query
(
"select timediff(1,0,1u) from ntb"
)
tdSql
.
error
(
"select timediff(1,0,1u) from ntb"
)
tdSql
.
checkRows
(
3
)
#
tdSql.checkRows(3)
tdSql
.
checkData
(
0
,
0
,
1000000
)
#
tdSql.checkData(0,0,1000000)
tdSql
.
query
(
"select timediff(1,0,1u) from db.ntb"
)
tdSql
.
error
(
"select timediff(1,0,1u) from db.ntb"
)
tdSql
.
checkRows
(
3
)
#
tdSql.checkRows(3)
tdSql
.
checkData
(
0
,
0
,
1000000
)
#
tdSql.checkData(0,0,1000000)
tdSql
.
query
(
"select timediff('2020-1-1 00:00:00','2020-1-2 00:00:00') from stb"
)
tdSql
.
query
(
"select timediff('2020-1-1 00:00:00','2020-1-2 00:00:00') from stb"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkRows
(
3
)
...
@@ -116,12 +116,12 @@ class TDTestCase:
...
@@ -116,12 +116,12 @@ class TDTestCase:
tdSql
.
query
(
"select timediff('2020-1-1 00:00:00','2020-1-2 00:00:00',1a) from db.stb"
)
tdSql
.
query
(
"select timediff('2020-1-1 00:00:00','2020-1-2 00:00:00',1a) from db.stb"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkData
(
0
,
0
,
86400000
)
tdSql
.
checkData
(
0
,
0
,
86400000
)
tdSql
.
query
(
"select timediff('2020-1-1 00:00:00','2020-1-2 00:00:00',1u) from stb"
)
tdSql
.
error
(
"select timediff('2020-1-1 00:00:00','2020-1-2 00:00:00',1u) from stb"
)
tdSql
.
checkRows
(
3
)
#
tdSql.checkRows(3)
tdSql
.
checkData
(
0
,
0
,
86400000000
)
#
tdSql.checkData(0,0,86400000000)
tdSql
.
query
(
"select timediff('2020-1-1 00:00:00','2020-1-2 00:00:00',1u) from db.stb"
)
tdSql
.
error
(
"select timediff('2020-1-1 00:00:00','2020-1-2 00:00:00',1u) from db.stb"
)
tdSql
.
checkRows
(
3
)
#
tdSql.checkRows(3)
tdSql
.
checkData
(
0
,
0
,
86400000000
)
#
tdSql.checkData(0,0,86400000000)
tdSql
.
query
(
"select timediff('2020-1-1 00:00:00','2020-1-1 12:00:00') from stb_1"
)
tdSql
.
query
(
"select timediff('2020-1-1 00:00:00','2020-1-1 12:00:00') from stb_1"
)
...
@@ -164,12 +164,12 @@ class TDTestCase:
...
@@ -164,12 +164,12 @@ class TDTestCase:
tdSql
.
query
(
"select timediff('2020-1-1 00:00:00','2020-1-1 12:00:00',1a) from db.stb_1"
)
tdSql
.
query
(
"select timediff('2020-1-1 00:00:00','2020-1-1 12:00:00',1a) from db.stb_1"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkData
(
0
,
0
,
43200000
)
tdSql
.
checkData
(
0
,
0
,
43200000
)
tdSql
.
query
(
"select timediff('2020-1-1 00:00:00','2020-1-1 12:00:00',1u) from stb_1"
)
tdSql
.
error
(
"select timediff('2020-1-1 00:00:00','2020-1-1 12:00:00',1u) from stb_1"
)
tdSql
.
checkRows
(
3
)
#
tdSql.checkRows(3)
tdSql
.
checkData
(
0
,
0
,
43200000000
)
#
tdSql.checkData(0,0,43200000000)
tdSql
.
query
(
"select timediff('2020-1-1 00:00:00','2020-1-1 12:00:00',1u) from db.stb_1"
)
tdSql
.
error
(
"select timediff('2020-1-1 00:00:00','2020-1-1 12:00:00',1u) from db.stb_1"
)
tdSql
.
checkRows
(
3
)
#
tdSql.checkRows(3)
tdSql
.
checkData
(
0
,
0
,
43200000000
)
#
tdSql.checkData(0,0,43200000000)
tdSql
.
query
(
"select timediff('a','b') from stb"
)
tdSql
.
query
(
"select timediff('a','b') from stb"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkRows
(
3
)
...
@@ -202,4 +202,4 @@ class TDTestCase:
...
@@ -202,4 +202,4 @@ class TDTestCase:
tdLog
.
success
(
f
"
{
__file__
}
successfully executed"
)
tdLog
.
success
(
f
"
{
__file__
}
successfully executed"
)
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
\ No newline at end of file
tests/system-test/2-query/elapsed.py
浏览文件 @
33525deb
此差异已折叠。
点击以展开。
tests/system-test/2-query/function_stateduration.py
浏览文件 @
33525deb
...
@@ -18,7 +18,7 @@ class TDTestCase:
...
@@ -18,7 +18,7 @@ class TDTestCase:
def
init
(
self
,
conn
,
logSql
):
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
f
"start to excute
{
__file__
}
"
)
tdLog
.
debug
(
f
"start to excute
{
__file__
}
"
)
tdSql
.
init
(
conn
.
cursor
())
tdSql
.
init
(
conn
.
cursor
())
def
prepare_datas
(
self
):
def
prepare_datas
(
self
):
tdSql
.
execute
(
tdSql
.
execute
(
'''create table stb1
'''create table stb1
...
@@ -26,7 +26,7 @@ class TDTestCase:
...
@@ -26,7 +26,7 @@ class TDTestCase:
tags (t1 int)
tags (t1 int)
'''
'''
)
)
tdSql
.
execute
(
tdSql
.
execute
(
'''
'''
create table t1
create table t1
...
@@ -68,7 +68,7 @@ class TDTestCase:
...
@@ -68,7 +68,7 @@ class TDTestCase:
( '2023-02-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( '2023-02-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
'''
'''
)
)
def
test_errors
(
self
):
def
test_errors
(
self
):
error_sql_lists
=
[
error_sql_lists
=
[
# "select stateduration(c1,'GT',5,1s) from t1"
# "select stateduration(c1,'GT',5,1s) from t1"
...
@@ -110,35 +110,35 @@ class TDTestCase:
...
@@ -110,35 +110,35 @@ class TDTestCase:
for
error_sql
in
error_sql_lists
:
for
error_sql
in
error_sql_lists
:
tdSql
.
error
(
error_sql
)
tdSql
.
error
(
error_sql
)
pass
pass
def
support_types
(
self
):
def
support_types
(
self
):
other_no_value_types
=
[
other_no_value_types
=
[
"select stateduration(ts,'GT',1,1s) from t1"
,
"select stateduration(ts,'GT',1,1s) from t1"
,
"select stateduration(c7,'GT',1,1s) from t1"
,
"select stateduration(c7,'GT',1,1s) from t1"
,
"select stateduration(c8,'GT',1,1s) from t1"
,
"select stateduration(c8,'GT',1,1s) from t1"
,
"select stateduration(c9,'GT',1,1s) from t1"
,
"select stateduration(c9,'GT',1,1s) from t1"
,
"select stateduration(ts,'GT',1,1s) from ct1"
,
"select stateduration(ts,'GT',1,1s) from ct1"
,
"select stateduration(c7,'GT',1,1s) from ct1"
,
"select stateduration(c7,'GT',1,1s) from ct1"
,
"select stateduration(c8,'GT',1,1s) from ct1"
,
"select stateduration(c8,'GT',1,1s) from ct1"
,
"select stateduration(c9,'GT',1,1s) from ct1"
,
"select stateduration(c9,'GT',1,1s) from ct1"
,
"select stateduration(ts,'GT',1,1s) from ct3"
,
"select stateduration(ts,'GT',1,1s) from ct3"
,
"select stateduration(c7,'GT',1,1s) from ct3"
,
"select stateduration(c7,'GT',1,1s) from ct3"
,
"select stateduration(c8,'GT',1,1s) from ct3"
,
"select stateduration(c8,'GT',1,1s) from ct3"
,
"select stateduration(c9,'GT',1,1s) from ct3"
,
"select stateduration(c9,'GT',1,1s) from ct3"
,
"select stateduration(ts,'GT',1,1s) from ct4"
,
"select stateduration(ts,'GT',1,1s) from ct4"
,
"select stateduration(c7,'GT',1,1s) from ct4"
,
"select stateduration(c7,'GT',1,1s) from ct4"
,
"select stateduration(c8,'GT',1,1s) from ct4"
,
"select stateduration(c8,'GT',1,1s) from ct4"
,
"select stateduration(c9,'GT',1,1s) from ct4"
,
"select stateduration(c9,'GT',1,1s) from ct4"
,
"select stateduration(ts,'GT',1,1s) from stb1 partition by tbname"
,
"select stateduration(ts,'GT',1,1s) from stb1 partition by tbname"
,
"select stateduration(c7,'GT',1,1s) from stb1 partition by tbname"
,
"select stateduration(c7,'GT',1,1s) from stb1 partition by tbname"
,
"select stateduration(c8,'GT',1,1s) from stb1 partition by tbname"
,
"select stateduration(c8,'GT',1,1s) from stb1 partition by tbname"
,
"select stateduration(c9,'GT',1,1s) from stb1 partition by tbname"
"select stateduration(c9,'GT',1,1s) from stb1 partition by tbname"
]
]
for
type_sql
in
other_no_value_types
:
for
type_sql
in
other_no_value_types
:
tdSql
.
error
(
type_sql
)
tdSql
.
error
(
type_sql
)
tdLog
.
info
(
"support type ok , sql is : %s"
%
type_sql
)
tdLog
.
info
(
"support type ok , sql is : %s"
%
type_sql
)
type_sql_lists
=
[
type_sql_lists
=
[
"select stateduration(c1,'GT',1,1s) from t1"
,
"select stateduration(c1,'GT',1,1s) from t1"
,
"select stateduration(c2,'GT',1,1s) from t1"
,
"select stateduration(c2,'GT',1,1s) from t1"
,
...
@@ -168,8 +168,8 @@ class TDTestCase:
...
@@ -168,8 +168,8 @@ class TDTestCase:
"select stateduration(c5,'GT',1,1s) from stb1 partition by tbname"
,
"select stateduration(c5,'GT',1,1s) from stb1 partition by tbname"
,
"select stateduration(c6,'GT',1,1s) from stb1 partition by tbname"
,
"select stateduration(c6,'GT',1,1s) from stb1 partition by tbname"
,
"select stateduration(c6,'GT',1,1s) as alisb from stb1 partition by tbname"
,
"select stateduration(c6,'GT',1,1s) as alisb from stb1 partition by tbname"
,
"select stateduration(c6,'GT',1,1s) alisb from stb1 partition by tbname"
,
"select stateduration(c6,'GT',1,1s) alisb from stb1 partition by tbname"
,
]
]
for
type_sql
in
type_sql_lists
:
for
type_sql
in
type_sql_lists
:
...
@@ -177,7 +177,7 @@ class TDTestCase:
...
@@ -177,7 +177,7 @@ class TDTestCase:
def
support_opers
(
self
):
def
support_opers
(
self
):
oper_lists
=
[
'LT'
,
'lt'
,
'Lt'
,
'lT'
,
'GT'
,
'gt'
,
'Gt'
,
'gT'
,
'LE'
,
'le'
,
'Le'
,
'lE'
,
'GE'
,
'ge'
,
'Ge'
,
'gE'
,
'NE'
,
'ne'
,
'Ne'
,
'nE'
,
'EQ'
,
'eq'
,
'Eq'
,
'eQ'
]
oper_lists
=
[
'LT'
,
'lt'
,
'Lt'
,
'lT'
,
'GT'
,
'gt'
,
'Gt'
,
'gT'
,
'LE'
,
'le'
,
'Le'
,
'lE'
,
'GE'
,
'ge'
,
'Ge'
,
'gE'
,
'NE'
,
'ne'
,
'Ne'
,
'nE'
,
'EQ'
,
'eq'
,
'Eq'
,
'eQ'
]
oper_errors
=
[
","
,
"*"
,
"NULL"
,
"tbname"
,
"ts"
,
"sum"
,
"_c0"
]
oper_errors
=
[
","
,
"*"
,
"NULL"
,
"tbname"
,
"ts"
,
"sum"
,
"_c0"
]
for
oper
in
oper_lists
:
for
oper
in
oper_lists
:
...
@@ -190,7 +190,7 @@ class TDTestCase:
...
@@ -190,7 +190,7 @@ class TDTestCase:
def
basic_stateduration_function
(
self
):
def
basic_stateduration_function
(
self
):
# basic query
# basic query
tdSql
.
query
(
"select c1 from ct3"
)
tdSql
.
query
(
"select c1 from ct3"
)
tdSql
.
checkRows
(
0
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select c1 from t1"
)
tdSql
.
query
(
"select c1 from t1"
)
...
@@ -211,9 +211,9 @@ class TDTestCase:
...
@@ -211,9 +211,9 @@ class TDTestCase:
tdSql
.
checkRows
(
0
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select stateduration(c6,'GT',1,1s) from ct3"
)
tdSql
.
query
(
"select stateduration(c6,'GT',1,1s) from ct3"
)
# will support _rowts mix with
# will support _rowts mix with
# tdSql.query("select (c6,'GT',1,1s),_rowts from ct3")
# tdSql.query("select (c6,'GT',1,1s),_rowts from ct3")
# auto check for t1 table
# auto check for t1 table
# used for regular table
# used for regular table
tdSql
.
query
(
"select stateduration(c6,'GT',1,1s) from t1"
)
tdSql
.
query
(
"select stateduration(c6,'GT',1,1s) from t1"
)
...
@@ -229,17 +229,17 @@ class TDTestCase:
...
@@ -229,17 +229,17 @@ class TDTestCase:
tdSql
.
error
(
"select stateduration(c6,'GT',1,1s),tbname from ct1"
)
tdSql
.
error
(
"select stateduration(c6,'GT',1,1s),tbname from ct1"
)
tdSql
.
error
(
"select stateduration(c6,'GT',1,1s),t1 from ct1"
)
tdSql
.
error
(
"select stateduration(c6,'GT',1,1s),t1 from ct1"
)
# unique with common col
# unique with common col
tdSql
.
error
(
"select stateduration(c6,'GT',1,1s) ,ts from ct1"
)
tdSql
.
error
(
"select stateduration(c6,'GT',1,1s) ,ts from ct1"
)
tdSql
.
error
(
"select stateduration(c6,'GT',1,1s) ,c1 from ct1"
)
tdSql
.
error
(
"select stateduration(c6,'GT',1,1s) ,c1 from ct1"
)
# unique with scalar function
# unique with scalar function
tdSql
.
error
(
"select stateduration(c6,'GT',1,1s) ,abs(c1) from ct1"
)
tdSql
.
error
(
"select stateduration(c6,'GT',1,1s) ,abs(c1) from ct1"
)
tdSql
.
error
(
"select stateduration(c6,'GT',1,1s) , unique(c2) from ct1"
)
tdSql
.
error
(
"select stateduration(c6,'GT',1,1s) , unique(c2) from ct1"
)
tdSql
.
error
(
"select stateduration(c6,'GT',1,1s) , abs(c2)+2 from ct1"
)
tdSql
.
error
(
"select stateduration(c6,'GT',1,1s) , abs(c2)+2 from ct1"
)
# unique with aggregate function
# unique with aggregate function
tdSql
.
error
(
"select stateduration(c6,'GT',1,1s) ,sum(c1) from ct1"
)
tdSql
.
error
(
"select stateduration(c6,'GT',1,1s) ,sum(c1) from ct1"
)
tdSql
.
error
(
"select stateduration(c6,'GT',1,1s) ,max(c1) from ct1"
)
tdSql
.
error
(
"select stateduration(c6,'GT',1,1s) ,max(c1) from ct1"
)
tdSql
.
error
(
"select stateduration(c6,'GT',1,1s) ,csum(c1) from ct1"
)
tdSql
.
error
(
"select stateduration(c6,'GT',1,1s) ,csum(c1) from ct1"
)
...
@@ -262,16 +262,16 @@ class TDTestCase:
...
@@ -262,16 +262,16 @@ class TDTestCase:
tdSql
.
checkData
(
0
,
0
,
0
)
tdSql
.
checkData
(
0
,
0
,
0
)
tdSql
.
checkData
(
1
,
0
,
6134400
)
tdSql
.
checkData
(
1
,
0
,
6134400
)
tdSql
.
checkData
(
6
,
0
,
-
1
)
tdSql
.
checkData
(
6
,
0
,
-
1
)
# unique with union all
# unique with union all
tdSql
.
query
(
"select stateduration(c1,'GT',1,1s) from ct4 union all select stateduration(c1,'GT',1,1s) from ct1"
)
tdSql
.
query
(
"select stateduration(c1,'GT',1,1s) from ct4 union all select stateduration(c1,'GT',1,1s) from ct1"
)
tdSql
.
checkRows
(
25
)
tdSql
.
checkRows
(
25
)
tdSql
.
query
(
"select stateduration(c1,'GT',1,1s) from ct4 union all select distinct(c1) from ct4"
)
tdSql
.
query
(
"select stateduration(c1,'GT',1,1s) from ct4 union all select distinct(c1) from ct4"
)
tdSql
.
checkRows
(
22
)
tdSql
.
checkRows
(
22
)
# unique with join
# unique with join
# prepare join datas with same ts
# prepare join datas with same ts
tdSql
.
execute
(
" use db "
)
tdSql
.
execute
(
" use db "
)
tdSql
.
execute
(
" create stable st1 (ts timestamp , num int) tags(ind int)"
)
tdSql
.
execute
(
" create stable st1 (ts timestamp , num int) tags(ind int)"
)
...
@@ -328,7 +328,7 @@ class TDTestCase:
...
@@ -328,7 +328,7 @@ class TDTestCase:
tdSql
.
checkRows
(
12
)
tdSql
.
checkRows
(
12
)
tdSql
.
query
(
"select stateduration(c1+2 ,'GT',1,1s) from t1"
)
tdSql
.
query
(
"select stateduration(c1+2 ,'GT',1,1s) from t1"
)
tdSql
.
checkRows
(
12
)
tdSql
.
checkRows
(
12
)
# bug for stable
# bug for stable
#partition by tbname
#partition by tbname
...
@@ -337,21 +337,20 @@ class TDTestCase:
...
@@ -337,21 +337,20 @@ class TDTestCase:
# tdSql.query(" select unique(c1) from stb1 partition by tbname ")
# tdSql.query(" select unique(c1) from stb1 partition by tbname ")
# tdSql.checkRows(21)
# tdSql.checkRows(21)
# group by
# group by
tdSql
.
error
(
"select stateduration(c1,'GT',1,1s) from ct1 group by c1"
)
tdSql
.
error
(
"select stateduration(c1,'GT',1,1s) from ct1 group by c1"
)
tdSql
.
error
(
"select stateduration(c1,'GT',1,1s) from ct1 group by tbname"
)
tdSql
.
error
(
"select stateduration(c1,'GT',1,1s) from ct1 group by tbname"
)
# super table
# super table
def
check_unit_time
(
self
):
def
check_unit_time
(
self
):
tdSql
.
execute
(
" use db "
)
tdSql
.
execute
(
" use db "
)
tdSql
.
error
(
"select stateduration(c1,'GT',1,1b) from ct1"
)
tdSql
.
error
(
"select stateduration(c1,'GT',1,1b) from ct1"
)
tdSql
.
error
(
"select stateduration(c1,'GT',1,1u) from ct1"
)
tdSql
.
error
(
"select stateduration(c1,'GT',1,1u) from ct1"
)
tdSql
.
error
(
"select stateduration(c1,'GT',1,1000s) from t1"
)
tdSql
.
query
(
"select stateduration(c1,'GT',1,1s) from t1"
)
tdSql
.
query
(
"select stateduration(c1,'GT',1,1s) from t1"
)
tdSql
.
checkData
(
10
,
0
,
63072035
)
tdSql
.
checkData
(
10
,
0
,
63072035
)
tdSql
.
query
(
"select stateduration(c1,'GT',1,1000s) from t1"
)
tdSql
.
checkData
(
10
,
0
,
int
(
63072035
/
1000
))
tdSql
.
query
(
"select stateduration(c1,'GT',1,1m) from t1"
)
tdSql
.
query
(
"select stateduration(c1,'GT',1,1m) from t1"
)
tdSql
.
checkData
(
10
,
0
,
int
(
63072035
/
60
))
tdSql
.
checkData
(
10
,
0
,
int
(
63072035
/
60
))
tdSql
.
query
(
"select stateduration(c1,'GT',1,1h) from t1"
)
tdSql
.
query
(
"select stateduration(c1,'GT',1,1h) from t1"
)
...
@@ -360,8 +359,8 @@ class TDTestCase:
...
@@ -360,8 +359,8 @@ class TDTestCase:
tdSql
.
checkData
(
10
,
0
,
int
(
63072035
/
60
/
24
/
60
))
tdSql
.
checkData
(
10
,
0
,
int
(
63072035
/
60
/
24
/
60
))
tdSql
.
query
(
"select stateduration(c1,'GT',1,1w) from t1"
)
tdSql
.
query
(
"select stateduration(c1,'GT',1,1w) from t1"
)
tdSql
.
checkData
(
10
,
0
,
int
(
63072035
/
60
/
7
/
24
/
60
))
tdSql
.
checkData
(
10
,
0
,
int
(
63072035
/
60
/
7
/
24
/
60
))
def
check_boundary_values
(
self
):
def
check_boundary_values
(
self
):
tdSql
.
execute
(
"drop database if exists bound_test"
)
tdSql
.
execute
(
"drop database if exists bound_test"
)
...
...
tests/system-test/2-query/json_tag.py
浏览文件 @
33525deb
...
@@ -675,7 +675,7 @@ class TDTestCase:
...
@@ -675,7 +675,7 @@ class TDTestCase:
tdSql
.
checkRows
(
3
)
tdSql
.
checkRows
(
3
)
tdSql
.
query
(
"select TO_UNIXTIMESTAMP(datastr) from jsons1 where jtag->'tag1'>1;"
)
tdSql
.
query
(
"select TO_UNIXTIMESTAMP(datastr) from jsons1 where jtag->'tag1'>1;"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkRows
(
3
)
tdSql
.
query
(
"select TIMETRUNCATE(ts,1
u
) from jsons1 where jtag->'tag1'>1;"
)
tdSql
.
query
(
"select TIMETRUNCATE(ts,1
s
) from jsons1 where jtag->'tag1'>1;"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkRows
(
3
)
tdSql
.
query
(
"select TIMEDIFF(ts,_c0) from jsons1 where jtag->'tag1'>1;"
)
tdSql
.
query
(
"select TIMEDIFF(ts,_c0) from jsons1 where jtag->'tag1'>1;"
)
tdSql
.
checkRows
(
3
)
tdSql
.
checkRows
(
3
)
...
...
tests/system-test/2-query/statecount.py
浏览文件 @
33525deb
...
@@ -18,7 +18,7 @@ class TDTestCase:
...
@@ -18,7 +18,7 @@ class TDTestCase:
def
init
(
self
,
conn
,
logSql
):
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
f
"start to excute
{
__file__
}
"
)
tdLog
.
debug
(
f
"start to excute
{
__file__
}
"
)
tdSql
.
init
(
conn
.
cursor
())
tdSql
.
init
(
conn
.
cursor
())
def
prepare_datas
(
self
):
def
prepare_datas
(
self
):
tdSql
.
execute
(
tdSql
.
execute
(
'''create table stb1
'''create table stb1
...
@@ -26,7 +26,7 @@ class TDTestCase:
...
@@ -26,7 +26,7 @@ class TDTestCase:
tags (t1 int)
tags (t1 int)
'''
'''
)
)
tdSql
.
execute
(
tdSql
.
execute
(
'''
'''
create table t1
create table t1
...
@@ -68,7 +68,7 @@ class TDTestCase:
...
@@ -68,7 +68,7 @@ class TDTestCase:
( '2023-02-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( '2023-02-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
'''
'''
)
)
def
test_errors
(
self
):
def
test_errors
(
self
):
error_sql_lists
=
[
error_sql_lists
=
[
# "select statecount(c1,'GT',5) from t1"
# "select statecount(c1,'GT',5) from t1"
...
@@ -110,35 +110,35 @@ class TDTestCase:
...
@@ -110,35 +110,35 @@ class TDTestCase:
for
error_sql
in
error_sql_lists
:
for
error_sql
in
error_sql_lists
:
tdSql
.
error
(
error_sql
)
tdSql
.
error
(
error_sql
)
pass
pass
def
support_types
(
self
):
def
support_types
(
self
):
other_no_value_types
=
[
other_no_value_types
=
[
"select statecount(ts,'GT',1) from t1"
,
"select statecount(ts,'GT',1) from t1"
,
"select statecount(c7,'GT',1) from t1"
,
"select statecount(c7,'GT',1) from t1"
,
"select statecount(c8,'GT',1) from t1"
,
"select statecount(c8,'GT',1) from t1"
,
"select statecount(c9,'GT',1) from t1"
,
"select statecount(c9,'GT',1) from t1"
,
"select statecount(ts,'GT',1) from ct1"
,
"select statecount(ts,'GT',1) from ct1"
,
"select statecount(c7,'GT',1) from ct1"
,
"select statecount(c7,'GT',1) from ct1"
,
"select statecount(c8,'GT',1) from ct1"
,
"select statecount(c8,'GT',1) from ct1"
,
"select statecount(c9,'GT',1) from ct1"
,
"select statecount(c9,'GT',1) from ct1"
,
"select statecount(ts,'GT',1) from ct3"
,
"select statecount(ts,'GT',1) from ct3"
,
"select statecount(c7,'GT',1) from ct3"
,
"select statecount(c7,'GT',1) from ct3"
,
"select statecount(c8,'GT',1) from ct3"
,
"select statecount(c8,'GT',1) from ct3"
,
"select statecount(c9,'GT',1) from ct3"
,
"select statecount(c9,'GT',1) from ct3"
,
"select statecount(ts,'GT',1) from ct4"
,
"select statecount(ts,'GT',1) from ct4"
,
"select statecount(c7,'GT',1) from ct4"
,
"select statecount(c7,'GT',1) from ct4"
,
"select statecount(c8,'GT',1) from ct4"
,
"select statecount(c8,'GT',1) from ct4"
,
"select statecount(c9,'GT',1) from ct4"
,
"select statecount(c9,'GT',1) from ct4"
,
"select statecount(ts,'GT',1) from stb1 partition by tbname"
,
"select statecount(ts,'GT',1) from stb1 partition by tbname"
,
"select statecount(c7,'GT',1) from stb1 partition by tbname"
,
"select statecount(c7,'GT',1) from stb1 partition by tbname"
,
"select statecount(c8,'GT',1) from stb1 partition by tbname"
,
"select statecount(c8,'GT',1) from stb1 partition by tbname"
,
"select statecount(c9,'GT',1) from stb1 partition by tbname"
"select statecount(c9,'GT',1) from stb1 partition by tbname"
]
]
for
type_sql
in
other_no_value_types
:
for
type_sql
in
other_no_value_types
:
tdSql
.
error
(
type_sql
)
tdSql
.
error
(
type_sql
)
tdLog
.
info
(
"support type ok , sql is : %s"
%
type_sql
)
tdLog
.
info
(
"support type ok , sql is : %s"
%
type_sql
)
type_sql_lists
=
[
type_sql_lists
=
[
"select statecount(c1,'GT',1) from t1"
,
"select statecount(c1,'GT',1) from t1"
,
"select statecount(c2,'GT',1) from t1"
,
"select statecount(c2,'GT',1) from t1"
,
...
@@ -168,8 +168,8 @@ class TDTestCase:
...
@@ -168,8 +168,8 @@ class TDTestCase:
"select statecount(c5,'GT',1) from stb1 partition by tbname"
,
"select statecount(c5,'GT',1) from stb1 partition by tbname"
,
"select statecount(c6,'GT',1) from stb1 partition by tbname"
,
"select statecount(c6,'GT',1) from stb1 partition by tbname"
,
"select statecount(c6,'GT',1) as alisb from stb1 partition by tbname"
,
"select statecount(c6,'GT',1) as alisb from stb1 partition by tbname"
,
"select statecount(c6,'GT',1) alisb from stb1 partition by tbname"
,
"select statecount(c6,'GT',1) alisb from stb1 partition by tbname"
,
]
]
for
type_sql
in
type_sql_lists
:
for
type_sql
in
type_sql_lists
:
...
@@ -177,7 +177,7 @@ class TDTestCase:
...
@@ -177,7 +177,7 @@ class TDTestCase:
def
support_opers
(
self
):
def
support_opers
(
self
):
oper_lists
=
[
'LT'
,
'lt'
,
'Lt'
,
'lT'
,
'GT'
,
'gt'
,
'Gt'
,
'gT'
,
'LE'
,
'le'
,
'Le'
,
'lE'
,
'GE'
,
'ge'
,
'Ge'
,
'gE'
,
'NE'
,
'ne'
,
'Ne'
,
'nE'
,
'EQ'
,
'eq'
,
'Eq'
,
'eQ'
]
oper_lists
=
[
'LT'
,
'lt'
,
'Lt'
,
'lT'
,
'GT'
,
'gt'
,
'Gt'
,
'gT'
,
'LE'
,
'le'
,
'Le'
,
'lE'
,
'GE'
,
'ge'
,
'Ge'
,
'gE'
,
'NE'
,
'ne'
,
'Ne'
,
'nE'
,
'EQ'
,
'eq'
,
'Eq'
,
'eQ'
]
oper_errors
=
[
","
,
"*"
,
"NULL"
,
"tbname"
,
"ts"
,
"sum"
,
"_c0"
]
oper_errors
=
[
","
,
"*"
,
"NULL"
,
"tbname"
,
"ts"
,
"sum"
,
"_c0"
]
for
oper
in
oper_lists
:
for
oper
in
oper_lists
:
...
@@ -190,7 +190,7 @@ class TDTestCase:
...
@@ -190,7 +190,7 @@ class TDTestCase:
def
basic_statecount_function
(
self
):
def
basic_statecount_function
(
self
):
# basic query
# basic query
tdSql
.
query
(
"select c1 from ct3"
)
tdSql
.
query
(
"select c1 from ct3"
)
tdSql
.
checkRows
(
0
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select c1 from t1"
)
tdSql
.
query
(
"select c1 from t1"
)
...
@@ -211,9 +211,9 @@ class TDTestCase:
...
@@ -211,9 +211,9 @@ class TDTestCase:
tdSql
.
checkRows
(
0
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select statecount(c6,'GT',1) from ct3"
)
tdSql
.
query
(
"select statecount(c6,'GT',1) from ct3"
)
# will support _rowts mix with
# will support _rowts mix with
# tdSql.query("select (c6,'GT',1),_rowts from ct3")
# tdSql.query("select (c6,'GT',1),_rowts from ct3")
# auto check for t1 table
# auto check for t1 table
# used for regular table
# used for regular table
tdSql
.
query
(
"select statecount(c6,'GT',1) from t1"
)
tdSql
.
query
(
"select statecount(c6,'GT',1) from t1"
)
...
@@ -229,17 +229,17 @@ class TDTestCase:
...
@@ -229,17 +229,17 @@ class TDTestCase:
tdSql
.
error
(
"select statecount(c6,'GT',1),tbname from ct1"
)
tdSql
.
error
(
"select statecount(c6,'GT',1),tbname from ct1"
)
tdSql
.
error
(
"select statecount(c6,'GT',1),t1 from ct1"
)
tdSql
.
error
(
"select statecount(c6,'GT',1),t1 from ct1"
)
# unique with common col
# unique with common col
tdSql
.
error
(
"select statecount(c6,'GT',1) ,ts from ct1"
)
tdSql
.
error
(
"select statecount(c6,'GT',1) ,ts from ct1"
)
tdSql
.
error
(
"select statecount(c6,'GT',1) ,c1 from ct1"
)
tdSql
.
error
(
"select statecount(c6,'GT',1) ,c1 from ct1"
)
# unique with scalar function
# unique with scalar function
tdSql
.
error
(
"select statecount(c6,'GT',1) ,abs(c1) from ct1"
)
tdSql
.
error
(
"select statecount(c6,'GT',1) ,abs(c1) from ct1"
)
tdSql
.
error
(
"select statecount(c6,'GT',1) , unique(c2) from ct1"
)
tdSql
.
error
(
"select statecount(c6,'GT',1) , unique(c2) from ct1"
)
tdSql
.
error
(
"select statecount(c6,'GT',1) , abs(c2)+2 from ct1"
)
tdSql
.
error
(
"select statecount(c6,'GT',1) , abs(c2)+2 from ct1"
)
# unique with aggregate function
# unique with aggregate function
tdSql
.
error
(
"select statecount(c6,'GT',1) ,sum(c1) from ct1"
)
tdSql
.
error
(
"select statecount(c6,'GT',1) ,sum(c1) from ct1"
)
tdSql
.
error
(
"select statecount(c6,'GT',1) ,max(c1) from ct1"
)
tdSql
.
error
(
"select statecount(c6,'GT',1) ,max(c1) from ct1"
)
tdSql
.
error
(
"select statecount(c6,'GT',1) ,csum(c1) from ct1"
)
tdSql
.
error
(
"select statecount(c6,'GT',1) ,csum(c1) from ct1"
)
...
@@ -262,16 +262,16 @@ class TDTestCase:
...
@@ -262,16 +262,16 @@ class TDTestCase:
tdSql
.
checkData
(
0
,
0
,
1
)
tdSql
.
checkData
(
0
,
0
,
1
)
tdSql
.
checkData
(
1
,
0
,
2
)
tdSql
.
checkData
(
1
,
0
,
2
)
tdSql
.
checkData
(
6
,
0
,
-
1
)
tdSql
.
checkData
(
6
,
0
,
-
1
)
# unique with union all
# unique with union all
tdSql
.
query
(
"select statecount(c1,'GT',1) from ct4 union all select statecount(c1,'GT',1) from ct1"
)
tdSql
.
query
(
"select statecount(c1,'GT',1) from ct4 union all select statecount(c1,'GT',1) from ct1"
)
tdSql
.
checkRows
(
25
)
tdSql
.
checkRows
(
25
)
tdSql
.
query
(
"select statecount(c1,'GT',1) from ct4 union all select distinct(c1) from ct4"
)
tdSql
.
query
(
"select statecount(c1,'GT',1) from ct4 union all select distinct(c1) from ct4"
)
tdSql
.
checkRows
(
22
)
tdSql
.
checkRows
(
22
)
# unique with join
# unique with join
# prepare join datas with same ts
# prepare join datas with same ts
tdSql
.
execute
(
" use db "
)
tdSql
.
execute
(
" use db "
)
tdSql
.
execute
(
" create stable st1 (ts timestamp , num int) tags(ind int)"
)
tdSql
.
execute
(
" create stable st1 (ts timestamp , num int) tags(ind int)"
)
...
@@ -323,7 +323,7 @@ class TDTestCase:
...
@@ -323,7 +323,7 @@ class TDTestCase:
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
checkData
(
1
,
0
,
0.000000000
)
tdSql
.
checkData
(
1
,
0
,
0.000000000
)
tdSql
.
checkData
(
3
,
0
,
-
1.000000000
)
tdSql
.
checkData
(
3
,
0
,
-
1.000000000
)
# bug for stable
# bug for stable
#partition by tbname
#partition by tbname
...
@@ -332,21 +332,20 @@ class TDTestCase:
...
@@ -332,21 +332,20 @@ class TDTestCase:
# tdSql.query(" select unique(c1) from stb1 partition by tbname ")
# tdSql.query(" select unique(c1) from stb1 partition by tbname ")
# tdSql.checkRows(21)
# tdSql.checkRows(21)
# group by
# group by
tdSql
.
query
(
"select statecount(c1,'GT',1) from ct1 group by c1"
)
tdSql
.
query
(
"select statecount(c1,'GT',1) from ct1 group by c1"
)
tdSql
.
error
(
"select statecount(c1,'GT',1) from ct1 group by tbname"
)
tdSql
.
error
(
"select statecount(c1,'GT',1) from ct1 group by tbname"
)
# super table
# super table
def
check_unit_time
(
self
):
def
check_unit_time
(
self
):
tdSql
.
execute
(
" use db "
)
tdSql
.
execute
(
" use db "
)
tdSql
.
error
(
"select stateduration(c1,'GT',1,1b) from ct1"
)
tdSql
.
error
(
"select stateduration(c1,'GT',1,1b) from ct1"
)
tdSql
.
error
(
"select stateduration(c1,'GT',1,1u) from ct1"
)
tdSql
.
error
(
"select stateduration(c1,'GT',1,1u) from ct1"
)
tdSql
.
error
(
"select stateduration(c1,'GT',1,1000s) from t1"
)
tdSql
.
query
(
"select stateduration(c1,'GT',1,1s) from t1"
)
tdSql
.
query
(
"select stateduration(c1,'GT',1,1s) from t1"
)
tdSql
.
checkData
(
10
,
0
,
63072035
)
tdSql
.
checkData
(
10
,
0
,
63072035
)
tdSql
.
query
(
"select stateduration(c1,'GT',1,1000s) from t1"
)
tdSql
.
checkData
(
10
,
0
,
int
(
63072035
/
1000
))
tdSql
.
query
(
"select stateduration(c1,'GT',1,1m) from t1"
)
tdSql
.
query
(
"select stateduration(c1,'GT',1,1m) from t1"
)
tdSql
.
checkData
(
10
,
0
,
int
(
63072035
/
60
))
tdSql
.
checkData
(
10
,
0
,
int
(
63072035
/
60
))
tdSql
.
query
(
"select stateduration(c1,'GT',1,1h) from t1"
)
tdSql
.
query
(
"select stateduration(c1,'GT',1,1h) from t1"
)
...
@@ -355,8 +354,8 @@ class TDTestCase:
...
@@ -355,8 +354,8 @@ class TDTestCase:
tdSql
.
checkData
(
10
,
0
,
int
(
63072035
/
60
/
24
/
60
))
tdSql
.
checkData
(
10
,
0
,
int
(
63072035
/
60
/
24
/
60
))
tdSql
.
query
(
"select stateduration(c1,'GT',1,1w) from t1"
)
tdSql
.
query
(
"select stateduration(c1,'GT',1,1w) from t1"
)
tdSql
.
checkData
(
10
,
0
,
int
(
63072035
/
60
/
7
/
24
/
60
))
tdSql
.
checkData
(
10
,
0
,
int
(
63072035
/
60
/
7
/
24
/
60
))
def
check_boundary_values
(
self
):
def
check_boundary_values
(
self
):
tdSql
.
execute
(
"drop database if exists bound_test"
)
tdSql
.
execute
(
"drop database if exists bound_test"
)
...
@@ -384,11 +383,11 @@ class TDTestCase:
...
@@ -384,11 +383,11 @@ class TDTestCase:
tdSql
.
execute
(
tdSql
.
execute
(
f
"insert into sub1_bound values ( now(), -2147483643, -9223372036854775803, -32763, -123, -3.39E+38, -1.69e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
f
"insert into sub1_bound values ( now(), -2147483643, -9223372036854775803, -32763, -123, -3.39E+38, -1.69e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
)
)
tdSql
.
error
(
tdSql
.
error
(
f
"insert into sub1_bound values ( now()+1s, 2147483648, 9223372036854775808, 32768, 128, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
f
"insert into sub1_bound values ( now()+1s, 2147483648, 9223372036854775808, 32768, 128, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
)
)
tdSql
.
query
(
"select statecount(c1,'GT',1) from sub1_bound"
)
tdSql
.
query
(
"select statecount(c1,'GT',1) from sub1_bound"
)
tdSql
.
checkRows
(
5
)
tdSql
.
checkRows
(
5
)
...
@@ -396,29 +395,29 @@ class TDTestCase:
...
@@ -396,29 +395,29 @@ class TDTestCase:
tdSql
.
prepare
()
tdSql
.
prepare
()
tdLog
.
printNoPrefix
(
"==========step1:create table =============="
)
tdLog
.
printNoPrefix
(
"==========step1:create table =============="
)
self
.
prepare_datas
()
self
.
prepare_datas
()
tdLog
.
printNoPrefix
(
"==========step2:test errors =============="
)
tdLog
.
printNoPrefix
(
"==========step2:test errors =============="
)
self
.
test_errors
()
self
.
test_errors
()
tdLog
.
printNoPrefix
(
"==========step3:support types ============"
)
tdLog
.
printNoPrefix
(
"==========step3:support types ============"
)
self
.
support_types
()
self
.
support_types
()
tdLog
.
printNoPrefix
(
"==========step4:support opers ============"
)
tdLog
.
printNoPrefix
(
"==========step4:support opers ============"
)
self
.
support_opers
()
self
.
support_opers
()
tdLog
.
printNoPrefix
(
"==========step5: statecount basic query ============"
)
tdLog
.
printNoPrefix
(
"==========step5: statecount basic query ============"
)
self
.
basic_statecount_function
()
self
.
basic_statecount_function
()
tdLog
.
printNoPrefix
(
"==========step6: statecount boundary query ============"
)
tdLog
.
printNoPrefix
(
"==========step6: statecount boundary query ============"
)
self
.
check_boundary_values
()
self
.
check_boundary_values
()
tdLog
.
printNoPrefix
(
"==========step6: statecount unit time test ============"
)
tdLog
.
printNoPrefix
(
"==========step6: statecount unit time test ============"
)
self
.
check_unit_time
()
self
.
check_unit_time
()
...
...
tests/system-test/2-query/timetruncate.py
浏览文件 @
33525deb
...
@@ -12,11 +12,11 @@ class TDTestCase:
...
@@ -12,11 +12,11 @@ class TDTestCase:
self
.
rowNum
=
10
self
.
rowNum
=
10
self
.
ts
=
1537146000000
# 2018-9-17 09:00:00.000
self
.
ts
=
1537146000000
# 2018-9-17 09:00:00.000
def
run
(
self
):
def
run
(
self
):
tdSql
.
prepare
()
tdSql
.
prepare
()
intData
=
[]
intData
=
[]
floatData
=
[]
floatData
=
[]
tdSql
.
execute
(
'''create table stb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
tdSql
.
execute
(
'''create table stb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
...
@@ -27,18 +27,18 @@ class TDTestCase:
...
@@ -27,18 +27,18 @@ class TDTestCase:
for
i
in
range
(
self
.
rowNum
):
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)"
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
))
%
(
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
))
intData
.
append
(
i
+
1
)
intData
.
append
(
i
+
1
)
floatData
.
append
(
i
+
0.1
)
floatData
.
append
(
i
+
0.1
)
for
i
in
range
(
self
.
rowNum
):
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)"
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
))
%
(
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
))
intData
.
append
(
i
+
1
)
intData
.
append
(
i
+
1
)
floatData
.
append
(
i
+
0.1
)
floatData
.
append
(
i
+
0.1
)
tdSql
.
query
(
"select timetruncate(1,1d) from ntb"
)
tdSql
.
query
(
"select timetruncate(1,1d) from ntb"
)
tdSql
.
checkRows
(
10
)
tdSql
.
checkRows
(
10
)
tdSql
.
query
(
"select timetruncate(1,1u) from ntb"
)
tdSql
.
error
(
"select timetruncate(1,1u) from ntb"
)
tdSql
.
checkRows
(
10
)
#
tdSql.checkRows(10)
tdSql
.
query
(
"select timetruncate(1,1a) from ntb"
)
tdSql
.
query
(
"select timetruncate(1,1a) from ntb"
)
tdSql
.
checkRows
(
10
)
tdSql
.
checkRows
(
10
)
tdSql
.
query
(
"select timetruncate(1,1m) from ntb"
)
tdSql
.
query
(
"select timetruncate(1,1m) from ntb"
)
...
@@ -97,8 +97,8 @@ class TDTestCase:
...
@@ -97,8 +97,8 @@ class TDTestCase:
tdSql
.
query
(
"select timetruncate(1,1d) from stb"
)
tdSql
.
query
(
"select timetruncate(1,1d) from stb"
)
tdSql
.
checkRows
(
10
)
tdSql
.
checkRows
(
10
)
tdSql
.
query
(
"select timetruncate(1,1u) from stb"
)
tdSql
.
error
(
"select timetruncate(1,1u) from stb"
)
tdSql
.
checkRows
(
10
)
#
tdSql.checkRows(10)
tdSql
.
query
(
"select timetruncate(1,1a) from stb"
)
tdSql
.
query
(
"select timetruncate(1,1a) from stb"
)
tdSql
.
checkRows
(
10
)
tdSql
.
checkRows
(
10
)
tdSql
.
query
(
"select timetruncate(1,1m) from stb"
)
tdSql
.
query
(
"select timetruncate(1,1m) from stb"
)
...
@@ -156,8 +156,8 @@ class TDTestCase:
...
@@ -156,8 +156,8 @@ class TDTestCase:
tdSql
.
query
(
"select timetruncate(1,1d) from stb_1"
)
tdSql
.
query
(
"select timetruncate(1,1d) from stb_1"
)
tdSql
.
checkRows
(
10
)
tdSql
.
checkRows
(
10
)
tdSql
.
query
(
"select timetruncate(1,1u) from stb_1"
)
tdSql
.
error
(
"select timetruncate(1,1u) from stb_1"
)
tdSql
.
checkRows
(
10
)
#
tdSql.checkRows(10)
tdSql
.
query
(
"select timetruncate(1,1a) from stb_1"
)
tdSql
.
query
(
"select timetruncate(1,1a) from stb_1"
)
tdSql
.
checkRows
(
10
)
tdSql
.
checkRows
(
10
)
tdSql
.
query
(
"select timetruncate(1,1m) from stb_1"
)
tdSql
.
query
(
"select timetruncate(1,1m) from stb_1"
)
...
@@ -217,4 +217,4 @@ class TDTestCase:
...
@@ -217,4 +217,4 @@ class TDTestCase:
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
\ No newline at end of file
tests/system-test/7-tmq/tmqConsFromTsdb.py
浏览文件 @
33525deb
此差异已折叠。
点击以展开。
tests/system-test/7-tmq/tmqConsFromTsdb1.py
0 → 100644
浏览文件 @
33525deb
import
taos
import
sys
import
time
import
socket
import
os
import
threading
import
math
from
util.log
import
*
from
util.sql
import
*
from
util.cases
import
*
from
util.dnodes
import
*
from
util.common
import
*
sys
.
path
.
append
(
"./7-tmq"
)
from
tmqCommon
import
*
class
TDTestCase
:
def
__init__
(
self
):
self
.
vgroups
=
1
self
.
ctbNum
=
10
self
.
rowsPerTbl
=
10000
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
f
"start to excute
{
__file__
}
"
)
tdSql
.
init
(
conn
.
cursor
(),
False
)
def
prepareTestEnv
(
self
):
tdLog
.
printNoPrefix
(
"======== test case 1: "
)
paraDict
=
{
'dbName'
:
'dbt'
,
'dropFlag'
:
1
,
'event'
:
''
,
'vgroups'
:
1
,
'stbName'
:
'stb'
,
'colPrefix'
:
'c'
,
'tagPrefix'
:
't'
,
'colSchema'
:
[{
'type'
:
'INT'
,
'count'
:
1
},{
'type'
:
'BIGINT'
,
'count'
:
1
},{
'type'
:
'DOUBLE'
,
'count'
:
1
},{
'type'
:
'BINARY'
,
'len'
:
32
,
'count'
:
1
},{
'type'
:
'NCHAR'
,
'len'
:
32
,
'count'
:
1
},{
'type'
:
'TIMESTAMP'
,
'count'
:
1
}],
'tagSchema'
:
[{
'type'
:
'INT'
,
'count'
:
1
},{
'type'
:
'BIGINT'
,
'count'
:
1
},{
'type'
:
'DOUBLE'
,
'count'
:
1
},{
'type'
:
'BINARY'
,
'len'
:
32
,
'count'
:
1
},{
'type'
:
'NCHAR'
,
'len'
:
32
,
'count'
:
1
}],
'ctbPrefix'
:
'ctb'
,
'ctbStartIdx'
:
0
,
'ctbNum'
:
10
,
'rowsPerTbl'
:
10000
,
'batchNum'
:
10
,
'startTs'
:
1640966400000
,
# 2022-01-01 00:00:00.000
'pollDelay'
:
3
,
'showMsg'
:
1
,
'showRow'
:
1
,
'snapshot'
:
1
}
paraDict
[
'vgroups'
]
=
self
.
vgroups
paraDict
[
'ctbNum'
]
=
self
.
ctbNum
paraDict
[
'rowsPerTbl'
]
=
self
.
rowsPerTbl
tmqCom
.
initConsumerTable
()
tdCom
.
create_database
(
tdSql
,
paraDict
[
"dbName"
],
paraDict
[
"dropFlag"
],
vgroups
=
paraDict
[
"vgroups"
],
replica
=
1
)
tdLog
.
info
(
"create stb"
)
tmqCom
.
create_stable
(
tdSql
,
dbName
=
paraDict
[
"dbName"
],
stbName
=
paraDict
[
"stbName"
])
tdLog
.
info
(
"create ctb"
)
tmqCom
.
create_ctable
(
tdSql
,
dbName
=
paraDict
[
"dbName"
],
stbName
=
paraDict
[
"stbName"
],
ctbPrefix
=
paraDict
[
'ctbPrefix'
],
ctbNum
=
paraDict
[
"ctbNum"
],
ctbStartIdx
=
paraDict
[
'ctbStartIdx'
])
tdLog
.
info
(
"insert data"
)
tmqCom
.
insert_data_interlaceByMultiTbl
(
tsql
=
tdSql
,
dbName
=
paraDict
[
"dbName"
],
ctbPrefix
=
paraDict
[
"ctbPrefix"
],
ctbNum
=
paraDict
[
"ctbNum"
],
rowsPerTbl
=
paraDict
[
"rowsPerTbl"
],
batchNum
=
paraDict
[
"batchNum"
],
startTs
=
paraDict
[
"startTs"
],
ctbStartIdx
=
paraDict
[
'ctbStartIdx'
])
tdLog
.
info
(
"restart taosd to ensure that the data falls into the disk"
)
tdDnodes
.
stop
(
1
)
tdDnodes
.
start
(
1
)
return
def
tmqCase3
(
self
):
tdLog
.
printNoPrefix
(
"======== test case 3: "
)
paraDict
=
{
'dbName'
:
'dbt'
,
'dropFlag'
:
1
,
'event'
:
''
,
'vgroups'
:
1
,
'stbName'
:
'stb'
,
'colPrefix'
:
'c'
,
'tagPrefix'
:
't'
,
'colSchema'
:
[{
'type'
:
'INT'
,
'count'
:
1
},{
'type'
:
'BIGINT'
,
'count'
:
1
},{
'type'
:
'DOUBLE'
,
'count'
:
1
},{
'type'
:
'BINARY'
,
'len'
:
32
,
'count'
:
1
},{
'type'
:
'NCHAR'
,
'len'
:
32
,
'count'
:
1
},{
'type'
:
'TIMESTAMP'
,
'count'
:
1
}],
'tagSchema'
:
[{
'type'
:
'INT'
,
'count'
:
1
},{
'type'
:
'BIGINT'
,
'count'
:
1
},{
'type'
:
'DOUBLE'
,
'count'
:
1
},{
'type'
:
'BINARY'
,
'len'
:
32
,
'count'
:
1
},{
'type'
:
'NCHAR'
,
'len'
:
32
,
'count'
:
1
}],
'ctbPrefix'
:
'ctb'
,
'ctbStartIdx'
:
0
,
'ctbNum'
:
10
,
'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
()
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
=
3
expectrowcnt
=
math
.
ceil
(
paraDict
[
"rowsPerTbl"
]
*
paraDict
[
"ctbNum"
]
/
3
)
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
)
consumerId
=
4
expectrowcnt
=
math
.
ceil
(
paraDict
[
"rowsPerTbl"
]
*
paraDict
[
"ctbNum"
]
*
2
/
3
)
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 the consume result"
)
expectRows
=
2
resultList
=
tmqCom
.
selectConsumeResult
(
expectRows
)
actConsumeTotalRows
=
resultList
[
0
]
+
resultList
[
1
]
if
not
(
totalRowsInserted
==
actConsumeTotalRows
):
tdLog
.
info
(
"sum of two consume rows: %d should be equal to total inserted rows: %d"
%
(
actConsumeTotalRows
,
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 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'
:
'BIGINT'
,
'count'
:
1
},{
'type'
:
'DOUBLE'
,
'count'
:
1
},{
'type'
:
'BINARY'
,
'len'
:
32
,
'count'
:
1
},{
'type'
:
'NCHAR'
,
'len'
:
32
,
'count'
:
1
},{
'type'
:
'TIMESTAMP'
,
'count'
:
1
}],
'tagSchema'
:
[{
'type'
:
'INT'
,
'count'
:
1
},{
'type'
:
'BIGINT'
,
'count'
:
1
},{
'type'
:
'DOUBLE'
,
'count'
:
1
},{
'type'
:
'BINARY'
,
'len'
:
32
,
'count'
:
1
},{
'type'
:
'NCHAR'
,
'len'
:
32
,
'count'
:
1
}],
'ctbPrefix'
:
'ctb'
,
'ctbStartIdx'
:
0
,
'ctbNum'
:
10
,
'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
()
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
.
prepareTestEnv
()
self
.
tmqCase3
()
self
.
tmqCase4
()
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
f
"
{
__file__
}
successfully executed"
)
event
=
threading
.
Event
()
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tests/system-test/fulltest.sh
浏览文件 @
33525deb
...
@@ -89,7 +89,7 @@ python3 ./test.py -f 2-query/query_cols_tags_and_or.py
...
@@ -89,7 +89,7 @@ python3 ./test.py -f 2-query/query_cols_tags_and_or.py
# python3 ./test.py -f 2-query/nestedQuery_str.py
# python3 ./test.py -f 2-query/nestedQuery_str.py
python3 ./test.py
-f
2-query/avg.py
python3 ./test.py
-f
2-query/avg.py
python3 ./test.py
-f
2-query/elapsed.py
#
python3 ./test.py -f 2-query/elapsed.py
python3 ./test.py
-f
2-query/csum.py
python3 ./test.py
-f
2-query/csum.py
python3 ./test.py
-f
2-query/mavg.py
python3 ./test.py
-f
2-query/mavg.py
python3 ./test.py
-f
2-query/diff.py
python3 ./test.py
-f
2-query/diff.py
...
...
tests/test/c/tmqSim.c
浏览文件 @
33525deb
...
@@ -36,6 +36,7 @@
...
@@ -36,6 +36,7 @@
#define MAX_CONSUMER_THREAD_CNT (16)
#define MAX_CONSUMER_THREAD_CNT (16)
#define MAX_VGROUP_CNT (32)
#define MAX_VGROUP_CNT (32)
int64_t
now
;
typedef
enum
{
typedef
enum
{
NOTIFY_CMD_START_CONSUM
,
NOTIFY_CMD_START_CONSUM
,
NOTIFY_CMD_START_COMMIT
,
NOTIFY_CMD_START_COMMIT
,
...
@@ -525,15 +526,15 @@ int32_t notifyMainScript(SThreadInfo* pInfo, int32_t cmdId) {
...
@@ -525,15 +526,15 @@ int32_t notifyMainScript(SThreadInfo* pInfo, int32_t cmdId) {
static
int32_t
g_once_commit_flag
=
0
;
static
int32_t
g_once_commit_flag
=
0
;
static
void
tmq_commit_cb_print
(
tmq_t
*
tmq
,
int32_t
code
,
void
*
param
)
{
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
)
{
if
(
0
==
g_once_commit_flag
)
{
g_once_commit_flag
=
1
;
g_once_commit_flag
=
1
;
notifyMainScript
((
SThreadInfo
*
)
param
,
(
int32_t
)
NOTIFY_CMD_START_COMMIT
);
notifyMainScript
((
SThreadInfo
*
)
param
,
(
int32_t
)
NOTIFY_CMD_START_COMMIT
);
}
}
char
tmpString
[
128
];
char
tmpString
[
128
];
taosFprintfFile
(
g_fp
,
"%s tmq_commit_cb_print() be called
\n
"
,
getCurrentTimeString
(
tmpString
));
taosFprintfFile
(
g_fp
,
"%s tmq_commit_cb_print() be called
\n
"
,
getCurrentTimeString
(
tmpString
));
}
}
void
build_consumer
(
SThreadInfo
*
pInfo
)
{
void
build_consumer
(
SThreadInfo
*
pInfo
)
{
...
@@ -588,12 +589,10 @@ void build_topic_list(SThreadInfo* pInfo) {
...
@@ -588,12 +589,10 @@ void build_topic_list(SThreadInfo* pInfo) {
int32_t
saveConsumeResult
(
SThreadInfo
*
pInfo
)
{
int32_t
saveConsumeResult
(
SThreadInfo
*
pInfo
)
{
char
sqlStr
[
1024
]
=
{
0
};
char
sqlStr
[
1024
]
=
{
0
};
int64_t
now
=
taosGetTimestampMs
();
// schema: ts timestamp, consumerid int, consummsgcnt bigint, checkresult int
// schema: ts timestamp, consumerid int, consummsgcnt bigint, checkresult int
sprintf
(
sqlStr
,
"insert into %s.consumeresult values (%"
PRId64
", %d, %"
PRId64
", %"
PRId64
", %d)"
,
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
];
char
tmpString
[
128
];
taosFprintfFile
(
g_fp
,
"%s, consume id %d result: %s
\n
"
,
getCurrentTimeString
(
tmpString
),
pInfo
->
consumerId
,
sqlStr
);
taosFprintfFile
(
g_fp
,
"%s, consume id %d result: %s
\n
"
,
getCurrentTimeString
(
tmpString
),
pInfo
->
consumerId
,
sqlStr
);
...
@@ -637,9 +636,9 @@ void loop_consume(SThreadInfo* pInfo) {
...
@@ -637,9 +636,9 @@ void loop_consume(SThreadInfo* pInfo) {
}
}
}
}
int64_t
lastTotalMsgs
=
0
;
int64_t
lastTotalMsgs
=
0
;
uint64_t
lastPrintTime
=
taosGetTimestampMs
();
uint64_t
lastPrintTime
=
taosGetTimestampMs
();
uint64_t
startTs
=
taosGetTimestampMs
();
uint64_t
startTs
=
taosGetTimestampMs
();
int32_t
consumeDelay
=
g_stConfInfo
.
consumeDelay
==
-
1
?
-
1
:
(
g_stConfInfo
.
consumeDelay
*
1000
);
int32_t
consumeDelay
=
g_stConfInfo
.
consumeDelay
==
-
1
?
-
1
:
(
g_stConfInfo
.
consumeDelay
*
1000
);
while
(
running
)
{
while
(
running
)
{
...
@@ -652,16 +651,16 @@ void loop_consume(SThreadInfo* pInfo) {
...
@@ -652,16 +651,16 @@ void loop_consume(SThreadInfo* pInfo) {
taos_free_result
(
tmqMsg
);
taos_free_result
(
tmqMsg
);
totalMsgs
++
;
totalMsgs
++
;
int64_t
currentPrintTime
=
taosGetTimestampMs
();
int64_t
currentPrintTime
=
taosGetTimestampMs
();
if
(
currentPrintTime
-
lastPrintTime
>
10
*
1000
)
{
if
(
currentPrintTime
-
lastPrintTime
>
10
*
1000
)
{
taosFprintfFile
(
g_fp
,
taosFprintfFile
(
"consumer id %d has currently poll total msgs: %"
PRId64
", period rate: %.3f msgs/second
\n
"
,
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
));
pInfo
->
consumerId
,
totalMsgs
,
(
totalMsgs
-
lastTotalMsgs
)
*
1000
.
0
/
(
currentPrintTime
-
lastPrintTime
));
lastPrintTime
=
currentPrintTime
;
lastPrintTime
=
currentPrintTime
;
lastTotalMsgs
=
totalMsgs
;
lastTotalMsgs
=
totalMsgs
;
}
}
if
(
0
==
once_flag
)
{
if
(
0
==
once_flag
)
{
once_flag
=
1
;
once_flag
=
1
;
notifyMainScript
(
pInfo
,
NOTIFY_CMD_START_CONSUM
);
notifyMainScript
(
pInfo
,
NOTIFY_CMD_START_CONSUM
);
...
@@ -678,7 +677,7 @@ void loop_consume(SThreadInfo* pInfo) {
...
@@ -678,7 +677,7 @@ void loop_consume(SThreadInfo* pInfo) {
break
;
break
;
}
}
}
}
if
(
0
==
running
)
{
if
(
0
==
running
)
{
taosFprintfFile
(
g_fp
,
"receive stop signal and not continue consume
\n
"
);
taosFprintfFile
(
g_fp
,
"receive stop signal and not continue consume
\n
"
);
}
}
...
@@ -696,6 +695,7 @@ void* consumeThreadFunc(void* param) {
...
@@ -696,6 +695,7 @@ void* consumeThreadFunc(void* param) {
pInfo
->
taos
=
taos_connect
(
NULL
,
"root"
,
"taosdata"
,
NULL
,
0
);
pInfo
->
taos
=
taos_connect
(
NULL
,
"root"
,
"taosdata"
,
NULL
,
0
);
if
(
pInfo
->
taos
==
NULL
)
{
if
(
pInfo
->
taos
==
NULL
)
{
taosFprintfFile
(
g_fp
,
"taos_connect() fail, can not notify and save consume result to main scripte
\n
"
);
taosFprintfFile
(
g_fp
,
"taos_connect() fail, can not notify and save consume result to main scripte
\n
"
);
ASSERT
(
0
);
return
NULL
;
return
NULL
;
}
}
...
@@ -855,6 +855,8 @@ int32_t getConsumeInfo() {
...
@@ -855,6 +855,8 @@ int32_t getConsumeInfo() {
}
}
int
main
(
int32_t
argc
,
char
*
argv
[])
{
int
main
(
int32_t
argc
,
char
*
argv
[])
{
now
=
taosGetTimestampMs
();
parseArgument
(
argc
,
argv
);
parseArgument
(
argc
,
argv
);
getConsumeInfo
();
getConsumeInfo
();
saveConfigToLogFile
();
saveConfigToLogFile
();
...
@@ -888,11 +890,11 @@ int main(int32_t argc, char* argv[]) {
...
@@ -888,11 +890,11 @@ int main(int32_t argc, char* argv[]) {
int64_t
t
=
end
-
start
;
int64_t
t
=
end
-
start
;
if
(
0
==
t
)
t
=
1
;
if
(
0
==
t
)
t
=
1
;
double
tInMs
=
(
double
)
t
/
1000000
.
0
;
double
tInMs
=
(
double
)
t
/
1000000
.
0
;
taosFprintfFile
(
g_fp
,
taosFprintfFile
(
g_fp
,
"Spent %.3f seconds to poll msgs: %"
PRIu64
" with %d thread(s), throughput: %.3f msgs/second
\n\n
"
,
"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
));
tInMs
,
totalMsgs
,
g_stConfInfo
.
numOfThread
,
(
double
)(
totalMsgs
/
tInMs
));
taosFprintfFile
(
g_fp
,
"==== close tmqlog ====
\n
"
);
taosFprintfFile
(
g_fp
,
"==== close tmqlog ====
\n
"
);
taosCloseFile
(
&
g_fp
);
taosCloseFile
(
&
g_fp
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录