Skip to content

Commit 58bf21e

Browse files
committed
kvserver: deflake TestLeaseTransferReplicatesLocks
If the Txn closure retries for some reason, this test would fail with a close-of-closed-channel panic. I've been unable to reproduce this to better describe why this transaction might see a retry. Epic: none Release note: None
1 parent d59016c commit 58bf21e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

pkg/kv/kvserver/client_replica_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5809,6 +5809,7 @@ func TestLeaseTransferReplicatesLocks(t *testing.T) {
58095809
txn2StartedOnce := sync.OnceFunc(func() { close(txn2Started) })
58105810
txn2Done := make(chan struct{})
58115811
txn1HasLock := make(chan struct{})
5812+
txn1HasLockOnce := sync.OnceFunc(func() { close(txn1HasLock) })
58125813

58135814
g := ctxgroup.WithContext(ctx)
58145815
g.Go(func() error {
@@ -5817,7 +5818,7 @@ func TestLeaseTransferReplicatesLocks(t *testing.T) {
58175818
if err != nil {
58185819
return err
58195820
}
5820-
close(txn1HasLock)
5821+
txn1HasLockOnce()
58215822
t.Log("txn1: lock acquired, waiting for txn2 cancellation")
58225823
<-txn2Done
58235824
t.Log("txn1: done")

0 commit comments

Comments
 (0)