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

panxiaolei 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 3f55d5d4d5 [Chore](excution) change some log fatal and dcheck to 
exception (#22890)
3f55d5d4d5 is described below

commit 3f55d5d4d5c9ddb1f68ed4d9c78e278ca15a0019
Author: Pxl <pxl...@qq.com>
AuthorDate: Tue Aug 15 10:45:00 2023 +0800

    [Chore](excution) change some log fatal and dcheck to exception (#22890)
    
    change some log fatal and dcheck to exception
---
 be/src/vec/core/block.cpp               | 56 ++++++++++++++-------------------
 be/src/vec/sink/vdata_stream_sender.cpp |  9 +++++-
 2 files changed, 32 insertions(+), 33 deletions(-)

diff --git a/be/src/vec/core/block.cpp b/be/src/vec/core/block.cpp
index 3036cd096a..5b89077bd3 100644
--- a/be/src/vec/core/block.cpp
+++ b/be/src/vec/core/block.cpp
@@ -141,8 +141,9 @@ void Block::initialize_index_by_name() {
 
 void Block::insert(size_t position, const ColumnWithTypeAndName& elem) {
     if (position > data.size()) {
-        LOG(FATAL) << fmt::format("Position out of bound in Block::insert(), 
max position = {}",
-                                  data.size());
+        throw Exception(ErrorCode::INTERNAL_ERROR,
+                        "invalid input position, position={}, data.size{}, 
names={}", position,
+                        data.size(), dump_names());
     }
 
     for (auto& name_pos : index_by_name) {
@@ -157,8 +158,9 @@ void Block::insert(size_t position, const 
ColumnWithTypeAndName& elem) {
 
 void Block::insert(size_t position, ColumnWithTypeAndName&& elem) {
     if (position > data.size()) {
-        LOG(FATAL) << fmt::format("Position out of bound in Block::insert(), 
max position = {}",
-                                  data.size());
+        throw Exception(ErrorCode::INTERNAL_ERROR,
+                        "invalid input position, position={}, data.size{}, 
names={}", position,
+                        data.size(), dump_names());
     }
 
     for (auto& name_pos : index_by_name) {
@@ -246,47 +248,36 @@ void Block::erase_impl(size_t position) {
 void Block::erase(const String& name) {
     auto index_it = index_by_name.find(name);
     if (index_it == index_by_name.end()) {
-        LOG(FATAL) << fmt::format("No such name in Block::erase(): '{}'", 
name);
+        throw Exception(ErrorCode::INTERNAL_ERROR, "No such name in Block, 
name={}, block_names={}",
+                        name, dump_names());
     }
 
     erase_impl(index_it->second);
 }
 
 ColumnWithTypeAndName& Block::safe_get_by_position(size_t position) {
-    if (data.empty()) {
-        LOG(FATAL) << "Block is empty";
-    }
-
     if (position >= data.size()) {
-        LOG(FATAL) << fmt::format(
-                "Position {} is out of bound in Block::safe_get_by_position(), 
max position = {}, "
-                "there are columns: {}",
-                position, data.size() - 1, dump_names());
+        throw Exception(ErrorCode::INTERNAL_ERROR,
+                        "invalid input position, position={}, data.size{}, 
names={}", position,
+                        data.size(), dump_names());
     }
-
     return data[position];
 }
 
 const ColumnWithTypeAndName& Block::safe_get_by_position(size_t position) 
const {
-    if (data.empty()) {
-        LOG(FATAL) << "Block is empty";
-    }
-
     if (position >= data.size()) {
-        LOG(FATAL) << fmt::format(
-                "Position {} is out of bound in Block::safe_get_by_position(), 
max position = {}, "
-                "there are columns: {}",
-                position, data.size() - 1, dump_names());
+        throw Exception(ErrorCode::INTERNAL_ERROR,
+                        "invalid input position, position={}, data.size{}, 
names={}", position,
+                        data.size(), dump_names());
     }
-
     return data[position];
 }
 
 ColumnWithTypeAndName& Block::get_by_name(const std::string& name) {
     auto it = index_by_name.find(name);
     if (index_by_name.end() == it) {
-        LOG(FATAL) << fmt::format("Not found column {} in block. There are 
only columns: {}", name,
-                                  dump_names());
+        throw Exception(ErrorCode::INTERNAL_ERROR, "No such name in Block, 
name={}, block_names={}",
+                        name, dump_names());
     }
 
     return data[it->second];
@@ -295,8 +286,8 @@ ColumnWithTypeAndName& Block::get_by_name(const 
std::string& name) {
 const ColumnWithTypeAndName& Block::get_by_name(const std::string& name) const 
{
     auto it = index_by_name.find(name);
     if (index_by_name.end() == it) {
-        LOG(FATAL) << fmt::format("Not found column {} in block. There are 
only columns: {}", name,
-                                  dump_names());
+        throw Exception(ErrorCode::INTERNAL_ERROR, "No such name in Block, 
name={}, block_names={}",
+                        name, dump_names());
     }
 
     return data[it->second];
@@ -325,8 +316,8 @@ bool Block::has(const std::string& name) const {
 size_t Block::get_position_by_name(const std::string& name) const {
     auto it = index_by_name.find(name);
     if (index_by_name.end() == it) {
-        LOG(FATAL) << fmt::format("Not found column {} in block. There are 
only columns: {}", name,
-                                  dump_names());
+        throw Exception(ErrorCode::INTERNAL_ERROR, "No such name in Block, 
name={}, block_names={}",
+                        name, dump_names());
     }
 
     return it->second;
@@ -943,7 +934,8 @@ void MutableBlock::add_rows(const Block* block, size_t 
row_begin, size_t length)
 void MutableBlock::erase(const String& name) {
     auto index_it = index_by_name.find(name);
     if (index_it == index_by_name.end()) {
-        LOG(FATAL) << fmt::format("No such name in Block::erase(): '{}'", 
name);
+        throw Exception(ErrorCode::INTERNAL_ERROR, "No such name in Block, 
name={}, block_names={}",
+                        name, dump_names());
     }
 
     auto position = index_it->second;
@@ -1080,8 +1072,8 @@ bool MutableBlock::has(const std::string& name) const {
 size_t MutableBlock::get_position_by_name(const std::string& name) const {
     auto it = index_by_name.find(name);
     if (index_by_name.end() == it) {
-        LOG(FATAL) << fmt::format("Not found column {} in block. There are 
only columns: {}", name,
-                                  dump_names());
+        throw Exception(ErrorCode::INTERNAL_ERROR, "No such name in Block, 
name={}, block_names={}",
+                        name, dump_names());
     }
 
     return it->second;
diff --git a/be/src/vec/sink/vdata_stream_sender.cpp 
b/be/src/vec/sink/vdata_stream_sender.cpp
index 244714d3e7..ffd15ebf14 100644
--- a/be/src/vec/sink/vdata_stream_sender.cpp
+++ b/be/src/vec/sink/vdata_stream_sender.cpp
@@ -787,7 +787,14 @@ void VDataStreamSender::_roll_pb_block() {
 }
 
 Status VDataStreamSender::_get_next_available_buffer(BroadcastPBlockHolder** 
holder) {
-    DCHECK(_broadcast_pb_blocks[_broadcast_pb_block_idx].available());
+    if (_broadcast_pb_block_idx >= _broadcast_pb_blocks.size()) {
+        return Status::InternalError(
+                "get_next_available_buffer meet invalid index, index={}, 
size={}",
+                _broadcast_pb_block_idx, _broadcast_pb_blocks.size());
+    }
+    if (!_broadcast_pb_blocks[_broadcast_pb_block_idx].available()) {
+        return Status::InternalError("broadcast_pb_blocks not available");
+    }
     *holder = &_broadcast_pb_blocks[_broadcast_pb_block_idx];
     _broadcast_pb_block_idx++;
     return Status::OK();


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

Reply via email to