Skip to content

Commit

Permalink
r/consensus: fixed validating configuration change in leader transfer
Browse files Browse the repository at this point in the history
In redpanda raft implementation supports relaxed consistency. With
relaxed consistency we not always update `_commit_index` even tho
entries were replicated to all the nodes. When performing leadership
transfer we need to take that into account. When configuration is
successfully replicated to majority of nodes and it is not in joint
consensus state we are safe to proceed with the transfer.

Signed-off-by: Michal Maslanka <michal@vectorized.io>
(cherry picked from commit 42d3d54)
  • Loading branch information
mmaslankaprv committed Nov 11, 2021
1 parent 4ceca9f commit 0a34ae0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/v/raft/consensus.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2577,14 +2577,16 @@ consensus::do_transfer_leadership(std::optional<model::node_id> target) {
make_error_code(errc::not_leader));
}

if (_configuration_manager.get_latest_offset() > _commit_index) {
auto conf = _configuration_manager.get_latest();
if (
_configuration_manager.get_latest_offset() > last_visible_index()
|| conf.type() == configuration_type::joint) {
vlog(
_ctxlog.warn,
"Cannot transfer leadership during configuration change");
return ss::make_ready_future<std::error_code>(
make_error_code(errc::configuration_change_in_progress));
}
auto conf = _configuration_manager.get_latest();
auto target_rni = conf.current_config().find(*target);

if (!target_rni) {
Expand Down

0 comments on commit 0a34ae0

Please sign in to comment.