Skip to content

Commit

Permalink
fix code and format
Browse files Browse the repository at this point in the history
Signed-off-by: Binbin <[email protected]>
  • Loading branch information
enjoy-binbin committed Oct 22, 2024
1 parent 901d0d7 commit 80bd495
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/cluster_legacy.c
Original file line number Diff line number Diff line change
Expand Up @@ -4433,22 +4433,19 @@ int clusterGetReplicaRank(void) {
void clusterLogCantFailover(int reason) {
char *msg;
static time_t lastlog_time = 0;

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

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

/* Special case: If the failure reason is due to data age, log 10 times less frequently. */
if (reason == CLUSTER_CANT_FAILOVER_DATA_AGE &&
if (reason == server.cluster->cant_failover_reason && 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 80bd495

Please sign in to comment.