Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6405167

Browse files
raft lease is always valid when replica is one Synchronize storage 2.0 pr 69 (vesoft-inc#2276)
Co-authored-by: dangleptr <[email protected]>
1 parent 703fb0a commit 6405167

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/kvstore/raftex/RaftPart.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1876,6 +1876,10 @@ void RaftPart::checkAndResetPeers(const std::vector<HostAddr>& peers) {
18761876
}
18771877

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

0 commit comments

Comments
 (0)