From 316e563ff2642ced2f01c1405f7f361ff42c6d60 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Mon, 30 Jan 2023 09:59:30 +0800 Subject: [PATCH] enh: adjust vgroup replica after split --- source/dnode/mnode/impl/src/mndVgroup.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/source/dnode/mnode/impl/src/mndVgroup.c b/source/dnode/mnode/impl/src/mndVgroup.c index af7654e19f..6d31e89790 100644 --- a/source/dnode/mnode/impl/src/mndVgroup.c +++ b/source/dnode/mnode/impl/src/mndVgroup.c @@ -1821,7 +1821,6 @@ static int32_t mndSplitVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SVgObj if (mndAddAlterVnodeHashRangeAction(pMnode, pTrans, pDb, &newVg1) != 0) goto _OVER; if (mndAddAlterVnodeHashRangeAction(pMnode, pTrans, pDb, &newVg2) != 0) goto _OVER; -#if 0 // adjust vgroup replica if (pDb->cfg.replications != newVg1.replica) { if (mndBuildAlterVgroupAction(pMnode, pTrans, pDb, pDb, &newVg1, pArray) != 0) goto _OVER; @@ -1829,7 +1828,6 @@ static int32_t mndSplitVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SVgObj if (pDb->cfg.replications != newVg2.replica) { if (mndBuildAlterVgroupAction(pMnode, pTrans, pDb, pDb, &newVg2, pArray) != 0) goto _OVER; } -#endif { SSdbRaw *pRaw = mndVgroupActionEncode(&newVg1); @@ -1851,6 +1849,16 @@ static int32_t mndSplitVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SVgObj (void)sdbSetRawStatus(pRaw, SDB_STATUS_READY); } + { + SSdbRaw *pRaw = mndVgroupActionEncode(pVgroup); + if (pRaw == NULL) return -1; + if (mndTransAppendCommitlog(pTrans, pRaw) != 0) { + sdbFreeRaw(pRaw); + return -1; + } + (void)sdbSetRawStatus(pRaw, SDB_STATUS_DROPPED); + } + mInfo("vgId:%d, vgroup info after adjust hash, replica:%d hashBegin:%u hashEnd:%u vnode:0 dnode:%d", newVg1.vgId, newVg1.replica, newVg1.hashBegin, newVg1.hashEnd, newVg1.vnodeGid[0].dnodeId); for (int32_t i = 0; i < newVg1.replica; ++i) { -- GitLab