Skip to content

Commit cdd3670

Browse files
committed
admission: ensure GetPebbleMetrics is not called after StoreGrantCoordinators.close
Fixes #140454, #144172 Epic: none Release note: None
1 parent 1c5f235 commit cdd3670

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

pkg/util/admission/grant_coordinator.go

+8
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,14 @@ func (sgc *StoreGrantCoordinators) TryGetSnapshotQueueForStore(storeID roachpb.S
276276
func (sgc *StoreGrantCoordinators) close() {
277277
// closeCh can be nil in tests that never called SetPebbleMetricsProvider.
278278
if sgc.closeCh != nil {
279+
// Ensure that the goroutine has observed the close and will no longer
280+
// call GetPebbleMetrics, since the engines will be closed soon after this
281+
// method returns, and calling GetPebbleMetrics on closed engines is not
282+
// permitted.
283+
sgc.closeCh <- struct{}{}
284+
// Close the channel, so that if close gets called twice due to a bug,
285+
// sending on the closed channel will panic instead of the send being
286+
// blocked forever.
279287
close(sgc.closeCh)
280288
}
281289

0 commit comments

Comments
 (0)