Use clusterNodeIsVotingPrimary function to check the right (#735)
Minor cleanups. --------- Signed-off-by: Binbin <binloveplay1314@qq.com>
This commit is contained in:
parent
b298dfd6ef
commit
2d6791bb11
@ -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. */
|
||||
if (nodeIsReplica(node) || node->numslots == 0) {
|
||||
serverLog(LL_NOTICE, "Clear FAIL state for node %.40s (%s):%s is reachable again.", node->name,
|
||||
/* For replicas or primaries without slots, that is, nodes without voting
|
||||
* right, we always clear the FAIL flag if we can contact the node again. */
|
||||
if (!clusterNodeIsVotingPrimary(node)) {
|
||||
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);
|
||||
@ -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
|
||||
@ -4086,7 +4086,7 @@ void clusterSendFailoverAuthIfNeeded(clusterNode *node, clusterMsg *request) {
|
||||
}
|
||||
|
||||
/* This function returns the "rank" of this instance, a replica, in the context
|
||||
* of its primar-replicas ring. The rank of the replica is given by the number of
|
||||
* of its primary-replicas ring. The rank of the replica is given by the number of
|
||||
* other replicas for the same primary that have a better replication offset
|
||||
* compared to the local one (better means, greater, so they claim more data).
|
||||
*
|
||||
@ -6022,7 +6022,7 @@ void clusterCommandSetSlot(client *c) {
|
||||
* 3. Upon replication completion, primary B executes `SETSLOT n NODE B` and
|
||||
* returns success to client C.
|
||||
* 4. The following steps can happen in parallel:
|
||||
* a. Client C issues `SETSLOT n NODE B` against parimary A.
|
||||
* a. Client C issues `SETSLOT n NODE B` against primary A.
|
||||
* b. Primary B gossips its new slot ownership to the cluster (including A, A', etc.).
|
||||
*
|
||||
* This ensures that all replicas have the latest topology information, enabling
|
||||
|
@ -287,18 +287,18 @@ struct _clusterNode {
|
||||
uint16_t *slot_info_pairs; /* Slots info represented as (start/end) pair (consecutive index). */
|
||||
int slot_info_pairs_count; /* Used number of slots in slot_info_pairs */
|
||||
int numslots; /* Number of slots handled by this node */
|
||||
int num_replicas; /* Number of replica nodes, if this is a primar */
|
||||
int num_replicas; /* Number of replica nodes, if this is a primary */
|
||||
clusterNode **replicas; /* pointers to replica nodes */
|
||||
clusterNode *replicaof; /* pointer to the primary node. Note that it
|
||||
may be NULL even if the node is a replica
|
||||
if we don't have the parimary node in our
|
||||
if we don't have the primary node in our
|
||||
tables. */
|
||||
unsigned long long last_in_ping_gossip; /* The number of the last carried in the ping gossip section */
|
||||
mstime_t ping_sent; /* Unix time we sent latest ping */
|
||||
mstime_t pong_received; /* Unix time we received the pong */
|
||||
mstime_t data_received; /* Unix time we received any data */
|
||||
mstime_t fail_time; /* Unix time when FAIL flag was set */
|
||||
mstime_t voted_time; /* Last time we voted for a replica of this parimary */
|
||||
mstime_t voted_time; /* Last time we voted for a replica of this primary */
|
||||
mstime_t repl_offset_time; /* Unix time we received offset for this node */
|
||||
mstime_t orphaned_time; /* Starting time of orphaned primary condition */
|
||||
long long repl_offset; /* Last known repl offset for this node. */
|
||||
|
Loading…
x
Reference in New Issue
Block a user