Repository navigation
Commit c05b767
authored
fix(bigtable/internal/transport): drop redundant defer p.Close() in AFE picker tests (#20311)
## Summary
Four AFE picker tests in `session_pool_afe_test.go` each declared `defer
p.Close()` on a pool returned by `newTestPool`. That defer runs
**before** the `t.Cleanup` registered by `newTestPool`, which is
`closeStreams(); _ = p.Close()`. When `Tick` fires during the checkout
loop and spawns a fresh session via the stub factory, the new session's
readLoop parks on `fakeStream.Recv`. The test-body defer then calls
`p.Close()`, which waits on `p.spawns` for the `createSession`
goroutine, which waits on `Session.WaitGoroutines` for the readLoop —
but the readLoop only exits when `closeStreams` closes the recv channel,
and `closeStreams` is inside the `t.Cleanup` that hasn't run yet.
Deadlock; test hangs to timeout.
`newTestPool`'s `t.Cleanup` already runs `closeStreams` first, then
`Close`, in the correct order — the per-test `defer p.Close()` was
redundant and actively wrong. Dropping it fixes the deadlock.
Fixes #20308.
## Test plan
- [x] Reproduced the hang: `go test -run
'^TestPool_LeastInFlight_FansOutAcrossAFEs$' -count=50 -race
-timeout=45s` — passes iters 1–3, hangs on iter 4 with goroutine dump
showing `defer p.Close()` → `p.spawns.Wait()` → stuck on
`Session.WaitGoroutines` → stuck on `fakeStream.Recv`.
- [x] Verified fix: same command with `-count=200 -race -timeout=90s` —
passes in ~3s.
- [x] `go test -count=1 -timeout=60s ./bigtable/internal/transport/...`
— full transport suite green.1 parent 5c49ac3 commit c05b767
1 file changed
Lines changed: 0 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
77 | | - | |
78 | 77 | | |
79 | 78 | | |
80 | 79 | | |
| |||
104 | 103 | | |
105 | 104 | | |
106 | 105 | | |
107 | | - | |
108 | 106 | | |
109 | 107 | | |
110 | 108 | | |
| |||
142 | 140 | | |
143 | 141 | | |
144 | 142 | | |
145 | | - | |
146 | 143 | | |
147 | 144 | | |
148 | 145 | | |
| |||
191 | 188 | | |
192 | 189 | | |
193 | 190 | | |
194 | | - | |
195 | 191 | | |
196 | 192 | | |
197 | 193 | | |
| |||
0 commit comments