-
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
[chore] Fix unhandled exceptions thrown by stoi #48965
base: master
Are you sure you want to change the base?
Conversation
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
@@ -337,6 +337,8 @@ Status StreamLoadAction::_on_header(HttpRequest* http_req, std::shared_ptr<Strea | |||
ctx->timeout_second = std::stoi(http_req->header(HTTP_TIMEOUT)); | |||
} catch (const std::invalid_argument& e) { | |||
return Status::InvalidArgument("Invalid timeout format, {}", e.what()); | |||
} catch (const std::out_of_range& e) { |
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 regression test.
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.
run buildall
@@ -157,7 +157,7 @@ class StreamLoadContext { | |||
// optional | |||
std::string sub_label; | |||
double max_filter_ratio = 0.0; | |||
int32_t timeout_second = -1; | |||
int64_t timeout_second = -1; |
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 don't need to change this type.
@@ -337,6 +337,8 @@ Status StreamLoadAction::_on_header(HttpRequest* http_req, std::shared_ptr<Strea | |||
ctx->timeout_second = std::stoi(http_req->header(HTTP_TIMEOUT)); | |||
} catch (const std::invalid_argument& e) { | |||
return Status::InvalidArgument("Invalid timeout format, {}", e.what()); | |||
} catch (const std::out_of_range& e) { |
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 also fix other places that use the stoi function together.
run buildall |
LOG(WARNING) << fmt::format("Invalid shard_id format: {}, error: {}", _shards, e.what()); | ||
} catch (std::out_of_range& e) { | ||
LOG(WARNING) << fmt::format("Shard_id value out of range: {}, error: {}", _shards, | ||
e.what()); |
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.
set shard_id = -1 ?
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.
+1
be/src/olap/data_dir.cpp
Outdated
} catch (std::invalid_argument&) { | ||
LOG(WARNING) << "Invalid cluster_id value: " << content; | ||
} catch (std::out_of_range&) { | ||
LOG(WARNING) << "cluster_id value out of range: " << content; |
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.
just return an errror.
<< ", error: " << e.what(); | ||
} catch (const std::out_of_range& e) { | ||
LOG(WARNING) << "ignore_above value out of range: " | ||
<< ",error: " << e.what(); |
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.
Maybe we should return an error.
be/src/olap/storage_engine.cpp
Outdated
} catch (const std::invalid_argument& e) { | ||
LOG(WARNING) << "Invalid expiration value format in dir_name: " << dir_name | ||
<< ",error: " << e.what(); | ||
actual_expire = 0; |
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.
do not set it to zero.
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.
why this cpp file is in regression-test folder?
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.
already remove
return; | ||
} | ||
} catch (const std::invalid_argument& e) { | ||
LOG(WARNING) << "Invalid idx format: " << s.obj_info().id() |
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.
do error handling as line 2782 does when we meet 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.
It's been modified
<< ", error: " << e.what(); | ||
return; | ||
} catch (const std::out_of_range& e) { | ||
LOG(WARNING) << "Idx value out of range: " << s.obj_info().id() |
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.
ditto
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.
It's been modified
BE UT Coverage ReportIncrement line coverage Increment coverage report
|
_ignore_above = std::stoi(ignore_above_value); | ||
} catch (const std::invalid_argument& e) { | ||
LOG(WARNING) << "Invalid ignore_above_value format: " << ignore_above_value | ||
<< ", using default, error: " << e.what(); |
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.
need to return Status::ErrorErrorCode::INVERTED_INDEX_CLUCENE_ERROR()
What problem does this PR solve?
Issue Number: close #xxx
Related PR: #48859
Problem Summary:
fixes the issue where providing a timeout value exceeding the range of int32 causes a core dump during streamload.
The root cause is that the timeout value parsed using
std::stoi()
can throw astd::out_of_range
exception if the value exceeds int32 limits, which wasn't handled correctly.Release note
None
Check List (For Author)
Test
Behavior changed:
Does this need documentation?
Check List (For Reviewer who merge this PR)