Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
d0c658d3
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看板
提交
d0c658d3
编写于
6月 14, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh: set vnode standby if drop it
上级
72bc32af
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
81 addition
and
9 deletion
+81
-9
include/common/tmsgdef.h
include/common/tmsgdef.h
+2
-1
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
+4
-2
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
+1
-0
source/dnode/mnode/impl/inc/mndInt.h
source/dnode/mnode/impl/inc/mndInt.h
+0
-2
source/dnode/mnode/impl/src/mndMain.c
source/dnode/mnode/impl/src/mndMain.c
+2
-2
source/dnode/mnode/impl/src/mndMnode.c
source/dnode/mnode/impl/src/mndMnode.c
+3
-2
source/dnode/mnode/impl/src/mndVgroup.c
source/dnode/mnode/impl/src/mndVgroup.c
+65
-0
source/dnode/vnode/src/vnd/vnodeSvr.c
source/dnode/vnode/src/vnd/vnodeSvr.c
+4
-0
未找到文件。
include/common/tmsgdef.h
浏览文件 @
d0c658d3
...
...
@@ -97,7 +97,6 @@ enum {
TD_DEF_MSG_TYPE
(
TDMT_MND_CREATE_MNODE
,
"create-mnode"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_ALTER_MNODE
,
"alter-mnode"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_DROP_MNODE
,
"drop-mnode"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_SET_STANDBY
,
"set-mnode-standby"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_CREATE_QNODE
,
"create-qnode"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_ALTER_QNODE
,
"alter-qnode"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_DROP_QNODE
,
"drop-qnode"
,
NULL
,
NULL
)
...
...
@@ -238,6 +237,8 @@ enum {
TD_DEF_MSG_TYPE
(
TDMT_SYNC_SNAPSHOT_SEND
,
"sync-snapshot-send"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_SYNC_SNAPSHOT_RSP
,
"sync-snapshot-rsp"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_SYNC_LEADER_TRANSFER
,
"sync-leader-transfer"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_SYNC_SET_MNODE_STANDBY
,
"set-mnode-standby"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_SYNC_SET_VNODE_STANDBY
,
"set-vnode-standby"
,
NULL
,
NULL
)
#if defined(TD_MSG_NUMBER_)
TDMT_MAX
...
...
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
浏览文件 @
d0c658d3
...
...
@@ -155,7 +155,6 @@ SArray *mmGetMsgHandles() {
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_CREATE_MNODE
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_ALTER_MNODE
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_ALTER_MNODE_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_SET_STANDBY_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_DROP_MNODE
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_CREATE_QNODE
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_DROP_QNODE
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
...
...
@@ -236,7 +235,10 @@ SArray *mmGetMsgHandles() {
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_APPEND_ENTRIES_REPLY
,
mmPutMsgToSyncQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_SNAPSHOT_SEND
,
mmPutMsgToSyncQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_SNAPSHOT_RSP
,
mmPutMsgToSyncQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_SET_STANDBY
,
mmPutMsgToSyncQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_SET_MNODE_STANDBY
,
mmPutMsgToSyncQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_SET_MNODE_STANDBY_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_SET_VNODE_STANDBY_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
code
=
0
;
...
...
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
浏览文件 @
d0c658d3
...
...
@@ -373,6 +373,7 @@ SArray *vmGetMsgHandles() {
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_REQUEST_VOTE_REPLY
,
vmPutMsgToSyncQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_APPEND_ENTRIES
,
vmPutMsgToSyncQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_APPEND_ENTRIES_REPLY
,
vmPutMsgToSyncQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_SET_VNODE_STANDBY
,
vmPutMsgToSyncQueue
,
0
)
==
NULL
)
goto
_OVER
;
code
=
0
;
...
...
source/dnode/mnode/impl/inc/mndInt.h
浏览文件 @
d0c658d3
...
...
@@ -124,8 +124,6 @@ void mndReleaseRpcRef(SMnode *pMnode);
void
mndSetRestore
(
SMnode
*
pMnode
,
bool
restored
);
void
mndSetStop
(
SMnode
*
pMnode
);
bool
mndGetStop
(
SMnode
*
pMnode
);
int32_t
mndAcquireSyncRef
(
SMnode
*
pMnode
);
void
mndReleaseSyncRef
(
SMnode
*
pMnode
);
#ifdef __cplusplus
}
...
...
source/dnode/mnode/impl/src/mndMain.c
浏览文件 @
d0c658d3
...
...
@@ -445,7 +445,7 @@ int32_t mndProcessSyncMsg(SRpcMsg *pMsg) {
SyncSnapshotRsp
*
pSyncMsg
=
syncSnapshotRspFromRpcMsg2
(
pMsg
);
code
=
syncNodeOnSnapshotRspCb
(
pSyncNode
,
pSyncMsg
);
syncSnapshotRspDestroy
(
pSyncMsg
);
}
else
if
(
pMsg
->
msgType
==
TDMT_
MND_SET
_STANDBY
)
{
}
else
if
(
pMsg
->
msgType
==
TDMT_
SYNC_SET_MNODE
_STANDBY
)
{
code
=
syncSetStandby
(
pMgmt
->
sync
);
SRpcMsg
rsp
=
{.
code
=
code
,
.
info
=
pMsg
->
info
};
tmsgSendRsp
(
&
rsp
);
...
...
@@ -486,7 +486,7 @@ int32_t mndProcessSyncMsg(SRpcMsg *pMsg) {
SyncAppendEntriesReply
*
pSyncMsg
=
syncAppendEntriesReplyFromRpcMsg2
(
pMsg
);
code
=
syncNodeOnAppendEntriesReplyCb
(
pSyncNode
,
pSyncMsg
);
syncAppendEntriesReplyDestroy
(
pSyncMsg
);
}
else
if
(
pMsg
->
msgType
==
TDMT_
MND_SET
_STANDBY
)
{
}
else
if
(
pMsg
->
msgType
==
TDMT_
SYNC_SET_MNODE
_STANDBY
)
{
code
=
syncSetStandby
(
pMgmt
->
sync
);
SRpcMsg
rsp
=
{.
code
=
code
,
.
info
=
pMsg
->
info
};
tmsgSendRsp
(
&
rsp
);
...
...
source/dnode/mnode/impl/src/mndMnode.c
浏览文件 @
d0c658d3
...
...
@@ -55,7 +55,8 @@ int32_t mndInitMnode(SMnode *pMnode) {
mndSetMsgHandle
(
pMnode
,
TDMT_MND_ALTER_MNODE_RSP
,
mndTransProcessRsp
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_DROP_MNODE
,
mndProcessDropMnodeReq
);
mndSetMsgHandle
(
pMnode
,
TDMT_DND_DROP_MNODE_RSP
,
mndTransProcessRsp
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_SET_STANDBY_RSP
,
mndTransProcessRsp
);
mndSetMsgHandle
(
pMnode
,
TDMT_SYNC_SET_MNODE_STANDBY_RSP
,
mndTransProcessRsp
);
mndSetMsgHandle
(
pMnode
,
TDMT_SYNC_SET_VNODE_STANDBY_RSP
,
mndTransProcessRsp
);
mndAddShowRetrieveHandle
(
pMnode
,
TSDB_MGMT_TABLE_MNODE
,
mndRetrieveMnodes
);
mndAddShowFreeIterHandle
(
pMnode
,
TSDB_MGMT_TABLE_MNODE
,
mndCancelGetNextMnode
);
...
...
@@ -511,7 +512,7 @@ static int32_t mndSetDropMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDnode
.
epSet
=
dropEpSet
,
.
pCont
=
pReq
,
.
contLen
=
contLen
,
.
msgType
=
TDMT_
MND_SET
_STANDBY
,
.
msgType
=
TDMT_
SYNC_SET_MNODE
_STANDBY
,
.
acceptableCode
=
TSDB_CODE_NODE_NOT_DEPLOYED
,
};
...
...
source/dnode/mnode/impl/src/mndVgroup.c
浏览文件 @
d0c658d3
...
...
@@ -322,6 +322,33 @@ void *mndBuildAlterVnodeReq(SMnode *pMnode, SDbObj *pDb, SVgObj *pVgroup, int32_
return
pReq
;
}
void
*
mndBuildSetVnodeStandbyReq
(
SMnode
*
pMnode
,
SDnodeObj
*
pDnode
,
SDbObj
*
pDb
,
SVgObj
*
pVgroup
,
int32_t
*
pContLen
)
{
SSetStandbyReq
standbyReq
=
{
0
};
standbyReq
.
dnodeId
=
pDnode
->
id
;
standbyReq
.
standby
=
1
;
int32_t
contLen
=
tSerializeSSetStandbyReq
(
NULL
,
0
,
&
standbyReq
);
if
(
contLen
<
0
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
}
contLen
+=
sizeof
(
SMsgHead
);
void
*
pReq
=
taosMemoryMalloc
(
contLen
);
if
(
pReq
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
}
tSerializeSSetStandbyReq
((
char
*
)
pReq
+
sizeof
(
SMsgHead
),
contLen
,
&
standbyReq
);
SMsgHead
*
pHead
=
pReq
;
pHead
->
contLen
=
htonl
(
contLen
);
pHead
->
vgId
=
htonl
(
pVgroup
->
vgId
);
*
pContLen
=
contLen
;
return
pReq
;
}
void
*
mndBuildDropVnodeReq
(
SMnode
*
pMnode
,
SDnodeObj
*
pDnode
,
SDbObj
*
pDb
,
SVgObj
*
pVgroup
,
int32_t
*
pContLen
)
{
SDropVnodeReq
dropReq
=
{
0
};
dropReq
.
dnodeId
=
pDnode
->
id
;
...
...
@@ -898,6 +925,39 @@ int32_t mndAddAlterVnodeAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgO
return
0
;
}
static
int32_t
mndAddSetVnodeStandByAction
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pDb
,
SVgObj
*
pVgroup
,
SVnodeGid
*
pVgid
,
bool
isRedo
)
{
STransAction
action
=
{
0
};
SDnodeObj
*
pDnode
=
mndAcquireDnode
(
pMnode
,
pVgid
->
dnodeId
);
if
(
pDnode
==
NULL
)
return
-
1
;
action
.
epSet
=
mndGetDnodeEpset
(
pDnode
);
mndReleaseDnode
(
pMnode
,
pDnode
);
int32_t
contLen
=
0
;
void
*
pReq
=
mndBuildSetVnodeStandbyReq
(
pMnode
,
pDnode
,
pDb
,
pVgroup
,
&
contLen
);
if
(
pReq
==
NULL
)
return
-
1
;
action
.
pCont
=
pReq
;
action
.
contLen
=
contLen
;
action
.
msgType
=
TDMT_DND_DROP_VNODE
;
action
.
acceptableCode
=
TSDB_CODE_NODE_NOT_DEPLOYED
;
if
(
isRedo
)
{
if
(
mndTransAppendRedoAction
(
pTrans
,
&
action
)
!=
0
)
{
taosMemoryFree
(
pReq
);
return
-
1
;
}
}
else
{
if
(
mndTransAppendUndoAction
(
pTrans
,
&
action
)
!=
0
)
{
taosMemoryFree
(
pReq
);
return
-
1
;
}
}
return
0
;
}
int32_t
mndAddDropVnodeAction
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pDb
,
SVgObj
*
pVgroup
,
SVnodeGid
*
pVgid
,
bool
isRedo
)
{
STransAction
action
=
{
0
};
...
...
@@ -952,6 +1012,7 @@ int32_t mndSetMoveVgroupInfoToTrans(SMnode *pMnode, STrans *pTrans, SDbObj *pDb,
SVnodeGid
del
=
newVg
.
vnodeGid
[
vnIndex
];
newVg
.
vnodeGid
[
vnIndex
]
=
newVg
.
vnodeGid
[
newVg
.
replica
];
memset
(
&
newVg
.
vnodeGid
[
newVg
.
replica
],
0
,
sizeof
(
SVnodeGid
));
if
(
mndAddSetVnodeStandByAction
(
pMnode
,
pTrans
,
pDb
,
pVgroup
,
&
del
,
true
)
!=
0
)
return
-
1
;
if
(
mndAddAlterVnodeAction
(
pMnode
,
pTrans
,
pDb
,
&
newVg
,
TDMT_VND_ALTER_REPLICA
)
!=
0
)
return
-
1
;
if
(
mndAddDropVnodeAction
(
pMnode
,
pTrans
,
pDb
,
&
newVg
,
&
del
,
true
)
!=
0
)
return
-
1
;
if
(
mndAddAlterVnodeConfirmAction
(
pMnode
,
pTrans
,
pDb
,
&
newVg
)
!=
0
)
return
-
1
;
...
...
@@ -1031,6 +1092,7 @@ static int32_t mndAddDecVgroupReplicaFromTrans(SMnode *pMnode, STrans *pTrans, S
memcpy
(
pGid
,
&
pVgroup
->
vnodeGid
[
pVgroup
->
replica
],
sizeof
(
SVnodeGid
));
memset
(
&
pVgroup
->
vnodeGid
[
pVgroup
->
replica
],
0
,
sizeof
(
SVnodeGid
));
if
(
mndAddSetVnodeStandByAction
(
pMnode
,
pTrans
,
pDb
,
pVgroup
,
&
delGid
,
true
)
!=
0
)
return
-
1
;
if
(
mndAddAlterVnodeAction
(
pMnode
,
pTrans
,
pDb
,
pVgroup
,
TDMT_VND_ALTER_REPLICA
)
!=
0
)
return
-
1
;
if
(
mndAddDropVnodeAction
(
pMnode
,
pTrans
,
pDb
,
pVgroup
,
&
delGid
,
true
)
!=
0
)
return
-
1
;
if
(
mndAddAlterVnodeConfirmAction
(
pMnode
,
pTrans
,
pDb
,
pVgroup
)
!=
0
)
return
-
1
;
...
...
@@ -1341,12 +1403,14 @@ int32_t mndBuildAlterVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, S
SVnodeGid
del1
=
{
0
};
if
(
mndRemoveVnodeFromVgroup
(
pMnode
,
&
newVgroup
,
pArray
,
&
del1
)
!=
0
)
return
-
1
;
if
(
mndAddSetVnodeStandByAction
(
pMnode
,
pTrans
,
pDb
,
pVgroup
,
&
del1
,
true
)
!=
0
)
return
-
1
;
if
(
mndAddAlterVnodeAction
(
pMnode
,
pTrans
,
pDb
,
&
newVgroup
,
TDMT_VND_ALTER_REPLICA
)
!=
0
)
return
-
1
;
if
(
mndAddDropVnodeAction
(
pMnode
,
pTrans
,
pDb
,
&
newVgroup
,
&
del1
,
true
)
!=
0
)
return
-
1
;
if
(
mndAddAlterVnodeConfirmAction
(
pMnode
,
pTrans
,
pDb
,
&
newVgroup
)
!=
0
)
return
-
1
;
SVnodeGid
del2
=
{
0
};
if
(
mndRemoveVnodeFromVgroup
(
pMnode
,
&
newVgroup
,
pArray
,
&
del2
)
!=
0
)
return
-
1
;
if
(
mndAddSetVnodeStandByAction
(
pMnode
,
pTrans
,
pDb
,
pVgroup
,
&
del2
,
true
)
!=
0
)
return
-
1
;
if
(
mndAddAlterVnodeAction
(
pMnode
,
pTrans
,
pDb
,
&
newVgroup
,
TDMT_VND_ALTER_REPLICA
)
!=
0
)
return
-
1
;
if
(
mndAddDropVnodeAction
(
pMnode
,
pTrans
,
pDb
,
&
newVgroup
,
&
del2
,
true
)
!=
0
)
return
-
1
;
if
(
mndAddAlterVnodeConfirmAction
(
pMnode
,
pTrans
,
pDb
,
&
newVgroup
)
!=
0
)
return
-
1
;
...
...
@@ -1396,6 +1460,7 @@ static int32_t mndSplitVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SVgObj
}
else
if
(
newVg1
.
replica
==
3
)
{
SVnodeGid
del1
=
{
0
};
if
(
mndRemoveVnodeFromVgroup
(
pMnode
,
&
newVg1
,
pArray
,
&
del1
)
!=
0
)
goto
_OVER
;
if
(
mndAddSetVnodeStandByAction
(
pMnode
,
pTrans
,
pDb
,
pVgroup
,
&
del1
,
true
)
!=
0
)
return
-
1
;
if
(
mndAddAlterVnodeAction
(
pMnode
,
pTrans
,
pDb
,
&
newVg1
,
TDMT_VND_ALTER_REPLICA
)
!=
0
)
goto
_OVER
;
if
(
mndAddDropVnodeAction
(
pMnode
,
pTrans
,
pDb
,
&
newVg1
,
&
del1
,
true
)
!=
0
)
goto
_OVER
;
if
(
mndAddAlterVnodeConfirmAction
(
pMnode
,
pTrans
,
pDb
,
&
newVg1
)
!=
0
)
goto
_OVER
;
...
...
source/dnode/vnode/src/vnd/vnodeSvr.c
浏览文件 @
d0c658d3
...
...
@@ -368,6 +368,10 @@ int32_t vnodeProcessSyncReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
ret
=
syncNodeOnAppendEntriesReplyCb
(
pSyncNode
,
pSyncMsg
);
syncAppendEntriesReplyDestroy
(
pSyncMsg
);
}
else
if
(
pRpcMsg
->
msgType
==
TDMT_SYNC_SET_MNODE_STANDBY
)
{
ret
=
syncSetStandby
(
pVnode
->
sync
);
SRpcMsg
rsp
=
{.
code
=
ret
,
.
info
=
pMsg
->
info
};
tmsgSendRsp
(
&
rsp
);
}
else
{
vError
(
"==vnodeProcessSyncReq== error msg type:%d"
,
pRpcMsg
->
msgType
);
ret
=
TAOS_SYNC_OTHER_ERROR
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录