Issue #8637
Updated by daviddavis over 3 years ago
This was something I noticed while working on #8603. I haven't actually reproduced it so it's purely theoretical.
The `TaskReservedResource` has [a cascade delete on its `ReservedResource` FK](https://github.com/pulp/pulpcore/blob/dd749995ba71a5f504d5ecbe0c8db90c38751baf/pulpcore/app/models/task.py#L66), which could cause a race condition:
1. Task 1 [confirms that the reserved resource has no other tasks](https://github.com/pulp/pulpcore/blob/dd749995ba71a5f504d5ecbe0c8db90c38751baf/pulpcore/app/models/task.py#L361)
2. Task 2 reserves the resource
3. Task 1 calls delete which cascades and deletes Task 2's reservations of the resource