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

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

commit 2cbe6740a59ffeb82fdcce1de0b73ebab35b5b7c
Author: TengJianPing <[email protected]>
AuthorDate: Wed May 15 12:36:23 2024 +0800

    [fix](reader) avoid be coredump in block reader in abnormal situation 
(#34878)
---
 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 beb0bb7c8cc..1714e3584f9 100644
--- a/be/src/vec/olap/block_reader.cpp
+++ b/be/src/vec/olap/block_reader.cpp
@@ -163,9 +163,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 =
@@ -181,7 +181,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()];
@@ -194,6 +201,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) {
@@ -246,7 +255,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 f21909315a4..6f9792929db 100644
--- a/be/src/vec/olap/block_reader.h
+++ b/be/src/vec/olap/block_reader.h
@@ -72,7 +72,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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to