Skip to content

Commit

Permalink
Merge pull request #7406 from dlex/7343_fix-use-after-move-in-delete-…
Browse files Browse the repository at this point in the history
…topic-cmd

Fix a use-after-move in `partition_balancer`
  • Loading branch information
dlex authored Nov 22, 2022
2 parents 2212820 + d1a16bc commit efa17cc
Showing 1 changed file with 25 additions and 24 deletions.
49 changes: 25 additions & 24 deletions src/v/cluster/topic_updates_dispatcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,32 +53,33 @@ topic_updates_dispatcher::apply_update(model::record_batch b) {
del_cmd.key, *topic_assignments);
}
return dispatch_updates_to_cores(del_cmd, base_offset)
.then([this,
tp_ns = std::move(del_cmd.key),
topic_assignments = std::move(topic_assignments),
in_progress = std::move(in_progress),
allocation_domain = get_allocation_domain(
del_cmd.key)](std::error_code ec) {
if (ec == errc::success) {
vassert(
topic_assignments.has_value(),
"Topic had to exist before successful delete");
deallocate_topic(
*topic_assignments, in_progress, allocation_domain);
.then(
[this,
tp_ns = std::move(del_cmd.key),
topic_assignments = std::move(topic_assignments),
in_progress = std::move(in_progress)](std::error_code ec) {
if (ec == errc::success) {
vassert(
topic_assignments.has_value(),
"Topic had to exist before successful delete");
deallocate_topic(
*topic_assignments,
in_progress,
get_allocation_domain(tp_ns));

for (const auto& p_as : *topic_assignments) {
_partition_balancer_state.local()
.handle_ntp_update(
tp_ns.ns,
tp_ns.tp,
p_as.id,
p_as.replicas,
{});
}
}
for (const auto& p_as : *topic_assignments) {
_partition_balancer_state.local()
.handle_ntp_update(
tp_ns.ns,
tp_ns.tp,
p_as.id,
p_as.replicas,
{});
}
}

return ec;
});
return ec;
});
},
[this, base_offset](create_topic_cmd create_cmd) {
return dispatch_updates_to_cores(create_cmd, base_offset)
Expand Down

0 comments on commit efa17cc

Please sign in to comment.