Skip to content

Commit

Permalink
Merge #74556
Browse files Browse the repository at this point in the history
74556: kv: Cancel range cache lookup when shutting down. r=miretskiy a=miretskiy

Use stopper `WithCancelOnQuiesce` as a context when performing
rangecache lookup.

The primary motivation for this change is to speed up tests
which maybe stuck for 10 seconds waiting for timeout instead of
terminating upon server shutdown.

Release Notes: None

Co-authored-by: Yevgeniy Miretskiy <[email protected]>
  • Loading branch information
craig[bot] and Yevgeniy Miretskiy committed Jan 7, 2022
2 parents f377f02 + fb4d62d commit e73cce6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/kv/kvclient/rangecache/range_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,9 @@ func (rc *RangeCache) tryLookup(
// Clear the context's cancelation. This request services potentially many
// callers waiting for its result, and using the flight's leader's
// cancelation doesn't make sense.
ctx = logtags.WithTags(context.Background(), logtags.FromContext(ctx))
ctx, cancel := rc.stopper.WithCancelOnQuiesce(
logtags.WithTags(context.Background(), logtags.FromContext(ctx)))
defer cancel()
ctx = tracing.ContextWithSpan(ctx, reqSpan)

// Since we don't inherit any other cancelation, let's put in a generous
Expand Down

0 comments on commit e73cce6

Please sign in to comment.