You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If another process grabbed a timed-out lock and hasn't released it yet, the simple check for "if not DBMutex.objects.filter(id=self.lock.id).exists()" doesn't verify current ownership of the lock, and so it may not raise the timeout exception when it should.
It would be best if the local object and SQL object contained an owner identifier that was based on a unique machine+process+thread ID.
Then this code could double-check that the lock exists and is still owned by itself as expected.
Alternatively, it might be good-enough to just generate a random 64-bit integer to use for this purpose (would work in 99.9999% of cases).
The text was updated successfully, but these errors were encountered:
I think this is a great idea. Unfortunately I don't know when I would be able to get to this. I'd gladly accept a pull request for this fix that uses either of the two approaches. Please let me know if we should put instructions on contributing. Thanks for your suggestions
I'm evaluating some synchronization options for an internal Django-based website at the large software company I work at. Just wanted to note this potential issue and see if anyone else agreed or had suggestions...
If we end up using this code as a base, I'll make sure we contribute any fixes back via pull requests. Thanks.
https://github.com/ambitioninc/django-db-mutex/blob/develop/db_mutex/db_mutex.py#L112
If another process grabbed a timed-out lock and hasn't released it yet, the simple check for "if not DBMutex.objects.filter(id=self.lock.id).exists()" doesn't verify current ownership of the lock, and so it may not raise the timeout exception when it should.
It would be best if the local object and SQL object contained an owner identifier that was based on a unique machine+process+thread ID.
Then this code could double-check that the lock exists and is still owned by itself as expected.
Alternatively, it might be good-enough to just generate a random 64-bit integer to use for this purpose (would work in 99.9999% of cases).
The text was updated successfully, but these errors were encountered: