Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raft config update fix #364

Merged
merged 3 commits into from
Jan 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions src/v/raft/consensus.cc
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,15 @@ consensus::success_reply consensus::update_follower_index(

void consensus::maybe_promote_to_voter(model::node_id id) {
(void)ss::with_gate(_bg, [this, id] {
const auto& latest_cfg = _configuration_manager.get_latest();

// node is no longer part of current configuration, skip promotion
if (!latest_cfg.current_config().contains(id)) {
return ss::now();
}

// is voter already
if (config().is_voter(id)) {
if (latest_cfg.is_voter(id)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it is possible that maybe_promote_to_voter is called for a node id that is already a voter, is it possible that it is called for a node id that is already a voter and is also not in the current configuration? would that need a special case like demotion to candidate?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean by demotion to candidate ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking back at this i don't think i have the same question now. i must have be confused about the combination of conditions.

return ss::now();
}
auto it = _fstats.find(id);
Expand Down Expand Up @@ -493,8 +500,6 @@ bool consensus::should_skip_vote(bool ignore_heartbeat) {
}

skip_vote |= _vstate == vote_state::leader; // already a leader
skip_vote |= !_configuration_manager.get_latest().is_voter(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this change mean that vote_stm::vote would now allow a non-voter cast a vote?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

non-voters were always allow to cast a vote but not to request a vote. This behavior didn't change

_self); // not a voter

return skip_vote;
}
Expand Down Expand Up @@ -543,6 +548,12 @@ void consensus::dispatch_vote(bool leadership_transfer) {
// update target priority
_target_priority = next_target_priority();

// skip sending vote request if current node is not a voter
if (!_configuration_manager.get_latest().is_voter(_self)) {
arm_vote_timeout();
return;
}

// if priority is to low, skip dispatching votes, do not take priority into
// account when we transfer leadership
if (current_priority_to_low && !leadership_transfer) {
Expand Down
22 changes: 14 additions & 8 deletions src/v/raft/tests/membership_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,6 @@ FIXTURE_TEST(try_remove_all_voters, raft_test_fixture) {
BOOST_REQUIRE_EQUAL(result, raft::errc::invalid_configuration_update);
}

// TODO: Fix failing test. For more details see: #342
#if 0
FIXTURE_TEST(replace_whole_group, raft_test_fixture) {
raft_group gr = raft_group(raft::group_id(0), 3);
gr.enable_all();
Expand Down Expand Up @@ -251,11 +249,19 @@ FIXTURE_TEST(replace_whole_group, raft_test_fixture) {
},
"new nodes are up to date");

info("waiting for new group leader");
auto new_leader_id = wait_for_group_leader(gr);
auto& new_leader = gr.get_member(new_leader_id);
wait_for(
5s,
[&gr]() {
info("waiting for new group leader");
auto new_leader_id = wait_for_group_leader(gr);