Commit 11bc00a
feat(client): bound the connect dial and handshake separately
A steady-state operation may legitimately wait a long time for a large or
slow response; establishing a connection may not. The pool salvages a
connection whose operation just failed by calling connect() through
reconnect(), and behind a proxy that accepts instantly while its backend
is unreachable, the dial always "succeeds" — the first SCRAM reply is
what stalls. That salvage attempt then cost a second full receive timeout
on top of the failure it was recovering from: a 10s operation deadline
produced a measured 21.8s outage per dead pooled connection.
The new connectTimeout bounds both the TCP dial and the handshake
receives, and only those: the flag arming the shorter deadline is scoped
to connect() with a finally, so a slow first real query never inherits it
and a failed handshake never leaves it armed on a reused client. Defaults
to $timeout, so existing callers keep their behaviour.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>1 parent 78818fd commit 11bc00a
2 files changed
Lines changed: 137 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
61 | 83 | | |
62 | 84 | | |
63 | 85 | | |
| |||
157 | 179 | | |
158 | 180 | | |
159 | 181 | | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
160 | 187 | | |
161 | 188 | | |
162 | 189 | | |
| |||
169 | 196 | | |
170 | 197 | | |
171 | 198 | | |
172 | | - | |
| 199 | + | |
| 200 | + | |
173 | 201 | | |
174 | 202 | | |
175 | 203 | | |
| |||
189 | 217 | | |
190 | 218 | | |
191 | 219 | | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
192 | 223 | | |
193 | 224 | | |
194 | 225 | | |
195 | 226 | | |
196 | 227 | | |
197 | 228 | | |
| 229 | + | |
198 | 230 | | |
199 | 231 | | |
200 | 232 | | |
| |||
259 | 291 | | |
260 | 292 | | |
261 | 293 | | |
262 | | - | |
| 294 | + | |
| 295 | + | |
263 | 296 | | |
264 | 297 | | |
265 | 298 | | |
266 | 299 | | |
267 | 300 | | |
268 | 301 | | |
269 | | - | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
270 | 306 | | |
271 | | - | |
| 307 | + | |
| 308 | + | |
272 | 309 | | |
273 | | - | |
| 310 | + | |
274 | 311 | | |
275 | | - | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
276 | 321 | | |
277 | 322 | | |
278 | 323 | | |
| |||
475 | 520 | | |
476 | 521 | | |
477 | 522 | | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
478 | 533 | | |
479 | 534 | | |
480 | 535 | | |
| |||
495 | 550 | | |
496 | 551 | | |
497 | 552 | | |
498 | | - | |
| 553 | + | |
499 | 554 | | |
500 | 555 | | |
501 | 556 | | |
| |||
540 | 595 | | |
541 | 596 | | |
542 | 597 | | |
543 | | - | |
| 598 | + | |
544 | 599 | | |
545 | 600 | | |
546 | 601 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
183 | 183 | | |
184 | 184 | | |
185 | 185 | | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
186 | 246 | | |
187 | 247 | | |
188 | 248 | | |
| |||
644 | 704 | | |
645 | 705 | | |
646 | 706 | | |
647 | | - | |
648 | | - | |
649 | | - | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
650 | 721 | | |
651 | 722 | | |
652 | 723 | | |
| |||
0 commit comments