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 e4c8e2b7718 [Chore](log) do not get stacktrace when error_code's 
stacktrace is false (#35974)
e4c8e2b7718 is described below

commit e4c8e2b77185f7032faedf90fbf0840a3684009f
Author: Pxl <[email protected]>
AuthorDate: Thu Jun 6 19:30:26 2024 +0800

    [Chore](log) do not get stacktrace when error_code's stacktrace is false 
(#35974)
    
    ## Proposed changes
    do not get stacktrace when error_code's stacktrace is false
---
 be/src/agent/task_worker_pool.cpp                         | 2 +-
 be/src/common/exception.cpp                               | 8 ++++++--
 be/src/common/exception.h                                 | 2 +-
 be/src/olap/rowset/segment_v2/segment_writer.cpp          | 2 +-
 be/src/olap/rowset/segment_v2/vertical_segment_writer.cpp | 4 ++--
 5 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/be/src/agent/task_worker_pool.cpp 
b/be/src/agent/task_worker_pool.cpp
index 8ec3d105089..e7aac86163a 100644
--- a/be/src/agent/task_worker_pool.cpp
+++ b/be/src/agent/task_worker_pool.cpp
@@ -1117,7 +1117,7 @@ void report_tablet_callback(StorageEngine& engine, const 
TMasterInfo& master_inf
         auto& resource = resource_list.emplace_back();
         int64_t id = -1;
         if (auto [_, ec] = std::from_chars(id_str.data(), id_str.data() + 
id_str.size(), id);
-            ec == std::errc {}) [[unlikely]] {
+            ec != std::errc {}) [[unlikely]] {
             LOG(ERROR) << "invalid resource id format: " << id_str;
         } else {
             resource.__set_id(id);
diff --git a/be/src/common/exception.cpp b/be/src/common/exception.cpp
index 37e357ec32f..c6139c0f995 100644
--- a/be/src/common/exception.cpp
+++ b/be/src/common/exception.cpp
@@ -25,7 +25,9 @@ Exception::Exception(int code, const std::string_view& msg) {
     _code = code;
     _err_msg = std::make_unique<ErrMsg>();
     _err_msg->_msg = msg;
-    _err_msg->_stack = get_stack_trace();
+    if (ErrorCode::error_states[abs(code)].stacktrace) {
+        _err_msg->_stack = get_stack_trace();
+    }
     if (config::exit_on_exception) {
         LOG(FATAL) << "[ExitOnException] error code: " << code << ", message: 
" << msg;
     }
@@ -35,7 +37,9 @@ Exception::Exception(const Exception& nested, int code, const 
std::string_view&
     _code = code;
     _err_msg = std::make_unique<ErrMsg>();
     _err_msg->_msg = msg;
-    _err_msg->_stack = get_stack_trace();
+    if (ErrorCode::error_states[abs(code)].stacktrace) {
+        _err_msg->_stack = get_stack_trace();
+    }
     _nested_excption = std::make_unique<Exception>();
     _nested_excption->_code = nested._code;
     _nested_excption->_err_msg = std::make_unique<ErrMsg>();
diff --git a/be/src/common/exception.h b/be/src/common/exception.h
index 39d675a7cc4..0ec8d334e8b 100644
--- a/be/src/common/exception.h
+++ b/be/src/common/exception.h
@@ -54,7 +54,7 @@ public:
 
     const char* what() const noexcept override { return to_string().c_str(); }
 
-    Status to_status() const { return Status(code(), _err_msg->_msg, 
_err_msg->_stack); }
+    Status to_status() const { return {code(), _err_msg->_msg, 
_err_msg->_stack}; }
 
 private:
     int _code;
diff --git a/be/src/olap/rowset/segment_v2/segment_writer.cpp 
b/be/src/olap/rowset/segment_v2/segment_writer.cpp
index b7fa5aea794..7e80195477b 100644
--- a/be/src/olap/rowset/segment_v2/segment_writer.cpp
+++ b/be/src/olap/rowset/segment_v2/segment_writer.cpp
@@ -371,7 +371,7 @@ Status 
SegmentWriter::append_block_with_partial_content(const vectorized::Block*
     auto* tablet = static_cast<Tablet*>(_tablet.get());
     if (block->columns() <= _tablet_schema->num_key_columns() ||
         block->columns() >= _tablet_schema->num_columns()) {
-        return Status::InternalError(
+        return Status::InvalidArgument(
                 fmt::format("illegal partial update block columns: {}, num key 
columns: {}, total "
                             "schema columns: {}",
                             block->columns(), 
_tablet_schema->num_key_columns(),
diff --git a/be/src/olap/rowset/segment_v2/vertical_segment_writer.cpp 
b/be/src/olap/rowset/segment_v2/vertical_segment_writer.cpp
index 4f28393fb7d..9f1d2736b88 100644
--- a/be/src/olap/rowset/segment_v2/vertical_segment_writer.cpp
+++ b/be/src/olap/rowset/segment_v2/vertical_segment_writer.cpp
@@ -706,14 +706,14 @@ Status VerticalSegmentWriter::batch_block(const 
vectorized::Block* block, size_t
         !_opts.rowset_ctx->is_transient_rowset_writer) {
         if (block->columns() <= _tablet_schema->num_key_columns() ||
             block->columns() >= _tablet_schema->num_columns()) {
-            return Status::InternalError(fmt::format(
+            return Status::InvalidArgument(fmt::format(
                     "illegal partial update block columns: {}, num key 
columns: {}, total "
                     "schema columns: {}",
                     block->columns(), _tablet_schema->num_key_columns(),
                     _tablet_schema->num_columns()));
         }
     } else if (block->columns() != _tablet_schema->num_columns()) {
-        return Status::InternalError(
+        return Status::InvalidArgument(
                 "illegal block columns, block columns = {}, tablet_schema 
columns = {}",
                 block->columns(), _tablet_schema->num_columns());
     }


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

Reply via email to