Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
4c929973
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看板
提交
4c929973
编写于
8月 09, 2023
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(stream): use streamId&taskId to identify the stream task in the stream meta.
上级
3cdb1635
变更
9
显示空白变更内容
内联
并排
Showing
9 changed file
with
58 addition
and
54 deletion
+58
-54
include/common/tmsg.h
include/common/tmsg.h
+3
-0
include/libs/stream/tstream.h
include/libs/stream/tstream.h
+1
-1
source/dnode/mnode/impl/src/mndStream.c
source/dnode/mnode/impl/src/mndStream.c
+6
-0
source/dnode/snode/src/snode.c
source/dnode/snode/src/snode.c
+9
-14
source/dnode/vnode/src/tq/tq.c
source/dnode/vnode/src/tq/tq.c
+18
-19
source/dnode/vnode/src/tq/tqRestore.c
source/dnode/vnode/src/tq/tqRestore.c
+4
-4
source/libs/stream/src/streamExec.c
source/libs/stream/src/streamExec.c
+1
-1
source/libs/stream/src/streamMeta.c
source/libs/stream/src/streamMeta.c
+11
-12
source/libs/stream/src/streamRecover.c
source/libs/stream/src/streamRecover.c
+5
-3
未找到文件。
include/common/tmsg.h
浏览文件 @
4c929973
...
...
@@ -2767,6 +2767,7 @@ typedef struct {
typedef
struct
{
SMsgHead
head
;
int64_t
leftForVer
;
int64_t
streamId
;
int32_t
taskId
;
}
SVDropStreamTaskReq
;
...
...
@@ -2958,6 +2959,7 @@ int32_t tDecodeMqVgOffset(SDecoder* pDecoder, SMqVgOffset* pOffset);
typedef
struct
{
SMsgHead
head
;
int64_t
streamId
;
int32_t
taskId
;
}
SVPauseStreamTaskReq
;
...
...
@@ -2976,6 +2978,7 @@ int32_t tDeserializeSMPauseStreamReq(void* buf, int32_t bufLen, SMPauseStreamReq
typedef
struct
{
SMsgHead
head
;
int32_t
taskId
;
int64_t
streamId
;
int8_t
igUntreated
;
}
SVResumeStreamTaskReq
;
...
...
include/libs/stream/tstream.h
浏览文件 @
4c929973
...
...
@@ -646,7 +646,7 @@ int32_t streamMetaRemoveTask(SStreamMeta* pMeta, int32_t taskId);
int32_t
streamMetaRegisterTask
(
SStreamMeta
*
pMeta
,
int64_t
ver
,
SStreamTask
*
pTask
,
bool
*
pAdded
);
int32_t
streamMetaUnregisterTask
(
SStreamMeta
*
pMeta
,
int32_t
taskId
);
int32_t
streamMetaGetNumOfTasks
(
SStreamMeta
*
pMeta
);
// todo remove it
SStreamTask
*
streamMetaAcquireTask
(
SStreamMeta
*
pMeta
,
int32_t
taskId
);
SStreamTask
*
streamMetaAcquireTask
(
SStreamMeta
*
pMeta
,
int
64_t
streamId
,
int
32_t
taskId
);
void
streamMetaReleaseTask
(
SStreamMeta
*
pMeta
,
SStreamTask
*
pTask
);
int32_t
streamMetaBegin
(
SStreamMeta
*
pMeta
);
...
...
source/dnode/mnode/impl/src/mndStream.c
浏览文件 @
4c929973
...
...
@@ -649,6 +649,8 @@ static int32_t mndPersistTaskDropReq(STrans *pTrans, SStreamTask *pTask) {
pReq
->
head
.
vgId
=
htonl
(
pTask
->
info
.
nodeId
);
pReq
->
taskId
=
pTask
->
id
.
taskId
;
pReq
->
streamId
=
pTask
->
id
.
streamId
;
STransAction
action
=
{
0
};
memcpy
(
&
action
.
epSet
,
&
pTask
->
info
.
epSet
,
sizeof
(
SEpSet
));
action
.
pCont
=
pReq
;
...
...
@@ -1361,6 +1363,8 @@ static int32_t mndPauseStreamTask(STrans *pTrans, SStreamTask *pTask) {
}
pReq
->
head
.
vgId
=
htonl
(
pTask
->
info
.
nodeId
);
pReq
->
taskId
=
pTask
->
id
.
taskId
;
pReq
->
streamId
=
pTask
->
id
.
streamId
;
STransAction
action
=
{
0
};
memcpy
(
&
action
.
epSet
,
&
pTask
->
info
.
epSet
,
sizeof
(
SEpSet
));
action
.
pCont
=
pReq
;
...
...
@@ -1501,7 +1505,9 @@ static int32_t mndResumeStreamTask(STrans *pTrans, SStreamTask *pTask, int8_t ig
}
pReq
->
head
.
vgId
=
htonl
(
pTask
->
info
.
nodeId
);
pReq
->
taskId
=
pTask
->
id
.
taskId
;
pReq
->
streamId
=
pTask
->
id
.
streamId
;
pReq
->
igUntreated
=
igUntreated
;
STransAction
action
=
{
0
};
memcpy
(
&
action
.
epSet
,
&
pTask
->
info
.
epSet
,
sizeof
(
SEpSet
));
action
.
pCont
=
pReq
;
...
...
source/dnode/snode/src/snode.c
浏览文件 @
4c929973
...
...
@@ -35,9 +35,7 @@ void sndEnqueueStreamDispatch(SSnode *pSnode, SRpcMsg *pMsg) {
tDecoderClear
(
&
decoder
);
int32_t
taskId
=
req
.
taskId
;
SStreamTask
*
pTask
=
streamMetaAcquireTask
(
pSnode
->
pMeta
,
taskId
);
SStreamTask
*
pTask
=
streamMetaAcquireTask
(
pSnode
->
pMeta
,
req
.
streamId
,
req
.
taskId
);
if
(
pTask
)
{
SRpcMsg
rsp
=
{
.
info
=
pMsg
->
info
,
...
...
@@ -181,7 +179,7 @@ int32_t sndProcessTaskDropReq(SSnode *pSnode, char *msg, int32_t msgLen) {
SVDropStreamTaskReq
*
pReq
=
(
SVDropStreamTaskReq
*
)
msg
;
qDebug
(
"snode:%d receive msg to drop stream task:0x%x"
,
pSnode
->
pMeta
->
vgId
,
pReq
->
taskId
);
SStreamTask
*
pTask
=
streamMetaAcquireTask
(
pSnode
->
pMeta
,
pReq
->
taskId
);
SStreamTask
*
pTask
=
streamMetaAcquireTask
(
pSnode
->
pMeta
,
pReq
->
streamId
,
pReq
->
taskId
);
if
(
pTask
==
NULL
)
{
qError
(
"vgId:%d failed to acquire s-task:0x%x when dropping it"
,
pSnode
->
pMeta
->
vgId
,
pReq
->
taskId
);
return
0
;
...
...
@@ -194,8 +192,7 @@ int32_t sndProcessTaskDropReq(SSnode *pSnode, char *msg, int32_t msgLen) {
int32_t
sndProcessTaskRunReq
(
SSnode
*
pSnode
,
SRpcMsg
*
pMsg
)
{
SStreamTaskRunReq
*
pReq
=
pMsg
->
pCont
;
int32_t
taskId
=
pReq
->
taskId
;
SStreamTask
*
pTask
=
streamMetaAcquireTask
(
pSnode
->
pMeta
,
taskId
);
SStreamTask
*
pTask
=
streamMetaAcquireTask
(
pSnode
->
pMeta
,
pReq
->
streamId
,
pReq
->
taskId
);
if
(
pTask
)
{
streamProcessRunReq
(
pTask
);
streamMetaReleaseTask
(
pSnode
->
pMeta
,
pTask
);
...
...
@@ -213,9 +210,8 @@ int32_t sndProcessTaskDispatchReq(SSnode *pSnode, SRpcMsg *pMsg, bool exec) {
SDecoder
decoder
;
tDecoderInit
(
&
decoder
,
(
uint8_t
*
)
msgBody
,
msgLen
);
tDecodeStreamDispatchReq
(
&
decoder
,
&
req
);
int32_t
taskId
=
req
.
taskId
;
SStreamTask
*
pTask
=
streamMetaAcquireTask
(
pSnode
->
pMeta
,
taskId
);
SStreamTask
*
pTask
=
streamMetaAcquireTask
(
pSnode
->
pMeta
,
req
.
streamId
,
req
.
taskId
);
if
(
pTask
)
{
SRpcMsg
rsp
=
{
.
info
=
pMsg
->
info
,
.
code
=
0
};
streamProcessDispatchMsg
(
pTask
,
&
req
,
&
rsp
,
exec
);
...
...
@@ -235,8 +231,7 @@ int32_t sndProcessTaskRetrieveReq(SSnode *pSnode, SRpcMsg *pMsg) {
tDecoderInit
(
&
decoder
,
msgBody
,
msgLen
);
tDecodeStreamRetrieveReq
(
&
decoder
,
&
req
);
tDecoderClear
(
&
decoder
);
int32_t
taskId
=
req
.
dstTaskId
;
SStreamTask
*
pTask
=
streamMetaAcquireTask
(
pSnode
->
pMeta
,
taskId
);
SStreamTask
*
pTask
=
streamMetaAcquireTask
(
pSnode
->
pMeta
,
req
.
streamId
,
req
.
dstTaskId
);
if
(
pTask
)
{
SRpcMsg
rsp
=
{
.
info
=
pMsg
->
info
,
.
code
=
0
};
...
...
@@ -252,7 +247,7 @@ int32_t sndProcessTaskRetrieveReq(SSnode *pSnode, SRpcMsg *pMsg) {
int32_t
sndProcessTaskDispatchRsp
(
SSnode
*
pSnode
,
SRpcMsg
*
pMsg
)
{
SStreamDispatchRsp
*
pRsp
=
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
));
int32_t
taskId
=
ntohl
(
pRsp
->
upstreamTaskId
);
SStreamTask
*
pTask
=
streamMetaAcquireTask
(
pSnode
->
pMeta
,
taskId
);
SStreamTask
*
pTask
=
streamMetaAcquireTask
(
pSnode
->
pMeta
,
pRsp
->
streamId
,
taskId
);
if
(
pTask
)
{
streamProcessDispatchRsp
(
pTask
,
pRsp
,
pMsg
->
code
);
streamMetaReleaseTask
(
pSnode
->
pMeta
,
pTask
);
...
...
@@ -297,7 +292,7 @@ int32_t sndProcessStreamTaskScanHistoryFinishReq(SSnode *pSnode, SRpcMsg *pMsg)
tDecoderClear
(
&
decoder
);
// find task
SStreamTask
*
pTask
=
streamMetaAcquireTask
(
pSnode
->
pMeta
,
req
.
downstreamTaskId
);
SStreamTask
*
pTask
=
streamMetaAcquireTask
(
pSnode
->
pMeta
,
req
.
streamId
,
req
.
downstreamTaskId
);
if
(
pTask
==
NULL
)
{
return
-
1
;
}
...
...
@@ -340,7 +335,7 @@ int32_t sndProcessStreamTaskCheckReq(SSnode *pSnode, SRpcMsg *pMsg) {
.
upstreamTaskId
=
req
.
upstreamTaskId
,
};
SStreamTask
*
pTask
=
streamMetaAcquireTask
(
pSnode
->
pMeta
,
taskId
);
SStreamTask
*
pTask
=
streamMetaAcquireTask
(
pSnode
->
pMeta
,
req
.
streamId
,
taskId
);
if
(
pTask
!=
NULL
)
{
rsp
.
status
=
streamTaskCheckStatus
(
pTask
);
...
...
@@ -400,7 +395,7 @@ int32_t sndProcessStreamTaskCheckRsp(SSnode* pSnode, SRpcMsg* pMsg) {
qDebug
(
"tq task:0x%x (vgId:%d) recv check rsp(reqId:0x%"
PRIx64
") from 0x%x (vgId:%d) status %d"
,
rsp
.
upstreamTaskId
,
rsp
.
upstreamNodeId
,
rsp
.
reqId
,
rsp
.
downstreamTaskId
,
rsp
.
downstreamNodeId
,
rsp
.
status
);
SStreamTask
*
pTask
=
streamMetaAcquireTask
(
pSnode
->
pMeta
,
rsp
.
upstreamTaskId
);
SStreamTask
*
pTask
=
streamMetaAcquireTask
(
pSnode
->
pMeta
,
rsp
.
streamId
,
rsp
.
upstreamTaskId
);
if
(
pTask
==
NULL
)
{
qError
(
"tq failed to locate the stream task:0x%x (vgId:%d), it may have been destroyed"
,
rsp
.
upstreamTaskId
,
pSnode
->
pMeta
->
vgId
);
...
...
source/dnode/vnode/src/tq/tq.c
浏览文件 @
4c929973
...
...
@@ -1062,7 +1062,7 @@ int32_t tqProcessStreamTaskCheckReq(STQ* pTq, SRpcMsg* pMsg) {
.
upstreamTaskId
=
req
.
upstreamTaskId
,
};
SStreamTask
*
pTask
=
streamMetaAcquireTask
(
pTq
->
pStreamMeta
,
taskId
);
SStreamTask
*
pTask
=
streamMetaAcquireTask
(
pTq
->
pStreamMeta
,
req
.
streamId
,
taskId
);
if
(
pTask
!=
NULL
)
{
rsp
.
status
=
streamTaskCheckStatus
(
pTask
);
streamMetaReleaseTask
(
pTq
->
pStreamMeta
,
pTask
);
...
...
@@ -1099,7 +1099,7 @@ int32_t tqProcessStreamTaskCheckRsp(STQ* pTq, int64_t sversion, SRpcMsg* pMsg) {
tqDebug
(
"tq task:0x%x (vgId:%d) recv check rsp(reqId:0x%"
PRIx64
") from 0x%x (vgId:%d) status %d"
,
rsp
.
upstreamTaskId
,
rsp
.
upstreamNodeId
,
rsp
.
reqId
,
rsp
.
downstreamTaskId
,
rsp
.
downstreamNodeId
,
rsp
.
status
);
SStreamTask
*
pTask
=
streamMetaAcquireTask
(
pTq
->
pStreamMeta
,
rsp
.
upstreamTaskId
);
SStreamTask
*
pTask
=
streamMetaAcquireTask
(
pTq
->
pStreamMeta
,
rsp
.
streamId
,
rsp
.
upstreamTaskId
);
if
(
pTask
==
NULL
)
{
tqError
(
"tq failed to locate the stream task:0x%x (vgId:%d), it may have been destroyed"
,
rsp
.
upstreamTaskId
,
pTq
->
pStreamMeta
->
vgId
);
...
...
@@ -1160,7 +1160,7 @@ int32_t tqProcessTaskDeployReq(STQ* pTq, int64_t sversion, char* msg, int32_t ms
// not added into meta store
if
(
added
)
{
tqDebug
(
"vgId:%d s-task:0x%x is deployed and add into meta, numOfTasks:%d"
,
vgId
,
taskId
,
numOfTasks
);
SStreamTask
*
p
=
streamMetaAcquireTask
(
pStreamMeta
,
taskId
);
SStreamTask
*
p
=
streamMetaAcquireTask
(
pStreamMeta
,
pTask
->
id
.
streamId
,
taskId
);
if
(
p
!=
NULL
)
{
// reset the downstreamReady flag.
streamTaskCheckDownstreamTasks
(
p
);
}
...
...
@@ -1178,7 +1178,7 @@ int32_t tqProcessTaskScanHistory(STQ* pTq, SRpcMsg* pMsg) {
SStreamMeta
*
pMeta
=
pTq
->
pStreamMeta
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
SStreamTask
*
pTask
=
streamMetaAcquireTask
(
pMeta
,
pReq
->
taskId
);
SStreamTask
*
pTask
=
streamMetaAcquireTask
(
pMeta
,
pReq
->
streamId
,
pReq
->
taskId
);
if
(
pTask
==
NULL
)
{
tqError
(
"vgId:%d failed to acquire stream task:0x%x during stream recover, task may have been destroyed"
,
pMeta
->
vgId
,
pReq
->
taskId
);
...
...
@@ -1234,7 +1234,7 @@ int32_t tqProcessTaskScanHistory(STQ* pTq, SRpcMsg* pMsg) {
bool
done
=
false
;
// 1. get the related stream task
pStreamTask
=
streamMetaAcquireTask
(
pMeta
,
pTask
->
streamTaskId
.
taskId
);
pStreamTask
=
streamMetaAcquireTask
(
pMeta
,
pTask
->
streamTaskId
.
streamId
,
pTask
->
streamTaskId
.
taskId
);
if
(
pStreamTask
==
NULL
)
{
// todo delete this task, if the related stream task is dropped
qError
(
"failed to find s-task:0x%x, it may have been destroyed, drop fill-history task:%s"
,
...
...
@@ -1350,7 +1350,7 @@ int32_t tqProcessTaskTransferStateReq(STQ* pTq, SRpcMsg* pMsg) {
tqDebug
(
"vgId:%d start to process transfer state msg, from s-task:0x%x"
,
pTq
->
pStreamMeta
->
vgId
,
req
.
downstreamTaskId
);
SStreamTask
*
pTask
=
streamMetaAcquireTask
(
pTq
->
pStreamMeta
,
req
.
downstreamTaskId
);
SStreamTask
*
pTask
=
streamMetaAcquireTask
(
pTq
->
pStreamMeta
,
req
.
streamId
,
req
.
downstreamTaskId
);
if
(
pTask
==
NULL
)
{
tqError
(
"failed to find task:0x%x, it may have been dropped already. process transfer state failed"
,
req
.
downstreamTaskId
);
return
-
1
;
...
...
@@ -1386,7 +1386,7 @@ int32_t tqProcessTaskScanHistoryFinishReq(STQ* pTq, SRpcMsg* pMsg) {
tDecodeStreamScanHistoryFinishReq
(
&
decoder
,
&
req
);
tDecoderClear
(
&
decoder
);
SStreamTask
*
pTask
=
streamMetaAcquireTask
(
pTq
->
pStreamMeta
,
req
.
downstreamTaskId
);
SStreamTask
*
pTask
=
streamMetaAcquireTask
(
pTq
->
pStreamMeta
,
req
.
streamId
,
req
.
downstreamTaskId
);
if
(
pTask
==
NULL
)
{
tqError
(
"vgId:%d process scan history finish msg, failed to find task:0x%x, it may be destroyed"
,
pTq
->
pStreamMeta
->
vgId
,
req
.
downstreamTaskId
);
...
...
@@ -1412,7 +1412,7 @@ int32_t tqProcessTaskScanHistoryFinishRsp(STQ* pTq, SRpcMsg* pMsg) {
tDecodeCompleteHistoryDataMsg
(
&
decoder
,
&
req
);
tDecoderClear
(
&
decoder
);
SStreamTask
*
pTask
=
streamMetaAcquireTask
(
pTq
->
pStreamMeta
,
req
.
upstreamTaskId
);
SStreamTask
*
pTask
=
streamMetaAcquireTask
(
pTq
->
pStreamMeta
,
req
.
streamId
,
req
.
upstreamTaskId
);
if
(
pTask
==
NULL
)
{
tqError
(
"vgId:%d process scan history finish rsp, failed to find task:0x%x, it may be destroyed"
,
pTq
->
pStreamMeta
->
vgId
,
req
.
upstreamTaskId
);
...
...
@@ -1503,7 +1503,7 @@ int32_t tqProcessTaskRunReq(STQ* pTq, SRpcMsg* pMsg) {
return
0
;
}
SStreamTask
*
pTask
=
streamMetaAcquireTask
(
pTq
->
pStreamMeta
,
taskId
);
SStreamTask
*
pTask
=
streamMetaAcquireTask
(
pTq
->
pStreamMeta
,
pReq
->
streamId
,
taskId
);
if
(
pTask
!=
NULL
)
{
// even in halt status, the data in inputQ must be processed
int8_t
st
=
pTask
->
status
.
taskStatus
;
...
...
@@ -1538,7 +1538,7 @@ int32_t tqProcessTaskDispatchReq(STQ* pTq, SRpcMsg* pMsg, bool exec) {
tDecoderInit
(
&
decoder
,
(
uint8_t
*
)
msgBody
,
msgLen
);
tDecodeStreamDispatchReq
(
&
decoder
,
&
req
);
SStreamTask
*
pTask
=
streamMetaAcquireTask
(
pTq
->
pStreamMeta
,
req
.
taskId
);
SStreamTask
*
pTask
=
streamMetaAcquireTask
(
pTq
->
pStreamMeta
,
req
.
streamId
,
req
.
taskId
);
if
(
pTask
)
{
SRpcMsg
rsp
=
{.
info
=
pMsg
->
info
,
.
code
=
0
};
streamProcessDispatchMsg
(
pTask
,
&
req
,
&
rsp
,
exec
);
...
...
@@ -1553,7 +1553,7 @@ int32_t tqProcessTaskDispatchReq(STQ* pTq, SRpcMsg* pMsg, bool exec) {
int32_t
tqProcessTaskDispatchRsp
(
STQ
*
pTq
,
SRpcMsg
*
pMsg
)
{
SStreamDispatchRsp
*
pRsp
=
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
));
int32_t
taskId
=
ntohl
(
pRsp
->
upstreamTaskId
);
SStreamTask
*
pTask
=
streamMetaAcquireTask
(
pTq
->
pStreamMeta
,
taskId
);
SStreamTask
*
pTask
=
streamMetaAcquireTask
(
pTq
->
pStreamMeta
,
pRsp
->
streamId
,
taskId
);
int32_t
vgId
=
pTq
->
pStreamMeta
->
vgId
;
if
(
pTask
)
{
...
...
@@ -1569,7 +1569,7 @@ int32_t tqProcessTaskDispatchRsp(STQ* pTq, SRpcMsg* pMsg) {
int32_t
tqProcessTaskDropReq
(
STQ
*
pTq
,
int64_t
sversion
,
char
*
msg
,
int32_t
msgLen
)
{
SVDropStreamTaskReq
*
pReq
=
(
SVDropStreamTaskReq
*
)
msg
;
tqDebug
(
"vgId:%d receive msg to drop stream task:0x%x"
,
TD_VID
(
pTq
->
pVnode
),
pReq
->
taskId
);
SStreamTask
*
pTask
=
streamMetaAcquireTask
(
pTq
->
pStreamMeta
,
pReq
->
taskId
);
SStreamTask
*
pTask
=
streamMetaAcquireTask
(
pTq
->
pStreamMeta
,
pReq
->
streamId
,
pReq
->
taskId
);
if
(
pTask
==
NULL
)
{
tqError
(
"vgId:%d failed to acquire s-task:0x%x when dropping it"
,
pTq
->
pStreamMeta
->
vgId
,
pReq
->
taskId
);
return
0
;
...
...
@@ -1584,7 +1584,7 @@ int32_t tqProcessTaskPauseReq(STQ* pTq, int64_t sversion, char* msg, int32_t msg
SVPauseStreamTaskReq
*
pReq
=
(
SVPauseStreamTaskReq
*
)
msg
;
SStreamMeta
*
pMeta
=
pTq
->
pStreamMeta
;
SStreamTask
*
pTask
=
streamMetaAcquireTask
(
pMeta
,
pReq
->
taskId
);
SStreamTask
*
pTask
=
streamMetaAcquireTask
(
pMeta
,
pReq
->
streamId
,
pReq
->
taskId
);
if
(
pTask
==
NULL
)
{
tqError
(
"vgId:%d process pause req, failed to acquire task:0x%x, it may have been dropped already"
,
pMeta
->
vgId
,
pReq
->
taskId
);
...
...
@@ -1597,7 +1597,7 @@ int32_t tqProcessTaskPauseReq(STQ* pTq, int64_t sversion, char* msg, int32_t msg
SStreamTask
*
pHistoryTask
=
NULL
;
if
(
pTask
->
historyTaskId
.
taskId
!=
0
)
{
pHistoryTask
=
streamMetaAcquireTask
(
pMeta
,
pTask
->
historyTaskId
.
taskId
);
pHistoryTask
=
streamMetaAcquireTask
(
pMeta
,
pTask
->
historyTaskId
.
streamId
,
pTask
->
historyTaskId
.
taskId
);
if
(
pHistoryTask
==
NULL
)
{
tqError
(
"vgId:%d process pause req, failed to acquire fill-history task:0x%x, it may have been dropped already"
,
pMeta
->
vgId
,
pTask
->
historyTaskId
.
taskId
);
...
...
@@ -1656,13 +1656,13 @@ int32_t tqProcessTaskResumeImpl(STQ* pTq, SStreamTask* pTask, int64_t sversion,
int32_t
tqProcessTaskResumeReq
(
STQ
*
pTq
,
int64_t
sversion
,
char
*
msg
,
int32_t
msgLen
)
{
SVResumeStreamTaskReq
*
pReq
=
(
SVResumeStreamTaskReq
*
)
msg
;
SStreamTask
*
pTask
=
streamMetaAcquireTask
(
pTq
->
pStreamMeta
,
pReq
->
taskId
);
SStreamTask
*
pTask
=
streamMetaAcquireTask
(
pTq
->
pStreamMeta
,
pReq
->
streamId
,
pReq
->
taskId
);
int32_t
code
=
tqProcessTaskResumeImpl
(
pTq
,
pTask
,
sversion
,
pReq
->
igUntreated
);
if
(
code
!=
0
)
{
return
code
;
}
SStreamTask
*
pHistoryTask
=
streamMetaAcquireTask
(
pTq
->
pStreamMeta
,
pTask
->
historyTaskId
.
taskId
);
SStreamTask
*
pHistoryTask
=
streamMetaAcquireTask
(
pTq
->
pStreamMeta
,
pTask
->
historyTaskId
.
streamId
,
pTask
->
historyTaskId
.
taskId
);
if
(
pHistoryTask
)
{
code
=
tqProcessTaskResumeImpl
(
pTq
,
pHistoryTask
,
sversion
,
pReq
->
igUntreated
);
}
...
...
@@ -1681,8 +1681,7 @@ int32_t tqProcessTaskRetrieveReq(STQ* pTq, SRpcMsg* pMsg) {
tDecodeStreamRetrieveReq
(
&
decoder
,
&
req
);
tDecoderClear
(
&
decoder
);
int32_t
taskId
=
req
.
dstTaskId
;
SStreamTask
*
pTask
=
streamMetaAcquireTask
(
pTq
->
pStreamMeta
,
taskId
);
SStreamTask
*
pTask
=
streamMetaAcquireTask
(
pTq
->
pStreamMeta
,
req
.
streamId
,
req
.
dstTaskId
);
if
(
pTask
)
{
SRpcMsg
rsp
=
{.
info
=
pMsg
->
info
,
.
code
=
0
};
...
...
@@ -1720,7 +1719,7 @@ int32_t vnodeEnqueueStreamMsg(SVnode* pVnode, SRpcMsg* pMsg) {
tDecoderClear
(
&
decoder
);
int32_t
taskId
=
req
.
taskId
;
SStreamTask
*
pTask
=
streamMetaAcquireTask
(
pTq
->
pStreamMeta
,
taskId
);
SStreamTask
*
pTask
=
streamMetaAcquireTask
(
pTq
->
pStreamMeta
,
req
.
streamId
,
req
.
taskId
);
if
(
pTask
!=
NULL
)
{
SRpcMsg
rsp
=
{.
info
=
pMsg
->
info
,
.
code
=
0
};
streamProcessDispatchMsg
(
pTask
,
&
req
,
&
rsp
,
false
);
...
...
source/dnode/vnode/src/tq/tqRestore.c
浏览文件 @
4c929973
...
...
@@ -72,8 +72,8 @@ int32_t tqStreamTasksStatusCheck(STQ* pTq) {
taosWUnLockLatch
(
&
pMeta
->
lock
);
for
(
int32_t
i
=
0
;
i
<
numOfTasks
;
++
i
)
{
int32_t
*
pTaskId
=
taosArrayGet
(
pTaskList
,
i
);
SStreamTask
*
pTask
=
streamMetaAcquireTask
(
pMeta
,
*
pT
askId
);
SStreamId
*
pTaskId
=
taosArrayGet
(
pTaskList
,
i
);
SStreamTask
*
pTask
=
streamMetaAcquireTask
(
pMeta
,
pTaskId
->
streamId
,
pTaskId
->
t
askId
);
if
(
pTask
==
NULL
)
{
continue
;
}
...
...
@@ -242,8 +242,8 @@ int32_t createStreamTaskRunReq(SStreamMeta* pStreamMeta, bool* pScanIdle) {
numOfTasks
=
taosArrayGetSize
(
pTaskList
);
for
(
int32_t
i
=
0
;
i
<
numOfTasks
;
++
i
)
{
int32_t
*
pTaskId
=
taosArrayGet
(
pTaskList
,
i
);
SStreamTask
*
pTask
=
streamMetaAcquireTask
(
pStreamMeta
,
*
pT
askId
);
SStreamId
*
pTaskId
=
taosArrayGet
(
pTaskList
,
i
);
SStreamTask
*
pTask
=
streamMetaAcquireTask
(
pStreamMeta
,
pTaskId
->
streamId
,
pTaskId
->
t
askId
);
if
(
pTask
==
NULL
)
{
continue
;
}
...
...
source/libs/stream/src/streamExec.c
浏览文件 @
4c929973
...
...
@@ -290,7 +290,7 @@ static void waitForTaskIdle(SStreamTask* pTask, SStreamTask* pStreamTask) {
static
int32_t
streamDoTransferStateToStreamTask
(
SStreamTask
*
pTask
)
{
SStreamMeta
*
pMeta
=
pTask
->
pMeta
;
SStreamTask
*
pStreamTask
=
streamMetaAcquireTask
(
pMeta
,
pTask
->
streamTaskId
.
taskId
);
SStreamTask
*
pStreamTask
=
streamMetaAcquireTask
(
pMeta
,
pTask
->
streamTaskId
.
streamId
,
pTask
->
streamTaskId
.
taskId
);
if
(
pStreamTask
==
NULL
)
{
// todo: destroy the fill-history task here
qError
(
"s-task:%s failed to find related stream task:0x%x, it may have been destroyed or closed"
,
pTask
->
id
.
idStr
,
...
...
source/libs/stream/src/streamMeta.c
浏览文件 @
4c929973
...
...
@@ -66,14 +66,14 @@ SStreamMeta* streamMetaOpen(const char* path, void* ahandle, FTaskExpand expandF
goto
_err
;
}
_hash_fn_t
fp
=
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_
INT
);
_hash_fn_t
fp
=
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_
VARCHAR
);
pMeta
->
pTasks
=
taosHashInit
(
64
,
fp
,
true
,
HASH_NO_LOCK
);
if
(
pMeta
->
pTasks
==
NULL
)
{
goto
_err
;
}
// task list
pMeta
->
pTaskList
=
taosArrayInit
(
4
,
sizeof
(
int32_t
));
pMeta
->
pTaskList
=
taosArrayInit
(
4
,
sizeof
(
SStreamId
));
if
(
pMeta
->
pTaskList
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_err
;
...
...
@@ -248,7 +248,7 @@ int32_t streamMetaRegisterTask(SStreamMeta* pMeta, int64_t ver, SStreamTask* pTa
return
-
1
;
}
taosArrayPush
(
pMeta
->
pTaskList
,
&
pTask
->
id
.
taskId
);
taosArrayPush
(
pMeta
->
pTaskList
,
&
pTask
->
id
);
if
(
streamMetaSaveTask
(
pMeta
,
pTask
)
<
0
)
{
tFreeStreamTask
(
pTask
);
...
...
@@ -274,10 +274,11 @@ int32_t streamMetaGetNumOfTasks(SStreamMeta* pMeta) {
return
(
int32_t
)
size
;
}
SStreamTask
*
streamMetaAcquireTask
(
SStreamMeta
*
pMeta
,
int32_t
taskId
)
{
SStreamTask
*
streamMetaAcquireTask
(
SStreamMeta
*
pMeta
,
int
64_t
streamId
,
int
32_t
taskId
)
{
taosRLockLatch
(
&
pMeta
->
lock
);
SStreamTask
**
ppTask
=
(
SStreamTask
**
)
taosHashGet
(
pMeta
->
pTasks
,
&
taskId
,
sizeof
(
int32_t
));
int64_t
keys
[
2
]
=
{
streamId
,
taskId
};
SStreamTask
**
ppTask
=
(
SStreamTask
**
)
taosHashGet
(
pMeta
->
pTasks
,
keys
,
sizeof
(
keys
));
if
(
ppTask
!=
NULL
)
{
if
(
!
streamTaskShouldStop
(
&
(
*
ppTask
)
->
status
))
{
int32_t
ref
=
atomic_add_fetch_32
(
&
(
*
ppTask
)
->
refCnt
,
1
);
...
...
@@ -304,10 +305,10 @@ void streamMetaReleaseTask(SStreamMeta* pMeta, SStreamTask* pTask) {
}
}
static
void
doRemoveIdFromList
(
SStreamMeta
*
pMeta
,
int32_t
num
,
int32_t
taskI
d
)
{
static
void
doRemoveIdFromList
(
SStreamMeta
*
pMeta
,
int32_t
num
,
SStreamId
*
i
d
)
{
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
int32_t
*
pTaskId
=
taosArrayGet
(
pMeta
->
pTaskList
,
i
);
if
(
*
pTaskId
==
taskId
)
{
SStreamId
*
pTaskId
=
taosArrayGet
(
pMeta
->
pTaskList
,
i
);
if
(
pTaskId
->
streamId
==
id
->
streamId
&&
pTaskId
->
taskId
==
id
->
taskId
)
{
taosArrayRemove
(
pMeta
->
pTaskList
,
i
);
break
;
}
...
...
@@ -360,9 +361,7 @@ int32_t streamMetaUnregisterTask(SStreamMeta* pMeta, int32_t taskId) {
atomic_store_8
(
&
pTask
->
status
.
taskStatus
,
TASK_STATUS__DROPPING
);
ASSERT
(
pTask
->
status
.
timerActive
==
0
);
int32_t
num
=
taosArrayGetSize
(
pMeta
->
pTaskList
);
doRemoveIdFromList
(
pMeta
,
num
,
pTask
->
id
.
taskId
);
doRemoveIdFromList
(
pMeta
,
(
int32_t
)
taosArrayGetSize
(
pMeta
->
pTaskList
),
&
pTask
->
id
);
// remove the ref by timer
if
(
pTask
->
triggerParam
!=
0
)
{
...
...
@@ -484,7 +483,7 @@ int32_t streamLoadTasks(SStreamMeta* pMeta, int64_t ver) {
return
-
1
;
}
taosArrayPush
(
pMeta
->
pTaskList
,
&
pTask
->
id
.
taskId
);
taosArrayPush
(
pMeta
->
pTaskList
,
&
pTask
->
id
);
}
else
{
tdbFree
(
pKey
);
tdbFree
(
pVal
);
...
...
source/libs/stream/src/streamRecover.c
浏览文件 @
4c929973
...
...
@@ -20,6 +20,7 @@
typedef
struct
SStreamTaskRetryInfo
{
SStreamMeta
*
pMeta
;
int32_t
taskId
;
int64_t
streamId
;
}
SStreamTaskRetryInfo
;
static
int32_t
streamSetParamForScanHistory
(
SStreamTask
*
pTask
);
...
...
@@ -556,12 +557,12 @@ static void tryLaunchHistoryTask(void* param, void* tmrId) {
}
taosWUnLockLatch
(
&
pMeta
->
lock
);
SStreamTask
*
pTask
=
streamMetaAcquireTask
(
pMeta
,
pInfo
->
taskId
);
SStreamTask
*
pTask
=
streamMetaAcquireTask
(
pMeta
,
pInfo
->
streamId
,
pInfo
->
taskId
);
if
(
pTask
!=
NULL
)
{
ASSERT
(
pTask
->
status
.
timerActive
==
1
);
// abort the timer if intend to stop task
SStreamTask
*
pHTask
=
streamMetaAcquireTask
(
pMeta
,
pTask
->
historyTaskId
.
taskId
);
SStreamTask
*
pHTask
=
streamMetaAcquireTask
(
pMeta
,
pTask
->
historyTaskId
.
streamId
,
pTask
->
historyTaskId
.
taskId
);
if
(
pHTask
==
NULL
&&
(
!
streamTaskShouldStop
(
&
pTask
->
status
)))
{
const
char
*
pStatus
=
streamGetTaskStatusStr
(
pTask
->
status
.
taskStatus
);
qWarn
(
...
...
@@ -603,6 +604,7 @@ int32_t streamLaunchFillHistoryTask(SStreamTask* pTask) {
SStreamTaskRetryInfo
*
pInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
SStreamTaskRetryInfo
));
pInfo
->
taskId
=
pTask
->
id
.
taskId
;
pInfo
->
streamId
=
pTask
->
id
.
streamId
;
pInfo
->
pMeta
=
pTask
->
pMeta
;
if
(
pTask
->
launchTaskTimer
==
NULL
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录