Commit b4b950c
m.mazaherifard
pool: prevent trimming the last idle connection under load
Previously, the inactivity timer could terminate idle connections even
when doing so left the pool effectively empty. Under heavy load this
forced the pool to create new connections, causing extra overhead and
occasional TimeoutErrors during acquire().
This change adds a guard in PoolConnectionHolder so that idle
deactivation only happens when it is safe:
- never below pool min_size
- never if there are waiters
- never removing the last idle connection
This ensures the pool retains at least one ready connection and avoids
spurious connection churn under load.1 parent 5b14653 commit b4b950c
1 file changed
+47
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
287 | 287 | | |
288 | 288 | | |
289 | 289 | | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
290 | 330 | | |
291 | 331 | | |
292 | 332 | | |
293 | 333 | | |
294 | 334 | | |
295 | 335 | | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
296 | 343 | | |
297 | 344 | | |
298 | 345 | | |
| |||
0 commit comments