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_create method by two different worker processes.
This results in a duplicates parcel entry. The next worker running get_or_create will fetch two different entries, which are basically identical. This will break the logic, since this is not supposed to happen.
Enhancement
The get_or_create calls 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.html
We should implement this!
# 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_create` method by two different worker processes.
This results in a duplicates parcel entry. The next worker running `get_or_create` will fetch two different entries, which are basically identical. This will break the logic, since this is not supposed to happen.
# Enhancement
The `get_or_create` calls 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.html
We should implement this!
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
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