Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
5e16db4e
T
TDengine
项目概览
taosdata
/
TDengine
接近 2 年 前同步成功
通知
1191
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看板
提交
5e16db4e
编写于
5月 16, 2023
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(stream):extract delete msg from wal.
上级
d585f34e
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
110 addition
and
33 deletion
+110
-33
source/dnode/vnode/inc/vnode.h
source/dnode/vnode/inc/vnode.h
+1
-1
source/dnode/vnode/src/inc/tq.h
source/dnode/vnode/src/inc/tq.h
+2
-1
source/dnode/vnode/src/inc/vnodeInt.h
source/dnode/vnode/src/inc/vnodeInt.h
+1
-1
source/dnode/vnode/src/tq/tq.c
source/dnode/vnode/src/tq/tq.c
+61
-1
source/dnode/vnode/src/tq/tqPush.c
source/dnode/vnode/src/tq/tqPush.c
+2
-2
source/dnode/vnode/src/tq/tqRead.c
source/dnode/vnode/src/tq/tqRead.c
+32
-13
source/dnode/vnode/src/tq/tqRestore.c
source/dnode/vnode/src/tq/tqRestore.c
+8
-11
source/dnode/vnode/src/tq/tqUtil.c
source/dnode/vnode/src/tq/tqUtil.c
+2
-2
source/libs/wal/src/walRead.c
source/libs/wal/src/walRead.c
+1
-1
未找到文件。
source/dnode/vnode/inc/vnode.h
浏览文件 @
5e16db4e
...
...
@@ -258,7 +258,7 @@ int32_t tqSeekVer(STqReader *pReader, int64_t ver, const char *id);
int32_t
tqNextBlockInWal
(
STqReader
*
pReader
);
bool
tqNextBlockImpl
(
STqReader
*
pReader
);
int32_t
extract
SubmitMsgFromWal
(
SWalReader
*
pReader
,
SPackedData
*
pPackedData
);
int32_t
extract
MsgFromWal
(
SWalReader
*
pReader
,
void
**
pItem
,
const
char
*
id
);
int32_t
tqReaderSetSubmitMsg
(
STqReader
*
pReader
,
void
*
msgStr
,
int32_t
msgLen
,
int64_t
ver
);
bool
tqNextDataBlockFilterOut
(
STqReader
*
pReader
,
SHashObj
*
filterOutUids
);
int32_t
tqRetrieveDataBlock
(
STqReader
*
pReader
,
SSubmitTbData
**
pSubmitTbDataRet
);
...
...
source/dnode/vnode/src/inc/tq.h
浏览文件 @
5e16db4e
...
...
@@ -182,8 +182,9 @@ int32_t tqExpandTask(STQ* pTq, SStreamTask* pTask, int64_t ver);
int32_t
tqStreamTasksScanWal
(
STQ
*
pTq
);
// tq util
int32_t
extractDelDataBlock
(
const
void
*
pData
,
int32_t
len
,
int64_t
ver
,
SStreamRefDataBlock
**
pRefBlock
);
char
*
createStreamTaskIdStr
(
int64_t
streamId
,
int32_t
taskId
);
int32_t
tqAddInputBlockNLaunchTask
(
SStreamTask
*
pTask
,
SStreamQueueItem
*
pQueueItem
,
int64_t
ver
);
int32_t
tqAddInputBlockNLaunchTask
(
SStreamTask
*
pTask
,
SStreamQueueItem
*
pQueueItem
);
int32_t
tqExtractDataForMq
(
STQ
*
pTq
,
STqHandle
*
pHandle
,
const
SMqPollReq
*
pRequest
,
SRpcMsg
*
pMsg
);
bool
tqIsHandleExecuting
(
STqHandle
*
pHandle
);
...
...
source/dnode/vnode/src/inc/vnodeInt.h
浏览文件 @
5e16db4e
...
...
@@ -213,7 +213,7 @@ int32_t tqProcessTaskDropReq(STQ* pTq, int64_t version, char* msg, int32_t msgLe
int32_t
tqProcessStreamTaskCheckReq
(
STQ
*
pTq
,
SRpcMsg
*
pMsg
);
int32_t
tqProcessStreamTaskCheckRsp
(
STQ
*
pTq
,
int64_t
version
,
char
*
msg
,
int32_t
msgLen
);
int32_t
tqProcessSubmitReqForSubscribe
(
STQ
*
pTq
);
int32_t
tqProcessDelReq
(
STQ
*
pTq
,
void
*
pReq
,
int32_t
len
,
int64_t
ver
);
int32_t
tqProcessDel
eteData
Req
(
STQ
*
pTq
,
void
*
pReq
,
int32_t
len
,
int64_t
ver
);
int32_t
tqProcessTaskRunReq
(
STQ
*
pTq
,
SRpcMsg
*
pMsg
);
int32_t
tqProcessTaskDispatchReq
(
STQ
*
pTq
,
SRpcMsg
*
pMsg
,
bool
exec
);
int32_t
tqProcessTaskDispatchRsp
(
STQ
*
pTq
,
SRpcMsg
*
pMsg
);
...
...
source/dnode/vnode/src/tq/tq.c
浏览文件 @
5e16db4e
...
...
@@ -942,7 +942,66 @@ int32_t tqProcessTaskRecoverFinishRsp(STQ* pTq, SRpcMsg* pMsg) {
return
0
;
}
int32_t
tqProcessDelReq
(
STQ
*
pTq
,
void
*
pReq
,
int32_t
len
,
int64_t
ver
)
{
int32_t
extractDelDataBlock
(
const
void
*
pData
,
int32_t
len
,
int64_t
ver
,
SStreamRefDataBlock
**
pRefBlock
)
{
SDecoder
*
pCoder
=
&
(
SDecoder
){
0
};
SDeleteRes
*
pRes
=
&
(
SDeleteRes
){
0
};
pRes
->
uidList
=
taosArrayInit
(
0
,
sizeof
(
tb_uid_t
));
if
(
pRes
->
uidList
==
NULL
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
tDecoderInit
(
pCoder
,
(
uint8_t
*
)
pData
,
len
);
tDecodeDeleteRes
(
pCoder
,
pRes
);
tDecoderClear
(
pCoder
);
int32_t
numOfTables
=
taosArrayGetSize
(
pRes
->
uidList
);
if
(
numOfTables
==
0
||
pRes
->
affectedRows
==
0
)
{
taosArrayDestroy
(
pRes
->
uidList
);
return
TSDB_CODE_SUCCESS
;
}
SSDataBlock
*
pDelBlock
=
createSpecialDataBlock
(
STREAM_DELETE_DATA
);
blockDataEnsureCapacity
(
pDelBlock
,
numOfTables
);
pDelBlock
->
info
.
rows
=
numOfTables
;
pDelBlock
->
info
.
version
=
ver
;
for
(
int32_t
i
=
0
;
i
<
numOfTables
;
i
++
)
{
// start key column
SColumnInfoData
*
pStartCol
=
taosArrayGet
(
pDelBlock
->
pDataBlock
,
START_TS_COLUMN_INDEX
);
colDataSetVal
(
pStartCol
,
i
,
(
const
char
*
)
&
pRes
->
skey
,
false
);
// end key column
SColumnInfoData
*
pEndCol
=
taosArrayGet
(
pDelBlock
->
pDataBlock
,
END_TS_COLUMN_INDEX
);
colDataSetVal
(
pEndCol
,
i
,
(
const
char
*
)
&
pRes
->
ekey
,
false
);
// uid column
SColumnInfoData
*
pUidCol
=
taosArrayGet
(
pDelBlock
->
pDataBlock
,
UID_COLUMN_INDEX
);
int64_t
*
pUid
=
taosArrayGet
(
pRes
->
uidList
,
i
);
colDataSetVal
(
pUidCol
,
i
,
(
const
char
*
)
pUid
,
false
);
colDataSetNULL
(
taosArrayGet
(
pDelBlock
->
pDataBlock
,
GROUPID_COLUMN_INDEX
),
i
);
colDataSetNULL
(
taosArrayGet
(
pDelBlock
->
pDataBlock
,
CALCULATE_START_TS_COLUMN_INDEX
),
i
);
colDataSetNULL
(
taosArrayGet
(
pDelBlock
->
pDataBlock
,
CALCULATE_END_TS_COLUMN_INDEX
),
i
);
}
taosArrayDestroy
(
pRes
->
uidList
);
int32_t
*
pRef
=
taosMemoryMalloc
(
sizeof
(
int32_t
));
*
pRef
=
1
;
*
pRefBlock
=
taosAllocateQitem
(
sizeof
(
SStreamRefDataBlock
),
DEF_QITEM
,
0
);
if
(
pRefBlock
==
NULL
)
{
taosMemoryFree
(
pRef
);
return
TSDB_CODE_OUT_OF_MEMORY
;
}
(
*
pRefBlock
)
->
type
=
STREAM_INPUT__REF_DATA_BLOCK
;
(
*
pRefBlock
)
->
pBlock
=
pDelBlock
;
(
*
pRefBlock
)
->
dataRef
=
pRef
;
atomic_add_fetch_32
((
*
pRefBlock
)
->
dataRef
,
1
);
return
TSDB_CODE_SUCCESS
;
}
int32_t
tqProcessDeleteDataReq
(
STQ
*
pTq
,
void
*
pReq
,
int32_t
len
,
int64_t
ver
)
{
bool
failed
=
false
;
SDecoder
*
pCoder
=
&
(
SDecoder
){
0
};
SDeleteRes
*
pRes
=
&
(
SDeleteRes
){
0
};
...
...
@@ -962,6 +1021,7 @@ int32_t tqProcessDelReq(STQ* pTq, void* pReq, int32_t len, int64_t ver) {
taosArrayDestroy
(
pRes
->
uidList
);
return
0
;
}
SSDataBlock
*
pDelBlock
=
createSpecialDataBlock
(
STREAM_DELETE_DATA
);
blockDataEnsureCapacity
(
pDelBlock
,
sz
);
pDelBlock
->
info
.
rows
=
sz
;
...
...
source/dnode/vnode/src/tq/tqPush.c
浏览文件 @
5e16db4e
...
...
@@ -34,12 +34,12 @@ int32_t tqPushMsg(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t v
return
0
;
}
if
(
msgType
==
TDMT_VND_SUBMIT
)
{
if
(
msgType
==
TDMT_VND_SUBMIT
||
msgType
==
TDMT_VND_DELETE
)
{
tqStartStreamTasks
(
pTq
);
}
if
(
msgType
==
TDMT_VND_DELETE
)
{
tqProcessDel
Req
(
pTq
,
POINTER_SHIFT
(
msg
,
sizeof
(
SMsgHead
)),
msgLen
-
sizeof
(
SMsgHead
),
ver
);
// tqProcessDeleteData
Req(pTq, POINTER_SHIFT(msg, sizeof(SMsgHead)), msgLen - sizeof(SMsgHead), ver);
}
}
...
...
source/dnode/vnode/src/tq/tqRead.c
浏览文件 @
5e16db4e
...
...
@@ -301,25 +301,44 @@ int32_t tqSeekVer(STqReader* pReader, int64_t ver, const char* id) {
return
0
;
}
int32_t
extractSubmitMsgFromWal
(
SWalReader
*
pReader
,
SPackedData
*
pPackedData
)
{
if
(
walNextValidMsg
(
pReader
)
<
0
)
{
return
-
1
;
int32_t
extractMsgFromWal
(
SWalReader
*
pReader
,
void
**
pItem
,
const
char
*
id
)
{
int32_t
code
=
walNextValidMsg
(
pReader
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
void
*
pBody
=
POINTER_SHIFT
(
pReader
->
pHead
->
head
.
body
,
sizeof
(
SSubmitReq2Msg
));
int32_t
len
=
pReader
->
pHead
->
head
.
bodyLen
-
sizeof
(
SSubmitReq2Msg
);
int64_t
ver
=
pReader
->
pHead
->
head
.
version
;
void
*
data
=
taosMemoryMalloc
(
len
);
if
(
data
==
NULL
)
{
// todo: for all stream in this vnode, keep this offset in the offset files, and wait for a moment, and then retry
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
tqError
(
"vgId:%d, failed to copy submit data for stream processing, since out of memory"
,
0
);
return
-
1
;
if
(
pReader
->
pHead
->
head
.
msgType
==
TDMT_VND_SUBMIT
)
{
void
*
pBody
=
POINTER_SHIFT
(
pReader
->
pHead
->
head
.
body
,
sizeof
(
SSubmitReq2Msg
));
int32_t
len
=
pReader
->
pHead
->
head
.
bodyLen
-
sizeof
(
SSubmitReq2Msg
);
void
*
data
=
taosMemoryMalloc
(
len
);
if
(
data
==
NULL
)
{
// todo: for all stream in this vnode, keep this offset in the offset files, and wait for a moment, and then retry
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
tqError
(
"vgId:%d, failed to copy submit data for stream processing, since out of memory"
,
0
);
return
-
1
;
}
memcpy
(
data
,
pBody
,
len
);
SPackedData
data1
=
(
SPackedData
){.
ver
=
ver
,
.
msgLen
=
len
,
.
msgStr
=
data
};
*
pItem
=
(
SStreamQueueItem
*
)
streamDataSubmitNew
(
data1
,
STREAM_INPUT__DATA_SUBMIT
);
if
(
*
pItem
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
tqError
(
"%s failed to create data submit for stream since out of memory"
,
id
);
return
terrno
;
}
}
else
if
(
pReader
->
pHead
->
head
.
msgType
==
TDMT_VND_DELETE
)
{
void
*
pBody
=
POINTER_SHIFT
(
pReader
->
pHead
->
head
.
body
,
sizeof
(
SMsgHead
));
int32_t
len
=
pReader
->
pHead
->
head
.
bodyLen
-
sizeof
(
SMsgHead
);
extractDelDataBlock
(
pBody
,
len
,
ver
,
(
SStreamRefDataBlock
**
)
pItem
);
}
else
{
ASSERT
(
0
);
}
memcpy
(
data
,
pBody
,
len
);
*
pPackedData
=
(
SPackedData
){.
ver
=
ver
,
.
msgLen
=
len
,
.
msgStr
=
data
};
return
0
;
}
...
...
source/dnode/vnode/src/tq/tqRestore.c
浏览文件 @
5e16db4e
...
...
@@ -124,7 +124,7 @@ int32_t createStreamRunReq(SStreamMeta* pStreamMeta, bool* pScanIdle) {
tqDebug
(
"vgId:%d s-task:%s wal reader seek to ver:%"
PRId64
,
vgId
,
pTask
->
id
.
idStr
,
pTask
->
chkInfo
.
currentVer
);
}
else
{
int64_t
currentVer
=
walReaderGetCurrentVer
(
pTask
->
exec
.
pWalReader
);
if
(
currentVer
!
=
-
1
)
{
if
(
currentVer
=
=
-
1
)
{
int32_t
code
=
walReaderSeekVer
(
pTask
->
exec
.
pWalReader
,
pTask
->
chkInfo
.
currentVer
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
// no data in wal, quit
streamMetaReleaseTask
(
pStreamMeta
,
pTask
);
...
...
@@ -137,26 +137,24 @@ int32_t createStreamRunReq(SStreamMeta* pStreamMeta, bool* pScanIdle) {
}
// append the data for the stream
tqDebug
(
"vgId:%d s-task:%s wal reader seek to ver:%"
PRId64
,
vgId
,
pTask
->
id
.
idStr
,
pTask
->
chkInfo
.
currentVer
);
//
tqDebug("vgId:%d s-task:%s wal reader seek to ver:%" PRId64, vgId, pTask->id.idStr, pTask->chkInfo.currentVer);
S
PackedData
packData
=
{
0
}
;
int32_t
code
=
extract
SubmitMsgFromWal
(
pTask
->
exec
.
pWalReader
,
&
packData
);
S
StreamQueueItem
*
pItem
=
NULL
;
int32_t
code
=
extract
MsgFromWal
(
pTask
->
exec
.
pWalReader
,
(
void
**
)
&
pItem
,
pTask
->
id
.
idStr
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
// failed, continue
streamMetaReleaseTask
(
pStreamMeta
,
pTask
);
continue
;
}
SStreamDataSubmit2
*
p
=
streamDataSubmitNew
(
packData
,
STREAM_INPUT__DATA_SUBMIT
);
if
(
p
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
tqError
(
"%s failed to create data submit for stream since out of memory"
,
pTask
->
id
.
idStr
);
// delete ignore
if
(
pItem
==
NULL
)
{
streamMetaReleaseTask
(
pStreamMeta
,
pTask
);
continue
;
}
noNewDataInWal
=
false
;
code
=
tqAddInputBlockNLaunchTask
(
pTask
,
(
SStreamQueueItem
*
)
p
,
packData
.
ver
);
code
=
tqAddInputBlockNLaunchTask
(
pTask
,
pItem
);
if
(
code
==
TSDB_CODE_SUCCESS
)
{
pTask
->
chkInfo
.
currentVer
=
walReaderGetCurrentVer
(
pTask
->
exec
.
pWalReader
);
tqDebug
(
"s-task:%s set the ver:%"
PRId64
" from WALReader after extract block from WAL"
,
pTask
->
id
.
idStr
,
...
...
@@ -165,8 +163,7 @@ int32_t createStreamRunReq(SStreamMeta* pStreamMeta, bool* pScanIdle) {
tqError
(
"s-task:%s append input queue failed, ver:%"
PRId64
,
pTask
->
id
.
idStr
,
pTask
->
chkInfo
.
currentVer
);
}
streamDataSubmitDestroy
(
p
);
taosFreeQitem
(
p
);
streamMetaReleaseTask
(
pStreamMeta
,
pTask
);
}
...
...
source/dnode/vnode/src/tq/tqUtil.c
浏览文件 @
5e16db4e
...
...
@@ -26,10 +26,10 @@ char* createStreamTaskIdStr(int64_t streamId, int32_t taskId) {
return
taosStrdup
(
buf
);
}
int32_t
tqAddInputBlockNLaunchTask
(
SStreamTask
*
pTask
,
SStreamQueueItem
*
pQueueItem
,
int64_t
ver
)
{
int32_t
tqAddInputBlockNLaunchTask
(
SStreamTask
*
pTask
,
SStreamQueueItem
*
pQueueItem
)
{
int32_t
code
=
tAppendDataToInputQueue
(
pTask
,
pQueueItem
);
if
(
code
<
0
)
{
tqError
(
"s-task:%s failed to put into queue, too many, next
start ver:%"
PRId64
,
pTask
->
id
.
idStr
,
ver
);
tqError
(
"s-task:%s failed to put into queue, too many, next
ver:%"
PRId64
,
pTask
->
id
.
idStr
,
/*pPackedData->ver*/
0L
);
return
-
1
;
}
...
...
source/libs/wal/src/walRead.c
浏览文件 @
5e16db4e
...
...
@@ -87,7 +87,7 @@ int32_t walNextValidMsg(SWalReader *pReader) {
return
-
1
;
}
if
(
pReader
->
pHead
->
head
.
msgType
==
TDMT_VND_SUBMIT
||
if
(
pReader
->
pHead
->
head
.
msgType
==
TDMT_VND_SUBMIT
||
pReader
->
pHead
->
head
.
msgType
==
TDMT_VND_DELETE
||
(
IS_META_MSG
(
pReader
->
pHead
->
head
.
msgType
)
&&
pReader
->
cond
.
scanMeta
))
{
if
(
walFetchBodyNew
(
pReader
)
<
0
)
{
return
-
1
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录