Commit d7d8279
Identify pooled connections by pointer instead of backend PID
PostgreSQL can assign a terminated backend's PID to a new backend, so a PID does not uniquely identify a connection
over time. PID reuse is common on the Windows CI runners, where it made these tests fail:
TestPoolAcquireChecksIdleConns: []uint32{0xd48, 0x23bc, 0x1738} should not contain 0x1738
TestPoolAfterRelease: expected: 5, actual: 4
Compare *pgx.Conn pointers instead. TestPoolAfterRelease keeps them in a map, which also retains the destroyed
connections so their addresses cannot be reused either. TestPoolAcquireChecksIdleConns still needs the PIDs to call
pg_terminate_backend().
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent 4aafe91 commit d7d8279
2 files changed
Lines changed: 31 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
176 | 176 | | |
177 | 177 | | |
178 | 178 | | |
| 179 | + | |
179 | 180 | | |
180 | 181 | | |
| 182 | + | |
181 | 183 | | |
182 | 184 | | |
183 | 185 | | |
| |||
199 | 201 | | |
200 | 202 | | |
201 | 203 | | |
202 | | - | |
| 204 | + | |
203 | 205 | | |
204 | 206 | | |
205 | | - | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
206 | 212 | | |
207 | 213 | | |
208 | 214 | | |
| |||
477 | 483 | | |
478 | 484 | | |
479 | 485 | | |
480 | | - | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
481 | 490 | | |
482 | 491 | | |
483 | 492 | | |
484 | 493 | | |
485 | | - | |
| 494 | + | |
486 | 495 | | |
487 | 496 | | |
488 | 497 | | |
489 | 498 | | |
490 | | - | |
| 499 | + | |
491 | 500 | | |
492 | 501 | | |
493 | 502 | | |
| |||
1405 | 1414 | | |
1406 | 1415 | | |
1407 | 1416 | | |
1408 | | - | |
1409 | | - | |
| 1417 | + | |
| 1418 | + | |
1410 | 1419 | | |
1411 | | - | |
1412 | | - | |
1413 | | - | |
1414 | | - | |
| 1420 | + | |
1415 | 1421 | | |
1416 | 1422 | | |
1417 | 1423 | | |
| |||
1425 | 1431 | | |
1426 | 1432 | | |
1427 | 1433 | | |
1428 | | - | |
1429 | | - | |
| 1434 | + | |
1430 | 1435 | | |
1431 | 1436 | | |
1432 | 1437 | | |
1433 | 1438 | | |
1434 | 1439 | | |
1435 | 1440 | | |
1436 | 1441 | | |
1437 | | - | |
| 1442 | + | |
1438 | 1443 | | |
1439 | 1444 | | |
1440 | 1445 | | |
1441 | 1446 | | |
1442 | 1447 | | |
1443 | | - | |
| 1448 | + | |
1444 | 1449 | | |
1445 | 1450 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1328 | 1328 | | |
1329 | 1329 | | |
1330 | 1330 | | |
| 1331 | + | |
1331 | 1332 | | |
1332 | 1333 | | |
1333 | | - | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
1334 | 1337 | | |
1335 | 1338 | | |
1336 | 1339 | | |
| |||
1359 | 1362 | | |
1360 | 1363 | | |
1361 | 1364 | | |
1362 | | - | |
| 1365 | + | |
1363 | 1366 | | |
1364 | | - | |
| 1367 | + | |
1365 | 1368 | | |
1366 | 1369 | | |
1367 | 1370 | | |
1368 | 1371 | | |
1369 | 1372 | | |
1370 | 1373 | | |
1371 | | - | |
| 1374 | + | |
| 1375 | + | |
| 1376 | + | |
| 1377 | + | |
| 1378 | + | |
1372 | 1379 | | |
1373 | 1380 | | |
1374 | 1381 | | |
| |||
0 commit comments