Skip to content

Commit

Permalink
Merge branch 'master' into shortest_path
Browse files Browse the repository at this point in the history
  • Loading branch information
nevermore3 authored Jun 1, 2022
2 parents 644281a + 1ee34dd commit d5b887d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/kvstore/raftex/RaftPart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,15 @@ const char* RaftPart::roleStr(Role role) const {
void RaftPart::start(std::vector<HostAddr>&& peers, bool asLearner) {
std::lock_guard<std::mutex> g(raftLock_);

// There are some rare cases that the part start as learner, but wal is not empty. For example,
// the node is dead, and one partition is removed from raft group (majority still alive). However,
// the part is added back to raft group again as learner. So the wal may be not empty, what is
// worse, there could be case that commitLogId is 0, but wal's lastLogId is not 0, which is
// obviously not expected
if (asLearner) {
wal_->reset();
}

lastLogId_ = wal_->lastLogId();
lastLogTerm_ = wal_->lastLogTerm();
term_ = lastLogTerm_;
Expand Down
1 change: 1 addition & 0 deletions src/kvstore/wal/FileBasedWal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,7 @@ bool FileBasedWal::reset() {
unlink(absFn.c_str());
}
lastLogId_ = firstLogId_ = 0;
lastLogTerm_ = 0;
return true;
}

Expand Down

0 comments on commit d5b887d

Please sign in to comment.