Skip to content

Commit

Permalink
Merge pull request #4216 from dotnwat/backport-4188
Browse files Browse the repository at this point in the history
[21.11.x]: backport #4157
  • Loading branch information
dotnwat committed Apr 6, 2022
2 parents 311f8e2 + 018f358 commit 1cda696
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 19 deletions.
9 changes: 2 additions & 7 deletions src/v/raft/prevote_stm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,8 @@ ss::future<bool> prevote_stm::do_prevote() {
// dispatch requests to all voters
_config->for_each_voter([this](vnode id) { (void)dispatch_prevote(id); });

// wait until majority
const size_t majority = (_config->unique_voter_count() / 2) + 1;

return _sem.wait(majority)
.then([this] { return process_replies(); })
// process results
.then([this]() { return _success; });
// process results
return process_replies().then([this]() { return _success; });
}

ss::future<> prevote_stm::process_replies() {
Expand Down
17 changes: 5 additions & 12 deletions src/v/raft/vote_stm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -144,18 +144,11 @@ ss::future<> vote_stm::do_vote() {
// dispatch requests to all voters
_config->for_each_voter([this](vnode id) { (void)dispatch_one(id); });

// wait until majority
const size_t majority = (_config->unique_voter_count() / 2) + 1;

return _sem.wait(majority)
.then([this] { return process_replies(); })
// porcess results
.then([this]() {
return _ptr->_op_lock.get_units().then(
[this](ss::semaphore_units<> u) {
return update_vote_state(std::move(u));
});
});
return process_replies().then([this]() {
return _ptr->_op_lock.get_units().then([this](ss::semaphore_units<> u) {
return update_vote_state(std::move(u));
});
});
}

ss::future<> vote_stm::process_replies() {
Expand Down

0 comments on commit 1cda696

Please sign in to comment.