mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-22 16:18:28 -05:00
Sentinel: limit reconnection frequency to the ping period
This commit is contained in:
parent
0eb0b55ff0
commit
3ab49895b4
@ -146,6 +146,8 @@ typedef struct instanceLink {
|
||||
mstime_t last_pong_time; /* Last time the instance replied to ping,
|
||||
whatever the reply was. That's used to check
|
||||
if the link is idle and must be reconnected. */
|
||||
mstime_t last_reconn_time; /* Last reconnection attempt performed when
|
||||
the link was down. */
|
||||
} instanceLink;
|
||||
|
||||
typedef struct sentinelRedisInstance {
|
||||
@ -921,6 +923,7 @@ instanceLink *createInstanceLink(void) {
|
||||
link->pc = NULL;
|
||||
link->cc_conn_time = 0;
|
||||
link->pc_conn_time = 0;
|
||||
link->last_reconn_time = 0;
|
||||
link->pc_last_activity = 0;
|
||||
/* We set the last_ping_time to "now" even if we actually don't have yet
|
||||
* a connection with the node, nor we sent a ping.
|
||||
@ -1826,6 +1829,10 @@ void sentinelSetClientName(sentinelRedisInstance *ri, redisAsyncContext *c, char
|
||||
void sentinelReconnectInstance(sentinelRedisInstance *ri) {
|
||||
if (ri->link->disconnected == 0) return;
|
||||
instanceLink *link = ri->link;
|
||||
mstime_t now = mstime();
|
||||
|
||||
if (now - ri->link->last_reconn_time < SENTINEL_PING_PERIOD) return;
|
||||
ri->link->last_reconn_time = now;
|
||||
|
||||
/* Commands connection. */
|
||||
if (link->cc == NULL) {
|
||||
|
Loading…
Reference in New Issue
Block a user