[Feat]: Race Condition in TaskUpdater for Terminal States
pankaj-bind opened this issue · 0 comments
pankaj-bind commented
Is your feature request related to a problem? Please describe.
The TaskUpdater is vulnerable to a race condition when handling terminal states. Concurrent updates (e.g., two simultaneous calls to complete() and failed()) can lead to inconsistent task statuses because the state checks are not atomic.
A locking mechanism is needed to ensure that once a task begins to transition to a terminal state, no other updates can be processed.
Describe the solution you'd like
Steps to reproduce the behavior:
- Trigger two simultaneous async calls to update a task's status to two different terminal states.
- For example:
asyncio.gather(task_updater.complete(), task_updater.failed()). - Observe that it may be possible for both operations to proceed further than they should, creating a race condition.
Describe alternatives you've considered
No response
Additional context
No response
Code of Conduct
- I agree to follow this project's Code of Conduct