Commit 2d90d3e
committed
fix(Postgres): validate-on-checkout, mirror MsSql pool behaviour
The 1.9.49 retry-on-bad-conn was insufficient: after a postgres
restart the pool typically holds many dead connections, so the first
op fails (caught), AcquireAsync hands out ANOTHER dead one for the
retry, and that second op also fails. Result: every request still
errors with 'terminating connection due to administrator command',
and the only fix is to restart the consuming process.
Verified against a live restart on a production VPS — all six
post-restart probes returned HTTP 500.
Add validate-on-checkout, matching the MsSqlConnectionPool design:
AcquireAsync now loops over idle connections, runs a quick SELECT 1
liveness probe, discards any that fail, and only returns a connection
that successfully responded. If the pool is empty after discards, a
fresh connection is opened. PostgresConnection.IsOpen alone is not
sufficient — it stays true even after the backend kills the socket.
Combined with the WithRetryAsync wrapper from 1.9.49, the pool now
self-heals after a backend restart with zero caller intervention.
Bump version to 1.9.51.1 parent 12ede72 commit 2d90d3e
2 files changed
Lines changed: 49 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
17 | | - | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
18 | 22 | | |
19 | 23 | | |
20 | 24 | | |
| |||
24 | 28 | | |
25 | 29 | | |
26 | 30 | | |
| 31 | + | |
27 | 32 | | |
28 | 33 | | |
29 | 34 | | |
30 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
31 | 48 | | |
32 | 49 | | |
33 | 50 | | |
34 | 51 | | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
| 52 | + | |
40 | 53 | | |
41 | | - | |
| 54 | + | |
42 | 55 | | |
43 | | - | |
44 | | - | |
45 | | - | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
46 | 62 | | |
47 | | - | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
48 | 66 | | |
49 | | - | |
50 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
51 | 78 | | |
52 | | - | |
53 | 79 | | |
54 | | - | |
55 | | - | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
56 | 88 | | |
57 | 89 | | |
58 | 90 | | |
| |||
0 commit comments