Skip to content
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

Lock timeout exceptions may not always be raised correctly #8

Open
markerrj opened this issue Apr 8, 2014 · 2 comments
Open

Lock timeout exceptions may not always be raised correctly #8

markerrj opened this issue Apr 8, 2014 · 2 comments

Comments

@markerrj
Copy link

markerrj commented Apr 8, 2014

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).

@wesleykendall
Copy link
Contributor

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

@markerrj
Copy link
Author

markerrj commented Apr 9, 2014

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants