TD-2513
This commit is contained in:
parent
48eda0ab88
commit
995a6b90ea
|
@ -377,6 +377,24 @@ static int32_t mnodeCreateMnodeCb(SMnodeMsg *pMsg, int32_t code) {
|
|||
return code;
|
||||
}
|
||||
|
||||
static bool mnodeAllOnline() {
|
||||
void *pIter = NULL;
|
||||
bool allOnline = true;
|
||||
|
||||
while (1) {
|
||||
SMnodeObj *pMnode = NULL;
|
||||
pIter = mnodeGetNextMnode(pIter, &pMnode);
|
||||
if (pMnode == NULL) break;
|
||||
if (pMnode->role != TAOS_SYNC_ROLE_MASTER && pMnode->role != TAOS_SYNC_ROLE_SLAVE) {
|
||||
allOnline = false;
|
||||
mnodeDecMnodeRef(pMnode);
|
||||
}
|
||||
}
|
||||
mnodeCancelGetNextMnode(pIter);
|
||||
|
||||
return allOnline;
|
||||
}
|
||||
|
||||
void mnodeCreateMnode(int32_t dnodeId, char *dnodeEp, bool needConfirm) {
|
||||
SMnodeObj *pMnode = calloc(1, sizeof(SMnodeObj));
|
||||
pMnode->mnodeId = dnodeId;
|
||||
|
@ -389,6 +407,11 @@ void mnodeCreateMnode(int32_t dnodeId, char *dnodeEp, bool needConfirm) {
|
|||
.fpRsp = mnodeCreateMnodeCb
|
||||
};
|
||||
|
||||
if (needConfirm && !mnodeAllOnline()) {
|
||||
mDebug("wait all mnode online then create new mnode");
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
if (needConfirm) {
|
||||
code = mnodeSendCreateMnodeMsg(dnodeId, dnodeEp);
|
||||
|
|
|
@ -715,7 +715,7 @@ static SSyncPeer *syncCheckMaster(SSyncNode *pNode) {
|
|||
|
||||
if (onlineNum <= replica * 0.5) {
|
||||
if (nodeRole != TAOS_SYNC_ROLE_UNSYNCED) {
|
||||
if (nodeRole == TAOS_SYNC_ROLE_MASTER && onlineNum == replica * 0.5) {
|
||||
if (nodeRole == TAOS_SYNC_ROLE_MASTER && onlineNum == replica * 0.5 && onlineNum >= 1) {
|
||||
sInfo("vgId:%d, self keep work as master, online:%d replica:%d", pNode->vgId, onlineNum, replica);
|
||||
} else {
|
||||
nodeRole = TAOS_SYNC_ROLE_UNSYNCED;
|
||||
|
|
|
@ -106,9 +106,10 @@ int32_t vnodeReadCfg(SVnodeObj *pVnode) {
|
|||
cJSON *vgCfgVersion = cJSON_GetObjectItem(root, "vgCfgVersion");
|
||||
if (!vgCfgVersion || vgCfgVersion->type != cJSON_Number) {
|
||||
vError("vgId:%d, failed to read %s, vgCfgVersion not found", pVnode->vgId, file);
|
||||
goto PARSE_VCFG_ERROR;
|
||||
}
|
||||
vnodeMsg.cfg.vgCfgVersion = 0;
|
||||
} else {
|
||||
vnodeMsg.cfg.vgCfgVersion = vgCfgVersion->valueint;
|
||||
}
|
||||
|
||||
cJSON *cacheBlockSize = cJSON_GetObjectItem(root, "cacheBlockSize");
|
||||
if (!cacheBlockSize || cacheBlockSize->type != cJSON_Number) {
|
||||
|
|
Loading…
Reference in New Issue