Skip to content

Commit

Permalink
Merge pull request nats-io#3446 from nats-io/leaderless-tweak
Browse files Browse the repository at this point in the history
Tweak lost quorum reporting
  • Loading branch information
derekcollison authored Sep 7, 2022
2 parents e3e092d + b86e941 commit dcd3162
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions server/jetstream_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -690,16 +690,26 @@ func (js *jetStream) isGroupLeaderless(rg *raftGroup) bool {
// If we don't have a leader.
if rg.node.GroupLeader() == _EMPTY_ {
// Threshold for jetstream startup.
const startupThreshold = 2 * time.Second
const startupThreshold = 5 * time.Second
// Minimum threshold for lost quorom reporting.
const minLostThreshold = 3 * time.Second

if rg.node.HadPreviousLeader() {
// Make sure we have been running long enough to intelligently determine this.
if time.Since(js.started) > startupThreshold {
return true
} else {
return false
}
}

// Set to lower threshold
lqThreshold := lostQuorumInterval
if lqThreshold < minLostThreshold {
lqThreshold = minLostThreshold
}
// Make sure we have been running for enough time.
if time.Since(rg.node.Created()) > lostQuorumInterval {
if time.Since(rg.node.Created()) > lqThreshold {
return true
}
}
Expand Down

0 comments on commit dcd3162

Please sign in to comment.