Skip to content

Commit

Permalink
Merge pull request #129 from jingyichen1223/ISSUE-121
Browse files Browse the repository at this point in the history
ISSUE-121: fix issue
  • Loading branch information
jingyichen1223 authored Apr 15, 2024
2 parents 7d1c44c + 99c5bfb commit b92542a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/infra/raft/v2/RaftCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -644,9 +644,13 @@ void RaftCore::handleAppendEntriesResponse(const AppendEntries::Response &respon
assert(peer.mMatchIndex + 1 < peer.mNextIndex);

if (response.last_log_index() < mLog->getFirstLogIndex()) {
// reset peer.mNextIndex until peer's data is recovered.
auto prevNextIndex = peer.mNextIndex;
peer.mNextIndex = mLog->getLastLogIndex() + 1;
if (response.last_log_index() == 0 && mLog->getFirstLogIndex() == 1) {
peer.mNextIndex = response.last_log_index() + 1;
} else {
// reset peer.mNextIndex until peer's data is recovered.
peer.mNextIndex = mLog->getLastLogIndex() + 1;
}
SPDLOG_WARN("There is gap between Follower {} lastLogIndex({}) and {} firstLogIndex({})",
response.id(), response.last_log_index(), selfId(), mLog->getFirstLogIndex());
SPDLOG_INFO("{} reset Follower {}: nextIndex from {} to {}",
Expand Down

0 comments on commit b92542a

Please sign in to comment.