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

Fix race condition when setting mutex key #6

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

clupprich
Copy link

There's the possibility of a race condition when we're acquiring a new mutex:

DistributedMutex.attempt_to_lock first checks if current_lock is nil and only then sets the mutex key. However, the command that's used there is SET, which

If key already holds a value, it is overwritten[…].

We need to either use SETNX (which is deprecated) or use SET command with the NX option to

Only set the key if it does not already exist.

I'm also setting the expiration time for the key in the same command, as we don't wanna touch that if it already exists.

Had to limit the version of Rake that can be used, as it would error with newer versions.

clupprich and others added 3 commits January 14, 2022 14:50
11.0 introduces a breaking change that removes the `#last_comment` method that rspec < 3 needs.
@clupprich
Copy link
Author

Pinging @ericescalante who originally implemented the switch from memcached -> Redis in a58f6ca.

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

Successfully merging this pull request may close these issues.

1 participant