Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
server: fix flaky drain test under race
While previously `TestDrain` would issue a drain request twice, and expect that after the second drain request there would be no remaining leases, we have seen in some race builds that a lease extension can occur before that second drain, leaving one lease remaining after the second drain request. This can be seen in the following log example: ``` I230325 00:39:18.151604 14728 1@server/drain.go:145 ⋮ [T1,n1] 383 drain request received with doDrain = true, shutdown = false ... I230325 00:39:18.155547 986 kv/kvserver/replica_proposal.go:272 ⋮ [T1,n1,s1,r51/1:‹/Table/5{0-1}›,raft] 385 new range lease repl=(n1,s1):1 seq=1 start=0,0 exp=1679704764.152223164,0 pro=1679704758.152223164,0 following repl=(n1,s1):1 seq=1 start=0,0 exp=1679704746.135729956,0 pro=1679704740.135729956,0 I230325 00:39:18.172450 14728 1@server/drain.go:399 ⋮ [T1,n1] 386 (DEBUG) initiating kvserver node drain I230325 00:39:18.172613 14728 1@kv/kvserver/store.go:1559 ⋮ [T1,drain,n1,s1] 387 (DEBUG) store marked as draining I230325 00:39:18.182123 14728 1@server/drain.go:293 ⋮ [T1,n1] 388 drain remaining: 1 I230325 00:39:18.182249 14728 1@server/drain.go:295 ⋮ [T1,n1] 389 drain details: range lease iterations: 1 I230325 00:39:18.182404 14728 1@server/drain.go:175 ⋮ [T1,n1] 390 drain request completed without server shutdown ``` This change modifies the test to repeatedly issue drain requests until there is no remaining work, allowing the drain to complete upon subsequent requests. Fixes: cockroachdb#86974 Release note: None
- Loading branch information