diff --git a/source/libs/sync/inc/syncInt.h b/source/libs/sync/inc/syncInt.h index dba2266285b33ba4b3e56548e62d7c5a75827998..10218f69e6a7b1e7dedba0837340595bfad69a8d 100644 --- a/source/libs/sync/inc/syncInt.h +++ b/source/libs/sync/inc/syncInt.h @@ -58,6 +58,8 @@ typedef struct SSyncRespMgr SSyncRespMgr; typedef struct SSyncSnapshotSender SSyncSnapshotSender; typedef struct SSyncSnapshotReceiver SSyncSnapshotReceiver; +extern bool gRaftDetailLog; + typedef struct SSyncNode { // init by SSyncInfo SyncGroupId vgId; diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index d549e3bd9d52679904f802c0f3f6eb43a8a427bd..fe4ff61aad6d223949f9a420a45d144505fe83bc 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -35,6 +35,8 @@ #include "syncVoteMgr.h" #include "tref.h" +bool gRaftDetailLog = false; + static int32_t tsNodeRefId = -1; // ------ local funciton --------- @@ -1203,6 +1205,16 @@ void syncNodeBecomeLeader(SSyncNode* pSyncNode) { pSyncNode->pMatchIndex->index[i] = SYNC_INDEX_INVALID; } + // update sender private term + SSyncSnapshotSender* pMySender = syncNodeGetSnapshotSender(pSyncNode, &(pSyncNode->myRaftId)); + ASSERT(pMySender != NULL); + for (int i = 0; i < pSyncNode->pMatchIndex->replicaNum; ++i) { + if ((pSyncNode->senders)[i]->privateTerm > pMySender->privateTerm) { + pMySender->privateTerm = (pSyncNode->senders)[i]->privateTerm; + } + } + (pMySender->privateTerm) += 100; + // stop elect timer syncNodeStopElectTimer(pSyncNode);