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 00b994fea2 [chore](exception) Add config item 'exit_on_exception' (#24529) 00b994fea2 is described below commit 00b994fea223674cc2163aa168b7d49a39c38382 Author: Jerry Hu <mrh...@gmail.com> AuthorDate: Thu Sep 21 14:51:05 2023 +0800 [chore](exception) Add config item 'exit_on_exception' (#24529) --- be/src/common/config.cpp | 4 ++++ be/src/common/config.h | 3 +++ be/src/common/exception.cpp | 9 +++++++++ 3 files changed, 16 insertions(+) diff --git a/be/src/common/config.cpp b/be/src/common/config.cpp index 1b98ab1d88..c9370237aa 100644 --- a/be/src/common/config.cpp +++ b/be/src/common/config.cpp @@ -1090,6 +1090,9 @@ DEFINE_Int32(group_commit_insert_threads, "10"); DEFINE_mInt32(scan_thread_nice_value, "0"); +DEFINE_Bool(exit_on_exception, "false") + +// clang-format off #ifdef BE_TEST // test s3 DEFINE_String(test_s3_resource, "resource"); @@ -1100,6 +1103,7 @@ DEFINE_String(test_s3_region, "region"); DEFINE_String(test_s3_bucket, "bucket"); DEFINE_String(test_s3_prefix, "prefix"); #endif +// clang-format on std::map<std::string, Register::Field>* Register::_s_field_map = nullptr; std::map<std::string, std::function<bool()>>* RegisterConfValidator::_s_field_validator = nullptr; diff --git a/be/src/common/config.h b/be/src/common/config.h index da9140bfcb..fa94fe3643 100644 --- a/be/src/common/config.h +++ b/be/src/common/config.h @@ -1165,6 +1165,9 @@ DECLARE_mInt32(group_commit_insert_threads); // to lower the priority of scan threads DECLARE_Int32(scan_thread_nice_value); +// Use `LOG(FATAL)` to replace `throw` when true +DECLARE_mBool(exit_on_exception); + #ifdef BE_TEST // test s3 DECLARE_String(test_s3_resource); diff --git a/be/src/common/exception.cpp b/be/src/common/exception.cpp index 4efc981f5e..9da69bc678 100644 --- a/be/src/common/exception.cpp +++ b/be/src/common/exception.cpp @@ -17,6 +17,7 @@ #include "common/exception.h" +#include "common/config.h" #include "util/stack_util.h" namespace doris { @@ -25,7 +26,11 @@ Exception::Exception(int code, const std::string_view msg) { _err_msg = std::make_unique<ErrMsg>(); _err_msg->_msg = msg; _err_msg->_stack = get_stack_trace(); + if (config::exit_on_exception) { + LOG(FATAL) << "[ExitOnException] error code: " << code << ", message: " << msg; + } } + Exception::Exception(const Exception& nested, int code, const std::string_view msg) { _code = code; _err_msg = std::make_unique<ErrMsg>(); @@ -36,6 +41,10 @@ Exception::Exception(const Exception& nested, int code, const std::string_view m _nested_excption->_err_msg = std::make_unique<ErrMsg>(); _nested_excption->_err_msg->_msg = nested._err_msg->_msg; _nested_excption->_err_msg->_stack = nested._err_msg->_stack; + + if (config::exit_on_exception) { + LOG(FATAL) << "[ExitOnException] error code: " << code << ", message: " << msg; + } } } // namespace doris \ No newline at end of file --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org