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

stub: Only throw on cancellation for streaming responses #7173

Merged
merged 3 commits into from
Oct 1, 2020

Conversation

ejona86
Copy link
Member

@ejona86 ejona86 commented Jun 30, 2020

Unary are far more common than streaming, and we're throwing for unary even
though it doesn't help the service. Let's stop doing that. We also stop
throwing in onComplete() for all cases, because it doesn't help any service;
it doesn't stop the service's processing and isn't even all that informative
since the cancellation can happen even after onComplete() is called.


This is related to #7172, and the docs there would need to be updated. Whichever is merged last will need to be updated.

Note that I saw it is weird that we call both the cancellation and onError callbacks. We should probably just call onError, but that has a greater chance of "being noticed" so I didn't want it to add risk to this PR.

@ejona86 ejona86 requested a review from dapengzhang0 June 30, 2020 21:27
@ejona86 ejona86 marked this pull request as draft June 30, 2020 21:43
@ejona86 ejona86 force-pushed the stub-less-throw branch from 3c917ac to b7cf787 Compare July 1, 2020 14:39
@ejona86 ejona86 marked this pull request as ready for review July 1, 2020 14:47
@ejona86 ejona86 added the kokoro:run Add this label to a PR to tell Kokoro the code is safe and tests can be run label Jul 1, 2020
@grpc-kokoro grpc-kokoro removed the kokoro:run Add this label to a PR to tell Kokoro the code is safe and tests can be run label Jul 1, 2020
@@ -211,24 +215,26 @@ public void onReady() {
* @param method an adaptor to the actual method on the service implementation.
*/
private static <ReqT, RespT> ServerCallHandler<ReqT, RespT> asyncUnaryRequestCall(
Copy link
Member

Choose a reason for hiding this comment

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

I feel this method is just adding an annoying redirection. Why not just call new UnaryServerCallHandler<>(method, serverStreaming) directly whenever asyncUnaryRequestCall is called?

Copy link
Member Author

Choose a reason for hiding this comment

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

That sounds fine. Do you mind if I do that as a follow-up?

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, let me do it as a pre-refactor, since I was going to let this PR "sit" for us to discuss it in the API meeting.

ejona86 added a commit to ejona86/grpc-java that referenced this pull request Jul 1, 2020
The method did nothing; just inline its contents. Brought up as part of grpc#7173's
review.
ejona86 added a commit that referenced this pull request Jul 1, 2020
The method did nothing; just inline its contents. Brought up as part of #7173's
review.
@ejona86
Copy link
Member Author

ejona86 commented Jul 9, 2020

API review:

  • We feel comfortable with this change. We don't think many/any existing users will be impacted by this change, as the exception is not guaranteed in the face of cancellation (cancellation is racy). We do think it will help users to simplify their code.
  • It would probably be appropriate to point users to setOnCancelHandler within the cancellation exception. Just to tell them it exists and disables that exception, as an alternative to having a try-catch. We think most users would benefit from using the callback instead of the exception
  • We would like to be even more aggressive and remove the cancellation exception entirely, but have varying opinions on whether that is practical (e.g., whether it would break existing users). There are ways to remove the exception in more cases, even if not entirely.

ejona86 added 2 commits July 21, 2020 15:00
Unary are far more common than streaming, and we're throwing for unary even
though it doesn't help the service. Let's stop doing that. We also stop
throwing in onComplete() for all cases, because it doesn't help any service;
it doesn't stop the service's processing and isn't even all that informative
since the cancellation can happen even after onComplete() is called.
@ejona86 ejona86 requested a review from dapengzhang0 July 21, 2020 22:05
Copy link
Member

@dapengzhang0 dapengzhang0 left a comment

Choose a reason for hiding this comment

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

One comment, otherwise LGTM.

@ejona86 ejona86 merged commit 0cd56c2 into grpc:master Oct 1, 2020
@ejona86 ejona86 deleted the stub-less-throw branch October 1, 2020 20:10
dfawley pushed a commit to dfawley/grpc-java that referenced this pull request Jan 15, 2021
The method did nothing; just inline its contents. Brought up as part of grpc#7173's
review.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants