Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
f30d9a03
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看板
提交
f30d9a03
编写于
6月 10, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: redistribute vgroup to dnodes
上级
61d8644f
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
271 addition
and
56 deletion
+271
-56
include/util/taoserror.h
include/util/taoserror.h
+2
-1
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
+3
-0
source/dnode/mnode/impl/src/mndMain.c
source/dnode/mnode/impl/src/mndMain.c
+2
-2
source/dnode/mnode/impl/src/mndTrans.c
source/dnode/mnode/impl/src/mndTrans.c
+2
-2
source/dnode/mnode/impl/src/mndVgroup.c
source/dnode/mnode/impl/src/mndVgroup.c
+94
-50
source/dnode/vnode/src/vnd/vnodeSync.c
source/dnode/vnode/src/vnd/vnodeSync.c
+1
-0
source/util/src/terror.c
source/util/src/terror.c
+2
-1
tests/script/tsim/dnode/redistribute_vgroup_replica3_move_1_vnode.sim
.../tsim/dnode/redistribute_vgroup_replica3_move_1_vnode.sim
+165
-0
未找到文件。
include/util/taoserror.h
浏览文件 @
f30d9a03
...
...
@@ -85,7 +85,6 @@ int32_t* taosGetErrno();
#define TSDB_CODE_RPC_NETWORK_UNAVAIL TAOS_DEF_ERROR_CODE(0, 0x0102)
#define TSDB_CODE_RPC_FQDN_ERROR TAOS_DEF_ERROR_CODE(0, 0x0103)
#define TSDB_CODE_RPC_PORT_EADDRINUSE TAOS_DEF_ERROR_CODE(0, 0x0104)
#define TSDB_CODE_RPC_INDIRECT_NETWORK_UNAVAIL TAOS_DEF_ERROR_CODE(0, 0x0105)
//client
#define TSDB_CODE_TSC_INVALID_OPERATION TAOS_DEF_ERROR_CODE(0, 0x0200)
...
...
@@ -220,6 +219,7 @@ int32_t* taosGetErrno();
#define TSDB_CODE_MND_VGROUP_ALREADY_IN_DNODE TAOS_DEF_ERROR_CODE(0, 0x0392)
#define TSDB_CODE_MND_VGROUP_UN_CHANGED TAOS_DEF_ERROR_CODE(0, 0x0393)
#define TSDB_CODE_MND_HAS_OFFLINE_DNODE TAOS_DEF_ERROR_CODE(0, 0x0394)
#define TSDB_CODE_MND_INVALID_REPLICA TAOS_DEF_ERROR_CODE(0, 0x0395)
// mnode-stable
#define TSDB_CODE_MND_STB_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03A0)
...
...
@@ -260,6 +260,7 @@ int32_t* taosGetErrno();
#define TSDB_CODE_MND_TRANS_CONFLICT TAOS_DEF_ERROR_CODE(0, 0x03D3)
#define TSDB_CODE_MND_TRANS_UNKNOW_ERROR TAOS_DEF_ERROR_CODE(0, 0x03D4)
#define TSDB_CODE_MND_TRANS_CLOG_IS_NULL TAOS_DEF_ERROR_CODE(0, 0x03D5)
#define TSDB_CODE_MND_TRANS_NETWORK_UNAVAILL TAOS_DEF_ERROR_CODE(0, 0x03D6)
// mnode-mq
#define TSDB_CODE_MND_TOPIC_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03E0)
...
...
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
浏览文件 @
f30d9a03
...
...
@@ -170,6 +170,9 @@ SArray *mmGetMsgHandles() {
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_COMPACT_DB
,
mmPutNodeMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_GET_DB_CFG
,
mmPutNodeMsgToReadQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_VGROUP_LIST
,
mmPutNodeMsgToReadQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_REDISTRIBUTE_VGROUP
,
mmPutNodeMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_MERGE_VGROUP
,
mmPutNodeMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_BALANCE_VGROUP
,
mmPutNodeMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_CREATE_FUNC
,
mmPutNodeMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_RETRIEVE_FUNC
,
mmPutNodeMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_DROP_FUNC
,
mmPutNodeMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
...
...
source/dnode/mnode/impl/src/mndMain.c
浏览文件 @
f30d9a03
...
...
@@ -217,8 +217,8 @@ static int32_t mndInitSteps(SMnode *pMnode) {
if
(
mndAllocStep
(
pMnode
,
"mnode-cluster"
,
mndInitCluster
,
mndCleanupCluster
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-mnode"
,
mndInitMnode
,
mndCleanupMnode
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-qnode"
,
mndInitQnode
,
mndCleanupQnode
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-
q
node"
,
mndInitSnode
,
mndCleanupSnode
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-
q
node"
,
mndInitBnode
,
mndCleanupBnode
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-
s
node"
,
mndInitSnode
,
mndCleanupSnode
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-
b
node"
,
mndInitBnode
,
mndCleanupBnode
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-dnode"
,
mndInitDnode
,
mndCleanupDnode
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-user"
,
mndInitUser
,
mndCleanupUser
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-grant"
,
mndInitGrant
,
mndCleanupGrant
)
!=
0
)
return
-
1
;
...
...
source/dnode/mnode/impl/src/mndTrans.c
浏览文件 @
f30d9a03
...
...
@@ -781,7 +781,7 @@ static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans) {
sendRsp
=
true
;
}
}
else
{
if
(
pTrans
->
stage
==
TRN_STAGE_REDO_ACTION
&&
pTrans
->
failedTimes
>
3
)
{
if
(
pTrans
->
stage
==
TRN_STAGE_REDO_ACTION
&&
pTrans
->
failedTimes
>
2
)
{
if
(
code
==
0
)
code
=
TSDB_CODE_MND_TRANS_UNKNOW_ERROR
;
sendRsp
=
true
;
}
...
...
@@ -791,7 +791,7 @@ static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans) {
mDebug
(
"trans:%d, send rsp, code:0x%x stage:%s app:%p"
,
pTrans
->
id
,
code
,
mndTransStr
(
pTrans
->
stage
),
pTrans
->
rpcInfo
.
ahandle
);
if
(
code
==
TSDB_CODE_RPC_NETWORK_UNAVAIL
)
{
code
=
TSDB_CODE_
RPC_INDIRECT_NETWORK_UNAVAI
L
;
code
=
TSDB_CODE_
MND_TRANS_NETWORK_UNAVAIL
L
;
}
SRpcMsg
rspMsg
=
{.
code
=
code
,
.
info
=
pTrans
->
rpcInfo
};
...
...
source/dnode/mnode/impl/src/mndVgroup.c
浏览文件 @
f30d9a03
...
...
@@ -59,6 +59,10 @@ int32_t mndInitVgroup(SMnode *pMnode) {
mndSetMsgHandle
(
pMnode
,
TDMT_DND_DROP_VNODE_RSP
,
mndTransProcessRsp
);
mndSetMsgHandle
(
pMnode
,
TDMT_VND_COMPACT_RSP
,
mndTransProcessRsp
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_REDISTRIBUTE_VGROUP
,
mndProcessRedistributeVgroupMsg
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_MERGE_VGROUP
,
mndProcessSplitVgroupMsg
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_BALANCE_VGROUP
,
mndProcessBalanceVgroupMsg
);
mndAddShowRetrieveHandle
(
pMnode
,
TSDB_MGMT_TABLE_VGROUP
,
mndRetrieveVgroups
);
mndAddShowFreeIterHandle
(
pMnode
,
TSDB_MGMT_TABLE_VGROUP
,
mndCancelGetNextVgroup
);
mndAddShowRetrieveHandle
(
pMnode
,
TSDB_MGMT_TABLE_VNODES
,
mndRetrieveVnodes
);
...
...
@@ -1009,10 +1013,10 @@ static int32_t mndAddDecVgroupReplicaFromTrans(SMnode *pMnode, STrans *pTrans, S
if
(
pGid
==
NULL
)
return
0
;
pVgroup
->
replica
--
;
memcpy
(
&
delGid
,
pGid
,
sizeof
(
SVnodeGid
));
memcpy
(
pGid
,
&
pVgroup
->
vnodeGid
[
pVgroup
->
replica
],
sizeof
(
SVnodeGid
));
memset
(
&
pVgroup
->
vnodeGid
[
pVgroup
->
replica
],
0
,
sizeof
(
SVnodeGid
));
pVgroup
->
replica
--
;
if
(
mndAddAlterVnodeAction
(
pMnode
,
pTrans
,
pDb
,
pVgroup
,
TDMT_VND_ALTER_REPLICA
)
!=
0
)
return
-
1
;
if
(
mndAddDropVnodeAction
(
pMnode
,
pTrans
,
pDb
,
pVgroup
,
&
delGid
,
true
)
!=
0
)
return
-
1
;
...
...
@@ -1040,11 +1044,36 @@ static int32_t mndRedistributeVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb,
mInfo
(
"vgId:%d, vnode:%d dnode:%d"
,
newVg
.
vgId
,
i
,
newVg
.
vnodeGid
[
i
].
dnodeId
);
}
if
(
mndAddIncVgroupReplicaToTrans
(
pMnode
,
pTrans
,
pDb
,
&
newVg
,
pNew1
->
id
)
!=
0
)
goto
_OVER
;
if
(
mndAddDecVgroupReplicaFromTrans
(
pMnode
,
pTrans
,
pDb
,
&
newVg
,
pOld1
->
id
)
!=
0
)
goto
_OVER
;
if
(
pNew2
!=
NULL
)
{
if
(
pNew1
!=
pOld1
)
{
int32_t
numOfVnodes
=
mndGetVnodesNum
(
pMnode
,
pNew1
->
id
);
if
(
numOfVnodes
>=
pNew1
->
numOfSupportVnodes
)
{
mError
(
"vgId:%d, no enough vnodes in dnode:%d, numOfVnodes:%d support:%d"
,
newVg
.
vgId
,
pNew1
->
id
,
numOfVnodes
,
pNew1
->
numOfSupportVnodes
);
terrno
=
TSDB_CODE_MND_NO_ENOUGH_DNODES
;
goto
_OVER
;
}
if
(
mndAddIncVgroupReplicaToTrans
(
pMnode
,
pTrans
,
pDb
,
&
newVg
,
pNew1
->
id
)
!=
0
)
goto
_OVER
;
if
(
mndAddDecVgroupReplicaFromTrans
(
pMnode
,
pTrans
,
pDb
,
&
newVg
,
pOld1
->
id
)
!=
0
)
goto
_OVER
;
}
if
(
pNew2
!=
pOld2
)
{
int32_t
numOfVnodes
=
mndGetVnodesNum
(
pMnode
,
pNew2
->
id
);
if
(
numOfVnodes
>=
pNew2
->
numOfSupportVnodes
)
{
mError
(
"vgId:%d, no enough vnodes in dnode:%d, numOfVnodes:%d support:%d"
,
newVg
.
vgId
,
pNew2
->
id
,
numOfVnodes
,
pNew2
->
numOfSupportVnodes
);
terrno
=
TSDB_CODE_MND_NO_ENOUGH_DNODES
;
goto
_OVER
;
}
if
(
mndAddIncVgroupReplicaToTrans
(
pMnode
,
pTrans
,
pDb
,
&
newVg
,
pNew2
->
id
)
!=
0
)
goto
_OVER
;
if
(
mndAddDecVgroupReplicaFromTrans
(
pMnode
,
pTrans
,
pDb
,
&
newVg
,
pOld2
->
id
)
!=
0
)
goto
_OVER
;
}
if
(
pNew3
!=
pOld3
)
{
int32_t
numOfVnodes
=
mndGetVnodesNum
(
pMnode
,
pNew3
->
id
);
if
(
numOfVnodes
>=
pNew3
->
numOfSupportVnodes
)
{
mError
(
"vgId:%d, no enough vnodes in dnode:%d, numOfVnodes:%d support:%d"
,
newVg
.
vgId
,
pNew3
->
id
,
numOfVnodes
,
pNew3
->
numOfSupportVnodes
);
terrno
=
TSDB_CODE_MND_NO_ENOUGH_DNODES
;
goto
_OVER
;
}
if
(
mndAddIncVgroupReplicaToTrans
(
pMnode
,
pTrans
,
pDb
,
&
newVg
,
pNew3
->
id
)
!=
0
)
goto
_OVER
;
if
(
mndAddDecVgroupReplicaFromTrans
(
pMnode
,
pTrans
,
pDb
,
&
newVg
,
pOld3
->
id
)
!=
0
)
goto
_OVER
;
}
...
...
@@ -1070,88 +1099,105 @@ _OVER:
}
static
int32_t
mndProcessRedistributeVgroupMsg
(
SRpcMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
info
.
node
;
SUserObj
*
pUser
=
NULL
;
SDnodeObj
*
pNew1
=
NULL
;
SDnodeObj
*
pNew2
=
NULL
;
SDnodeObj
*
pNew3
=
NULL
;
SDnodeObj
*
pOld1
=
NULL
;
SDnodeObj
*
pOld2
=
NULL
;
SDnodeObj
*
pOld3
=
NULL
;
SVgObj
*
pVgroup
=
NULL
;
SDbObj
*
pDb
=
NULL
;
int32_t
code
=
-
1
;
int64_t
curMs
=
taosGetTimestampMs
();
SMDropMnodeReq
redReq
=
{
0
};
#if 0
if (tDeserializeSCreateDropMQSBNodeReq(pReq->pCont, pReq->contLen, &dropReq) != 0) {
SMnode
*
pMnode
=
pReq
->
info
.
node
;
SUserObj
*
pUser
=
NULL
;
SDnodeObj
*
pNew1
=
NULL
;
SDnodeObj
*
pNew2
=
NULL
;
SDnodeObj
*
pNew3
=
NULL
;
SDnodeObj
*
pOld1
=
NULL
;
SDnodeObj
*
pOld2
=
NULL
;
SDnodeObj
*
pOld3
=
NULL
;
SVgObj
*
pVgroup
=
NULL
;
SDbObj
*
pDb
=
NULL
;
int32_t
code
=
-
1
;
int64_t
curMs
=
taosGetTimestampMs
();
SRedistributeVgroupReq
redReq
=
{
0
};
if
(
tDeserializeSRedistributeVgroupReq
(
pReq
->
pCont
,
pReq
->
contLen
,
&
redReq
)
!=
0
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
goto
_OVER
;
}
#endif
mDebug
(
"vgId:%d, start to redistribute"
,
2
);
mInfo
(
"vgId:%d, start to redistribute to dnode %d:%d:%d"
,
redReq
.
vgId
,
redReq
.
dnodeId1
,
redReq
.
dnodeId2
,
redReq
.
dnodeId3
);
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
conn
.
user
);
if
(
pUser
==
NULL
)
{
terrno
=
TSDB_CODE_MND_NO_USER_FROM_CONN
;
goto
_OVER
;
}
if
(
mndCheckNodeAuth
(
pUser
)
!=
0
)
{
goto
_OVER
;
}
if
(
mndCheckNodeAuth
(
pUser
)
!=
0
)
goto
_OVER
;
pVgroup
=
mndAcquireVgroup
(
pMnode
,
2
);
pVgroup
=
mndAcquireVgroup
(
pMnode
,
redReq
.
vgId
);
if
(
pVgroup
==
NULL
)
goto
_OVER
;
pDb
=
mndAcquireDb
(
pMnode
,
pVgroup
->
dbName
);
if
(
pDb
==
NULL
)
goto
_OVER
;
if
(
pVgroup
->
replica
==
1
)
{
pNew1
=
mndAcquireDnode
(
pMnode
,
1
);
if
(
redReq
.
dnodeId2
!=
-
1
||
redReq
.
dnodeId3
!=
-
1
)
{
terrno
=
TSDB_CODE_MND_INVALID_REPLICA
;
goto
_OVER
;
}
pNew1
=
mndAcquireDnode
(
pMnode
,
redReq
.
dnodeId1
);
pOld1
=
mndAcquireDnode
(
pMnode
,
pVgroup
->
vnodeGid
[
0
].
dnodeId
);
if
(
pNew1
==
NULL
||
pOld1
==
NULL
)
goto
_OVER
;
if
(
!
mndIsDnodeOnline
(
pNew1
,
curMs
)
||
!
mndIsDnodeOnline
(
pOld1
,
curMs
))
{
terrno
=
TSDB_CODE_NODE_OFFLINE
;
if
(
pNew1
==
NULL
||
pOld1
==
NULL
)
{
terrno
=
TSDB_CODE_MND_DNODE_NOT_EXIST
;
goto
_OVER
;
}
if
(
pNew1
==
pOld1
)
{
terrno
=
TSDB_CODE_MND_VGROUP_UN_CHANGED
;
goto
_OVER
;
}
if
(
mndRedistributeVgroup
(
pMnode
,
pReq
,
pDb
,
pVgroup
,
pNew1
,
pOld1
,
NULL
,
NULL
,
NULL
,
NULL
)
!=
0
)
goto
_OVER
;
}
if
(
pVgroup
->
replica
==
3
)
{
pNew1
=
mndAcquireDnode
(
pMnode
,
1
);
pNew2
=
mndAcquireDnode
(
pMnode
,
2
);
pNew3
=
mndAcquireDnode
(
pMnode
,
3
);
if
(
!
mndIsDnodeOnline
(
pNew1
,
curMs
)
||
!
mndIsDnodeOnline
(
pOld1
,
curMs
))
{
terrno
=
TSDB_CODE_MND_HAS_OFFLINE_DNODE
;
goto
_OVER
;
}
code
=
mndRedistributeVgroup
(
pMnode
,
pReq
,
pDb
,
pVgroup
,
pNew1
,
pOld1
,
NULL
,
NULL
,
NULL
,
NULL
);
}
else
if
(
pVgroup
->
replica
==
3
)
{
if
(
redReq
.
dnodeId2
==
-
1
||
redReq
.
dnodeId3
==
-
1
)
{
terrno
=
TSDB_CODE_MND_INVALID_REPLICA
;
goto
_OVER
;
}
pNew1
=
mndAcquireDnode
(
pMnode
,
redReq
.
dnodeId1
);
pNew2
=
mndAcquireDnode
(
pMnode
,
redReq
.
dnodeId2
);
pNew3
=
mndAcquireDnode
(
pMnode
,
redReq
.
dnodeId3
);
pOld1
=
mndAcquireDnode
(
pMnode
,
pVgroup
->
vnodeGid
[
0
].
dnodeId
);
pOld2
=
mndAcquireDnode
(
pMnode
,
pVgroup
->
vnodeGid
[
1
].
dnodeId
);
pOld3
=
mndAcquireDnode
(
pMnode
,
pVgroup
->
vnodeGid
[
2
].
dnodeId
);
if
(
pNew1
==
NULL
||
pOld1
==
NULL
||
pNew2
==
NULL
||
pOld2
==
NULL
||
pNew3
==
NULL
||
pOld3
==
NULL
)
goto
_OVER
;
if
(
!
mndIsDnodeOnline
(
pNew1
,
curMs
)
||
!
mndIsDnodeOnline
(
pOld1
,
curMs
)
||
!
mndIsDnodeOnline
(
pNew2
,
curMs
)
||
!
mndIsDnodeOnline
(
pOld2
,
curMs
)
||
!
mndIsDnodeOnline
(
pNew3
,
curMs
)
||
!
mndIsDnodeOnline
(
pOld3
,
curMs
))
{
terrno
=
TSDB_CODE_NODE_OFFLINE
;
if
(
pNew1
==
NULL
||
pOld1
==
NULL
||
pNew2
==
NULL
||
pOld2
==
NULL
||
pNew3
==
NULL
||
pOld3
==
NULL
)
{
terrno
=
TSDB_CODE_MND_DNODE_NOT_EXIST
;
goto
_OVER
;
}
if
(
pNew1
==
pNew2
||
pNew1
==
pNew3
||
pNew2
==
pNew3
)
{
terrno
=
TSDB_CODE_MND_INVALID_REPLICA
;
goto
_OVER
;
}
bool
changed
=
tru
e
;
if
(
pNew1
!=
pOld1
||
pNew1
!=
pOld2
||
pNew1
!=
pOld3
)
changed
=
true
;
if
(
pNew2
!=
pOld1
||
pNew2
!=
pOld2
||
pNew2
!=
pOld3
)
changed
=
true
;
if
(
pNew3
!=
pOld1
||
pNew3
!=
pOld2
||
pNew3
!=
pOld3
)
changed
=
true
;
bool
changed
=
fals
e
;
if
(
pNew1
!=
pOld1
&&
pNew1
!=
pOld2
&&
pNew1
!=
pOld3
)
changed
=
true
;
if
(
pNew2
!=
pOld1
&&
pNew2
!=
pOld2
&&
pNew2
!=
pOld3
)
changed
=
true
;
if
(
pNew3
!=
pOld1
&&
pNew3
!=
pOld2
&&
pNew3
!=
pOld3
)
changed
=
true
;
if
(
!
changed
)
{
terrno
=
TSDB_CODE_MND_VGROUP_UN_CHANGED
;
goto
_OVER
;
}
if
(
mndRedistributeVgroup
(
pMnode
,
pReq
,
pDb
,
pVgroup
,
pNew1
,
pOld1
,
pNew2
,
pOld2
,
pNew3
,
pOld3
)
!=
0
)
goto
_OVER
;
if
(
!
mndIsDnodeOnline
(
pNew1
,
curMs
)
||
!
mndIsDnodeOnline
(
pOld1
,
curMs
)
||
!
mndIsDnodeOnline
(
pNew2
,
curMs
)
||
!
mndIsDnodeOnline
(
pOld2
,
curMs
)
||
!
mndIsDnodeOnline
(
pNew3
,
curMs
)
||
!
mndIsDnodeOnline
(
pOld3
,
curMs
))
{
terrno
=
TSDB_CODE_MND_HAS_OFFLINE_DNODE
;
goto
_OVER
;
}
code
=
mndRedistributeVgroup
(
pMnode
,
pReq
,
pDb
,
pVgroup
,
pNew1
,
pOld1
,
pNew2
,
pOld2
,
pNew3
,
pOld3
);
}
else
{
terrno
=
TSDB_CODE_MND_INVALID_REPLICA
;
goto
_OVER
;
}
if
(
code
==
0
)
code
=
TSDB_CODE_ACTION_IN_PROGRESS
;
_OVER:
if
(
code
!=
0
&&
code
!=
TSDB_CODE_ACTION_IN_PROGRESS
)
{
mDebug
(
"vgId:%d, failed to redistribute since %s"
,
1
,
terrstr
());
mError
(
"vgId:%d, failed to redistribute to dnode %d %d %d since %s"
,
redReq
.
vgId
,
redReq
.
dnodeId1
,
redReq
.
dnodeId2
,
redReq
.
dnodeId3
,
terrstr
());
}
mndReleaseDnode
(
pMnode
,
pNew1
);
...
...
@@ -1303,9 +1349,7 @@ static int32_t mndProcessSplitVgroupMsg(SRpcMsg *pReq) {
goto
_OVER
;
}
if
(
mndCheckNodeAuth
(
pUser
)
!=
0
)
{
goto
_OVER
;
}
if
(
mndCheckNodeAuth
(
pUser
)
!=
0
)
goto
_OVER
;
code
=
mndSplitVgroup
(
pMnode
,
pReq
,
pDb
,
pVgroup
);
if
(
code
==
0
)
code
=
TSDB_CODE_ACTION_IN_PROGRESS
;
...
...
source/dnode/vnode/src/vnd/vnodeSync.c
浏览文件 @
f30d9a03
...
...
@@ -187,6 +187,7 @@ static void vnodeSyncReconfig(struct SSyncFSM *pFsm, SSyncCfg newCfg, SReConfigC
// todo rpc response here
// build rpc msg
// put into apply queue
vnodePostBlockMsg
(
pVnode
,
TDMT_VND_ALTER_REPLICA
);
}
static
void
vnodeSyncCommitMsg
(
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
)
{
...
...
source/util/src/terror.c
浏览文件 @
f30d9a03
...
...
@@ -90,7 +90,6 @@ TAOS_DEFINE_ERROR(TSDB_CODE_RPC_AUTH_FAILURE, "Authentication failur
TAOS_DEFINE_ERROR
(
TSDB_CODE_RPC_NETWORK_UNAVAIL
,
"Unable to establish connection"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_RPC_FQDN_ERROR
,
"Unable to resolve FQDN"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_RPC_PORT_EADDRINUSE
,
"Port already in use"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_RPC_INDIRECT_NETWORK_UNAVAIL
,
"Unable to establish connection"
)
//client
TAOS_DEFINE_ERROR
(
TSDB_CODE_TSC_INVALID_OPERATION
,
"Invalid operation"
)
...
...
@@ -225,6 +224,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_VGROUP_NOT_IN_DNODE, "Vgroup not in dnode")
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_VGROUP_NOT_EXIST
,
"Vgroup does not exist"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_VGROUP_UN_CHANGED
,
"Vgroup distribution has not changed"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_HAS_OFFLINE_DNODE
,
"Offline dnode exists"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_INVALID_REPLICA
,
"Invalid vgroup replica"
)
// mnode-stable
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_STB_ALREADY_EXIST
,
"STable already exists"
)
...
...
@@ -265,6 +265,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_TRANS_INVALID_STAGE, "Invalid stage to kill
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_TRANS_CONFLICT
,
"Conflict transaction not completed"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_TRANS_UNKNOW_ERROR
,
"Unknown transaction error"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_TRANS_CLOG_IS_NULL
,
"Transaction commitlog is null"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_TRANS_NETWORK_UNAVAILL
,
"Unable to establish connection While execute transaction"
)
// mnode-mq
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_TOPIC_ALREADY_EXIST
,
"Topic already exists"
)
...
...
tests/script/tsim/dnode/redistribute_vgroup_replica3_move_1_vnode.sim
0 → 100644
浏览文件 @
f30d9a03
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/deploy.sh -n dnode2 -i 2
system sh/deploy.sh -n dnode3 -i 3
system sh/deploy.sh -n dnode4 -i 4
system sh/deploy.sh -n dnode5 -i 5
system sh/cfg.sh -n dnode1 -c supportVnodes -v 0
system sh/exec.sh -n dnode1 -s start
system sh/exec.sh -n dnode2 -s start
system sh/exec.sh -n dnode3 -s start
system sh/exec.sh -n dnode4 -s start
#system sh/exec.sh -n dnode5 -s start
sql connect
sql create user u1 pass 'taosdata'
print =============== step1 create dnode2
sql create dnode $hostname port 7200
sql create dnode $hostname port 7300
sql create dnode $hostname port 7400
sql create dnode $hostname port 7500
$x = 0
step1:
$ = $x + 1
sleep 1000
if $x == 10 then
print ====> dnode not ready!
return -1
endi
sql show dnodes
print ===> $data00 $data01 $data02 $data03 $data04 $data05
print ===> $data10 $data11 $data12 $data13 $data14 $data15
print ===> $data20 $data21 $data22 $data23 $data24 $data25
print ===> $data30 $data31 $data32 $data33 $data34 $data35
print ===> $data40 $data41 $data42 $data43 $data44 $data45
if $rows != 5 then
return -1
endi
if $data(1)[4] != ready then
goto step1
endi
if $data(2)[4] != ready then
goto step1
endi
if $data(3)[4] != ready then
goto step1
endi
if $data(4)[4] != ready then
goto step1
endi
#if $data(5)[4] != ready then
# goto step1
#endi
print =============== step2: create db
sql create database d1 vgroups 1 replica 3
# Invalid vgroup
sql_error redistribute vgroup 3 dnode 5 dnode 3 dnode 4
# un changed
sql_error redistribute vgroup 2 dnode 2 dnode 3 dnode 4
# no enought vnodes
sql_error redistribute vgroup 2 dnode 1 dnode 3 dnode 4
# offline vnodes
sql_error redistribute vgroup 2 dnode 5 dnode 3 dnode 4
# Invalid replica
sql_error redistribute vgroup 2 dnode 5
sql_error redistribute vgroup 2 dnode 5 dnode 3
sql_error redistribute vgroup 2 dnode 2 dnode 3
sql_error redistribute vgroup 2 dnode 2 dnode 2
sql_error redistribute vgroup 3 dnode 2 dnode 2
system sh/exec.sh -n dnode5 -s start
$x = 0
step2:
$ = $x + 1
sleep 1000
if $x == 10 then
print ====> dnode not ready!
return -1
endi
sql show dnodes
print ===> $data00 $data01 $data02 $data03 $data04 $data05
print ===> $data10 $data11 $data12 $data13 $data14 $data15
print ===> $data20 $data21 $data22 $data23 $data24 $data25
print ===> $data30 $data31 $data32 $data33 $data34 $data35
print ===> $data40 $data41 $data42 $data43 $data44 $data45
if $rows != 5 then
return -1
endi
if $data(1)[4] != ready then
goto step2
endi
if $data(2)[4] != ready then
goto step2
endi
if $data(3)[4] != ready then
goto step2
endi
if $data(4)[4] != ready then
goto step2
endi
if $data(5)[4] != ready then
goto step2
endi
return
print =============== step3: move follower
$leaderExist = 0
$leaderVnode = 0
$follower1 = 0
$follower2 = 0
$x = 0
step3:
$ = $x + 1
sleep 1000
if $x == 10 then
print ====> db not ready!
return -1
endi
sql show d1.vgroups
print ===> $data00 $data01 $data02 $data03 $data04 $data05
if $rows != 1 then
return -1
endi
if $data(2)[3] == leader then
$leaderExist = 1
$leaderVnode = 4
$follower1 = 2
$follower2 = 3
endi
if $data(2)[4] != ready then
$leaderExist = 1
$leaderVnode = 3
$follower1 = 2
$follower2 = 4
endi
if $data(3)[4] != ready then
$leaderExist = 1
$leaderVnode = 2
$follower1 = 3
$follower2 = 4
endi
if $leaderExist != 1 then
goto step3
endi
print redistribute vgroup 2 dnode $follower1 dnode $follower2 dnode 5
sql redistribute vgroup 2 dnode $follower1 dnode $follower2 dnode 5
print =============== step4: move leader
return
print =============== step3: drop dnode 3
return
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode2 -s stop -x SIGINT
system sh/exec.sh -n dnode3 -s stop -x SIGINT
system sh/exec.sh -n dnode4 -s stop -x SIGINT
system sh/exec.sh -n dnode5 -s stop -x SIGINT
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录