Race condition after async cancellations leads to degraded pool state #952
Replies: 1 comment
|
There has been a meaningful cleanup change since the 1.0.5 reproducer, and current main is worth retesting before treating this as the same bug. The pool now shields response cleanup from cancellation. In particular, That matters for the symptom in the reproducer: the permanently “active” requests/connections can occur when cancellation interrupts cleanup after a request has acquired pool/connection state but before the response-close path releases it. Shielding that critical cleanup is the right invariant: cancellation may abort the request, but it must not abort releasing pool bookkeeping or protocol capacity. I would therefore rerun this exact cancellation stress test against current httpcore before changing pool logic. If it still degrades, the next useful diagnostic is to identify which resource remains owned after cancellation: One place I'd scrutinize if it still reproduces is the pool's exception path itself: it removes/reassigns the pool request and then awaits closing connections. The stream-close paths are explicitly shielded; cancellation safety should be checked consistently for every await between removing a failed/cancelled request and completing the corresponding connection cleanup. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This bug has been haunting us recently. It happens after certain async cancellations, which cause the HTTP pool to get stuck in a degraded state, unable to issue requests. It looks like a resurfacing of this issue.
httpcore version:
1.0.5python version:
3.12.4Code to reproduce:
Output:
This is reproducible using the default python http server:
The bug applies to both asyncio and trio. However in trio it's much narrower. With asyncio it triggers almost immediately, while trio takes about 30 seconds.
Code to reproduce in trio:
Anyway sorry to bring this up again. I know these suck to troubleshoot. Let me know if there's anything else I can do to help in getting it fixed.
All reactions