Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
164bfd54
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
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看板
提交
164bfd54
编写于
8月 01, 2023
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh(stream): prepare update trans.
上级
75b1520b
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
122 addition
and
34 deletion
+122
-34
include/common/tmsgdef.h
include/common/tmsgdef.h
+1
-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
+119
-32
source/libs/stream/src/streamDispatch.c
source/libs/stream/src/streamDispatch.c
+1
-1
未找到文件。
include/common/tmsgdef.h
浏览文件 @
164bfd54
...
@@ -303,6 +303,7 @@ enum {
...
@@ -303,6 +303,7 @@ enum {
TD_DEF_MSG_TYPE
(
TDMT_VND_STREAM_TRIGGER
,
"vnode-stream-trigger"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_STREAM_TRIGGER
,
"vnode-stream-trigger"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_STREAM_SCAN_HISTORY
,
"vnode-stream-scan-history"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_STREAM_SCAN_HISTORY
,
"vnode-stream-scan-history"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_STREAM_CHECK_POINT_SOURCE
,
"vnode-stream-checkpoint-source"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_STREAM_CHECK_POINT_SOURCE
,
"vnode-stream-checkpoint-source"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_STREAM_TASK_UPDATE
,
"vnode-stream-update"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_STREAM_MAX_MSG
,
"vnd-stream-max"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_STREAM_MAX_MSG
,
"vnd-stream-max"
,
NULL
,
NULL
)
TD_NEW_MSG_SEG
(
TDMT_VND_TMQ_MSG
)
TD_NEW_MSG_SEG
(
TDMT_VND_TMQ_MSG
)
...
...
include/libs/stream/tstream.h
浏览文件 @
164bfd54
...
@@ -554,7 +554,7 @@ typedef struct {
...
@@ -554,7 +554,7 @@ typedef struct {
SEpSet
epset
;
SEpSet
epset
;
}
SStreamTaskUpdateInfo
;
}
SStreamTaskUpdateInfo
;
int32_t
tEncodeTaskUpdateMsg
(
SEncoder
*
pEncoder
,
const
SStreamTaskUpdateInfo
*
pMsg
);
int32_t
tEncode
Stream
TaskUpdateMsg
(
SEncoder
*
pEncoder
,
const
SStreamTaskUpdateInfo
*
pMsg
);
int32_t
tDecodeTaskUpdateMsg
(
SDecoder
*
pDecoder
,
SStreamTaskUpdateInfo
*
pMsg
);
int32_t
tDecodeTaskUpdateMsg
(
SDecoder
*
pDecoder
,
SStreamTaskUpdateInfo
*
pMsg
);
typedef
struct
{
typedef
struct
{
...
...
source/dnode/mnode/impl/src/mndStream.c
浏览文件 @
164bfd54
...
@@ -1736,13 +1736,121 @@ static int32_t mndProcessResumeStreamReq(SRpcMsg *pReq) {
...
@@ -1736,13 +1736,121 @@ static int32_t mndProcessResumeStreamReq(SRpcMsg *pReq) {
return
TSDB_CODE_ACTION_IN_PROGRESS
;
return
TSDB_CODE_ACTION_IN_PROGRESS
;
}
}
static
int32_t
doBuildStreamTaskUpdateMsg
(
void
**
pBuf
,
int32_t
*
pLen
,
int32_t
nodeId
,
const
SEpSet
*
pEpset
)
{
SStreamTaskUpdateInfo
req
=
{
0
};
req
.
nodeId
=
nodeId
;
req
.
epset
=
*
pEpset
;
int32_t
code
=
0
;
int32_t
blen
;
tEncodeSize
(
tEncodeStreamTaskUpdateMsg
,
&
req
,
blen
,
code
);
if
(
code
<
0
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
int32_t
tlen
=
sizeof
(
SMsgHead
)
+
blen
;
void
*
buf
=
taosMemoryMalloc
(
tlen
);
if
(
buf
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
void
*
abuf
=
POINTER_SHIFT
(
buf
,
sizeof
(
SMsgHead
));
SEncoder
encoder
;
tEncoderInit
(
&
encoder
,
abuf
,
tlen
);
tEncodeStreamTaskUpdateMsg
(
&
encoder
,
&
req
);
SMsgHead
*
pMsgHead
=
(
SMsgHead
*
)
buf
;
pMsgHead
->
contLen
=
htonl
(
tlen
);
pMsgHead
->
vgId
=
htonl
(
nodeId
);
tEncoderClear
(
&
encoder
);
*
pBuf
=
buf
;
*
pLen
=
tlen
;
return
TSDB_CODE_SUCCESS
;
}
// build trans to update the epset
static
int32_t
createStreamUpdateTrans
(
SMnode
*
pMnode
,
SStreamObj
*
pStream
,
int32_t
nodeId
,
SEpSet
*
pEpset
)
{
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_RETRY
,
TRN_CONFLICT_DB_INSIDE
,
NULL
,
"stream-task-update"
);
if
(
pTrans
==
NULL
)
{
mError
(
"failed to build stream task DAG update, reason: %s"
,
tstrerror
(
TSDB_CODE_OUT_OF_MEMORY
));
return
-
1
;
}
mDebug
(
"start to build stream:0x%"
PRIx64
" task DAG update"
,
pStream
->
uid
);
ASSERT
(
0
);
// mndTransSetDbName(pTrans, "stream-task-update", "checkpoint");
if
(
mndTransCheckConflict
(
pMnode
,
pTrans
)
!=
0
)
{
mError
(
"failed to build stream:0x%"
PRIx64
" task DAG update, code:%s"
,
pStream
->
uid
,
tstrerror
(
TSDB_CODE_MND_TRANS_CONFLICT
));
mndTransDrop
(
pTrans
);
return
-
1
;
}
taosWLockLatch
(
&
pStream
->
lock
);
int32_t
numOfLevels
=
taosArrayGetSize
(
pStream
->
tasks
);
for
(
int32_t
j
=
0
;
j
<
numOfLevels
;
++
j
)
{
SArray
*
pLevel
=
taosArrayGetP
(
pStream
->
tasks
,
j
);
int32_t
numOfTasks
=
taosArrayGetSize
(
pLevel
);
for
(
int32_t
k
=
0
;
k
<
numOfTasks
;
++
k
)
{
SStreamTask
*
pTask
=
taosArrayGetP
(
pLevel
,
k
);
void
*
pBuf
=
NULL
;
int32_t
len
=
0
;
doBuildStreamTaskUpdateMsg
(
&
pBuf
,
&
len
,
nodeId
,
pEpset
);
STransAction
action
=
{
0
};
action
.
epSet
=
pTask
->
info
.
epSet
;
action
.
pCont
=
pBuf
;
action
.
contLen
=
len
;
action
.
msgType
=
TDMT_VND_STREAM_TASK_UPDATE
;
if
(
mndTransAppendRedoAction
(
pTrans
,
&
action
)
!=
0
)
{
taosMemoryFree
(
pBuf
);
taosWUnLockLatch
(
&
pStream
->
lock
);
return
-
1
;
}
}
}
taosWUnLockLatch
(
&
pStream
->
lock
);
SSdbRaw
*
pCommitRaw
=
mndStreamActionEncode
(
pStream
);
if
(
pCommitRaw
==
NULL
)
{
mError
(
"failed to prepare trans rebalance since %s"
,
terrstr
());
return
-
1
;
}
if
(
mndTransAppendCommitlog
(
pTrans
,
pCommitRaw
)
!=
0
)
{
sdbFreeRaw
(
pCommitRaw
);
mError
(
"failed to prepare trans rebalance since %s"
,
terrstr
());
return
-
1
;
}
if
(
sdbSetRawStatus
(
pCommitRaw
,
SDB_STATUS_READY
)
!=
0
)
{
sdbFreeRaw
(
pCommitRaw
);
mError
(
"failed to prepare trans rebalance since %s"
,
terrstr
());
return
-
1
;
}
return
TSDB_CODE_SUCCESS
;
}
// todo: handle the database drop/stream drop case
// todo: handle the database drop/stream drop case
int32_t
mndProcessStreamHb
(
SRpcMsg
*
pReq
)
{
int32_t
mndProcessStreamHb
(
SRpcMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
info
.
node
;
SMnode
*
pMnode
=
pReq
->
info
.
node
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SStreamHbMsg
req
=
{
0
};
SStreamHbMsg
req
=
{
0
};
int32_t
code
=
TSDB_CODE_SUCCESS
;
SDecoder
decoder
=
{
0
};
SDecoder
decoder
=
{
0
};
tDecoderInit
(
&
decoder
,
(
uint8_t
*
)
pReq
->
pCont
,
pReq
->
contLen
);
tDecoderInit
(
&
decoder
,
(
uint8_t
*
)
pReq
->
pCont
,
pReq
->
contLen
);
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
...
@@ -1813,44 +1921,23 @@ int32_t mndProcessStreamHb(SRpcMsg *pReq) {
...
@@ -1813,44 +1921,23 @@ int32_t mndProcessStreamHb(SRpcMsg *pReq) {
}
}
}
}
{
// build trans to update the epset
code
=
createStreamUpdateTrans
(
pMnode
,
pStream
,
nodeId
,
&
newEpSet
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_RETRY
,
TRN_CONFLICT_DB_INSIDE
,
NULL
,
"stream-checkpoint"
);
if
(
pTrans
==
NULL
)
{
mError
(
"failed to trigger checkpoint, reason: %s"
,
tstrerror
(
TSDB_CODE_OUT_OF_MEMORY
));
return
-
1
;
}
// mDebug("start to trigger checkpoint, checkpointId: %" PRId64 "", checkpointId);
mndTransSetDbName
(
pTrans
,
"checkpoint"
,
"checkpoint"
);
if
(
mndTransCheckConflict
(
pMnode
,
pTrans
)
!=
0
)
{
mError
(
"failed to trigger checkpoint, checkpointId: %"
PRId64
", reason:%s"
,
checkpointId
,
tstrerror
(
TSDB_CODE_MND_TRANS_CONFLICT
));
mndTransDrop
(
pTrans
);
return
-
1
;
}
void
*
pBuf
=
NULL
;
int32_t
len
=
0
;
// doBuildStreamTaskUpdateMsg(&pBuf, &len, nodeId, newEpSet);
STransAction
action
=
{
0
};
action
.
epSet
=
/*mndGetVgroupEpset(pMnode, pVgObj)*/
;
action
.
pCont
=
pBuf
;
action
.
contLen
=
len
;
action
.
msgType
=
TDMT_VND_STREAM_CHECK_POINT_SOURCE
;
if
(
mndTransAppendRedoAction
(
pTrans
,
&
action
)
!=
0
)
{
taosMemoryFree
(
pBuf
);
taosWUnLockLatch
(
&
pStream
->
lock
);
return
-
1
;
}
}
}
taosWUnLockLatch
(
&
pStream
->
lock
);
taosWUnLockLatch
(
&
pStream
->
lock
);
}
}
}
}
// if (code == 0) {
// if (mndTransPrepare(pMnode, pTrans) != 0) {
// mError("failed to prepre trans rebalance since %s", terrstr());
// }
// }
// mndTransDrop(pTrans);
return
code
;
mTrace
(
"receive stream-meta hb from vgId:%d, active numOfTasks:%d"
,
req
.
vgId
,
req
.
numOfTasks
);
mTrace
(
"receive stream-meta hb from vgId:%d, active numOfTasks:%d"
,
req
.
vgId
,
req
.
numOfTasks
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
source/libs/stream/src/streamDispatch.c
浏览文件 @
164bfd54
...
@@ -959,7 +959,7 @@ int32_t streamNotifyUpstreamContinue(SStreamTask* pTask) {
...
@@ -959,7 +959,7 @@ int32_t streamNotifyUpstreamContinue(SStreamTask* pTask) {
return
0
;
return
0
;
}
}
int32_t
tEncodeTaskUpdateMsg
(
SEncoder
*
pEncoder
,
const
SStreamTaskUpdateInfo
*
pMsg
)
{
int32_t
tEncode
Stream
TaskUpdateMsg
(
SEncoder
*
pEncoder
,
const
SStreamTaskUpdateInfo
*
pMsg
)
{
if
(
tStartEncode
(
pEncoder
)
<
0
)
return
-
1
;
if
(
tStartEncode
(
pEncoder
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
pMsg
->
nodeId
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
pMsg
->
nodeId
)
<
0
)
return
-
1
;
if
(
tEncodeSEpSet
(
pEncoder
,
&
pMsg
->
epset
)
<
0
)
return
-
1
;
if
(
tEncodeSEpSet
(
pEncoder
,
&
pMsg
->
epset
)
<
0
)
return
-
1
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录