sf_replication_quorum_check changed
parent
e8e6cfc64a
commit
6dd3bfbb22
|
|
@ -143,22 +143,21 @@ static inline const char *sf_get_replication_quorum_caption(
|
|||
}
|
||||
|
||||
static inline bool sf_replication_quorum_check(const SFReplicationQuorum quorum,
|
||||
const bool vote_node_enabled, const int total_count,
|
||||
const int active_count)
|
||||
const int total_count, const int active_slave_count)
|
||||
{
|
||||
switch (quorum) {
|
||||
case sf_replication_quorum_any:
|
||||
return active_count > 0;
|
||||
return true;
|
||||
case sf_replication_quorum_auto:
|
||||
if (total_count % 2 == 0 && !vote_node_enabled) {
|
||||
return active_count > 0; //same as sf_replication_quorum_any
|
||||
if (total_count % 2 == 0) {
|
||||
return true; //same as sf_replication_quorum_any
|
||||
}
|
||||
//continue
|
||||
case sf_replication_quorum_majority:
|
||||
if (active_count == total_count) {
|
||||
if ((active_slave_count + 1) == total_count) {
|
||||
return true;
|
||||
} else {
|
||||
return active_count > total_count / 2;
|
||||
return (active_slave_count + 1) > total_count / 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -173,16 +172,21 @@ static inline bool sf_replication_quorum_check(const SFReplicationQuorum quorum,
|
|||
sf_load_replication_quorum_config_ex(quorum, ini_ctx, \
|
||||
sf_replication_quorum_auto)
|
||||
|
||||
#define SF_QUORUM_NEED_REQUEST_VOTE_NODE(quorum, vote_node_enabled, \
|
||||
server_count, active_count) \
|
||||
#define SF_ELECTION_QUORUM_NEED_REQUEST_VOTE_NODE(quorum, \
|
||||
vote_node_enabled, server_count, active_count) \
|
||||
(active_count < server_count && vote_node_enabled && \
|
||||
quorum != sf_election_quorum_any && server_count % 2 == 0)
|
||||
|
||||
#define SF_QUORUM_NEED_CHECK_VOTE_NODE(quorum, \
|
||||
#define SF_ELECTION_QUORUM_NEED_CHECK_VOTE_NODE(quorum, \
|
||||
vote_node_enabled, server_count) \
|
||||
(vote_node_enabled && quorum != sf_election_quorum_any \
|
||||
&& server_count % 2 == 0)
|
||||
|
||||
#define SF_REPLICATION_QUORUM_NEED_MAJORITY(quorum, server_count) \
|
||||
(server_count > 1 && (quorum == sf_replication_quorum_majority || \
|
||||
(quorum == sf_replication_quorum_auto && \
|
||||
server_count % 2 == 1)))
|
||||
|
||||
|
||||
#define SF_NET_RETRY_FINISHED(retry_times, counter, result) \
|
||||
!((SF_IS_RETRIABLE_ERROR(result) && ((retry_times > 0 && \
|
||||
|
|
|
|||
Loading…
Reference in New Issue