Skip to content
Open
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
20 changes: 17 additions & 3 deletions src/v/cluster/topics_frontend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1377,20 +1377,34 @@ topics_frontend::partitions_with_lost_majority(
const auto& assignments = (it->second).get_assignments();
const auto topic_revision = it->second.get_revision();
for (const auto& [_, assignment] : assignments) {
const auto& current = assignment.replicas;
auto current = assignment.replicas;
// sort for a consistent final output ordering.
std::ranges::sort(current, [](const auto& a, const auto& b) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit:
can we kick the sort to after the quorum loss determination?

We only need a sorted copy of assignment.replicas if theres quorum loss.

return a.node_id < b.node_id;
});
auto remaining = subtract_replica_sets_by_node_id(
current, dead_nodes);
auto lost_majority = remaining.size()
< (current.size() / 2) + 1;
if (!lost_majority) {
continue;
}
// Extract node_ids of dead replicas of this partition
std::vector<model::node_id> dead_replicas;
dead_replicas.reserve(dead_nodes.size());
for (const auto& replica : current) {
if (
std::ranges::find(dead_nodes, replica.node_id)
!= dead_nodes.end()) {
Comment on lines +1397 to +1398
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: use std::ranges::contains

dead_replicas.push_back(replica.node_id);
}
}
model::ntp ntp(tn.ns, tn.tp, assignment.id);
result.emplace_back(
std::move(ntp),
topic_revision,
assignment.replicas,
dead_nodes);
std::move(current),
std::move(dead_replicas));
co_await ss::coroutine::maybe_yield();
it.check();
}
Expand Down