Commit 91521cd
fix: drain idle connections when a broken connection is detected
When one connection to the dqlite server is found to be broken (e.g.,
after a leader change or server restart), other idle connections in
the pool are likely stale too — they point to the same server.
Previously, only the single broken connection was discarded. Other
idle connections would be handed out and fail one-by-one, each
requiring a full leader discovery + reconnect cycle. In a pool of
size N, this caused N-1 unnecessary failures after a leader change.
Add _drain_idle() which closes all idle connections in the queue.
Call it whenever a broken connection is detected — both at checkout
(dead connection replacement) and during use (connection invalidated
by execute/fetch error handlers). Subsequent acquire() calls create
fresh connections via leader discovery to the new leader.
Closes #093 (Phase 1: bulk invalidation)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 1386afe commit 91521cd
2 files changed
+63
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
76 | 92 | | |
77 | 93 | | |
78 | 94 | | |
| |||
113 | 129 | | |
114 | 130 | | |
115 | 131 | | |
116 | | - | |
| 132 | + | |
| 133 | + | |
117 | 134 | | |
| 135 | + | |
118 | 136 | | |
119 | 137 | | |
120 | 138 | | |
| |||
134 | 152 | | |
135 | 153 | | |
136 | 154 | | |
| 155 | + | |
| 156 | + | |
137 | 157 | | |
138 | 158 | | |
139 | 159 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
342 | 342 | | |
343 | 343 | | |
344 | 344 | | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
345 | 387 | | |
346 | 388 | | |
347 | 389 | | |
| |||
0 commit comments