Parcel calculation race condition #189

Closed
opened 2022-08-04 10:58:01 +02:00 by mpeltriaux · 1 comment
Owner

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!

# 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!
mpeltriaux added the
enhancement
label 2022-08-04 10:58:01 +02:00
mpeltriaux self-assigned this 2022-08-04 10:58:01 +02:00
mpeltriaux referenced this issue from a commit 2022-08-05 11:35:02 +02:00
mpeltriaux added reference 189_Parcel_calculation_race_condition 2022-08-08 11:19:02 +02:00
Author
Owner

Merged in #193

# Merged in #193
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: IT-Naturschutz/konova#189
No description provided.