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

c#: throw RpcException for failed network sends instead of InvalidOperationException #7925

Closed
wants to merge 1 commit into from
Closed

c#: throw RpcException for failed network sends instead of InvalidOperationException #7925

wants to merge 1 commit into from

Conversation

hinaria
Copy link

@hinaria hinaria commented Aug 30, 2016

Currently, gRPC throws an InvalidOperationException when it's network sends fail. This communicates the wrong semantics (that you're doing something wrong), and also makes it difficult to handle error scenarios where we actually attempted an invalid operation (like reading trailers before trailers are available).

Because InvalidOperationException here communicates the wrong semantics, we can't be sure if an InvalidOperationException occurred because we performed an invalid operation, or because of a transient error, without testing for the string "failed send" or "error sending status" which makes for some messy error handling code. If we instead throw an RpcException, clients can easily know that the issue occurred within the RPC layer, rather than failing a contract on its part.

This pull request changes them to throw RpcExceptions with UNAVAILABLE status, but I'd also considered INTERNAL. I feel that unavailable communicates the potential transient nature of communication errors better than internal does (where something is "very broken").

Hope this is reasonable, or you have a better solution. Thanks for your time!

@grpc-kokoro
Copy link

Thanks for your pull request. The automated tests will run as soon as one of the admins verifies this change is ok to test.

1 similar comment
@grpc-kokoro
Copy link

Thanks for your pull request. The automated tests will run as soon as one of the admins verifies this change is ok to test.

@grpc-kokoro
Copy link

Thanks for your pull request. The automated tests will run as soon as one of the admins verifies this change is ok to test.

1 similar comment
@grpc-kokoro
Copy link

Thanks for your pull request. The automated tests will run as soon as one of the admins verifies this change is ok to test.

@hinaria
Copy link
Author

hinaria commented Aug 30, 2016

Sorry, should have done this earlier, looked around and found these similar issues:

#7223 discusses the same issue and suggests a similar change
#7861 considered wrapping generic errors in a GrpcOperationFailedException

@apolcyn
Copy link
Contributor

apolcyn commented Aug 30, 2016

Thanks, but I think that a main issue with changing the exception type here is backwards compatibility. There does seem to be a lot of support in favor of making the breaking exception type change though, and I am thinking that a related change could be something to consider for the 1.1 release.

cc @jtattermusch

@hinaria
Copy link
Author

hinaria commented Aug 30, 2016

Ahh, makes total sense. I'd love to throw my support behind a more considered change for this to be part of 1.1 as well.

@jtattermusch
Copy link
Contributor

@imiuka, thanks for the pull request. I think the change you are suggesting is a step in right direction - and I agree with the resulting behavior in the situation in question. Unfortunately, the change needs to be a bit more complicated than that.

With your version of the change, you are artificially emitting the StatusCode.Unavailable, which is not necessarily the status code with which the RPC is going to finish - there are other error statuses that you can obtain in described situation. Also, you need to guarantee that once you receive StatusCode.Unavailable from an attempted stream write, you will also receive the same status after awaiting other operations on the same call (e.g. a streaming read or unary response) - there should really be one and only one StatusCode for each remote call.

So, the problem you are describing is real and we need to fix it - but in a different way. I think issue #7223 describes the problem really well, so if you don't mind, I will continue the discussion on this topic there. I will also close this PR for now with a promise to work on this issue in the nearest future.

@thelinuxfoundation
Copy link

Thank you for your pull request. Before we can look at your contribution, we need to ensure all contributors are covered by a Contributor License Agreement.

After the following items are addressed, please respond with a new comment here, and the automated system will re-verify.

Regards,
The Linux Foundation CLA GitHub bot

@lock lock bot locked as resolved and limited conversation to collaborators Jan 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants