Skip to content

Commit

Permalink
ENG-3822: #451: Check result of weak_ptr lock, before doing actual ca…
Browse files Browse the repository at this point in the history
…ll in LocalYBInboundCall

Summary:
Because of another issue still under investigation, there could be a case when we invoke LocalYBInboundCall::Response when
original outbound all is already destroyed.
To handle this case correctly we should check that result returned by weak_ptr lock is not null.

Test Plan: Jenknis

Reviewers: robert, mikhail

Reviewed By: mikhail

Subscribers: ybase

Differential Revision: https://phabricator.dev.yugabyte.com/D5388
  • Loading branch information
spolitov committed Aug 24, 2018
1 parent 0d36fc8 commit 3bd4f37
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/yb/rpc/local_call.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Status LocalOutboundCall::SetRequestParam(const google::protobuf::Message& req)
}

void LocalOutboundCall::Serialize(std::deque<RefCntBuffer> *output) const {
LOG(FATAL) << "local call should not require serialization";
LOG(FATAL) << "Local call should not require serialization";
}

const std::shared_ptr<LocalYBInboundCall>& LocalOutboundCall::CreateLocalInboundCall() {
Expand Down Expand Up @@ -77,11 +77,18 @@ const Endpoint& LocalYBInboundCall::local_address() const {
}

void LocalYBInboundCall::Respond(const google::protobuf::MessageLite& response, bool is_success) {
auto call = outbound_call();
if (!call) {
LOG(DFATAL) << "Outbound call is NULL during Respond, looks like double response. "
<< "is_success: " << is_success;
return;
}

if (is_success) {
outbound_call()->SetFinished();
call->SetFinished();
} else {
outbound_call()->SetFailed(STATUS(RemoteError, "Local call error"),
new ErrorStatusPB(yb::down_cast<const ErrorStatusPB&>(response)));
call->SetFailed(STATUS(RemoteError, "Local call error"),
new ErrorStatusPB(yb::down_cast<const ErrorStatusPB&>(response)));
}
}

Expand Down

0 comments on commit 3bd4f37

Please sign in to comment.