refactor: review syncNodeRequestVotePeersSnapshot

This commit is contained in:
Minghao Li 2022-06-01 15:52:09 +08:00
parent 320f21820b
commit 403f6085d5
1 changed files with 5 additions and 1 deletions

View File

@ -1273,16 +1273,20 @@ int32_t syncNodeGetLastIndexTerm(SSyncNode* pSyncNode, SyncIndex* pLastIndex, Sy
} else if (logLastIndex == snapshotLastIndex) { } else if (logLastIndex == snapshotLastIndex) {
*pLastIndex = snapshotLastIndex; *pLastIndex = snapshotLastIndex;
*pLastTerm = snapshot.lastApplyTerm; *pLastTerm = snapshot.lastApplyTerm;
} else if (logLastIndex < snapshotLastIndex) {
// maybe wal is deleted
*pLastIndex = snapshotLastIndex;
*pLastTerm = snapshot.lastApplyTerm;
} else { } else {
ASSERT(0); ASSERT(0);
} }
return 0; return 0;
} }
// get pre index and term of "index" // get pre index and term of "index"
int32_t syncNodeGetPreIndexTerm(SSyncNode* pSyncNode, SyncIndex index, SyncIndex* pPreIndex, SyncTerm* pPreTerm) { int32_t syncNodeGetPreIndexTerm(SSyncNode* pSyncNode, SyncIndex index, SyncIndex* pPreIndex, SyncTerm* pPreTerm) {
ASSERT(index >= SYNC_INDEX_BEGIN); ASSERT(index >= SYNC_INDEX_BEGIN);
ASSERT(!syncNodeIsIndexInSnapshot(pSyncNode, index));
int ret = 0; int ret = 0;
SyncIndex preIndex = index - 1; SyncIndex preIndex = index - 1;