Skip to content

Commit

Permalink
Merge #136785
Browse files Browse the repository at this point in the history
136785: sql: fix a race in TestShowTenantFingerprintsProtectsTimestamp r=yuzefovich a=yuzefovich

I think there is a possible race in `TestShowTenantFingerprintsProtectsTimestamp` where we have an atomic to make sure that we close the channel only once. If we have concurrent BatchRequests checking the `if` condition at the same time, both will try to close the channel leading to a panic. Switch to using compare-and-swap instead of load plus store.

Fixes: #136711.

Release note: None

Co-authored-by: Yahor Yuzefovich <[email protected]>
  • Loading branch information
craig[bot] and yuzefovich committed Dec 9, 2024
2 parents 128c952 + 4f90d59 commit a247ae5
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions pkg/sql/show_fingerprints_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,7 @@ func TestShowTenantFingerprintsProtectsTimestamp(t *testing.T) {
testingRequestFilter := func(_ context.Context, ba *kvpb.BatchRequest) *kvpb.Error {
for _, req := range ba.Requests {
if expReq := req.GetExport(); expReq != nil {
if expReq.ExportFingerprint && !exportStartedClosed.Load() {
exportStartedClosed.Store(true)
if expReq.ExportFingerprint && exportStartedClosed.CompareAndSwap(false, true) {
close(exportsStarted)
<-exportsResume
}
Expand Down

0 comments on commit a247ae5

Please sign in to comment.