Parcel calculation race condition #189
Loading…
x
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Status quo
Parcel calculation runs in parallel celery worker processes. This ensures the calculation is performed on a background process, which does not delay the response of the client's foreground process, resulting in an unsatisfying user experience.
However, if a lot of calculations are performed at the same time (e.g. during migration but also possible on mass insertion via API), the same parcel could be created on the used
get_or_createmethod by two different worker processes.This results in a duplicates parcel entry. The next worker running
get_or_createwill fetch two different entries, which are basically identical. This will break the logic, since this is not supposed to happen.Enhancement
The
get_or_createcalls have to live in a mutexed method, so each getting-or-creating call will not run parallel but serial. There is a handy tutorial on the official celery documentation regarding this issue: https://docs.celeryq.dev/en/latest/tutorials/task-cookbook.htmlWe should implement this!
Merged in #193