-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Potential race condition in Lock
#387
Comments
What seems to happen here is:
Adding a new check to the cleanup block where it calls |
As a side note, the |
I think that's exactly it. Except in my case it's not task A doing the cancelling but something else, but that's immaterial here. |
Task A contains this code: |
In the example I posted, yes. In the incidents on our production environment, no. |
I see. Anyway, there is a PR with the appropriate regression tests fixing the problem for both |
Thank you! |
Thanks for the quick response on this! |
I will cut a release once the contextvar propagation issue is solved (needs a PR that is almost ready). |
It was decided to add workarounds for trio rather than wait for the relevant PR to be merged and a new version released. Fixes #387.
Hello!
I'm trying to debug an issue we sometimes hit in production through httpx. We're not using anyio ourselves directly (it's regular asyncio), but httpx is based on it.
I'm not 100% sure the scenario I'm documenting here is the exact issue we're seeing, but there's a good chance. The symptoms we're seeing is that a lock instance gets stuck in the locked state with a finished task still set as the owner.
Here's the rough sketch, involving two tasks:
Task 1:
Task 2:
Task 1:
_owner_task
to Task 2, gets Task 2's event and sets itTask 2:
event.wait()
, propagates itThe lock
_owner_task
is still set to Task 2, rendering the lock stuck.In our production code it's not Task 1 cancelling Task 2, but aiohttp (but that's not relevant to the example).
Here's a Python snippet demonstrating the problem:
The lock should end up in a free state, but it gets stuck being owned by
task_b
.The text was updated successfully, but these errors were encountered: