Skip to content

Commit

Permalink
Merge #93363
Browse files Browse the repository at this point in the history
93363: kvserver: minor test cleanup r=andreimatei a=andreimatei

See individual commits.

Co-authored-by: Andrei Matei <[email protected]>
  • Loading branch information
craig[bot] and andreimatei committed Dec 14, 2022
2 parents 9aca4bf + ac3e298 commit dc9cfae
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions pkg/kv/kvserver/consistency_queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -542,25 +542,26 @@ func testConsistencyQueueRecomputeStatsImpl(t *testing.T, hadEstimates bool) {
// RecomputeStats does not see any skew in its MVCC stats when they are
// modified concurrently. Note that these writes don't interfere with the
// field we modified (SysCount).
//
// We want to run this task under the cluster's stopper, as opposed to the
// first node's stopper, so that the quiesce signal is delivered below before
// individual nodes start shutting down.
_ = tc.Stopper().RunAsyncTaskEx(ctx,
stop.TaskOpts{
TaskName: "recompute-loop",
// We want to run this task under the cluster's stopper, so that the
// quiesce signal is delivered below before individual nodes start
// shutting down. Since we're going to operate on a specific node, we
// can't mix the cluster stopper's tracer with the node's tracer, hence
// the Sterile option.
SpanOpt: stop.SterileRootSpan,
}, func(ctx context.Context) {
}, func(_ context.Context) {
// This channel terminates the loop early if the test takes more than five
// seconds. This is useful for stress race runs in CI where the tight loop
// can starve the actual work to be done.
done := time.After(5 * time.Second)
for {
require.NoError(t, db0.Put(ctx, fmt.Sprintf("%s%d", key, rand.Int63()), "ballast"))
// We're using context.Background for the KV call. As explained above,
// this task runs on the cluster's stopper, and so the ctx that was
// passed to this function has a span created with a Tracer that's
// different from the first node's Tracer. If we used the ctx, we'd be
// combining Tracers in the trace, which is illegal.
require.NoError(t, db0.Put(context.Background(), fmt.Sprintf("%s%d", key, rand.Int63()), "ballast"))
select {
case <-ctx.Done():
return
case <-tc.Stopper().ShouldQuiesce():
return
case <-done:
Expand Down

0 comments on commit dc9cfae

Please sign in to comment.