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

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


The following commit(s) were added to refs/heads/master by this push:
     new f174a304f27 [enhancement](exception) pageio method should return error 
when allocate memory failed (#40020)
f174a304f27 is described below

commit f174a304f2723b77bcf3de2614af1ba54613604f
Author: yiguolei <[email protected]>
AuthorDate: Wed Aug 28 21:05:11 2024 +0800

    [enhancement](exception) pageio method should return error when allocate 
memory failed (#40020)
    
    ## Proposed changes
    
    1. pageio method should return error when allocate memory failed just
    for point query.
    2. variant parsing logic should return error when allocate memory
    failed.
    
    ---------
    
    Co-authored-by: yiguolei <[email protected]>
---
 be/src/olap/rowset/segment_creator.cpp    |  2 +-
 be/src/olap/rowset/segment_creator.h      |  6 +++++-
 be/src/olap/rowset/segment_v2/page_io.cpp |  4 ++--
 be/src/olap/rowset/segment_v2/page_io.h   | 11 ++++++++++-
 be/src/vec/common/schema_util.cpp         | 14 ++++----------
 5 files changed, 22 insertions(+), 15 deletions(-)

diff --git a/be/src/olap/rowset/segment_creator.cpp 
b/be/src/olap/rowset/segment_creator.cpp
index c657238c020..1afd3215db4 100644
--- a/be/src/olap/rowset/segment_creator.cpp
+++ b/be/src/olap/rowset/segment_creator.cpp
@@ -83,7 +83,7 @@ Status SegmentFlusher::flush_single_block(const 
vectorized::Block* block, int32_
     return Status::OK();
 }
 
-Status SegmentFlusher::_parse_variant_columns(vectorized::Block& block) {
+Status SegmentFlusher::_internal_parse_variant_columns(vectorized::Block& 
block) {
     size_t num_rows = block.rows();
     if (num_rows == 0) {
         return Status::OK();
diff --git a/be/src/olap/rowset/segment_creator.h 
b/be/src/olap/rowset/segment_creator.h
index 961e161853c..c862fce87a4 100644
--- a/be/src/olap/rowset/segment_creator.h
+++ b/be/src/olap/rowset/segment_creator.h
@@ -141,7 +141,11 @@ public:
     bool need_buffering();
 
 private:
-    Status _parse_variant_columns(vectorized::Block& block);
+    // This method will catch exception when allocate memory failed
+    Status _parse_variant_columns(vectorized::Block& block) {
+        RETURN_IF_CATCH_EXCEPTION({ return 
_internal_parse_variant_columns(block); });
+    }
+    Status _internal_parse_variant_columns(vectorized::Block& block);
     Status _add_rows(std::unique_ptr<segment_v2::SegmentWriter>& 
segment_writer,
                      const vectorized::Block* block, size_t row_offset, size_t 
row_num);
     Status _add_rows(std::unique_ptr<segment_v2::VerticalSegmentWriter>& 
segment_writer,
diff --git a/be/src/olap/rowset/segment_v2/page_io.cpp 
b/be/src/olap/rowset/segment_v2/page_io.cpp
index cea4a23f742..07d5656ee8a 100644
--- a/be/src/olap/rowset/segment_v2/page_io.cpp
+++ b/be/src/olap/rowset/segment_v2/page_io.cpp
@@ -111,8 +111,8 @@ Status PageIO::write_page(io::FileWriter* writer, const 
std::vector<Slice>& body
     return Status::OK();
 }
 
-Status PageIO::read_and_decompress_page(const PageReadOptions& opts, 
PageHandle* handle,
-                                        Slice* body, PageFooterPB* footer) {
+Status PageIO::read_and_decompress_page_(const PageReadOptions& opts, 
PageHandle* handle,
+                                         Slice* body, PageFooterPB* footer) {
     opts.sanity_check();
     opts.stats->total_pages_num++;
 
diff --git a/be/src/olap/rowset/segment_v2/page_io.h 
b/be/src/olap/rowset/segment_v2/page_io.h
index 736b3e521f6..b23af4b0b35 100644
--- a/be/src/olap/rowset/segment_v2/page_io.h
+++ b/be/src/olap/rowset/segment_v2/page_io.h
@@ -123,8 +123,17 @@ public:
     //     `handle' holds the memory of page data,
     //     `body' points to page body,
     //     `footer' stores the page footer.
+    // This method is exception safe, it will failed when allocate memory 
failed.
     static Status read_and_decompress_page(const PageReadOptions& opts, 
PageHandle* handle,
-                                           Slice* body, PageFooterPB* footer);
+                                           Slice* body, PageFooterPB* footer) {
+        RETURN_IF_CATCH_EXCEPTION(
+                { return read_and_decompress_page_(opts, handle, body, 
footer); });
+    }
+
+private:
+    // An internal method that not deal with exception.
+    static Status read_and_decompress_page_(const PageReadOptions& opts, 
PageHandle* handle,
+                                            Slice* body, PageFooterPB* footer);
 };
 
 } // namespace segment_v2
diff --git a/be/src/vec/common/schema_util.cpp 
b/be/src/vec/common/schema_util.cpp
index 4d470ccc3b7..c0b48e01307 100644
--- a/be/src/vec/common/schema_util.cpp
+++ b/be/src/vec/common/schema_util.cpp
@@ -530,16 +530,10 @@ Status _parse_variant_columns(Block& block, const 
std::vector<int>& variant_pos,
 
 Status parse_variant_columns(Block& block, const std::vector<int>& variant_pos,
                              const ParseConfig& config) {
-    try {
-        // Parse each variant column from raw string column
-        RETURN_IF_ERROR(
-                vectorized::schema_util::_parse_variant_columns(block, 
variant_pos, config));
-    } catch (const doris::Exception& e) {
-        // TODO more graceful, max_filter_ratio
-        LOG(WARNING) << "encounter execption " << e.to_string();
-        return Status::InternalError(e.to_string());
-    }
-    return Status::OK();
+    // Parse each variant column from raw string column
+    RETURN_IF_CATCH_EXCEPTION({
+        return vectorized::schema_util::_parse_variant_columns(block, 
variant_pos, config);
+    });
 }
 
 Status encode_variant_sparse_subcolumns(ColumnObject& column) {


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to