From f48e0dfeaf06e7c568c8a28544ee9538ecf8a8dc Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Sat, 11 Oct 2025 16:39:57 +0800 Subject: [PATCH] [BugFix] fix asan error from PartitionedSpillerWriter::_remove_partition (backport #63903) (#63914) Signed-off-by: silverbullet233 <3675229+silverbullet233@users.noreply.github.com> Co-authored-by: eyes_on_me --- be/src/exec/spill/spill_components.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/be/src/exec/spill/spill_components.cpp b/be/src/exec/spill/spill_components.cpp index 39e1e23d83b..fe8f8bf04db 100644 --- a/be/src/exec/spill/spill_components.cpp +++ b/be/src/exec/spill/spill_components.cpp @@ -330,6 +330,12 @@ void PartitionedSpillerWriter::_remove_partition(const SpilledPartition* partiti auto iter = std::find_if(partitions.begin(), partitions.end(), [partition](auto& val) { return val->partition_id == partition->partition_id; }); _total_partition_num -= (iter != partitions.end()); + if (partition->block_group != nullptr) { + auto affinity_group = partition->block_group->get_affinity_group(); + DCHECK(affinity_group != kDefaultBlockAffinityGroup); + WARN_IF_ERROR(_spiller->block_manager()->release_affinity_group(affinity_group), + fmt::format("release affinity group {} error", affinity_group)); + } partitions.erase(iter); if (partitions.empty()) { _level_to_partitions.erase(level); @@ -337,12 +343,6 @@ void PartitionedSpillerWriter::_remove_partition(const SpilledPartition* partiti _min_level = level + 1; } } - if (partition->block_group != nullptr) { - auto affinity_group = partition->block_group->get_affinity_group(); - DCHECK(affinity_group != kDefaultBlockAffinityGroup); - WARN_IF_ERROR(_spiller->block_manager()->release_affinity_group(affinity_group), - fmt::format("release affinity group {} error", affinity_group)); - } } Status PartitionedSpillerWriter::_choose_partitions_to_flush(bool is_final_flush,