Fail SEND_MESSAGE ops if stream is closed for writes #19868
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #14812
Fail SEND_MESSAGE ops if stream is closed for writes.
Earlier, gRPC Core would not fail SEND_MESSAGE ops if the client had already received a status.
Looks like this was done so as to avoid status being overwritten by the error 'Attempt to send message after stream was closed'. This would happen because the surface layer (call.cc) initiates a CANCEL op when any op fails.
In the case of a streaming call, the C++ API depends on Write calls returning false when the stream is closed. If gRPC Core fails this write and cancels the call, we would lose the status reported by the server too.
This approach creates a bug where Writes on streaming calls never fail even if the stream has been closed.
New Approach -
If gRPC Core gets a SEND_MESSAGE op when the stream is closed for writes, we fail the write but we do not cancel the call.