Move rebuild config sdb to after restored.
This commit is contained in:
parent
6eb183a032
commit
474113da4e
|
@ -29,7 +29,7 @@ static int32_t mndCfgActionInsert(SSdb *pSdb, SConfigObj *obj);
|
|||
static int32_t mndCfgActionDelete(SSdb *pSdb, SConfigObj *obj);
|
||||
static int32_t mndCfgActionUpdate(SSdb *pSdb, SConfigObj *oldItem, SConfigObj *newObj);
|
||||
static int32_t mndCfgActionDeploy(SMnode *pMnode);
|
||||
static int32_t mndCfgActionPrepare(SMnode *pMnode);
|
||||
static int32_t mndCfgActionAfterRestored(SMnode *pMnode);
|
||||
|
||||
static int32_t mndProcessConfigReq(SRpcMsg *pReq);
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -53,7 +53,7 @@ int32_t mndInitConfig(SMnode *pMnode) {
|
|||
.updateFp = (SdbUpdateFp)mndCfgActionUpdate,
|
||||
.deleteFp = (SdbDeleteFp)mndCfgActionDelete,
|
||||
.deployFp = (SdbDeployFp)mndCfgActionDeploy,
|
||||
.prepareFp = (SdbPrepareFp)mndCfgActionPrepare};
|
||||
.afterRestoredFp = (SdbAfterRestoredFp)mndCfgActionAfterRestored};
|
||||
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_CONFIG, mndProcessConfigReq);
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_CONFIG_DNODE, mndProcessConfigDnodeReq);
|
||||
|
@ -214,7 +214,7 @@ static int32_t mndCfgActionUpdate(SSdb *pSdb, SConfigObj *pOld, SConfigObj *pNew
|
|||
|
||||
static int32_t mndCfgActionDeploy(SMnode *pMnode) { return mndInitWriteCfg(pMnode); }
|
||||
|
||||
static int32_t mndCfgActionPrepare(SMnode *pMnode) { return mndTryRebuildCfg(pMnode); }
|
||||
static int32_t mndCfgActionAfterRestored(SMnode *pMnode) { return mndTryRebuildCfg(pMnode); }
|
||||
|
||||
static int32_t mndProcessConfigReq(SRpcMsg *pReq) {
|
||||
SMnode *pMnode = pReq->info.node;
|
||||
|
|
|
@ -797,14 +797,7 @@ int32_t mndStart(SMnode *pMnode) {
|
|||
return -1;
|
||||
}
|
||||
mndSetRestored(pMnode, true);
|
||||
} else {
|
||||
if (sdbPrepare(pMnode->pSdb) != 0) {
|
||||
mError("failed to prepare sdb while start mnode");
|
||||
return -1;
|
||||
}
|
||||
mndSetRestored(pMnode, true);
|
||||
}
|
||||
|
||||
grantReset(pMnode, TSDB_GRANT_ALL, 0);
|
||||
|
||||
return mndInitTimer(pMnode);
|
||||
|
|
|
@ -14,11 +14,11 @@
|
|||
*/
|
||||
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "mndSync.h"
|
||||
#include "mndCluster.h"
|
||||
#include "mndStream.h"
|
||||
#include "mndSync.h"
|
||||
#include "mndTrans.h"
|
||||
#include "mndUser.h"
|
||||
#include "mndStream.h"
|
||||
|
||||
static int32_t mndSyncEqCtrlMsg(const SMsgCb *msgcb, SRpcMsg *pMsg) {
|
||||
if (pMsg == NULL || pMsg->pCont == NULL) {
|
||||
|
@ -309,6 +309,9 @@ void mndRestoreFinish(const SSyncFSM *pFsm, const SyncIndex commitIdx) {
|
|||
} else {
|
||||
mInfo("vgId:1, sync restore finished, repeat call");
|
||||
}
|
||||
if (sdbAfterRestored(pMnode->pSdb) != 0) {
|
||||
mError("failed to prepare sdb while start mnode");
|
||||
}
|
||||
} else {
|
||||
mInfo("vgId:1, sync restore finished");
|
||||
}
|
||||
|
|
|
@ -117,7 +117,7 @@ typedef int32_t (*SdbInsertFp)(SSdb *pSdb, void *pObj);
|
|||
typedef int32_t (*SdbUpdateFp)(SSdb *pSdb, void *pSrcObj, void *pDstObj);
|
||||
typedef int32_t (*SdbDeleteFp)(SSdb *pSdb, void *pObj, bool callFunc);
|
||||
typedef int32_t (*SdbDeployFp)(SMnode *pMnode);
|
||||
typedef int32_t (*SdbPrepareFp)(SMnode *pMnode);
|
||||
typedef int32_t (*SdbAfterRestoredFp)(SMnode *pMnode);
|
||||
typedef int32_t (*SdbValidateFp)(SMnode *pMnode, void *pTrans, SSdbRaw *pRaw);
|
||||
typedef SSdbRow *(*SdbDecodeFp)(SSdbRaw *pRaw);
|
||||
typedef SSdbRaw *(*SdbEncodeFp)(void *pObj);
|
||||
|
@ -208,7 +208,7 @@ typedef struct SSdb {
|
|||
SdbUpdateFp updateFps[SDB_MAX];
|
||||
SdbDeleteFp deleteFps[SDB_MAX];
|
||||
SdbDeployFp deployFps[SDB_MAX];
|
||||
SdbPrepareFp prepareFps[SDB_MAX];
|
||||
SdbAfterRestoredFp afterRestoredFps[SDB_MAX];
|
||||
SdbEncodeFp encodeFps[SDB_MAX];
|
||||
SdbDecodeFp decodeFps[SDB_MAX];
|
||||
SdbValidateFp validateFps[SDB_MAX];
|
||||
|
@ -225,7 +225,7 @@ typedef struct {
|
|||
ESdbType sdbType;
|
||||
EKeyType keyType;
|
||||
SdbDeployFp deployFp;
|
||||
SdbPrepareFp prepareFp;
|
||||
SdbAfterRestoredFp afterRestoredFp;
|
||||
SdbEncodeFp encodeFp;
|
||||
SdbDecodeFp decodeFp;
|
||||
SdbInsertFp insertFp;
|
||||
|
@ -279,7 +279,7 @@ int32_t sdbDeploy(SSdb *pSdb);
|
|||
* @param pSdb The sdb object.
|
||||
* @return int32_t 0 for success, -1 for failure.
|
||||
*/
|
||||
int32_t sdbPrepare(SSdb *pSdb);
|
||||
int32_t sdbAfterRestored(SSdb *pSdb);
|
||||
|
||||
/**
|
||||
* @brief Load sdb from file.
|
||||
|
|
|
@ -127,7 +127,7 @@ int32_t sdbSetTable(SSdb *pSdb, SSdbTable table) {
|
|||
pSdb->deployFps[sdbType] = table.deployFp;
|
||||
pSdb->encodeFps[sdbType] = table.encodeFp;
|
||||
pSdb->decodeFps[sdbType] = table.decodeFp;
|
||||
pSdb->prepareFps[sdbType] = table.prepareFp;
|
||||
pSdb->afterRestoredFps[sdbType] = table.afterRestoredFp;
|
||||
pSdb->validateFps[sdbType] = table.validateFp;
|
||||
|
||||
int32_t hashType = 0;
|
||||
|
|
|
@ -48,12 +48,12 @@ static int32_t sdbDeployData(SSdb *pSdb) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int32_t sdbPrepareData(SSdb *pSdb) {
|
||||
static int32_t sdbAfterRestoredData(SSdb *pSdb) {
|
||||
int32_t code = 0;
|
||||
mInfo("start to prepare sdb");
|
||||
|
||||
for (int32_t i = SDB_MAX - 1; i >= 0; --i) {
|
||||
SdbPrepareFp fp = pSdb->prepareFps[i];
|
||||
SdbAfterRestoredFp fp = pSdb->afterRestoredFps[i];
|
||||
if (fp == NULL) continue;
|
||||
|
||||
mInfo("start to prepare sdb:%s", sdbTableName(i));
|
||||
|
@ -666,9 +666,9 @@ int32_t sdbDeploy(SSdb *pSdb) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t sdbPrepare(SSdb *pSdb) {
|
||||
int32_t sdbAfterRestored(SSdb *pSdb) {
|
||||
int32_t code = 0;
|
||||
code = sdbPrepareData(pSdb);
|
||||
code = sdbAfterRestoredData(pSdb);
|
||||
if (code != 0) {
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue