httpcore.AsyncConnectionPool poisoning due to asyncio.CancelledError
#1053
Replies: 1 comment
-
|
I had a similar issue where the pool would stay congested even though it shouldn't and the only thing that could resolve the issue was restarting the service. Root Cause (Hypothesis)
Result: The connection created in step 4 is now orphaned since it exists in Why Orphans Are PermanentFor an
The orphan is invisible to every cleanup path in Minimal ReproductionRequirements: codeMonkey Patch Workaroundcode |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Also ported to pydantic/httpx2#982
Hello,
I’d like to report an issue we are encountering with the
httpx/httpcorestack.In a real-world scenario, our application (O) concurrently calls two downstream services (T1 and T2). We observed the following sequence:
httpx.PoolTimeout.httpx.PoolTimeouterrors.A simplified version of the real code looks like this:
Our hypothesis is that
t2_taskstarts execution but gets cancelled due to an exception int1_task. As a result, some connections may not be cleaned up properly, eventually exhausting the connection pool.I was able to reproduce what appears to be the same underlying issue with the following minimal example:
At this point, the pool reports one active connection even though there are no active or queued requests, and subsequent requests fail with
httpcore.PoolTimeout. This suggests that task cancellation duringpool.request()can leave the pool in an inconsistent state where connections are not properly released.Thank you for taking a look! Let me know if additional details or diagnostics would be helpful.
Beta Was this translation helpful? Give feedback.
All reactions