fix(sync) add multi mnodes

This commit is contained in:
Minghao Li 2022-05-26 18:03:38 +08:00
parent 14c95a0b31
commit 1a22de765c
2 changed files with 24 additions and 17 deletions

View File

@ -363,28 +363,32 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) {
break; break;
} }
} }
ASSERT(hit == true);
SReConfigCbMeta cbMeta = {0};
bool isDrop; bool isDrop;
syncNodeUpdateConfig(ths, &newSyncCfg, &isDrop);
// change isStandBy to normal // I am in newConfig
if (!isDrop) { if (hit) {
if (ths->state == TAOS_SYNC_STATE_LEADER) { syncNodeUpdateConfig(ths, &newSyncCfg, &isDrop);
syncNodeBecomeLeader(ths);
} else { // change isStandBy to normal
syncNodeBecomeFollower(ths); if (!isDrop) {
if (ths->state == TAOS_SYNC_STATE_LEADER) {
syncNodeBecomeLeader(ths);
} else {
syncNodeBecomeFollower(ths);
}
} }
char* sOld = syncCfg2Str(&oldSyncCfg);
char* sNew = syncCfg2Str(&newSyncCfg);
sInfo("==config change== 0x11 old:%s new:%s isDrop:%d \n", sOld, sNew, isDrop);
taosMemoryFree(sOld);
taosMemoryFree(sNew);
} }
char* sOld = syncCfg2Str(&oldSyncCfg); // always call FpReConfigCb
char* sNew = syncCfg2Str(&newSyncCfg);
sInfo("==config change== 0x11 old:%s new:%s isDrop:%d \n", sOld, sNew, isDrop);
taosMemoryFree(sOld);
taosMemoryFree(sNew);
if (ths->pFsm->FpReConfigCb != NULL) { if (ths->pFsm->FpReConfigCb != NULL) {
SReConfigCbMeta cbMeta = {0};
cbMeta.code = 0; cbMeta.code = 0;
cbMeta.currentTerm = ths->pRaftStore->currentTerm; cbMeta.currentTerm = ths->pRaftStore->currentTerm;
cbMeta.index = pEntry->index; cbMeta.index = pEntry->index;

View File

@ -141,7 +141,10 @@ void syncMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) {
break; break;
} }
} }
ASSERT(hit == true);
if (pSyncNode->state == TAOS_SYNC_STATE_LEADER) {
ASSERT(hit == true);
}
bool isDrop; bool isDrop;
syncNodeUpdateConfig(pSyncNode, &newSyncCfg, &isDrop); syncNodeUpdateConfig(pSyncNode, &newSyncCfg, &isDrop);