Skip to content

Commit

Permalink
kvserver: fix datarace in TestStrictGCEnforcement
Browse files Browse the repository at this point in the history
Fix race introduced in cockroachdb#77478.

Release justification: non-production code changes
Release note: None
  • Loading branch information
arulajmani committed Mar 14, 2022
1 parent f764959 commit d6d9d3d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pkg/kv/kvserver/client_replica_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3656,17 +3656,18 @@ func TestStrictGCEnforcement(t *testing.T) {
t.Run("protected timestamps are respected", func(t *testing.T) {
// Block the KVSubscriber rangefeed from progressing.
blockKVSubscriberCh := make(chan struct{})
var isBlocked bool
var isBlocked syncutil.AtomicBool
isBlocked.Set(false)
mu.Lock()
mu.blockOnTimestampUpdate = func() {
isBlocked = true
isBlocked.Set(true)
<-blockKVSubscriberCh
}
mu.Unlock()

// Ensure that the KVSubscriber has been blocked.
testutils.SucceedsSoon(t, func() error {
if !isBlocked {
if !isBlocked.Get() {
return errors.New("kvsubscriber not blocked yet")
}
return nil
Expand Down

0 comments on commit d6d9d3d

Please sign in to comment.