Skip to content

Commit

Permalink
Merge #98150
Browse files Browse the repository at this point in the history
98150: kv: don't gossip node liveness on lease extensions r=erikgrinaker a=nvanbenschoten

Informs: #97966

Before this change, we would gossip the entire node liveness range on each liveness lease extension (every few seconds). In cases where the liveness range is full of garbage, we have seen that this can be expensive.

This change updates the post-lease change hook to only gossip all liveness records on lease changes, never on lease extensions. This is possible because there is no risk of lost incremental liveness updates on lease extensions.

Release note: None

Co-authored-by: Nathan VanBenschoten <[email protected]>
  • Loading branch information
craig[bot] and nvanbenschoten committed Mar 8, 2023
2 parents 0fda198 + 1711028 commit 574ded4
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions pkg/kv/kvserver/replica_proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -430,14 +430,13 @@ func (r *Replica) leasePostApplyLocked(
}
}

// Potentially re-gossip if the range contains system data (e.g. system
// config or node liveness). We need to perform this gossip at startup as
// soon as possible. Trying to minimize how often we gossip is a fool's
// errand. The node liveness info will be gossiped frequently (every few
// seconds) in any case due to the liveness heartbeats. And the system config
// will be gossiped rarely because it falls on a range with an epoch-based
// range lease that is only reacquired extremely infrequently.
if iAmTheLeaseHolder {
// Potentially re-gossip if the range contains node liveness data. We need to
// perform this gossip at startup as soon as possible. We also need to perform
// this gossip if we're taking over after a leaseholder failure. In both cases,
// incremental liveness updates may have been lost, so we want to make sure that
// the latest view of node liveness ends up in gossip.
nls := keys.NodeLivenessSpan
if leaseChangingHands && iAmTheLeaseHolder && kvserverbase.ContainsKeyRange(r.descRLocked(), nls.Key, nls.EndKey) {
// NB: run these in an async task to keep them out of the critical section
// (r.mu is held here).
_ = r.store.stopper.RunAsyncTask(r.AnnotateCtx(context.Background()), "lease-triggers", func(ctx context.Context) {
Expand Down

0 comments on commit 574ded4

Please sign in to comment.