Closed jlledom closed 6 months ago
FYI @stanhu
Is the simplest solution here to catch ConnectionError
in message
and give up?
Alternatively, we could use a different method or use an argument to config
that avoids the call to resolve_master
or resolve_replica
.
@stanhu IMO catching errors in message
is the way to go. Because showing the URL in the message is not a vital feature. If we can have it, cool, but if something fails it's ok to just return super
, not a big deal. I would catch any error, not only ConnectionError
I don't like the rescue idea, I think we should just not call anything that could fail from here.
So we probably need a version of server_url
that just return something else if it wasn't resolved for a sentinel client.
@stanhu if you want to fix it it's all good, but if you don't have time let me know and I'll find the time.
@casperisfine I'll fix this.
So we probably need a version of server_url that just return something else if it wasn't resolved for a sentinel client.
The issue is that config
calls resolve_master
or resolve_replica
, so we need some config
object that doesn't attempt that.
I think https://github.com/redis-rb/redis-client/pull/183 should solve this.
It looks like this was fixed in v0.21.1. Thanks for the quick review and release!
Release 0.21.0 introduced a new error message handling: https://github.com/redis-rb/redis-client/pull/178
However, this blocks the execution when trying to connect to an invalid sentinel client. Check this example:
When using
0.20.0
. This is the result:And this is the result using
0.21.0
:After taking a quick look at the code, I'd say this happens because the new
HasConfig#message
method calls toconfig.server_url
:https://github.com/redis-rb/redis-client/blob/93c343a52c452e916d6f10e1b403469cc4c72116/lib/redis_client.rb#L87-L91
Which calls to
host
:https://github.com/redis-rb/redis-client/blob/93c343a52c452e916d6f10e1b403469cc4c72116/lib/redis_client/config.rb#L125-L138
Which, if I'm not wrong, ends up calling to
resolve_master
, and trying to connect again, thus raising the error again.https://github.com/redis-rb/redis-client/blob/93c343a52c452e916d6f10e1b403469cc4c72116/lib/redis_client/sentinel_config.rb#L138-L151