Commit 36e9a79
committed
close shared pool before goleak
CI intermittently failed in `test/race` with a `goleak` report for
`github.com/jackc/pgx/v5/pgconn/internal/bgreader.(*BGReader).bgRead`:
goleak: Errors on successful test run: found unexpected goroutines:
[Goroutine ... with github.com/jackc/pgx/v5/pgconn/internal/bgreader.(*BGReader).bgRead on top of the stack ...]
created by github.com/jackc/pgx/v5/pgconn/internal/bgreader.(*BGReader).Start
Failing run:
https://github.com/riverqueue/river/actions/runs/23095300730/job/67086685003
That stack does not point to a River-managed goroutine. It means a pgx
connection was still open when leak checking ran. In our test helpers,
the shared Postgres pool was intentionally kept alive until process
exit, but `goleak.Find` runs before exit. That allowed idle pgx
background reader goroutines to still be blocked in socket reads during
teardown even when package tests had otherwise finished cleanly.
Fix this by explicitly closing the shared test pool before running
`goleak.Find` in the shared `TestMain` wrapper. Internal tests now
reuse that shared wrapper directly so there is only one leak-checking
path to maintain. This addresses the flake at its source and keeps
`goleak` useful, rather than globally ignoring all `bgRead`
goroutines and potentially hiding real connection leaks.1 parent 8da91e9 commit 36e9a79
2 files changed
Lines changed: 4 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | | - | |
8 | 6 | | |
9 | 7 | | |
10 | 8 | | |
11 | 9 | | |
12 | | - | |
13 | | - | |
14 | 10 | | |
15 | 11 | | |
16 | 12 | | |
| |||
103 | 99 | | |
104 | 100 | | |
105 | 101 | | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
| 102 | + | |
116 | 103 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
356 | 356 | | |
357 | 357 | | |
358 | 358 | | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
359 | 362 | | |
360 | 363 | | |
361 | 364 | | |
| |||
0 commit comments