You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// checkLeaderLease is used to check if we can contact a quorum of nodes// within the last leader lease interval. If not, we need to step down,// as we may have lost connectivity. Returns the maximum duration without// contact. This must only be called from the main thread.func (r*Raft) checkLeaderLease() time.Duration {
// Track contacted nodes, we can always contact ourselfcontacted:=0// Store lease timeout for this one check invocation as we need to refer to it// in the loop and would be confusing if it ever becomes reloadable and// changes between iterations below.leaseTimeout:=r.config().LeaderLeaseTimeout// Check each followervarmaxDiff time.Durationnow:=time.Now()
for_, server:=ranger.configurations.latest.Servers {
ifserver.Suffrage==Voter {
ifserver.ID==r.localID {
contacted++continue
}
f:=r.leaderState.replState[server.ID]
diff:=now.Sub(f.LastContact())
ifdiff<=leaseTimeout {
contacted++ifdiff>maxDiff {
maxDiff=diff
}
} else {
// Log at least once at high value, then debug. Otherwise it gets very verbose.ifdiff<=3*leaseTimeout {
r.logger.Warn("failed to contact", "server-id", server.ID, "time", diff)
} else {
r.logger.Debug("failed to contact", "server-id", server.ID, "time", diff)
}
}
metrics.AddSample([]string{"raft", "leader", "lastContact"}, float32(diff/time.Millisecond))
}
}
// Verify we can contact a quorumquorum:=r.quorumSize()
ifcontacted<quorum {
r.logger.Warn("failed to contact quorum of nodes, stepping down")
//some questions here <----------------------r.setState(Follower)
metrics.IncrCounter([]string{"raft", "transition", "leader_lease_timeout"}, 1)
}
returnmaxDiff
}
As shown in the image below, in some cases, the leader does not need to step down .but here he has stepped down
The text was updated successfully, but these errors were encountered:
Why are LeaderLeadseTimeout and ElectTimeout inconsistent?, the source code here:
raft/raft.go
Line 937 in 8f99c15
As shown in the image below, in some cases, the leader does not need to step down .but here he has stepped down
The text was updated successfully, but these errors were encountered: