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;
|
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) {
|
void mnodeCreateMnode(int32_t dnodeId, char *dnodeEp, bool needConfirm) {
|
||||||
SMnodeObj *pMnode = calloc(1, sizeof(SMnodeObj));
|
SMnodeObj *pMnode = calloc(1, sizeof(SMnodeObj));
|
||||||
pMnode->mnodeId = dnodeId;
|
pMnode->mnodeId = dnodeId;
|
||||||
|
@ -389,6 +407,11 @@ void mnodeCreateMnode(int32_t dnodeId, char *dnodeEp, bool needConfirm) {
|
||||||
.fpRsp = mnodeCreateMnodeCb
|
.fpRsp = mnodeCreateMnodeCb
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (needConfirm && !mnodeAllOnline()) {
|
||||||
|
mDebug("wait all mnode online then create new mnode");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
if (needConfirm) {
|
if (needConfirm) {
|
||||||
code = mnodeSendCreateMnodeMsg(dnodeId, dnodeEp);
|
code = mnodeSendCreateMnodeMsg(dnodeId, dnodeEp);
|
||||||
|
|
|
@ -715,12 +715,12 @@ static SSyncPeer *syncCheckMaster(SSyncNode *pNode) {
|
||||||
|
|
||||||
if (onlineNum <= replica * 0.5) {
|
if (onlineNum <= replica * 0.5) {
|
||||||
if (nodeRole != TAOS_SYNC_ROLE_UNSYNCED) {
|
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);
|
sInfo("vgId:%d, self keep work as master, online:%d replica:%d", pNode->vgId, onlineNum, replica);
|
||||||
} else {
|
} else {
|
||||||
nodeRole = TAOS_SYNC_ROLE_UNSYNCED;
|
nodeRole = TAOS_SYNC_ROLE_UNSYNCED;
|
||||||
sInfo("vgId:%d, self change to unsynced state, online:%d replica:%d", pNode->vgId, onlineNum, replica);
|
sInfo("vgId:%d, self change to unsynced state, online:%d replica:%d", pNode->vgId, onlineNum, replica);
|
||||||
}
|
}
|
||||||
(*pNode->notifyRole)(pNode->vgId, nodeRole);
|
(*pNode->notifyRole)(pNode->vgId, nodeRole);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -106,9 +106,10 @@ int32_t vnodeReadCfg(SVnodeObj *pVnode) {
|
||||||
cJSON *vgCfgVersion = cJSON_GetObjectItem(root, "vgCfgVersion");
|
cJSON *vgCfgVersion = cJSON_GetObjectItem(root, "vgCfgVersion");
|
||||||
if (!vgCfgVersion || vgCfgVersion->type != cJSON_Number) {
|
if (!vgCfgVersion || vgCfgVersion->type != cJSON_Number) {
|
||||||
vError("vgId:%d, failed to read %s, vgCfgVersion not found", pVnode->vgId, file);
|
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;
|
||||||
}
|
}
|
||||||
vnodeMsg.cfg.vgCfgVersion = vgCfgVersion->valueint;
|
|
||||||
|
|
||||||
cJSON *cacheBlockSize = cJSON_GetObjectItem(root, "cacheBlockSize");
|
cJSON *cacheBlockSize = cJSON_GetObjectItem(root, "cacheBlockSize");
|
||||||
if (!cacheBlockSize || cacheBlockSize->type != cJSON_Number) {
|
if (!cacheBlockSize || cacheBlockSize->type != cJSON_Number) {
|
||||||
|
|
Loading…
Reference in New Issue