-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
update_lock
not race-condition-safe
#168
Comments
I think adding django-db-mutex dependency is reasonable to solve this. |
Ah, I just noticed that this package does not implement a waiting lock, it will just throw an exception when the lock is currently in use. Adding a retrying-mechanism (by adding the failed task back to the queue) would also be possible, but I wonder whether there is an easier way?
Do you think we could somehow abuse Another alternative seems to be django-cache-lock, but the caveat is that all dependent applications would have to use a caching backend (and the |
I think it will be hard to find a process-safe locking mechanism working in all situations. I have no better solution to suggest for now. django-db-mutex with a retry mechanism or extracting the django-db-mutex functionality we need might be the way to go. |
The
update_lock
uses the threading-library to avoid race conditions between the asynchronous post-save signal listeners:django-linkcheck/linkcheck/__init__.py
Lines 4 to 5 in 6d933de
django-linkcheck/linkcheck/listeners.py
Line 77 in a6599a6
However, when Django is deployed in a production environment using multiple processes, this might not be race-condition-safe since each process has its own lock.
An alternative might be django-db-mutex (https://django-db-mutex.readthedocs.io/), which achieves the synchronization via a separate database model. There might be environments where more performant solutions are available (e.g. a redis cache etc.), but the least common denominator might simply be the database.
The text was updated successfully, but these errors were encountered: