提交 fe834cc7 编写于 作者: S Shengliang Guan

only drop one vnode each time

上级 88171545
......@@ -214,8 +214,8 @@ static bool balanceCheckVgroupReady(SVgObj *pVgroup, SVnodeGid *pRmVnode) {
* desc: remove one vnode from vgroup
* all vnodes in vgroup should in ready state, except the balancing one
**/
static void balanceRemoveVnode(SVgObj *pVgroup) {
if (pVgroup->numOfVnodes <= 1) return;
static int32_t balanceRemoveVnode(SVgObj *pVgroup) {
if (pVgroup->numOfVnodes <= 1) return -1;
SVnodeGid *pRmVnode = NULL;
SVnodeGid *pSelVnode = NULL;
......@@ -258,9 +258,11 @@ static void balanceRemoveVnode(SVgObj *pVgroup) {
if (!balanceCheckVgroupReady(pVgroup, pSelVnode)) {
mDebug("vgId:%d, is not ready", pVgroup->vgId);
return -1;
} else {
mDebug("vgId:%d, is ready, discard dnode:%d", pVgroup->vgId, pSelVnode->dnodeId);
balanceDiscardVnode(pVgroup, pSelVnode);
return TSDB_CODE_SUCCESS;
}
}
......@@ -407,22 +409,22 @@ static int32_t balanceMonitorVgroups() {
int32_t dbReplica = pVgroup->pDb->cfg.replications;
int32_t vgReplica = pVgroup->numOfVnodes;
int32_t code;
if (vgReplica > dbReplica) {
mInfo("vgId:%d, replica:%d numOfVnodes:%d, try remove one vnode", pVgroup->vgId, dbReplica, vgReplica);
hasUpdatingVgroup = true;
balanceRemoveVnode(pVgroup);
code = balanceRemoveVnode(pVgroup);
} else if (vgReplica < dbReplica) {
mInfo("vgId:%d, replica:%d numOfVnodes:%d, try add one vnode", pVgroup->vgId, dbReplica, vgReplica);
hasUpdatingVgroup = true;
int32_t code = balanceAddVnode(pVgroup, NULL, NULL);
if (code == TSDB_CODE_SUCCESS) {
mnodeDecVgroupRef(pVgroup);
break;
}
code = balanceAddVnode(pVgroup, NULL, NULL);
}
mnodeDecVgroupRef(pVgroup);
if (code == TSDB_CODE_SUCCESS) {
break;
}
}
sdbFreeIter(pIter);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册