From 9dfc6afaa6157dfdeae3b2772a4c2406bc5dd3e9 Mon Sep 17 00:00:00 2001 From: Jerry Hu Date: Tue, 21 Mar 2023 09:00:06 +0800 Subject: [PATCH] [fix](agg) Avoid reusing a non-nullable column that has been converted to nullable within a block (#17944) 0# doris::signal::(anonymous namespace)::FailureSignalHandler(int, siginfo_t*, void*) at /root/doris/be/src/common/signal_handler.h:420 1# os::Linux::chained_handler(int, siginfo*, void*) in /usr/local/java/jdk1.8.0_202/jre/lib/amd64/server/libjvm.so 2# JVM_handle_linux_signal in /usr/local/java/jdk1.8.0_202/jre/lib/amd64/server/libjvm.so 3# signalHandler(int, siginfo*, void*) in /usr/local/java/jdk1.8.0_202/jre/lib/amd64/server/libjvm.so 4# 0x00007F4051C9F400 in /lib64/libc.so.6 5# memcpy at /root/doris/be/src/glibc-compatibility/memcpy/memcpy_x86_64.cpp:219 6# doris::vectorized::ColumnString::deserialize_and_insert_from_arena(char const*) at /root/doris/be/src/vec/columns/column_string.cpp:226 7# doris::vectorized::ColumnString::deserialize_vec_with_null_map(std::vector >&, unsigned long, unsigned char const*) at /root/doris/be/src/vec/columns/column_string.cpp:283 8# void doris::vectorized::AggregationNode::_serialize_with_serialized_key_result(doris::RuntimeState*, doris::vectorized::Block*, bool*)::{lambda(auto:1&&)#1}::operator(), false> >&>(doris::vectorized::AggregationMethodSerialized, false> >&) const at /root/doris/be/src/vec/exec/vaggregation_node.cpp:1232 9# doris::vectorized::AggregationNode::_serialize_with_serialized_key_result(doris::RuntimeState*, doris::vectorized::Block*, bool*) at /root/doris/be/src/vec/exec/vaggregation_node.cpp:1294 10# std::_Function_handler, std::_Placeholder<2>, std::_Placeholder<3>))(doris::RuntimeState*, doris::vectorized::Block*, bool*)> >::_M_invoke(std::_Any_data const&, doris::RuntimeState*&&, doris::vectorized::Block*&&, bool*&&) at /var/local/ldb-toolchain/include/c++/11/bits/std_function.h:293 11# doris::vectorized::AggregationNode::get_next(doris::RuntimeState*, doris::vectorized::Block*, bool*) at /root/doris/be/src/vec/exec/vaggregation_node.cpp:508 12# doris::ExecNode::get_next_after_projects(doris::RuntimeState*, doris::vectorized::Block*, bool*) at /root/doris/be/src/exec/exec_node.cpp:852 13# doris::PlanFragmentExecutor::get_vectorized_internal(doris::vectorized::Block**) at /root/doris/be/src/runtime/plan_fragment_executor.cpp:352 14# doris::PlanFragmentExecutor::open_vectorized_internal() at /root/doris/be/src/runtime/plan_fragment_executor.cpp:300 15# doris::PlanFragmentExecutor::open() at /root/doris/be/src/runtime/plan_fragment_executor.cpp:253 16# doris::FragmentExecState::execute() at /root/doris/be/src/runtime/fragment_mgr.cpp:251 17# doris::FragmentMgr::_exec_actual(std::shared_ptr, std::function) at /root/doris/be/src/runtime/fragment_mgr.cpp:498 18# std::_Function_handler)::{lambda()#1}>::_M_invoke(std::_Any_data const&) at /var/local/ldb-toolchain/include/c++/11/bits/std_function.h:291 19# doris::ThreadPool::dispatch_thread() at /root/doris/be/src/util/threadpool.cpp:542 20# doris::Thread::supervise_thread(void*) at /root/doris/be/src/util/thread.cpp:455 21# start_thread in /lib64/libpthread.so.0 22# clone in /lib64/libc.so.6 --- be/src/vec/exec/vaggregation_node.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/be/src/vec/exec/vaggregation_node.cpp b/be/src/vec/exec/vaggregation_node.cpp index 277f1f669162d0..42a5d67f9dcae8 100644 --- a/be/src/vec/exec/vaggregation_node.cpp +++ b/be/src/vec/exec/vaggregation_node.cpp @@ -978,8 +978,10 @@ Status AggregationNode::_pre_agg_with_serialized_key(doris::vectorized::Block* i SCOPED_TIMER(_streaming_agg_timer); ret_flag = true; - // will serialize value data to string column - bool mem_reuse = out_block->mem_reuse(); + // will serialize value data to string column. + // non-nullable column(id in `_make_nullable_keys`) + // will be converted to nullable. + bool mem_reuse = _make_nullable_keys.empty() && out_block->mem_reuse(); std::vector data_types; MutableColumns value_columns; @@ -1084,7 +1086,8 @@ Status AggregationNode::_execute_with_serialized_key(Block* block) { Status AggregationNode::_get_with_serialized_key_result(RuntimeState* state, Block* block, bool* eos) { - bool mem_reuse = block->mem_reuse(); + // non-nullable column(id in `_make_nullable_keys`) will be converted to nullable. + bool mem_reuse = _make_nullable_keys.empty() && block->mem_reuse(); auto column_withschema = VectorizedUtils::create_columns_with_type_and_name(_row_descriptor); int key_size = _probe_expr_ctxs.size(); @@ -1189,7 +1192,8 @@ Status AggregationNode::_serialize_with_serialized_key_result(RuntimeState* stat MutableColumns value_columns(agg_size); DataTypes value_data_types(agg_size); - bool mem_reuse = block->mem_reuse(); + // non-nullable column(id in `_make_nullable_keys`) will be converted to nullable. + bool mem_reuse = _make_nullable_keys.empty() && block->mem_reuse(); MutableColumns key_columns; for (int i = 0; i < key_size; ++i) {