Repository: valkey-io/valkey
File: src/cluster_legacy.c (C)

Code before:
            continue;
        }

        /* Check only if we have an active ping for this instance. */
        if (node->ping_sent == 0) continue;

        /* Check if this node looks unreachable.
         * Note that if we already received the PONG, then node->ping_sent
         * is zero, so can't reach this code at all, so we don't risk of
         * checking for a PONG delay if we didn't sent the PING.
         *
         * We also consider every incoming data as proof of liveness, since
         * our cluster bus link is also used for data: under heavy data
         * load pong delays are possible. */
        mstime_t node_delay = (ping_delay < data_delay) ? ping_delay : data_delay;

        if (node_delay > server.cluster_node_timeout) {
            /* Timeout reached. Set the node as possibly failing if it is
             * not already in this state. */
            if (!(node->flags & (CLUSTER_NODE_PFAIL | CLUSTER_NODE_FAIL))) {
                node->flags |= CLUSTER_NODE_PFAIL;
                update_state = 1;
                if (clusterNodeIsPrimary(myself) && server.cluster->size == 1) {
                    markNodeAsFailingIfNeeded(node);
                } else {
                    serverLog(LL_NOTICE, "NODE %.40s possibly failing.", node->name);
                }
            }
        }
    }
    dictReleaseIterator(di);

    /* If we are a replica node but the replication is still turned off,
     * enable it if we know the address of our primary and it appears to
     * be up. */
    if (nodeIsReplica(myself) && server.primary_host == NULL && myself->replicaof && nodeHasAddr(myself->replicaof)) {
        replicationSetPrimary(myself->replicaof->ip, getNodeDefaultReplicationPort(myself->replicaof));
    }

    /* Abort a manual failover if the timeout is reached. */
    manualFailoverCheckTimeout();

    if (nodeIsReplica(myself)) {
        clusterHandleManualFailover();
        if (!(server.cluster_module_flags & CLUSTER_MODULE_FLAG_NO_FAILOVER)) clusterHandleReplicaFailover();
        /* If there are orphaned replicas, and we are a replica among the primaries
         * with the max number of non-failing replicas, consider migrating to
         * the orphaned primaries. Note that it does not make sense to try
         * a migration if there is no primary with at least *two* working
         * replicas. */
        if (orphaned_primaries && max_replicas >= 2 && this_replicas == max_replicas &&

Review comment (bug):
```suggestion
                    serverLog(LL_NOTICE, "NODE %.40s (%s) possibly failing.", node->name, node->human_nodename);
```
It looks like we missed this one.

Code after:
        }

        /* Check only if we have an active ping for this instance. */
        if (node->ping_sent == 0) continue;

        /* Check if this node looks unreachable.
         * Note that if we already received the PONG, then node->ping_sent
         * is zero, so can't reach this code at all, so we don't risk of
         * checking for a PONG delay if we didn't sent the PING.
         *
         * We also consider every incoming data as proof of liveness, since
         * our cluster bus link is also used for data: under heavy data
         * load pong delays are possible. */
        mstime_t node_delay = (ping_delay < data_delay) ? ping_delay : data_delay;

        if (node_delay > server.cluster_node_timeout) {
            /* Timeout reached. Set the node as possibly failing if it is
             * not already in this state. */
            if (!(node->flags & (CLUSTER_NODE_PFAIL | CLUSTER_NODE_FAIL))) {
                node->flags |= CLUSTER_NODE_PFAIL;
                update_state = 1;
                if (clusterNodeIsPrimary(myself) && server.cluster->size == 1) {
                    markNodeAsFailingIfNeeded(node);
                } else {
                    serverLog(LL_NOTICE, "NODE %.40s (%s) possibly failing.", node->name, node->human_nodename);
                }
            }
        }
    }
    dictReleaseIterator(di);

    /* If we are a replica node but the replication is still turned off,
     * enable it if we know the address of our primary and it appears to
     * be up. */
    if (nodeIsReplica(myself) && server.primary_host == NULL && myself->replicaof && nodeHasAddr(myself->replicaof)) {
        replicationSetPrimary(myself->replicaof->ip, getNodeDefaultReplicationPort(myself->replicaof));
    }

    /* Abort a manual failover if the timeout is reached. */
    manualFailoverCheckTimeout();

    if (nodeIsReplica(myself)) {
        clusterHandleManualFailover();
        if (!(server.cluster_module_flags & CLUSTER_MODULE_FLAG_NO_FAILOVER)) clusterHandleReplicaFailover();
        /* If there are orphaned replicas, and we are a replica among the primaries
         * with the max number of non-failing replicas, consider migrating to
         * the orphaned primaries. Note that it does not make sense to try
         * a migration if there is no primary with at least *two* working
         * replicas. */
        if (orphaned_primaries && max_replicas >= 2 && this_replicas == max_replicas &&
            server.cluster_allow_replica_migration)