-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Enhancement](Log) Reduce usage of log fatal(PART I) #42344
Conversation
Thank you for your contribution to Apache Doris. Since 2024-03-18, the Document has been moved to doris-website. |
clang-tidy review says "All clean, LGTM! 👍" |
be/src/vec/functions/function_cast.h
Outdated
@@ -651,7 +651,7 @@ struct ConvertImplNumberToJsonb { | |||
} else if constexpr (std::is_same_v<ColumnFloat64, ColumnType>) { | |||
writer.writeDouble(data[i]); | |||
} else { | |||
LOG(FATAL) << "unsupported type "; | |||
throw Exception(Status::NotSupported("unsupported type ")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for if constexpr
, you can use static_assert
rather than throw
be/src/common/elf.cpp
Outdated
@@ -40,21 +41,22 @@ Elf::Elf(const std::string& path) { | |||
std::error_code ec; | |||
elf_size = std::filesystem::file_size(_file, ec); | |||
if (ec) { | |||
LOG(FATAL) << fmt::format("failed to get file size {}: ({}), {}", _file.native(), | |||
ec.value(), ec.message()); | |||
throw Exception(Status::IOError("failed to get file size {}: ({}), {}", _file.native(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add a new error type. we can call it FatalError
. and for all Exception changed from LOG(FATAL)
, use it as the error code
|
build.sh
Outdated
@@ -551,8 +551,8 @@ FE_MODULES="$( | |||
|
|||
# Clean and build Backend | |||
if [[ "${BUILD_BE}" -eq 1 ]]; then | |||
update_submodule "be/src/apache-orc" "apache-orc" "https://github.com/apache/doris-thirdparty/archive/refs/heads/orc.tar.gz" | |||
update_submodule "be/src/clucene" "clucene" "https://github.com/apache/doris-thirdparty/archive/refs/heads/clucene.tar.gz" | |||
# update_submodule "be/src/apache-orc" "apache-orc" "https://github.com/apache/doris-thirdparty/archive/ads/clucene.tarefs/heads/orc.tar.gz" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't commit this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
be/src/gutil/strings/numbers.cc
Outdated
@@ -10,15 +10,18 @@ | |||
#include <ctype.h> | |||
#include <errno.h> | |||
#include <float.h> // for DBL_DIG and FLT_DIG | |||
#include <math.h> // for HUGE_VAL | |||
#include <inttypes.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: inclusion of deprecated C++ header 'inttypes.h'; consider using 'cinttypes' instead [modernize-deprecated-headers]
#include <inttypes.h> | |
#include <cinttypes> |
be/src/gutil/strings/numbers.cc
Outdated
@@ -10,15 +10,18 @@ | |||
#include <ctype.h> | |||
#include <errno.h> | |||
#include <float.h> // for DBL_DIG and FLT_DIG | |||
#include <math.h> // for HUGE_VAL | |||
#include <inttypes.h> | |||
#include <math.h> // for HUGE_VAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: inclusion of deprecated C++ header 'math.h'; consider using 'cmath' instead [modernize-deprecated-headers]
#include <math.h> // for HUGE_VAL | |
#include <cmath> // for HUGE_VAL |
be/src/olap/comparison_predicate.h
Outdated
@@ -524,7 +526,7 @@ class ComparisonPredicateBase : public ColumnPredicate { | |||
_base_loop_bit<is_nullable, is_and>(sel, size, flags, null_map, data_array, | |||
dict_code); | |||
} else { | |||
LOG(FATAL) << "column_dictionary must use StringRef predicate."; | |||
static_assert(!std::is_same_v<T, StringRef>, "column_dictionary must use StringRef predicate."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we wrote if constexpr (std::is_same_v<T, StringRef>)
upon
so here going into else
means T
is not same with StringRef
. we want a failure here. so I think we should assert std::is_same_v<T, StringRef>
, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry I made a mistake here, and I have done fixing three similar errors in this file right away
be/src/gutil/port.h
Outdated
@@ -780,7 +780,7 @@ typedef int ssize_t; | |||
using std::ostream; | |||
inline ostream& operator<<(ostream& os, const unsigned __int64& num) { | |||
// Fake operator; doesn't actually do anything. | |||
LOG(FATAL) << "64-bit ostream operator << not supported in VC++ 6"; | |||
throw Exception(Statsu::FatalError("64-bit ostream operator << not supported in VC++ 6")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here's a typo?
be/src/gutil/strings/escaping.cc
Outdated
@@ -899,8 +902,7 @@ int Base64UnescapeInternal(const char* src, int szsrc, char* dest, int szdest, | |||
// of data bytes that must remain in the input to avoid aborting the | |||
// loop. | |||
#define GET_INPUT(label, remain) \ | |||
label: \ | |||
--szsrc; \ | |||
label : --szsrc; \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dont re-format it if you didn't change
be/src/common/exception.cpp
Outdated
@@ -29,7 +29,8 @@ Exception::Exception(int code, const std::string_view& msg) { | |||
_err_msg->_stack = get_stack_trace(); | |||
} | |||
if (config::exit_on_exception) { | |||
LOG(FATAL) << "[ExitOnException] error code: " << code << ", message: " << msg; | |||
throw Exception( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dont change this. we want always exit on exception here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should leave dwarf.cpp
, elf.cpp
and gutil/port.h
as they are. dont patch this change on those filles.
be/src/gutil/strings/util.cc
Outdated
@@ -489,7 +491,7 @@ const char* strstr_delimited(const char* haystack, const char* needle, char deli | |||
++haystack; | |||
} | |||
} | |||
LOG(FATAL) << "Unreachable statement"; | |||
throw doris::Exception(doris::Status::FatalError("Unreachable statement")); | |||
return nullptr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this line
be/src/olap/in_list_predicate.h
Outdated
@@ -431,8 +431,8 @@ class InListPredicateBase : public ColumnPredicate { | |||
} | |||
} | |||
} else { | |||
LOG(FATAL) << "column_dictionary must use StringRef predicate."; | |||
__builtin_unreachable(); | |||
throw Exception( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use static_assert
. or just not modify this in this PR
be/src/olap/key_coder.h
Outdated
@@ -300,7 +300,7 @@ class KeyCoderTraits<FieldType::OLAP_FIELD_TYPE_CHAR> { | |||
} | |||
|
|||
static Status decode_ascending(Slice* encoded_key, size_t index_size, uint8_t* cell_ptr) { | |||
LOG(FATAL) << "decode_ascending is not implemented"; | |||
throw Exception(Status::FatalError("decode_ascending is not implemented")); | |||
return Status::OK(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove the return
s
run buildall |
run buildall |
clang-tidy review says "All clean, LGTM! 👍" |
clang-tidy review says "All clean, LGTM! 👍" |
run buildall |
run buildall |
clang-tidy review says "All clean, LGTM! 👍" |
run buildall |
clang-tidy review says "All clean, LGTM! 👍" |
run buildall |
clang-tidy review says "All clean, LGTM! 👍" |
TeamCity be ut coverage result: |
run p0 |
1 similar comment
run p0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
PR approved by anyone and no changes requested. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
PR approved by at least one committer and no changes requested. |
Proposed changes
Issue Number: close #40835
use
throw Exception
to replace them which not inif constexpr
, and change part ofINTERNAL_ERROR
in this pr(fileaggregate_function_reader_first_last.h
andaggregate_function_window.h
) toFatalError
.for those in
if constexpr else{...}
, usestatic_assert
about template argument which used in that judgement to advance them to compile timebut there seems to be some bugs with the template parameter instantiation in the files
comparison_predicate.h
,set_probe_sink_operator.cpp
,set_sink_operator.cpp
,in_list_predicate.h
andset_source_operator.cpp
that I haven't modified yet.