You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the Redis server does failover to a replica using master-slave replication, the old master is demoted to read-only (either manually or by a sentinel), read operations can continue, but writers receive a READONLY error message, and are expected to reconnect to a newly promoted replica. In Redis::Fast, this can be handled by setting up a hook on the READONLY error message. From their documentation:
my $r = Redis::Fast->new(
reconnect => 1, # The value greater than 0 is required
reconnect_on_error => sub {
my ($error, $ret, $command) = @_;
if ($error =~ /READONLY You can't write against a read only slave/) {
# force reconnect
return 1;
}
# do nothing
return -1;
},
);
In Mojo::Redis this is not possible, because the Mojo::Redis::Connection->on(error => ...) event gets emitted only when the current request is not a promise, and it is called for a single connection out of many in the connection pool. Also, I am not sure whether the event handler can lead to resubmitting the current request.
Please support a sane way how to detect a server failover to another replica, and reconnect in case the server goes read-only. So far it seems that Mojo::Redis stays connected to the old master indefinitely, and keeps getting the READONLY errors for write requests.
Thanks!
The text was updated successfully, but these errors were encountered:
When the Redis server does failover to a replica using master-slave replication, the old master is demoted to read-only (either manually or by a sentinel), read operations can continue, but writers receive a READONLY error message, and are expected to reconnect to a newly promoted replica. In
Redis::Fast
, this can be handled by setting up a hook on the READONLY error message. From their documentation:In Mojo::Redis this is not possible, because the
Mojo::Redis::Connection->on(error => ...)
event gets emitted only when the current request is not a promise, and it is called for a single connection out of many in the connection pool. Also, I am not sure whether the event handler can lead to resubmitting the current request.Please support a sane way how to detect a server failover to another replica, and reconnect in case the server goes read-only. So far it seems that Mojo::Redis stays connected to the old master indefinitely, and keeps getting the READONLY errors for write requests.
Thanks!
The text was updated successfully, but these errors were encountered: