Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
b60b1796
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
b60b1796
编写于
4月 20, 2023
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(stream): add lock during check wal to create new stream task.
上级
742b5ee0
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
45 addition
and
43 deletion
+45
-43
source/dnode/vnode/src/tq/tqRestore.c
source/dnode/vnode/src/tq/tqRestore.c
+45
-37
source/libs/stream/src/streamMeta.c
source/libs/stream/src/streamMeta.c
+0
-6
未找到文件。
source/dnode/vnode/src/tq/tqRestore.c
浏览文件 @
b60b1796
...
...
@@ -15,8 +15,7 @@
#include "tq.h"
static
int32_t
streamTaskReplayWal
(
SStreamMeta
*
pStreamMeta
,
STqOffsetStore
*
pOffsetStore
,
bool
*
pScanIdle
);
static
int32_t
transferToNormalTask
(
SStreamMeta
*
pStreamMeta
,
SArray
*
pTaskList
);
static
int32_t
doCreateReqsByScanWal
(
SStreamMeta
*
pStreamMeta
,
STqOffsetStore
*
pOffsetStore
,
bool
*
pScanIdle
);
// this function should be executed by stream threads.
// there is a case that the WAL increases more fast than the restore procedure, and this restore procedure
...
...
@@ -32,7 +31,7 @@ int tqStreamTasksScanWal(STQ* pTq) {
// check all restore tasks
bool
shouldIdle
=
true
;
streamTaskReplay
Wal
(
pTq
->
pStreamMeta
,
pTq
->
pOffsetStore
,
&
shouldIdle
);
doCreateReqsByScan
Wal
(
pTq
->
pStreamMeta
,
pTq
->
pOffsetStore
,
&
shouldIdle
);
int32_t
times
=
0
;
...
...
@@ -55,50 +54,50 @@ int tqStreamTasksScanWal(STQ* pTq) {
int64_t
el
=
(
taosGetTimestampMs
()
-
st
);
tqDebug
(
"vgId:%d scan wal for stream tasks completed, elapsed time:%"
PRId64
" ms"
,
vgId
,
el
);
// restore wal scan flag
// atomic_store_8(&pTq->pStreamMeta->walScan, 0);
return
0
;
}
//int32_t transferToNormalTask(SStreamMeta* pStreamMeta, SArray* pTaskList) {
// int32_t numOfTask = taosArrayGetSize(pTaskList);
// if (numOfTask <= 0) {
// return TSDB_CODE_SUCCESS;
// }
//
// // todo: add lock
// for (int32_t i = 0; i < numOfTask; ++i) {
// SStreamTask* pTask = taosArrayGetP(pTaskList, i);
// tqDebug("vgId:%d transfer s-task:%s state restore -> ready, checkpoint:%" PRId64 " checkpoint id:%" PRId64,
// pStreamMeta->vgId, pTask->id.idStr, pTask->chkInfo.version, pTask->chkInfo.id);
// taosHashRemove(pStreamMeta->pWalReadTasks, &pTask->id.taskId, sizeof(pTask->id.taskId));
//
// // NOTE: do not change the following order
// atomic_store_8(&pTask->status.taskStatus, TASK_STATUS__NORMAL);
// taosHashPut(pStreamMeta->pTasks, &pTask->id.taskId, sizeof(pTask->id.taskId), &pTask, POINTER_BYTES);
// }
//
// return TSDB_CODE_SUCCESS;
//}
int32_t
streamTaskReplayWal
(
SStreamMeta
*
pStreamMeta
,
STqOffsetStore
*
pOffsetStore
,
bool
*
pScanIdle
)
{
static
SArray
*
extractTaskIdList
(
SStreamMeta
*
pStreamMeta
,
int32_t
numOfTasks
)
{
SArray
*
pTaskIdList
=
taosArrayInit
(
numOfTasks
,
sizeof
(
int32_t
));
void
*
pIter
=
NULL
;
int32_t
vgId
=
pStreamMeta
->
vgId
;
*
pScanIdle
=
true
;
bool
allWalChecked
=
true
;
tqDebug
(
"vgId:%d start to check wal to extract new submit block"
,
vgId
);
while
(
1
)
{
taosWLockLatch
(
&
pStreamMeta
->
lock
);
while
(
1
)
{
pIter
=
taosHashIterate
(
pStreamMeta
->
pTasks
,
pIter
);
if
(
pIter
==
NULL
)
{
break
;
}
SStreamTask
*
pTask
=
*
(
SStreamTask
**
)
pIter
;
taosArrayPush
(
pTaskIdList
,
&
pTask
->
id
.
taskId
);
}
taosWUnLockLatch
(
&
pStreamMeta
->
lock
);
return
pTaskIdList
;
}
int32_t
doCreateReqsByScanWal
(
SStreamMeta
*
pStreamMeta
,
STqOffsetStore
*
pOffsetStore
,
bool
*
pScanIdle
)
{
*
pScanIdle
=
true
;
bool
noNewDataInWal
=
true
;
int32_t
vgId
=
pStreamMeta
->
vgId
;
int32_t
numOfTasks
=
taosHashGetSize
(
pStreamMeta
->
pTasks
);
if
(
numOfTasks
==
0
)
{
return
TSDB_CODE_SUCCESS
;
}
tqDebug
(
"vgId:%d start to check wal to extract new submit block for %d tasks"
,
vgId
,
numOfTasks
);
SArray
*
pTaskIdList
=
extractTaskIdList
(
pStreamMeta
,
numOfTasks
);
for
(
int32_t
i
=
0
;
i
<
numOfTasks
;
++
i
)
{
int32_t
*
pTaskId
=
taosArrayGet
(
pTaskIdList
,
i
);
SStreamTask
*
pTask
=
streamMetaAcquireTask
(
pStreamMeta
,
*
pTaskId
);
if
(
pTask
==
NULL
)
{
continue
;
}
if
(
pTask
->
taskLevel
!=
TASK_LEVEL__SOURCE
)
{
streamMetaReleaseTask
(
pStreamMeta
,
pTask
);
continue
;
}
...
...
@@ -106,6 +105,7 @@ int32_t streamTaskReplayWal(SStreamMeta* pStreamMeta, STqOffsetStore* pOffsetSto
pTask
->
status
.
taskStatus
==
TASK_STATUS__WAIT_DOWNSTREAM
)
{
tqDebug
(
"s-task:%s skip push data, not ready for processing, status %d"
,
pTask
->
id
.
idStr
,
pTask
->
status
.
taskStatus
);
streamMetaReleaseTask
(
pStreamMeta
,
pTask
);
continue
;
}
...
...
@@ -115,6 +115,7 @@ int32_t streamTaskReplayWal(SStreamMeta* pStreamMeta, STqOffsetStore* pOffsetSto
if
(
tInputQueueIsFull
(
pTask
))
{
tqDebug
(
"vgId:%d s-task:%s input queue is full, do nothing"
,
vgId
,
pTask
->
id
.
idStr
);
streamMetaReleaseTask
(
pStreamMeta
,
pTask
);
continue
;
}
...
...
@@ -127,6 +128,7 @@ int32_t streamTaskReplayWal(SStreamMeta* pStreamMeta, STqOffsetStore* pOffsetSto
// seek the stored version and extract data from WAL
int32_t
code
=
walReadSeekVer
(
pTask
->
exec
.
pWalReader
,
pOffset
->
val
.
version
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
// no data in wal, quit
streamMetaReleaseTask
(
pStreamMeta
,
pTask
);
continue
;
}
...
...
@@ -136,6 +138,7 @@ int32_t streamTaskReplayWal(SStreamMeta* pStreamMeta, STqOffsetStore* pOffsetSto
SPackedData
packData
=
{
0
};
code
=
extractSubmitMsgFromWal
(
pTask
->
exec
.
pWalReader
,
&
packData
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
// failed, continue
streamMetaReleaseTask
(
pStreamMeta
,
pTask
);
continue
;
}
...
...
@@ -143,10 +146,11 @@ int32_t streamTaskReplayWal(SStreamMeta* pStreamMeta, STqOffsetStore* pOffsetSto
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
);
streamMetaReleaseTask
(
pStreamMeta
,
pTask
);
continue
;
}
allWalChecked
=
false
;
noNewDataInWal
=
false
;
tqDebug
(
"s-task:%s submit data extracted from WAL"
,
pTask
->
id
.
idStr
);
code
=
tqAddInputBlockNLaunchTask
(
pTask
,
(
SStreamQueueItem
*
)
p
,
packData
.
ver
);
...
...
@@ -160,11 +164,15 @@ int32_t streamTaskReplayWal(SStreamMeta* pStreamMeta, STqOffsetStore* pOffsetSto
streamDataSubmitDestroy
(
p
);
taosFreeQitem
(
p
);
streamMetaReleaseTask
(
pStreamMeta
,
pTask
);
}
if
(
allWalChecked
)
{
// all wal are checked, and no new data available in wal.
if
(
noNewDataInWal
)
{
*
pScanIdle
=
true
;
}
taosArrayDestroy
(
pTaskIdList
);
return
0
;
}
source/libs/stream/src/streamMeta.c
浏览文件 @
b60b1796
...
...
@@ -84,11 +84,6 @@ void streamMetaClose(SStreamMeta* pMeta) {
tdbClose
(
pMeta
->
db
);
void
*
pIter
=
NULL
;
// while(pMeta->walScan) {
// qDebug("wait stream daemon quit");
// taosMsleep(100);
// }
while
(
1
)
{
pIter
=
taosHashIterate
(
pMeta
->
pTasks
,
pIter
);
if
(
pIter
==
NULL
)
{
...
...
@@ -102,7 +97,6 @@ void streamMetaClose(SStreamMeta* pMeta) {
}
tFreeStreamTask
(
pTask
);
/*streamMetaReleaseTask(pMeta, pTask);*/
}
taosHashCleanup
(
pMeta
->
pTasks
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录