enh: update numOfVgroups while split
This commit is contained in:
parent
f6248d21df
commit
71a17e4c47
|
@ -30,6 +30,7 @@ int32_t mndValidateDbInfo(SMnode *pMnode, SDbVgVersion *pDbs, int32_t numOfDbs,
|
|||
int32_t mndExtractDbInfo(SMnode *pMnode, SDbObj *pDb, SUseDbRsp *pRsp, const SUseDbReq *pReq);
|
||||
bool mndIsDbReady(SMnode *pMnode, SDbObj *pDb);
|
||||
|
||||
SSdbRaw *mndDbActionEncode(SDbObj *pDb);
|
||||
const char *mndGetDbStr(const char *src);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
#define DB_VER_NUMBER 1
|
||||
#define DB_RESERVE_SIZE 54
|
||||
|
||||
static SSdbRaw *mndDbActionEncode(SDbObj *pDb);
|
||||
static SSdbRow *mndDbActionDecode(SSdbRaw *pRaw);
|
||||
static int32_t mndDbActionInsert(SSdb *pSdb, SDbObj *pDb);
|
||||
static int32_t mndDbActionDelete(SSdb *pSdb, SDbObj *pDb);
|
||||
|
@ -74,7 +73,7 @@ int32_t mndInitDb(SMnode *pMnode) {
|
|||
|
||||
void mndCleanupDb(SMnode *pMnode) {}
|
||||
|
||||
static SSdbRaw *mndDbActionEncode(SDbObj *pDb) {
|
||||
SSdbRaw *mndDbActionEncode(SDbObj *pDb) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
||||
int32_t size = sizeof(SDbObj) + pDb->cfg.numOfRetensions * sizeof(SRetention) + DB_RESERVE_SIZE;
|
||||
|
@ -259,6 +258,7 @@ static int32_t mndDbActionUpdate(SSdb *pSdb, SDbObj *pOld, SDbObj *pNew) {
|
|||
pOld->updateTime = pNew->updateTime;
|
||||
pOld->cfgVersion = pNew->cfgVersion;
|
||||
pOld->vgVersion = pNew->vgVersion;
|
||||
pOld->cfg.numOfVgroups = pNew->cfg.numOfVgroups;
|
||||
pOld->cfg.buffer = pNew->cfg.buffer;
|
||||
pOld->cfg.pageSize = pNew->cfg.pageSize;
|
||||
pOld->cfg.pages = pNew->cfg.pages;
|
||||
|
|
|
@ -1859,6 +1859,7 @@ static int32_t mndSplitVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SVgObj
|
|||
int32_t code = -1;
|
||||
STrans *pTrans = NULL;
|
||||
SSdbRaw *pRaw = NULL;
|
||||
SDbObj dbObj = {0};
|
||||
SArray *pArray = mndBuildDnodesArray(pMnode, 0);
|
||||
|
||||
pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, pReq, "split-vgroup");
|
||||
|
@ -1955,6 +1956,20 @@ static int32_t mndSplitVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SVgObj
|
|||
(void)sdbSetRawStatus(pRaw, SDB_STATUS_DROPPED);
|
||||
pRaw = NULL;
|
||||
|
||||
memcpy(&dbObj, pDb, sizeof(SDbObj));
|
||||
if (dbObj.cfg.pRetensions != NULL) {
|
||||
dbObj.cfg.pRetensions = taosArrayDup(pDb->cfg.pRetensions, NULL);
|
||||
if (dbObj.cfg.pRetensions == NULL) goto _OVER;
|
||||
}
|
||||
dbObj.vgVersion++;
|
||||
dbObj.updateTime = taosGetTimestampMs();
|
||||
dbObj.cfg.numOfVgroups++;
|
||||
pRaw = mndDbActionEncode(&dbObj);
|
||||
if (pRaw == NULL) goto _OVER;
|
||||
if (mndTransAppendCommitlog(pTrans, pRaw) != 0) goto _OVER;
|
||||
(void)sdbSetRawStatus(pRaw, SDB_STATUS_READY);
|
||||
pRaw = NULL;
|
||||
|
||||
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
|
||||
code = 0;
|
||||
|
||||
|
@ -1962,6 +1977,7 @@ _OVER:
|
|||
taosArrayDestroy(pArray);
|
||||
mndTransDrop(pTrans);
|
||||
sdbFreeRaw(pRaw);
|
||||
taosArrayDestroy(dbObj.cfg.pRetensions);
|
||||
return code;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue