This is an automated email from the ASF dual-hosted git repository. morningman pushed a commit to branch branch-2.0-alpha in repository https://gitbox.apache.org/repos/asf/doris.git
commit 4cf2644cb5871acf75b35ec8f9310ad88ff64f67 Author: Yongqiang YANG <98214048+dataroar...@users.noreply.github.com> AuthorDate: Thu Apr 27 14:22:09 2023 +0800 [fix](memleak) avoid memleak due to race condition (#19071) --- be/src/util/core_local.cpp | 8 ++++++-- be/src/vec/aggregate_functions/aggregate_function_hll_union_agg.h | 3 +++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/be/src/util/core_local.cpp b/be/src/util/core_local.cpp index 2077d87908..4af164573d 100644 --- a/be/src/util/core_local.cpp +++ b/be/src/util/core_local.cpp @@ -55,8 +55,12 @@ public: } CoreDataBlock* block = _blocks[block_id]; if (block == nullptr) { - block = new CoreDataBlock(); - _blocks[block_id] = block; + std::lock_guard<SpinLock> l(_lock); + block = _blocks[block_id]; + if (block == nullptr) { + block = new CoreDataBlock(); + _blocks[block_id] = block; + } } size_t offset = (id % ELEMENTS_PER_BLOCK) * ELEMENT_BYTES; return block->at(offset); diff --git a/be/src/vec/aggregate_functions/aggregate_function_hll_union_agg.h b/be/src/vec/aggregate_functions/aggregate_function_hll_union_agg.h index 3e8ee3cb29..acc46d9e17 100644 --- a/be/src/vec/aggregate_functions/aggregate_function_hll_union_agg.h +++ b/be/src/vec/aggregate_functions/aggregate_function_hll_union_agg.h @@ -33,6 +33,9 @@ namespace doris::vectorized { struct AggregateFunctionHLLData { HyperLogLog dst_hll {}; + AggregateFunctionHLLData() = default; + ~AggregateFunctionHLLData() = default; + void merge(const AggregateFunctionHLLData& rhs) { dst_hll.merge(rhs.dst_hll); } void write(BufferWritable& buf) const { --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org