Skip to content

Commit

Permalink
Use clusterNodeIsVotingPrimary function to check the right
Browse files Browse the repository at this point in the history
Minor cleanups.

Signed-off-by: Binbin <[email protected]>
  • Loading branch information
enjoy-binbin committed Jul 2, 2024
1 parent fa01a29 commit be75c86
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/cluster_legacy.c
Original file line number Diff line number Diff line change
Expand Up @@ -1902,10 +1902,10 @@ void clearNodeFailureIfNeeded(clusterNode *node) {

serverAssert(nodeFailed(node));

/* For replicas we always clear the FAIL flag if we can contact the
* node again. */
/* For replicas or primaries without slots, we always clear the FAIL flag
* if we can contact the node again. */
if (nodeIsReplica(node) || node->numslots == 0) {
serverLog(LL_NOTICE, "Clear FAIL state for node %.40s (%s):%s is reachable again.", node->name,
serverLog(LL_NOTICE, "Clear FAIL state for node %.40s (%s): %s is reachable again.", node->name,
node->human_nodename, nodeIsReplica(node) ? "replica" : "primary without slots");
node->flags &= ~CLUSTER_NODE_FAIL;
clusterDoBeforeSleep(CLUSTER_TODO_UPDATE_STATE | CLUSTER_TODO_SAVE_CONFIG);
Expand Down Expand Up @@ -4006,9 +4006,9 @@ void clusterSendFailoverAuthIfNeeded(clusterNode *node, clusterMsg *request) {

/* IF we are not a primary serving at least 1 slot, we don't have the
* right to vote, as the cluster size is the number
* of primariies serving at least one slot, and quorum is the cluster
* of primaries serving at least one slot, and quorum is the cluster
* size + 1 */
if (nodeIsReplica(myself) || myself->numslots == 0) return;
if (!clusterNodeIsVotingPrimary(myself)) return;

/* Request epoch must be >= our currentEpoch.
* Note that it is impossible for it to actually be greater since
Expand Down

0 comments on commit be75c86

Please sign in to comment.