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

Fix a multithreading bug in grpc ClientCall #5196

Merged
merged 4 commits into from
Jul 15, 2019

Conversation

raulchen
Copy link
Contributor

@raulchen raulchen commented Jul 15, 2019

What do these changes do?

Problem.

ClientCallManager returns a raw pointer of ClientCall, and the caller can use call->GetStatus() to tell whether the request was successfully sent. However, there's a small chance that the reply is received too fast. And a call may be deleted before call->GetStatus().

Solution

This PR fixes this issue by adding a ClientCallTag and make ClientCall a shared_ptr.
Also fixes some typos and some small issues reported by clang-tidy.

Related issue number

Linter

  • I've run scripts/format.sh to lint the changes in this PR.

@raulchen
Copy link
Contributor Author

@zhijunfu @jiangzihao2009

@raulchen raulchen requested a review from jovany-wang July 15, 2019 05:04
GrpcServer(const std::string &name, const uint32_t port)
: name_(name), port_(port), is_closed_(true) {}
GrpcServer(std::string name, const uint32_t port)
: name_(std::move(name)), port_(port), is_closed_(true) {}
Copy link
Contributor

Choose a reason for hiding this comment

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

The previous code seemed clearer to me, why did you change it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Clang-tidy suggests this change. Passing by value + move has some advantages over passing by const reference + copy.
The biggest advantage is that you can avoid copying data. E.g.,

std::string name = "....";
GrpcServer(std::move(name));  // no copy at all.

See https://stackoverflow.com/questions/51705967/advantages-of-pass-by-value-and-stdmove-over-pass-by-reference/51706522 for more details.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok interesting, thanks for the explanation :)

@raulchen raulchen merged commit 7342117 into ray-project:master Jul 15, 2019
@raulchen raulchen deleted the fix_client_call branch July 15, 2019 06:50
@AmplabJenkins
Copy link

Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-PRB/15378/
Test PASSed.

@AmplabJenkins
Copy link

Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-Perf-Integration-PRB/1682/
Test FAILed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants