Skip to content

Commit

Permalink
c/backend: wait for leader to be elected before finishing abort cancel
Browse files Browse the repository at this point in the history
When forcibly aborting reconfiguration we should wait for the new leader
to be elected in the configuration that the partition was forced to.
This way we can be certain that the new configuration will finally be
replicated to the majority of nodes even tough the leader may not
exists at the time when configuration is replicated.

Fixes: redpanda-data#9243

Signed-off-by: Michal Maslanka <michal@redpanda.com>
(cherry picked from commit 3948312)
  • Loading branch information
mmaslankaprv authored and Michal Maslanka committed Jul 20, 2023
1 parent 37bc48f commit 8ae0c0d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/v/cluster/controller_backend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,10 @@ controller_backend::process_partition_reconfiguration(
* configuration so old replicas are not longer needed.
*/
if (can_finish_update(
type, target_assignment.replicas, previous_replicas)) {
partition->get_leader_id(),
type,
target_assignment.replicas,
previous_replicas)) {
co_return co_await dispatch_update_finished(
std::move(ntp), target_assignment);
}
Expand Down Expand Up @@ -1009,12 +1012,14 @@ controller_backend::process_partition_reconfiguration(
}

bool controller_backend::can_finish_update(
std::optional<model::node_id> current_leader,
topic_table_delta::op_type update_type,
const std::vector<model::broker_shard>& current_replicas,
const std::vector<model::broker_shard>& previous_replicas) {
// force abort update may be finished by any node
if (update_type == topic_table_delta::op_type::force_abort_update) {
return true;
return current_leader == _self;
;
}
// update may be finished by a node that was added to replica set
if (!has_local_replicas(_self, previous_replicas)) {
Expand Down
1 change: 1 addition & 0 deletions src/v/cluster/controller_backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ class controller_backend
model::ntp, ss::shard_id, partition_assignment);

bool can_finish_update(
std::optional<model::node_id>,
topic_table_delta::op_type,
const std::vector<model::broker_shard>&,
const std::vector<model::broker_shard>&);
Expand Down

0 comments on commit 8ae0c0d

Please sign in to comment.