Skip to content
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

[thrift][bugfix]try to fix thrift request overflow crash. #12890

Merged
merged 7 commits into from
Sep 10, 2020
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,10 @@ FilterStatus Router::UpstreamRequest::start() {
return FilterStatus::StopIteration;
}

if (upstream_host_ == nullptr) {
return FilterStatus::StopIteration;
}

return FilterStatus::Continue;
}

Expand Down Expand Up @@ -502,9 +506,8 @@ void Router::UpstreamRequest::onResetStream(ConnectionPool::PoolFailureReason re
switch (reason) {
case ConnectionPool::PoolFailureReason::Overflow:
parent_.callbacks_->sendLocalReply(
AppException(
AppExceptionType::InternalError,
fmt::format("too many connections to '{}'", upstream_host_->address()->asString())),
AppException(AppExceptionType::InternalError,
fmt::format("thrift upstream request: too many connections")),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two things:

  1. Since you've removed the string interpolation, you don't need to call fmt::format here.
  2. There is another case below that uses upstream_host_ below. That should be modified as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean the Timeout case? When it hits that case ,as far as I can see the upstream_host_ will keep the real one.Could you please check if it's right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should depend on that behavior even if it's true.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think is better to report more detail about the Exception.How about change like this
`

  parent_.callbacks_->sendLocalReply(
      AppException(
          AppExceptionType::InternalError,
          fmt::format("connection failure '{}'", (upstream_host_ != nullptr)
                                                     ? upstream_host_->address()->asString()
                                                     : "to upstream")),
      true);

`

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

true);
break;
case ConnectionPool::PoolFailureReason::LocalConnectionFailure:
Expand Down