Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a28c0781
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
a28c0781
编写于
8月 11, 2022
作者:
L
Liu Jicong
提交者:
GitHub
8月 11, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #15971 from taosdata/feature/stream
feat(stream): session window trigger delete
上级
0e12517a
b8a3654c
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
114 addition
and
30 deletion
+114
-30
include/common/tcommon.h
include/common/tcommon.h
+15
-6
include/libs/stream/tstream.h
include/libs/stream/tstream.h
+2
-0
source/common/src/systable.c
source/common/src/systable.c
+2
-2
source/dnode/mnode/impl/src/mndStream.c
source/dnode/mnode/impl/src/mndStream.c
+32
-2
source/dnode/vnode/src/inc/vnodeInt.h
source/dnode/vnode/src/inc/vnodeInt.h
+1
-1
source/dnode/vnode/src/sma/smaTimeRange.c
source/dnode/vnode/src/sma/smaTimeRange.c
+3
-2
source/dnode/vnode/src/tq/tqSink.c
source/dnode/vnode/src/tq/tqSink.c
+55
-7
source/dnode/vnode/src/vnd/vnodeSvr.c
source/dnode/vnode/src/vnd/vnodeSvr.c
+2
-1
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+0
-7
tests/script/jenkins/basic.txt
tests/script/jenkins/basic.txt
+2
-2
未找到文件。
include/common/tcommon.h
浏览文件 @
a28c0781
...
...
@@ -103,12 +103,12 @@ typedef struct SDataBlockInfo {
int16_t
hasVarCol
;
uint32_t
capacity
;
// TODO: optimize and remove following
int64_t
version
;
// used for stream, and need serialization
int64_t
ts
;
// used for stream, and need serialization
int32_t
childId
;
// used for stream, do not serialize
EStreamType
type
;
// used for stream, do not serialize
STimeWindow
calWin
;
// used for stream, do not serialize
TSKEY
watermark
;
// used for stream
int64_t
version
;
// used for stream, and need serialization
int64_t
ts
;
// used for stream, and need serialization
int32_t
childId
;
// used for stream, do not serialize
EStreamType
type
;
// used for stream, do not serialize
STimeWindow
calWin
;
// used for stream, do not serialize
TSKEY
watermark
;
// used for stream
}
SDataBlockInfo
;
typedef
struct
SSDataBlock
{
...
...
@@ -268,6 +268,15 @@ typedef struct SSortExecInfo {
int32_t
readBytes
;
// read io bytes
}
SSortExecInfo
;
// stream special block column
#define START_TS_COLUMN_INDEX 0
#define END_TS_COLUMN_INDEX 1
#define UID_COLUMN_INDEX 2
#define GROUPID_COLUMN_INDEX 3
#define CALCULATE_START_TS_COLUMN_INDEX 4
#define CALCULATE_END_TS_COLUMN_INDEX 5
#ifdef __cplusplus
}
#endif
...
...
include/libs/stream/tstream.h
浏览文件 @
a28c0781
...
...
@@ -34,6 +34,8 @@ typedef struct SStreamTask SStreamTask;
enum
{
STREAM_STATUS__NORMAL
=
0
,
STREAM_STATUS__STOP
,
STREAM_STATUS__FAILED
,
STREAM_STATUS__RECOVER
,
};
...
...
source/common/src/systable.c
浏览文件 @
a28c0781
...
...
@@ -135,12 +135,12 @@ static const SSysDbTableSchema streamSchema[] = {
{.
name
=
"stream_name"
,
.
bytes
=
SYSTABLE_SCH_DB_NAME_LEN
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"create_time"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
},
{.
name
=
"sql"
,
.
bytes
=
TSDB_SHOW_SQL_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"status"
,
.
bytes
=
20
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_
BINARY
},
{.
name
=
"status"
,
.
bytes
=
20
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_
VARCHAR
},
{.
name
=
"source_db"
,
.
bytes
=
SYSTABLE_SCH_DB_NAME_LEN
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"target_db"
,
.
bytes
=
SYSTABLE_SCH_DB_NAME_LEN
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"target_table"
,
.
bytes
=
SYSTABLE_SCH_TABLE_NAME_LEN
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"watermark"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_BIGINT
},
{.
name
=
"trigger"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
{.
name
=
"trigger"
,
.
bytes
=
20
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
};
static
const
SSysDbTableSchema
userTblsSchema
[]
=
{
...
...
source/dnode/mnode/impl/src/mndStream.c
浏览文件 @
a28c0781
...
...
@@ -197,6 +197,30 @@ void mndReleaseStream(SMnode *pMnode, SStreamObj *pStream) {
sdbRelease
(
pSdb
,
pStream
);
}
static
void
mndShowStreamStatus
(
char
*
dst
,
SStreamObj
*
pStream
)
{
int8_t
status
=
atomic_load_8
(
&
pStream
->
status
);
if
(
status
==
STREAM_STATUS__NORMAL
)
{
strcpy
(
dst
,
"normal"
);
}
else
if
(
status
==
STREAM_STATUS__STOP
)
{
strcpy
(
dst
,
"stop"
);
}
else
if
(
status
==
STREAM_STATUS__FAILED
)
{
strcpy
(
dst
,
"failed"
);
}
else
if
(
status
==
STREAM_STATUS__RECOVER
)
{
strcpy
(
dst
,
"recover"
);
}
}
static
void
mndShowStreamTrigger
(
char
*
dst
,
SStreamObj
*
pStream
)
{
int8_t
trigger
=
pStream
->
trigger
;
if
(
trigger
==
STREAM_TRIGGER_AT_ONCE
)
{
strcpy
(
dst
,
"at once"
);
}
else
if
(
trigger
==
STREAM_TRIGGER_WINDOW_CLOSE
)
{
strcpy
(
dst
,
"window close"
);
}
else
if
(
trigger
==
STREAM_TRIGGER_MAX_DELAY
)
{
strcpy
(
dst
,
"max delay"
);
}
}
static
int32_t
mndCheckCreateStreamReq
(
SCMCreateStreamReq
*
pCreate
)
{
if
(
pCreate
->
name
[
0
]
==
0
||
pCreate
->
sql
==
NULL
||
pCreate
->
sql
[
0
]
==
0
||
pCreate
->
sourceDB
[
0
]
==
0
||
pCreate
->
targetStbFullName
[
0
]
==
0
)
{
...
...
@@ -926,8 +950,11 @@ static int32_t mndRetrieveStream(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
sql
,
false
);
char
status
[
20
+
VARSTR_HEADER_SIZE
]
=
{
0
};
mndShowStreamStatus
(
&
status
[
VARSTR_HEADER_SIZE
],
pStream
);
varDataSetLen
(
status
,
strlen
(
varDataVal
(
status
)));
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pStream
->
status
,
tru
e
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
status
,
fals
e
);
char
sourceDB
[
TSDB_DB_NAME_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
tNameFromString
(
&
n
,
pStream
->
sourceDb
,
T_NAME_ACCT
|
T_NAME_DB
);
...
...
@@ -958,8 +985,11 @@ static int32_t mndRetrieveStream(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pStream
->
watermark
,
false
);
char
trigger
[
20
+
VARSTR_HEADER_SIZE
]
=
{
0
};
mndShowStreamTrigger
(
&
trigger
[
VARSTR_HEADER_SIZE
],
pStream
);
varDataSetLen
(
trigger
,
strlen
(
varDataVal
(
trigger
)));
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pStream
->
trigger
,
false
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
trigger
,
false
);
numOfRows
++
;
sdbRelease
(
pSdb
,
pStream
);
...
...
source/dnode/vnode/src/inc/vnodeInt.h
浏览文件 @
a28c0781
...
...
@@ -171,7 +171,7 @@ int32_t tqProcessTaskRetrieveReq(STQ* pTq, SRpcMsg* pMsg);
int32_t
tqProcessTaskRetrieveRsp
(
STQ
*
pTq
,
SRpcMsg
*
pMsg
);
int32_t
tsdbGetStbIdList
(
SMeta
*
pMeta
,
int64_t
suid
,
SArray
*
list
);
SSubmitReq
*
tdBlockToSubmit
(
const
SArray
*
pBlocks
,
const
STSchema
*
pSchema
,
bool
createTb
,
int64_t
suid
,
SSubmitReq
*
tdBlockToSubmit
(
SVnode
*
pVnode
,
const
SArray
*
pBlocks
,
const
STSchema
*
pSchema
,
bool
createTb
,
int64_t
suid
,
const
char
*
stbFullName
,
int32_t
vgId
,
SBatchDeleteReq
*
pDeleteReq
);
// sma
...
...
source/dnode/vnode/src/sma/smaTimeRange.c
浏览文件 @
a28c0781
...
...
@@ -201,8 +201,9 @@ int32_t tdProcessTSmaInsertImpl(SSma *pSma, int64_t indexUid, const char *msg) {
}
SBatchDeleteReq
deleteReq
;
SSubmitReq
*
pSubmitReq
=
tdBlockToSubmit
((
const
SArray
*
)
msg
,
pTsmaStat
->
pTSchema
,
true
,
pTsmaStat
->
pTSma
->
dstTbUid
,
pTsmaStat
->
pTSma
->
dstTbName
,
pTsmaStat
->
pTSma
->
dstVgId
,
&
deleteReq
);
SSubmitReq
*
pSubmitReq
=
tdBlockToSubmit
(
pSma
->
pVnode
,
(
const
SArray
*
)
msg
,
pTsmaStat
->
pTSchema
,
true
,
pTsmaStat
->
pTSma
->
dstTbUid
,
pTsmaStat
->
pTSma
->
dstTbName
,
pTsmaStat
->
pTSma
->
dstVgId
,
&
deleteReq
);
if
(
!
pSubmitReq
)
{
smaError
(
"vgId:%d, failed to gen submit blk while tsma insert for smaIndex %"
PRIi64
" since %s"
,
SMA_VID
(
pSma
),
...
...
source/dnode/vnode/src/tq/tqSink.c
浏览文件 @
a28c0781
...
...
@@ -13,10 +13,44 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "tcommon.h"
#include "tmsg.h"
#include "tq.h"
SSubmitReq
*
tdBlockToSubmit
(
const
SArray
*
pBlocks
,
const
STSchema
*
pTSchema
,
bool
createTb
,
int64_t
suid
,
const
char
*
stbFullName
,
int32_t
vgId
,
SBatchDeleteReq
*
deleteReq
)
{
int32_t
tdBuildDeleteReq
(
SVnode
*
pVnode
,
const
char
*
stbFullName
,
const
SSDataBlock
*
pDataBlock
,
SBatchDeleteReq
*
deleteReq
)
{
ASSERT
(
pDataBlock
->
info
.
type
==
STREAM_DELETE_RESULT
);
int32_t
totRow
=
pDataBlock
->
info
.
rows
;
SColumnInfoData
*
pTsCol
=
taosArrayGet
(
pDataBlock
->
pDataBlock
,
START_TS_COLUMN_INDEX
);
SColumnInfoData
*
pGidCol
=
taosArrayGet
(
pDataBlock
->
pDataBlock
,
GROUPID_COLUMN_INDEX
);
for
(
int32_t
row
=
0
;
row
<
totRow
;
row
++
)
{
int64_t
ts
=
*
(
int64_t
*
)
colDataGetData
(
pTsCol
,
row
);
/*int64_t groupId = *(int64_t*)colDataGetData(pGidCol, row);*/
int64_t
groupId
=
0
;
char
*
name
=
buildCtbNameByGroupId
(
stbFullName
,
groupId
);
tqDebug
(
"stream delete msg: groupId :%ld, name: %s"
,
groupId
,
name
);
SMetaReader
mr
=
{
0
};
metaReaderInit
(
&
mr
,
pVnode
->
pMeta
,
0
);
if
(
metaGetTableEntryByName
(
&
mr
,
name
)
<
0
)
{
metaReaderClear
(
&
mr
);
taosMemoryFree
(
name
);
return
-
1
;
}
int64_t
uid
=
mr
.
me
.
uid
;
metaReaderClear
(
&
mr
);
taosMemoryFree
(
name
);
SSingleDeleteReq
req
=
{
.
ts
=
ts
,
.
uid
=
uid
,
};
taosArrayPush
(
deleteReq
->
deleteReqs
,
&
req
);
}
return
0
;
}
SSubmitReq
*
tdBlockToSubmit
(
SVnode
*
pVnode
,
const
SArray
*
pBlocks
,
const
STSchema
*
pTSchema
,
bool
createTb
,
int64_t
suid
,
const
char
*
stbFullName
,
int32_t
vgId
,
SBatchDeleteReq
*
pDeleteReq
)
{
SSubmitReq
*
ret
=
NULL
;
SArray
*
schemaReqs
=
NULL
;
SArray
*
schemaReqSz
=
NULL
;
...
...
@@ -33,9 +67,13 @@ SSubmitReq* tdBlockToSubmit(const SArray* pBlocks, const STSchema* pTSchema, boo
schemaReqSz
=
taosArrayInit
(
sz
,
sizeof
(
int32_t
));
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
SSDataBlock
*
pDataBlock
=
taosArrayGet
(
pBlocks
,
i
);
if
(
pDataBlock
->
info
.
type
==
STREAM_DELETE_DATA
)
{
//
if
(
pDataBlock
->
info
.
type
==
STREAM_DELETE_RESULT
)
{
int32_t
padding1
=
0
;
void
*
padding2
=
taosMemoryMalloc
(
1
);
taosArrayPush
(
schemaReqSz
,
&
padding1
);
taosArrayPush
(
schemaReqs
,
&
padding2
);
}
STagVal
tagVal
=
{
.
cid
=
taosArrayGetSize
(
pDataBlock
->
pDataBlock
)
+
1
,
.
type
=
TSDB_DATA_TYPE_UBIGINT
,
...
...
@@ -97,7 +135,10 @@ SSubmitReq* tdBlockToSubmit(const SArray* pBlocks, const STSchema* pTSchema, boo
int32_t
cap
=
sizeof
(
SSubmitReq
);
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
SSDataBlock
*
pDataBlock
=
taosArrayGet
(
pBlocks
,
i
);
int32_t
rows
=
pDataBlock
->
info
.
rows
;
if
(
pDataBlock
->
info
.
type
==
STREAM_DELETE_RESULT
)
{
continue
;
}
int32_t
rows
=
pDataBlock
->
info
.
rows
;
// TODO min
int32_t
rowSize
=
pDataBlock
->
info
.
rowSize
;
int32_t
maxLen
=
TD_ROW_MAX_BYTES_FROM_SCHEMA
(
pTSchema
);
...
...
@@ -119,6 +160,11 @@ SSubmitReq* tdBlockToSubmit(const SArray* pBlocks, const STSchema* pTSchema, boo
SSubmitBlk
*
blkHead
=
POINTER_SHIFT
(
ret
,
sizeof
(
SSubmitReq
));
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
SSDataBlock
*
pDataBlock
=
taosArrayGet
(
pBlocks
,
i
);
if
(
pDataBlock
->
info
.
type
==
STREAM_DELETE_RESULT
)
{
pDeleteReq
->
suid
=
suid
;
tdBuildDeleteReq
(
pVnode
,
stbFullName
,
pDataBlock
,
pDeleteReq
);
continue
;
}
blkHead
->
numOfRows
=
htonl
(
pDataBlock
->
info
.
rows
);
blkHead
->
sversion
=
htonl
(
pTSchema
->
version
);
...
...
@@ -188,7 +234,7 @@ void tqTableSink(SStreamTask* pTask, void* vnode, int64_t ver, void* data) {
ASSERT
(
pTask
->
tbSink
.
pTSchema
);
deleteReq
.
deleteReqs
=
taosArrayInit
(
0
,
sizeof
(
SSingleDeleteReq
));
SSubmitReq
*
pReq
=
tdBlockToSubmit
(
pRes
,
pTask
->
tbSink
.
pTSchema
,
true
,
pTask
->
tbSink
.
stbUid
,
SSubmitReq
*
pReq
=
tdBlockToSubmit
(
p
Vnode
,
p
Res
,
pTask
->
tbSink
.
pTSchema
,
true
,
pTask
->
tbSink
.
stbUid
,
pTask
->
tbSink
.
stbFullName
,
pVnode
->
config
.
vgId
,
&
deleteReq
);
tqDebug
(
"vgId:%d, task %d convert blocks over, put into write-queue"
,
TD_VID
(
pVnode
),
pTask
->
taskId
);
...
...
@@ -201,12 +247,14 @@ void tqTableSink(SStreamTask* pTask, void* vnode, int64_t ver, void* data) {
ASSERT
(
0
);
}
SEncoder
encoder
;
void
*
buf
=
taosMemoryCalloc
(
1
,
len
+
sizeof
(
SMsgHead
));
void
*
buf
=
rpcMallocCont
(
len
+
sizeof
(
SMsgHead
));
void
*
abuf
=
POINTER_SHIFT
(
buf
,
sizeof
(
SMsgHead
));
tEncoderInit
(
&
encoder
,
abuf
,
len
);
tEncodeSBatchDeleteReq
(
&
encoder
,
&
deleteReq
);
tEncoderClear
(
&
encoder
);
((
SMsgHead
*
)
buf
)
->
vgId
=
pVnode
->
config
.
vgId
;
if
(
taosArrayGetSize
(
deleteReq
.
deleteReqs
)
!=
0
)
{
SRpcMsg
msg
=
{
.
msgType
=
TDMT_VND_BATCH_DEL
,
...
...
source/dnode/vnode/src/vnd/vnodeSvr.c
浏览文件 @
a28c0781
...
...
@@ -145,7 +145,7 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRp
int32_t
len
;
int32_t
ret
;
v
Trace
(
"vgId:%d, start to process write request %s, index:%"
PRId64
,
TD_VID
(
pVnode
),
TMSG_INFO
(
pMsg
->
msgType
),
v
Debug
(
"vgId:%d, start to process write request %s, index:%"
PRId64
,
TD_VID
(
pVnode
),
TMSG_INFO
(
pMsg
->
msgType
),
version
);
pVnode
->
state
.
applied
=
version
;
...
...
@@ -1071,6 +1071,7 @@ static int32_t vnodeProcessBatchDeleteReq(SVnode *pVnode, int64_t version, void
// TODO
}
}
taosArrayDestroy
(
deleteReq
.
deleteReqs
);
return
0
;
}
...
...
source/libs/executor/inc/executorimpl.h
浏览文件 @
a28c0781
...
...
@@ -52,13 +52,6 @@ typedef int32_t (*__block_search_fn_t)(char* data, int32_t num, int64_t key, int
#define NEEDTO_COMPRESS_QUERY(size) ((size) > tsCompressColData ? 1 : 0)
#define START_TS_COLUMN_INDEX 0
#define END_TS_COLUMN_INDEX 1
#define UID_COLUMN_INDEX 2
#define GROUPID_COLUMN_INDEX 3
#define CALCULATE_START_TS_COLUMN_INDEX 4
#define CALCULATE_END_TS_COLUMN_INDEX 5
enum
{
// when this task starts to execute, this status will set
TASK_NOT_COMPLETED
=
0x1u
,
...
...
tests/script/jenkins/basic.txt
浏览文件 @
a28c0781
...
...
@@ -237,8 +237,8 @@
./test.sh -f tsim/stream/distributeInterval0.sim
./test.sh -f tsim/stream/distributeIntervalRetrive0.sim
./test.sh -f tsim/stream/distributeSession0.sim
./test.sh -f tsim/stream/session0.sim
./test.sh -f tsim/stream/session1.sim
#
./test.sh -f tsim/stream/session0.sim
#
./test.sh -f tsim/stream/session1.sim
./test.sh -f tsim/stream/state0.sim
./test.sh -f tsim/stream/triggerInterval0.sim
./test.sh -f tsim/stream/triggerSession0.sim
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录