Skip to content

Fix a multithreading bug in grpc ClientCall#5196

Merged
raulchen merged 4 commits intoray-project:masterfrom
antgroup:fix_client_call
Jul 15, 2019
Merged

Fix a multithreading bug in grpc ClientCall#5196
raulchen merged 4 commits intoray-project:masterfrom
antgroup:fix_client_call

Conversation

@raulchen
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown

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
Copy Markdown

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