Skip to content

Commit

Permalink
raft lease is always valid when replica is one Synchronize storage 2.…
Browse files Browse the repository at this point in the history
…0 pr 69 (#2276)

Co-authored-by: dangleptr <37216992+dangleptr@users.noreply.github.com>
  • Loading branch information
panda-sheep and dangleptr authored Aug 6, 2020
1 parent 703fb0a commit 6405167
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/kvstore/raftex/RaftPart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1876,6 +1876,10 @@ void RaftPart::checkAndResetPeers(const std::vector<HostAddr>& peers) {
}

bool RaftPart::leaseValid() {
std::lock_guard<std::mutex> g(raftLock_);
if (hosts_.empty()) {
return true;
}
// When majority has accepted a log, leader obtains a lease which last for heartbeat.
// However, we need to take off the net io time. On the left side of the inequality is
// the time duration since last time leader send a log (the log has been accepted as well)
Expand Down

0 comments on commit 6405167

Please sign in to comment.