Skip to content

Commit

Permalink
Update src/cluster_legacy.c
Browse files Browse the repository at this point in the history
Co-authored-by: Ping Xie <[email protected]>
Signed-off-by: Binbin <[email protected]>
  • Loading branch information
enjoy-binbin and PingXie authored Oct 22, 2024
1 parent 2fb5558 commit 901d0d7
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/cluster_legacy.c
Original file line number Diff line number Diff line change
Expand Up @@ -4436,15 +4436,19 @@ void clusterLogCantFailover(int reason) {

/* Don't log if we have the same reason for some time. */
if (reason == server.cluster->cant_failover_reason &&
time(NULL) - lastlog_time < CLUSTER_CANT_FAILOVER_RELOG_PERIOD)
time_t now = time(NULL);

/* General logging suppression if the same reason has occurred recently. */
if (now - lastlog_time < CLUSTER_CANT_FAILOVER_RELOG_PERIOD) {
return;
}

/* If data age is too old, this log may be printed repeatedly since it
* can not be automatically recovered. In this case, limit its frequency. */
if (reason == server.cluster->cant_failover_reason && reason == CLUSTER_CANT_FAILOVER_DATA_AGE &&
time(NULL) - lastlog_time < 10 * CLUSTER_CANT_FAILOVER_RELOG_PERIOD)
/* Special case: If the failure reason is due to data age, log 10 times less frequently. */
if (reason == CLUSTER_CANT_FAILOVER_DATA_AGE &&
now - lastlog_time < 10 * CLUSTER_CANT_FAILOVER_RELOG_PERIOD) {
return;

}
}
server.cluster->cant_failover_reason = reason;

switch (reason) {
Expand Down

0 comments on commit 901d0d7

Please sign in to comment.