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

Race condition in the lock acquisition #3

Open
jer opened this issue Sep 24, 2014 · 1 comment
Open

Race condition in the lock acquisition #3

jer opened this issue Sep 24, 2014 · 1 comment

Comments

@jer
Copy link

jer commented Sep 24, 2014

Unless I'm mistaken, this isn't enough to prevent a race condition, right? https://github.com/websterclay/chef-dominodes/blob/master/libraries/dominodes.rb#L46

Host A fetches the databag
Host B fetches the databag
Host A writes
Host A reads
Host B writes
Host B reads

@jer
Copy link
Author

jer commented Sep 24, 2014

You could probably accomplish this by having each host create an item named after itself to indicate its intent to exercise the lock. Your check could ensure that only 1 item exists. If it doesn't, you resolve the winner somehow -- perhaps by just deleting the item and starting over.

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

1 participant