redlock-rb
redlock-rb copied to clipboard
Upgrading from 1.3.2 to 2.0.1 causing errors
We just upgraded from 1.3.2 to 2.0.1. Local machine and specs worked fine, but once deployed, we started getting errors.
undefined method `-' for "K":String
/app/shared/bundle/ruby/2.7.0/gems/redlock-2.0.1/lib/redlock/client.rb:302
and
NoMethodError: undefined method `last' for #<Hash:0x00005555e3ec7280>
/app/shared/bundle/ruby/2.7.0/gems/redlock-2.0.1/lib/redlock/client.rb:289
From what I can see, the structure of the data stored in redis has changed between versions, so that locks created prior to upgrading are not longer compatible with the new version.
This breakage is not documented, and there does not seem to be a migration option.
Sorry @KieranP did you find a way to fix it? If you did, would you mind to send a PR explanning the problem and the solution?
@leandromoreira I'm afraid not. We ended up rolling back to version 1.3.2 right away to prevent further breakages. I suspect any change would need to either clear all locks (not ideal), or be able to run a rake task to convert all the 1.3.2 locks into a 2.0+ compatible format. But it's not something we're going to worry about for now since 1.3.2 continues to work for us.
We are also facing the same issue but without having any keys from previous versions. These keys have been created on 2.0.1
undefined method `-' for "K":String
This is leading me to suspect this is an issue in Redlock 2.0.1 and unrelated to upgrading.
Somehow this line might be returning a "K" ?
min_ttl = ttls.sort.last(@quorum).first