Skip to content

Commit a02f809

Browse files
committed
test: avoid data race
1 parent 4613c40 commit a02f809

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

modules/globallock/locker_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ func TestLocker(t *testing.T) {
2929
oldExpiry := redisLockExpiry
3030
redisLockExpiry = 5 * time.Second // make it shorter for testing
3131
defer func() {
32+
// Avoid data race.
33+
// The startExtend goroutine may still be running and reading redisLockExpiry.
34+
// Wait for a while since it will be stopped soon after Close is called.
35+
time.Sleep(time.Second)
36+
3237
redisLockExpiry = oldExpiry
3338
}()
3439

0 commit comments

Comments
 (0)