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);
|
int32_t mndExtractDbInfo(SMnode *pMnode, SDbObj *pDb, SUseDbRsp *pRsp, const SUseDbReq *pReq);
|
||||||
bool mndIsDbReady(SMnode *pMnode, SDbObj *pDb);
|
bool mndIsDbReady(SMnode *pMnode, SDbObj *pDb);
|
||||||
|
|
||||||
|
SSdbRaw *mndDbActionEncode(SDbObj *pDb);
|
||||||
const char *mndGetDbStr(const char *src);
|
const char *mndGetDbStr(const char *src);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -32,7 +32,6 @@
|
||||||
#define DB_VER_NUMBER 1
|
#define DB_VER_NUMBER 1
|
||||||
#define DB_RESERVE_SIZE 54
|
#define DB_RESERVE_SIZE 54
|
||||||
|
|
||||||
static SSdbRaw *mndDbActionEncode(SDbObj *pDb);
|
|
||||||
static SSdbRow *mndDbActionDecode(SSdbRaw *pRaw);
|
static SSdbRow *mndDbActionDecode(SSdbRaw *pRaw);
|
||||||
static int32_t mndDbActionInsert(SSdb *pSdb, SDbObj *pDb);
|
static int32_t mndDbActionInsert(SSdb *pSdb, SDbObj *pDb);
|
||||||
static int32_t mndDbActionDelete(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) {}
|
void mndCleanupDb(SMnode *pMnode) {}
|
||||||
|
|
||||||
static SSdbRaw *mndDbActionEncode(SDbObj *pDb) {
|
SSdbRaw *mndDbActionEncode(SDbObj *pDb) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
int32_t size = sizeof(SDbObj) + pDb->cfg.numOfRetensions * sizeof(SRetention) + DB_RESERVE_SIZE;
|
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->updateTime = pNew->updateTime;
|
||||||
pOld->cfgVersion = pNew->cfgVersion;
|
pOld->cfgVersion = pNew->cfgVersion;
|
||||||
pOld->vgVersion = pNew->vgVersion;
|
pOld->vgVersion = pNew->vgVersion;
|
||||||
|
pOld->cfg.numOfVgroups = pNew->cfg.numOfVgroups;
|
||||||
pOld->cfg.buffer = pNew->cfg.buffer;
|
pOld->cfg.buffer = pNew->cfg.buffer;
|
||||||
pOld->cfg.pageSize = pNew->cfg.pageSize;
|
pOld->cfg.pageSize = pNew->cfg.pageSize;
|
||||||
pOld->cfg.pages = pNew->cfg.pages;
|
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;
|
int32_t code = -1;
|
||||||
STrans *pTrans = NULL;
|
STrans *pTrans = NULL;
|
||||||
SSdbRaw *pRaw = NULL;
|
SSdbRaw *pRaw = NULL;
|
||||||
|
SDbObj dbObj = {0};
|
||||||
SArray *pArray = mndBuildDnodesArray(pMnode, 0);
|
SArray *pArray = mndBuildDnodesArray(pMnode, 0);
|
||||||
|
|
||||||
pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, pReq, "split-vgroup");
|
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);
|
(void)sdbSetRawStatus(pRaw, SDB_STATUS_DROPPED);
|
||||||
pRaw = NULL;
|
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;
|
if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER;
|
||||||
code = 0;
|
code = 0;
|
||||||
|
|
||||||
|
@ -1962,6 +1977,7 @@ _OVER:
|
||||||
taosArrayDestroy(pArray);
|
taosArrayDestroy(pArray);
|
||||||
mndTransDrop(pTrans);
|
mndTransDrop(pTrans);
|
||||||
sdbFreeRaw(pRaw);
|
sdbFreeRaw(pRaw);
|
||||||
|
taosArrayDestroy(dbObj.cfg.pRetensions);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue