This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
     new 3b124e1e569 [fix](reader) avoid be coredump in block reader in 
abnormal situation (#34881)
3b124e1e569 is described below

commit 3b124e1e56996ee33ce016804166a54518bbdb6c
Author: TengJianPing <18241664+jackte...@users.noreply.github.com>
AuthorDate: Wed May 15 19:34:21 2024 +0800

    [fix](reader) avoid be coredump in block reader in abnormal situation 
(#34881)
---
 be/src/vec/olap/block_reader.cpp | 17 +++++++++++++----
 be/src/vec/olap/block_reader.h   |  2 +-
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/be/src/vec/olap/block_reader.cpp b/be/src/vec/olap/block_reader.cpp
index 0778a6b8eaa..d69efa181e8 100644
--- a/be/src/vec/olap/block_reader.cpp
+++ b/be/src/vec/olap/block_reader.cpp
@@ -153,9 +153,9 @@ Status BlockReader::_init_collect_iter(const ReaderParams& 
read_params) {
     return Status::OK();
 }
 
-void BlockReader::_init_agg_state(const ReaderParams& read_params) {
+Status BlockReader::_init_agg_state(const ReaderParams& read_params) {
     if (_eof) {
-        return;
+        return Status::OK();
     }
 
     _stored_data_columns =
@@ -171,7 +171,14 @@ void BlockReader::_init_agg_state(const ReaderParams& 
read_params) {
         AggregateFunctionPtr function =
                 column.get_aggregate_function(vectorized::AGG_READER_SUFFIX);
 
-        DCHECK(function != nullptr);
+        // to avoid coredump when something goes wrong(i.e. column missmatch)
+        if (!function) {
+            return Status::InternalError(
+                    "Failed to init reader when init agg state: "
+                    "tablet_id: {}, schema_hash: {}, reader_type: {}, version: 
{}",
+                    read_params.tablet->tablet_id(), 
read_params.tablet->schema_hash(),
+                    int(read_params.reader_type), 
read_params.version.to_string());
+        }
         _agg_functions.push_back(function);
         // create aggregate data
         AggregateDataPtr place = new char[function->size_of_data()];
@@ -184,6 +191,8 @@ void BlockReader::_init_agg_state(const ReaderParams& 
read_params) {
         // calculate `_has_variable_length_tag` tag. like string, array, map
         _stored_has_variable_length_tag[idx] = 
_stored_data_columns[idx]->is_variable_length();
     }
+
+    return Status::OK();
 }
 
 Status BlockReader::init(const ReaderParams& read_params) {
@@ -237,7 +246,7 @@ Status BlockReader::init(const ReaderParams& read_params) {
         break;
     case KeysType::AGG_KEYS:
         _next_block_func = &BlockReader::_agg_key_next_block;
-        _init_agg_state(read_params);
+        RETURN_IF_ERROR(_init_agg_state(read_params));
         break;
     default:
         DCHECK(false) << "No next row function for type:" << 
tablet()->keys_type();
diff --git a/be/src/vec/olap/block_reader.h b/be/src/vec/olap/block_reader.h
index 7e578e9a0e2..05b26f0c52c 100644
--- a/be/src/vec/olap/block_reader.h
+++ b/be/src/vec/olap/block_reader.h
@@ -78,7 +78,7 @@ private:
 
     Status _init_collect_iter(const ReaderParams& read_params);
 
-    void _init_agg_state(const ReaderParams& read_params);
+    Status _init_agg_state(const ReaderParams& read_params);
 
     Status _insert_data_normal(MutableColumns& columns);
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to