Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
98551: instancestorage: ensure that the cache goroutine shuts down gracefully r=ajwerner a=ajwerner

`(*stop.Stopper).AddCloser` registers a closer to be called after all async tasks have exited. The cache was running, waiting to be closed. We instead need to hook up its context to exit when the stopper is quiescing.

Epic: none

Release note: None

Co-authored-by: ajwerner <[email protected]>
  • Loading branch information
craig[bot] and ajwerner committed Mar 14, 2023
2 parents 19e5845 + 1e3c190 commit 0205bfe
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/sql/sqlinstance/instancestorage/instancereader.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,19 @@ func (r *Reader) Start(ctx context.Context, self sqlinstance.InstanceInfo) {
timestamp: hlc.Timestamp{}, // intentionally zero
},
})
// Make sure that the reader shuts down gracefully.
ctx, cancel := r.stopper.WithCancelOnQuiesce(ctx)
err := r.stopper.RunAsyncTask(ctx, "start-instance-reader", func(ctx context.Context) {
cache, err := r.storage.newInstanceCache(ctx)
if err != nil {
r.setInitialScanDone(err)
return
}
r.stopper.AddCloser(cache)
r.setCache(cache)
r.setInitialScanDone(nil)
})
if err != nil {
cancel()
r.setInitialScanDone(err)
}
}
Expand Down

0 comments on commit 0205bfe

Please sign in to comment.