Skip to content

Commit c90958e

Browse files
committed
[fix](spill) Memory leak in the arena used by the aggregation source operator
After switching spill partition in partitioned aggregation source operator, the agg_arena_pool also needs to be reset.
1 parent 6eee338 commit c90958e

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

be/src/pipeline/exec/aggregation_source_operator.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,14 @@ size_t AggSourceOperatorX::get_estimated_memory_size_for_merging(RuntimeState* s
543543
return size;
544544
}
545545

546+
Status AggSourceOperatorX::reset_hash_table(RuntimeState* state) {
547+
auto& local_state = get_local_state(state);
548+
auto& ss = *local_state.Base::_shared_state;
549+
RETURN_IF_ERROR(ss.reset_hash_table());
550+
ss.agg_arena_pool.clear(true);
551+
return Status::OK();
552+
}
553+
546554
void AggLocalState::_emplace_into_hash_table(vectorized::AggregateDataPtr* places,
547555
vectorized::ColumnRawPtrs& key_columns,
548556
uint32_t num_rows) {

be/src/pipeline/exec/aggregation_source_operator.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ class AggSourceOperatorX : public OperatorX<AggLocalState> {
114114

115115
size_t get_estimated_memory_size_for_merging(RuntimeState* state, size_t rows) const;
116116

117+
Status reset_hash_table(RuntimeState* state);
118+
117119
private:
118120
friend class AggLocalState;
119121

be/src/pipeline/exec/partitioned_aggregation_source_operator.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@ Status PartitionedAggSourceOperatorX::get_block(RuntimeState* state, vectorized:
181181
local_state._need_to_merge_data_for_current_partition = true;
182182
status = local_state._shared_state->in_mem_shared_state->reset_hash_table();
183183
RETURN_IF_ERROR(status);
184+
status = _agg_source_operator->reset_hash_table(runtime_state);
185+
RETURN_IF_ERROR(status);
184186
*eos = false;
185187
}
186188
}

0 commit comments

Comments
 (0)