Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
5089528a
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看板
提交
5089528a
编写于
3月 28, 2023
作者:
5
54liuyao
提交者:
liuyao
4月 23, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat:stream pause&resume
上级
f2c36621
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
356 addition
and
0 deletion
+356
-0
include/common/tmsg.h
include/common/tmsg.h
+35
-0
include/common/tmsgdef.h
include/common/tmsgdef.h
+4
-0
include/libs/stream/tstream.h
include/libs/stream/tstream.h
+1
-0
source/common/src/tmsg.c
source/common/src/tmsg.c
+53
-0
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
+3
-0
source/dnode/mgmt/mgmt_snode/src/smHandle.c
source/dnode/mgmt/mgmt_snode/src/smHandle.c
+2
-0
source/dnode/mnode/impl/src/mndStream.c
source/dnode/mnode/impl/src/mndStream.c
+236
-0
source/dnode/vnode/src/inc/vnodeInt.h
source/dnode/vnode/src/inc/vnodeInt.h
+2
-0
source/dnode/vnode/src/tq/tq.c
source/dnode/vnode/src/tq/tq.c
+10
-0
source/dnode/vnode/src/vnd/vnodeSvr.c
source/dnode/vnode/src/vnd/vnodeSvr.c
+10
-0
未找到文件。
include/common/tmsg.h
浏览文件 @
5089528a
...
...
@@ -2866,6 +2866,41 @@ typedef struct {
int32_t
tEncodeSTqOffset
(
SEncoder
*
pEncoder
,
const
STqOffset
*
pOffset
);
int32_t
tDecodeSTqOffset
(
SDecoder
*
pDecoder
,
STqOffset
*
pOffset
);
typedef
struct
{
SMsgHead
head
;
int32_t
taskId
;
}
SVPauseStreamTaskReq
;
typedef
struct
{
int8_t
reserved
;
}
SVPauseStreamTaskRsp
;
typedef
struct
{
char
name
[
TSDB_STREAM_FNAME_LEN
];
int8_t
igNotExists
;
}
SMPauseStreamReq
;
int32_t
tSerializeSMPauseStreamReq
(
void
*
buf
,
int32_t
bufLen
,
const
SMPauseStreamReq
*
pReq
);
int32_t
tDeserializeSMPauseStreamReq
(
void
*
buf
,
int32_t
bufLen
,
SMPauseStreamReq
*
pReq
);
typedef
struct
{
SMsgHead
head
;
int32_t
taskId
;
}
SVResumeStreamTaskReq
;
typedef
struct
{
int8_t
reserved
;
}
SVResumeStreamTaskRsp
;
typedef
struct
{
char
name
[
TSDB_STREAM_FNAME_LEN
];
int8_t
igNotExists
;
int8_t
igUntreated
;
}
SMResumeStreamReq
;
int32_t
tSerializeSMResumeStreamReq
(
void
*
buf
,
int32_t
bufLen
,
const
SMResumeStreamReq
*
pReq
);
int32_t
tDeserializeSMResumeStreamReq
(
void
*
buf
,
int32_t
bufLen
,
SMResumeStreamReq
*
pReq
);
typedef
struct
{
char
name
[
TSDB_TABLE_FNAME_LEN
];
char
stb
[
TSDB_TABLE_FNAME_LEN
];
...
...
include/common/tmsgdef.h
浏览文件 @
5089528a
...
...
@@ -176,6 +176,8 @@ enum {
// TD_DEF_MSG_TYPE(TDMT_MND_STREAM_BEGIN_CHECKPOINT, "stream-begin-checkpoint", NULL, NULL)
TD_DEF_MSG_TYPE
(
TDMT_MND_MAX_MSG
,
"mnd-max"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_BALANCE_VGROUP_LEADER
,
"balance-vgroup-leader"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_PAUSE_STREAM
,
"pause-stream"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_RESUME_STREAM
,
"resume-stream"
,
NULL
,
NULL
)
TD_NEW_MSG_SEG
(
TDMT_VND_MSG
)
TD_DEF_MSG_TYPE
(
TDMT_VND_SUBMIT
,
"submit"
,
SSubmitReq
,
SSubmitRsp
)
...
...
@@ -254,6 +256,8 @@ enum {
TD_DEF_MSG_TYPE
(
TDMT_STREAM_TASK_REPORT_CHECKPOINT
,
"stream-report-checkpoint"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_STREAM_TASK_RESTORE_CHECKPOINT
,
"stream-restore-checkpoint"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_STREAM_MAX_MSG
,
"stream-max"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_STREAM_TASK_PAUSE
,
"stream-task-pause"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_STREAM_TASK_RESUME
,
"stream-task-resume"
,
NULL
,
NULL
)
TD_NEW_MSG_SEG
(
TDMT_MON_MSG
)
TD_DEF_MSG_TYPE
(
TDMT_MON_MAX_MSG
,
"monitor-max"
,
NULL
,
NULL
)
...
...
include/libs/stream/tstream.h
浏览文件 @
5089528a
...
...
@@ -39,6 +39,7 @@ enum {
STREAM_STATUS__INIT
,
STREAM_STATUS__FAILED
,
STREAM_STATUS__RECOVER
,
STREAM_STATUS__PAUSE
,
};
enum
{
...
...
source/common/src/tmsg.c
浏览文件 @
5089528a
...
...
@@ -7541,3 +7541,56 @@ void tDestroySSubmitRsp2(SSubmitRsp2 *pRsp, int32_t flag) {
}
}
}
int32_t
tSerializeSMPauseStreamReq
(
void
*
buf
,
int32_t
bufLen
,
const
SMPauseStreamReq
*
pReq
)
{
SEncoder
encoder
=
{
0
};
tEncoderInit
(
&
encoder
,
buf
,
bufLen
);
if
(
tStartEncode
(
&
encoder
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
name
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
igNotExists
)
<
0
)
return
-
1
;
tEndEncode
(
&
encoder
);
int32_t
tlen
=
encoder
.
pos
;
tEncoderClear
(
&
encoder
);
return
tlen
;
}
int32_t
tDeserializeSMPauseStreamReq
(
void
*
buf
,
int32_t
bufLen
,
SMPauseStreamReq
*
pReq
)
{
SDecoder
decoder
=
{
0
};
tDecoderInit
(
&
decoder
,
buf
,
bufLen
);
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
name
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
igNotExists
)
<
0
)
return
-
1
;
tEndDecode
(
&
decoder
);
tDecoderClear
(
&
decoder
);
return
0
;
}
int32_t
tSerializeSMResumeStreamReq
(
void
*
buf
,
int32_t
bufLen
,
const
SMResumeStreamReq
*
pReq
)
{
SEncoder
encoder
=
{
0
};
tEncoderInit
(
&
encoder
,
buf
,
bufLen
);
if
(
tStartEncode
(
&
encoder
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
name
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
igNotExists
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
igUntreated
)
<
0
)
return
-
1
;
tEndEncode
(
&
encoder
);
int32_t
tlen
=
encoder
.
pos
;
tEncoderClear
(
&
encoder
);
return
tlen
;
}
int32_t
tDeserializeSMResumeStreamReq
(
void
*
buf
,
int32_t
bufLen
,
SMResumeStreamReq
*
pReq
)
{
SDecoder
decoder
=
{
0
};
tDecoderInit
(
&
decoder
,
buf
,
bufLen
);
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
name
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
igNotExists
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
igUntreated
)
<
0
)
return
-
1
;
tEndDecode
(
&
decoder
);
tDecoderClear
(
&
decoder
);
return
0
;
}
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
浏览文件 @
5089528a
...
...
@@ -140,6 +140,9 @@ SArray *mmGetMsgHandles() {
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_DROP_SMA
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_CREATE_STREAM
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_DROP_STREAM
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_PAUSE_STREAM
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_RESUME_STREAM
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_GET_INDEX
,
mmPutMsgToReadQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_GET_TABLE_INDEX
,
mmPutMsgToReadQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_TMQ_CREATE_TOPIC
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
...
...
source/dnode/mgmt/mgmt_snode/src/smHandle.c
浏览文件 @
5089528a
...
...
@@ -74,6 +74,8 @@ SArray *smGetMsgHandles() {
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_STREAM_TASK_DISPATCH_RSP
,
smPutNodeMsgToStreamQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_STREAM_RETRIEVE
,
smPutNodeMsgToStreamQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_STREAM_RETRIEVE_RSP
,
smPutNodeMsgToStreamQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_STREAM_TASK_PAUSE
,
smPutNodeMsgToMgmtQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_STREAM_TASK_RESUME
,
smPutNodeMsgToMgmtQueue
,
1
)
==
NULL
)
goto
_OVER
;
code
=
0
;
_OVER:
...
...
source/dnode/mnode/impl/src/mndStream.c
浏览文件 @
5089528a
...
...
@@ -47,6 +47,8 @@ static int32_t mndRetrieveStream(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
static
void
mndCancelGetNextStream
(
SMnode
*
pMnode
,
void
*
pIter
);
static
int32_t
mndRetrieveStreamTask
(
SRpcMsg
*
pReq
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rows
);
static
void
mndCancelGetNextStreamTask
(
SMnode
*
pMnode
,
void
*
pIter
);
static
int32_t
mndProcessPauseStreamReq
(
SRpcMsg
*
pReq
);
static
int32_t
mndProcessResumeStreamReq
(
SRpcMsg
*
pReq
);
int32_t
mndInitStream
(
SMnode
*
pMnode
)
{
SSdbTable
table
=
{
...
...
@@ -70,6 +72,9 @@ int32_t mndInitStream(SMnode *pMnode) {
// mndSetMsgHandle(pMnode, TDMT_MND_STREAM_BEGIN_CHECKPOINT, mndProcessStreamDoCheckpoint);
mndSetMsgHandle
(
pMnode
,
TDMT_STREAM_TASK_REPORT_CHECKPOINT
,
mndTransProcessRsp
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_PAUSE_STREAM
,
mndProcessPauseStreamReq
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_RESUME_STREAM
,
mndProcessResumeStreamReq
);
mndAddShowRetrieveHandle
(
pMnode
,
TSDB_MGMT_TABLE_STREAMS
,
mndRetrieveStream
);
mndAddShowFreeIterHandle
(
pMnode
,
TSDB_MGMT_TABLE_STREAMS
,
mndCancelGetNextStream
);
mndAddShowRetrieveHandle
(
pMnode
,
TSDB_MGMT_TABLE_STREAM_TASKS
,
mndRetrieveStreamTask
);
...
...
@@ -226,6 +231,8 @@ static void mndShowStreamStatus(char *dst, SStreamObj *pStream) {
strcpy
(
dst
,
"failed"
);
}
else
if
(
status
==
STREAM_STATUS__RECOVER
)
{
strcpy
(
dst
,
"recover"
);
}
else
if
(
status
==
STREAM_STATUS__PAUSE
)
{
strcpy
(
dst
,
"pause"
);
}
}
...
...
@@ -1269,3 +1276,232 @@ static void mndCancelGetNextStreamTask(SMnode *pMnode, void *pIter) {
SSdb
*
pSdb
=
pMnode
->
pSdb
;
sdbCancelFetch
(
pSdb
,
pIter
);
}
static
int32_t
mndPauseStreamTask
(
STrans
*
pTrans
,
SStreamTask
*
pTask
)
{
SVPauseStreamTaskReq
*
pReq
=
taosMemoryCalloc
(
1
,
sizeof
(
SVPauseStreamTaskReq
));
if
(
pReq
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
pReq
->
head
.
vgId
=
htonl
(
pTask
->
nodeId
);
pReq
->
taskId
=
pTask
->
id
.
taskId
;
STransAction
action
=
{
0
};
memcpy
(
&
action
.
epSet
,
&
pTask
->
epSet
,
sizeof
(
SEpSet
));
action
.
pCont
=
pReq
;
action
.
contLen
=
sizeof
(
SVPauseStreamTaskReq
);
action
.
msgType
=
TDMT_STREAM_TASK_RESUME
;
if
(
mndTransAppendRedoAction
(
pTrans
,
&
action
)
!=
0
)
{
taosMemoryFree
(
pReq
);
return
-
1
;
}
return
0
;
}
int32_t
mndPauseAllStreamTasks
(
STrans
*
pTrans
,
SStreamObj
*
pStream
)
{
int32_t
size
=
taosArrayGetSize
(
pStream
->
tasks
);
for
(
int32_t
i
=
0
;
i
<
size
;
i
++
)
{
SArray
*
pTasks
=
taosArrayGetP
(
pStream
->
tasks
,
i
);
int32_t
sz
=
taosArrayGetSize
(
pTasks
);
for
(
int32_t
j
=
0
;
j
<
sz
;
j
++
)
{
SStreamTask
*
pTask
=
taosArrayGetP
(
pTasks
,
j
);
if
(
mndPauseStreamTask
(
pTrans
,
pTask
)
<
0
)
{
return
-
1
;
}
}
}
return
0
;
}
static
int32_t
mndPersistStreamLog
(
STrans
*
pTrans
,
const
SStreamObj
*
pStream
,
int8_t
status
)
{
SStreamObj
streamObj
=
{
0
};
memcpy
(
streamObj
.
name
,
pStream
->
name
,
TSDB_STREAM_FNAME_LEN
);
streamObj
.
status
=
status
;
SSdbRaw
*
pCommitRaw
=
mndStreamActionEncode
(
&
streamObj
);
if
(
pCommitRaw
==
NULL
)
return
-
1
;
if
(
mndTransAppendCommitlog
(
pTrans
,
pCommitRaw
)
!=
0
)
{
mError
(
"stream trans:%d, failed to append commit log since %s"
,
pTrans
->
id
,
terrstr
());
mndTransDrop
(
pTrans
);
return
-
1
;
}
(
void
)
sdbSetRawStatus
(
pCommitRaw
,
SDB_STATUS_READY
);
return
0
;
}
static
int32_t
mndProcessPauseStreamReq
(
SRpcMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
info
.
node
;
SStreamObj
*
pStream
=
NULL
;
SMPauseStreamReq
pauseReq
=
{
0
};
if
(
tDeserializeSMPauseStreamReq
(
pReq
->
pCont
,
pReq
->
contLen
,
&
pauseReq
)
<
0
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
return
-
1
;
}
pStream
=
mndAcquireStream
(
pMnode
,
pauseReq
.
name
);
if
(
pStream
==
NULL
)
{
if
(
pauseReq
.
igNotExists
)
{
mInfo
(
"stream:%s, not exist, if exist is set"
,
pauseReq
.
name
);
sdbRelease
(
pMnode
->
pSdb
,
pStream
);
return
0
;
}
else
{
terrno
=
TSDB_CODE_MND_STREAM_NOT_EXIST
;
return
-
1
;
}
}
if
(
mndCheckDbPrivilegeByName
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_WRITE_DB
,
pStream
->
targetDb
)
!=
0
)
{
sdbRelease
(
pMnode
->
pSdb
,
pStream
);
return
-
1
;
}
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_RETRY
,
TRN_CONFLICT_DB_INSIDE
,
pReq
,
"pause-stream"
);
if
(
pTrans
==
NULL
)
{
mError
(
"stream:%s, failed to pause stream since %s"
,
pauseReq
.
name
,
terrstr
());
sdbRelease
(
pMnode
->
pSdb
,
pStream
);
return
-
1
;
}
mInfo
(
"trans:%d, used to pause stream:%s"
,
pTrans
->
id
,
pauseReq
.
name
);
mndTransSetDbName
(
pTrans
,
pStream
->
sourceDb
,
pStream
->
targetDb
);
if
(
mndTrancCheckConflict
(
pMnode
,
pTrans
)
!=
0
)
{
sdbRelease
(
pMnode
->
pSdb
,
pStream
);
mndTransDrop
(
pTrans
);
return
-
1
;
}
// pause all tasks
if
(
mndPauseAllStreamTasks
(
pTrans
,
pStream
)
<
0
)
{
mError
(
"stream:%s, failed to drop task since %s"
,
pauseReq
.
name
,
terrstr
());
sdbRelease
(
pMnode
->
pSdb
,
pStream
);
mndTransDrop
(
pTrans
);
return
-
1
;
}
// pause stream
if
(
mndPersistStreamLog
(
pTrans
,
pStream
,
STREAM_STATUS__PAUSE
)
<
0
)
{
sdbRelease
(
pMnode
->
pSdb
,
pStream
);
mndTransDrop
(
pTrans
);
return
-
1
;
}
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
{
mError
(
"trans:%d, failed to prepare pause stream trans since %s"
,
pTrans
->
id
,
terrstr
());
sdbRelease
(
pMnode
->
pSdb
,
pStream
);
mndTransDrop
(
pTrans
);
return
-
1
;
}
sdbRelease
(
pMnode
->
pSdb
,
pStream
);
mndTransDrop
(
pTrans
);
return
TSDB_CODE_ACTION_IN_PROGRESS
;
}
static
int32_t
mndResumeStreamTask
(
STrans
*
pTrans
,
SStreamTask
*
pTask
)
{
SVResumeStreamTaskReq
*
pReq
=
taosMemoryCalloc
(
1
,
sizeof
(
SVResumeStreamTaskReq
));
if
(
pReq
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
pReq
->
head
.
vgId
=
htonl
(
pTask
->
nodeId
);
pReq
->
taskId
=
pTask
->
id
.
taskId
;
STransAction
action
=
{
0
};
memcpy
(
&
action
.
epSet
,
&
pTask
->
epSet
,
sizeof
(
SEpSet
));
action
.
pCont
=
pReq
;
action
.
contLen
=
sizeof
(
SVPauseStreamTaskReq
);
action
.
msgType
=
TDMT_STREAM_TASK_RESUME
;
if
(
mndTransAppendRedoAction
(
pTrans
,
&
action
)
!=
0
)
{
taosMemoryFree
(
pReq
);
return
-
1
;
}
return
0
;
}
int32_t
mndResumeAllStreamTasks
(
STrans
*
pTrans
,
SStreamObj
*
pStream
)
{
int32_t
size
=
taosArrayGetSize
(
pStream
->
tasks
);
for
(
int32_t
i
=
0
;
i
<
size
;
i
++
)
{
SArray
*
pTasks
=
taosArrayGetP
(
pStream
->
tasks
,
i
);
int32_t
sz
=
taosArrayGetSize
(
pTasks
);
for
(
int32_t
j
=
0
;
j
<
sz
;
j
++
)
{
SStreamTask
*
pTask
=
taosArrayGetP
(
pTasks
,
j
);
if
(
mndResumeStreamTask
(
pTrans
,
pTask
)
<
0
)
{
return
-
1
;
}
}
}
return
0
;
}
static
int32_t
mndProcessResumeStreamReq
(
SRpcMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
info
.
node
;
SStreamObj
*
pStream
=
NULL
;
SMPauseStreamReq
pauseReq
=
{
0
};
if
(
tDeserializeSMPauseStreamReq
(
pReq
->
pCont
,
pReq
->
contLen
,
&
pauseReq
)
<
0
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
return
-
1
;
}
pStream
=
mndAcquireStream
(
pMnode
,
pauseReq
.
name
);
if
(
pStream
==
NULL
)
{
if
(
pauseReq
.
igNotExists
)
{
mInfo
(
"stream:%s, not exist, if exist is set"
,
pauseReq
.
name
);
sdbRelease
(
pMnode
->
pSdb
,
pStream
);
return
0
;
}
else
{
terrno
=
TSDB_CODE_MND_STREAM_NOT_EXIST
;
return
-
1
;
}
}
if
(
mndCheckDbPrivilegeByName
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_WRITE_DB
,
pStream
->
targetDb
)
!=
0
)
{
sdbRelease
(
pMnode
->
pSdb
,
pStream
);
return
-
1
;
}
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_RETRY
,
TRN_CONFLICT_DB_INSIDE
,
pReq
,
"pause-stream"
);
if
(
pTrans
==
NULL
)
{
mError
(
"stream:%s, failed to pause stream since %s"
,
pauseReq
.
name
,
terrstr
());
sdbRelease
(
pMnode
->
pSdb
,
pStream
);
return
-
1
;
}
mInfo
(
"trans:%d, used to pause stream:%s"
,
pTrans
->
id
,
pauseReq
.
name
);
mndTransSetDbName
(
pTrans
,
pStream
->
sourceDb
,
pStream
->
targetDb
);
if
(
mndTrancCheckConflict
(
pMnode
,
pTrans
)
!=
0
)
{
sdbRelease
(
pMnode
->
pSdb
,
pStream
);
mndTransDrop
(
pTrans
);
return
-
1
;
}
// resume all tasks
if
(
mndResumeAllStreamTasks
(
pTrans
,
pStream
)
<
0
)
{
mError
(
"stream:%s, failed to drop task since %s"
,
pauseReq
.
name
,
terrstr
());
sdbRelease
(
pMnode
->
pSdb
,
pStream
);
mndTransDrop
(
pTrans
);
return
-
1
;
}
// resume stream
if
(
mndPersistStreamLog
(
pTrans
,
pStream
,
STREAM_STATUS__NORMAL
)
<
0
)
{
sdbRelease
(
pMnode
->
pSdb
,
pStream
);
mndTransDrop
(
pTrans
);
return
-
1
;
}
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
{
mError
(
"trans:%d, failed to prepare pause stream trans since %s"
,
pTrans
->
id
,
terrstr
());
sdbRelease
(
pMnode
->
pSdb
,
pStream
);
mndTransDrop
(
pTrans
);
return
-
1
;
}
sdbRelease
(
pMnode
->
pSdb
,
pStream
);
mndTransDrop
(
pTrans
);
return
TSDB_CODE_ACTION_IN_PROGRESS
;
}
source/dnode/vnode/src/inc/vnodeInt.h
浏览文件 @
5089528a
...
...
@@ -211,6 +211,8 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg);
// tq-stream
int32_t
tqProcessTaskDeployReq
(
STQ
*
pTq
,
int64_t
version
,
char
*
msg
,
int32_t
msgLen
);
int32_t
tqProcessTaskDropReq
(
STQ
*
pTq
,
int64_t
version
,
char
*
msg
,
int32_t
msgLen
);
int32_t
tqProcessTaskPauseReq
(
STQ
*
pTq
,
int64_t
version
,
char
*
msg
,
int32_t
msgLen
);
int32_t
tqProcessTaskResumeReq
(
STQ
*
pTq
,
int64_t
version
,
char
*
msg
,
int32_t
msgLen
);
int32_t
tqProcessStreamTaskCheckReq
(
STQ
*
pTq
,
SRpcMsg
*
pMsg
);
int32_t
tqProcessStreamTaskCheckRsp
(
STQ
*
pTq
,
int64_t
version
,
char
*
msg
,
int32_t
msgLen
);
int32_t
tqProcessSubmitReq
(
STQ
*
pTq
,
SPackedData
submit
);
...
...
source/dnode/vnode/src/tq/tq.c
浏览文件 @
5089528a
...
...
@@ -1205,6 +1205,16 @@ int32_t tqProcessTaskDropReq(STQ* pTq, int64_t sversion, char* msg, int32_t msgL
return
0
;
}
int32_t
tqProcessTaskPauseReq
(
STQ
*
pTq
,
int64_t
sversion
,
char
*
msg
,
int32_t
msgLen
)
{
SVPauseStreamTaskReq
*
pReq
=
(
SVPauseStreamTaskReq
*
)
msg
;
return
0
;
}
int32_t
tqProcessTaskResumeReq
(
STQ
*
pTq
,
int64_t
sversion
,
char
*
msg
,
int32_t
msgLen
)
{
SVResumeStreamTaskReq
*
pReq
=
(
SVResumeStreamTaskReq
*
)
msg
;
return
0
;
}
int32_t
tqProcessTaskRetrieveReq
(
STQ
*
pTq
,
SRpcMsg
*
pMsg
)
{
char
*
msgStr
=
pMsg
->
pCont
;
char
*
msgBody
=
POINTER_SHIFT
(
msgStr
,
sizeof
(
SMsgHead
));
...
...
source/dnode/vnode/src/vnd/vnodeSvr.c
浏览文件 @
5089528a
...
...
@@ -409,6 +409,16 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRp
goto
_err
;
}
}
break
;
case
TDMT_STREAM_TASK_PAUSE
:
{
if
(
tqProcessTaskPauseReq
(
pVnode
->
pTq
,
version
,
pMsg
->
pCont
,
pMsg
->
contLen
)
<
0
)
{
goto
_err
;
}
}
break
;
case
TDMT_STREAM_TASK_RESUME
:
{
if
(
tqProcessTaskResumeReq
(
pVnode
->
pTq
,
version
,
pMsg
->
pCont
,
pMsg
->
contLen
)
<
0
)
{
goto
_err
;
}
}
break
;
case
TDMT_VND_STREAM_RECOVER_BLOCKING_STAGE
:
{
if
(
tqProcessTaskRecover2Req
(
pVnode
->
pTq
,
version
,
pMsg
->
pCont
,
pMsg
->
contLen
)
<
0
)
{
goto
_err
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录