enh: add mndTransCommitVgStatus
This commit is contained in:
parent
76a20b2221
commit
fced627021
|
@ -2103,6 +2103,18 @@ static int32_t mndAddAdjustVnodeHashRangeAction(SMnode *pMnode, STrans *pTrans,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t mndTransCommitVgStatus(STrans *pTrans, SVgObj *pVg, ESdbStatus vgStatus) {
|
||||||
|
SSdbRaw *pRaw = mndVgroupActionEncode(pVg);
|
||||||
|
if (pRaw == NULL) goto _err;
|
||||||
|
if (mndTransAppendCommitlog(pTrans, pRaw) != 0) goto _err;
|
||||||
|
(void)sdbSetRawStatus(pRaw, vgStatus);
|
||||||
|
pRaw = NULL;
|
||||||
|
return 0;
|
||||||
|
_err:
|
||||||
|
sdbFreeRaw(pRaw);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t mndSplitVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SVgObj *pVgroup) {
|
int32_t mndSplitVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SVgObj *pVgroup) {
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
STrans *pTrans = NULL;
|
STrans *pTrans = NULL;
|
||||||
|
@ -2181,28 +2193,16 @@ int32_t mndSplitVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SVgObj *pVgro
|
||||||
if (pDb->cfg.replications != newVg1.replica) {
|
if (pDb->cfg.replications != newVg1.replica) {
|
||||||
if (mndBuildAlterVgroupAction(pMnode, pTrans, pDb, pDb, &newVg1, pArray) != 0) goto _OVER;
|
if (mndBuildAlterVgroupAction(pMnode, pTrans, pDb, pDb, &newVg1, pArray) != 0) goto _OVER;
|
||||||
} else {
|
} else {
|
||||||
pRaw = mndVgroupActionEncode(&newVg1);
|
if (mndTransCommitVgStatus(pTrans, &newVg1, SDB_STATUS_READY) < 0) goto _OVER;
|
||||||
if (pRaw == NULL) goto _OVER;
|
|
||||||
if (mndTransAppendCommitlog(pTrans, pRaw) != 0) goto _OVER;
|
|
||||||
(void)sdbSetRawStatus(pRaw, SDB_STATUS_READY);
|
|
||||||
pRaw = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pDb->cfg.replications != newVg2.replica) {
|
if (pDb->cfg.replications != newVg2.replica) {
|
||||||
if (mndBuildAlterVgroupAction(pMnode, pTrans, pDb, pDb, &newVg2, pArray) != 0) goto _OVER;
|
if (mndBuildAlterVgroupAction(pMnode, pTrans, pDb, pDb, &newVg2, pArray) != 0) goto _OVER;
|
||||||
} else {
|
} else {
|
||||||
pRaw = mndVgroupActionEncode(&newVg2);
|
if (mndTransCommitVgStatus(pTrans, &newVg2, SDB_STATUS_READY) < 0) goto _OVER;
|
||||||
if (pRaw == NULL) goto _OVER;
|
|
||||||
if (mndTransAppendCommitlog(pTrans, pRaw) != 0) goto _OVER;
|
|
||||||
(void)sdbSetRawStatus(pRaw, SDB_STATUS_READY);
|
|
||||||
pRaw = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pRaw = mndVgroupActionEncode(pVgroup);
|
if (mndTransCommitVgStatus(pTrans, pVgroup, SDB_STATUS_DROPPED) < 0) goto _OVER;
|
||||||
if (pRaw == NULL) goto _OVER;
|
|
||||||
if (mndTransAppendCommitlog(pTrans, pRaw) != 0) goto _OVER;
|
|
||||||
(void)sdbSetRawStatus(pRaw, SDB_STATUS_DROPPED);
|
|
||||||
pRaw = NULL;
|
|
||||||
|
|
||||||
memcpy(&dbObj, pDb, sizeof(SDbObj));
|
memcpy(&dbObj, pDb, sizeof(SDbObj));
|
||||||
if (dbObj.cfg.pRetensions != NULL) {
|
if (dbObj.cfg.pRetensions != NULL) {
|
||||||
|
|
Loading…
Reference in New Issue