Unverified Commit 93186886 authored by Shaya Potter's avatar Shaya Potter Committed by GitHub
Browse files

Fix quorum_msg_id assert (#3)

Before this commit, active and voting flags were ignored resulting with a result that does not agree with `raft_get_num_voting_nodes()` and an assertion.

This could be seen when a leader node gets removed while a read operation is in progress.
parent e2440e4e
...@@ -1604,14 +1604,15 @@ raft_msg_id_t quorum_msg_id(raft_server_t* me_) ...@@ -1604,14 +1604,15 @@ raft_msg_id_t quorum_msg_id(raft_server_t* me_)
for (i = 0; i < me->num_nodes; i++) { for (i = 0; i < me->num_nodes; i++) {
raft_node_t* node = me->nodes[i]; raft_node_t* node = me->nodes[i];
if (me->node == node) {
msg_ids[msg_ids_count++] = me->msg_id;
continue;
}
if (!raft_node_is_active(node) || !raft_node_is_voting(node)) if (!raft_node_is_active(node) || !raft_node_is_voting(node))
continue; continue;
msg_ids[msg_ids_count++] = raft_node_get_last_acked_msgid(node); if (me->node == node) {
msg_ids[msg_ids_count++] = me->msg_id;
} else {
msg_ids[msg_ids_count++] = raft_node_get_last_acked_msgid(node);
}
} }
qsort(msg_ids, msg_ids_count, sizeof(raft_msg_id_t), msgid_cmp); qsort(msg_ids, msg_ids_count, sizeof(raft_msg_id_t), msgid_cmp);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment