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

Re-raise Redis connection errors in #lock #110

Merged

Conversation

panozzaj
Copy link
Contributor

@panozzaj panozzaj commented Jun 2, 2022

This is a fix for the example I presented in a prior issue.

Currently, #lock returns false when a lock cannot be acquired, whether due to a lock already being present on the key, or a connection issue. This PR stops swallowing Redis connection errors, since they are different from the key already being locked. The Redlock user can determine how to correctly handle these errors.

I updated the existing tests for the new logic. I didn't see anything in the documentation referencing the existing behavior, so didn't make any documentation changes.

Please note that this change may violate expectations for others using the library if they rely on the previous "return false on connection error" logic. I could imagine that someone would not be wrapping their logic in a rescue, so it would fail in a previously unexpected manner. I think the maintainers may want to consider whether this is a breaking change that would need a bigger semver change.

Also, thanks for maintaining this project! It has been helpful in preventing the race condition that I outlined in the issue (at least a handful of times in the last week.)

@leandromoreira
Copy link
Owner

thanks @panozzaj I really would love to hear @maltoe 's thought on this, it essentially changes the established API / expectation, if we want to merge this I'd say we must change a major version.

@LyleDavis
Copy link

It would be great to get this in if possible, this has bitten us twice now in production resulting in data fixes 😅

If there are worries about breaking changes in the API in a way that makes this unreleasable would it be possible to add some form of either callback or logging so we can see when a lock has failed to acquire because of a redis connection error vs it actually being locked?

@maltoe
Copy link
Collaborator

maltoe commented Aug 24, 2022

PR looks good, change looks sensible to me. With regards to the API changes: Sure, technically incompatible, albeit maybe a minor case since it's on the error path anyway? However, if you want to bump the major version, sure, that should alert more people to the CHANGELOG. ...which doesn't exist yet, maybe a good time to create one now?

@leandromoreira Sorry for not responding to your ping for so long, I'm currently on an extended time-off. Besides, I haven't been using Ruby or Redlock myself for the past years, unfortunately, so am generally not paying much attention anymore. Hence, I guess it's best if I officially stepped down as your co-host of this fabulous show 🎪 Sorry to let you hanging like this.

@panozzaj
Copy link
Contributor Author

Thanks for the update @maltoe, hope you are doing well on your time off.

Seems like we'll want to merge this and cut a new release (at least minor) and add a changelog. I looked, and think that the process for releasing a new version is not documented for this project.

At this point I would recommend merging this since merging would be useful for @LyleDavis and us (could point our Gemfile version to the master branch). And then do the release and (new) changelog as a follow-on PR.

What do you think @leandromoreira?

@LyleDavis
Copy link

Any news on this? It has bitten us in production again and there isn't a neat way of reaching into the gem to change the behaviour without monkey-patching at the moment 😢

@leandromoreira
Copy link
Owner

SO SORRY @LyleDavis

@leandromoreira leandromoreira merged commit c8e2980 into leandromoreira:main Sep 12, 2022
@leandromoreira
Copy link
Owner

PR looks good, change looks sensible to me. With regards to the API changes: Sure, technically incompatible, albeit maybe a minor case since it's on the error path anyway? However, if you want to bump the major version, sure, that should alert more people to the CHANGELOG. ...which doesn't exist yet, maybe a good time to create one now?

@leandromoreira Sorry for not responding to your ping for so long, I'm currently on an extended time-off. Besides, I haven't been using Ruby or Redlock myself for the past years, unfortunately, so am generally not paying much attention anymore. Hence, I guess it's best if I officially stepped down as your co-host of this fabulous show 🎪 Sorry to let you hanging like this.

No need to apologize :) you've always helped a lot, thank you :)

@leandromoreira
Copy link
Owner

@panozzaj @LyleDavis I'm off from my home/computer so unless @maltoe does a new release I only will be able to do it next Saturday. Sorry to let you waiting and thanks for the all the efforts.

@dem
Copy link

dem commented Oct 13, 2022

@panozzaj great work on finding this and providing PR to fix it 👍

It hit us in production in one tricky case and investigations bring us here

@leandromoreira Any updates on release new version of gem?

@leandromoreira
Copy link
Owner

@dem sorry I'll try to do it by tomorrow

@leandromoreira
Copy link
Owner

leandromoreira commented Oct 14, 2022

It's done, thank you all people, sorry for making you wait!

https://github.com/leandromoreira/redlock-rb/releases/tag/1.3.1

https://rubygems.org/gems/redlock

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.

5 participants