Ref #2211
On a role mismatch, the reconnect in redis_check_conn() sleeps one
second, asks INFO again and sleeps once more: two seconds under
r->lock, which every Redis update holds before the ng reply (#1865).
After a failover, with --redis on the old master's address, every
update did this, and ng requests timed out.
Make one attempt, with no sleep. After a role failure, or a failure
that took --redis-reconnect-slow (100 ms) or more, skip Redis
operations on that connection for --redis-reconnect-pause (1000 ms),
through restore_tick_us as --redis-allowed-errors does. A quick failure
(connection refused) is retried at once, as before. As with a failed
attempt, a skipped operation is not written; skips are logged once per
pause. The startup connection keeps its eleven attempts.
Tested by auto-daemon-tests-redis-errors.pl.
Change-Id: Ia84288f1c6fe97c4317689fef75d0ff5fc9061f8
pull/2221/head
Kevin Binetruy1 month agocommitted byRichard Fuchs
{"redis-disable-time",0,0,G_OPTION_ARG_INT,&redis_disable_time,"Number of seconds redis communication is disabled because of errors","INT"},
{"redis-cmd-timeout",0,0,G_OPTION_ARG_INT,&rtpe_config.redis_cmd_timeout,"Sets a timeout in milliseconds for redis commands","INT"},
{"redis-connect-timeout",0,0,G_OPTION_ARG_INT,&rtpe_config.redis_connect_timeout,"Sets a timeout in milliseconds for redis connections","INT"},
{"redis-reconnect-pause",0,0,G_OPTION_ARG_INT,&rtpe_config.redis_reconnect_pause,"Milliseconds without Redis reconnect attempts after a slow or wrong-role failure","INT"},
{"redis-reconnect-slow",0,0,G_OPTION_ARG_INT,&rtpe_config.redis_reconnect_slow,"A failed Redis reconnect attempt taking this many milliseconds or more is followed by the pause","INT"},
{"redis-format",0,0,G_OPTION_ARG_STRING,&redis_format,"Format for persistent storage in Redis/KeyDB","native|bencode|JSON"},
{"subscribe-keyspace",'k',0,G_OPTION_ARG_STRING_ARRAY,&ks_a,"Subscription keyspace list","INT INT ..."},
{"redis-tcp-keepalive-time",0,0,G_OPTION_ARG_INT,&rtpe_config.redis_tcp_keepalive_time,"Positive value sets tcp_keepalive_time for redis connections","INT"},