-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
client stream fails poorly when using CloseSend() #1876
Comments
The
For a streaming RPC, the client is expected to call |
Hey @menghanl, I think this issue should remain open. Let me preface the following with: I understand this is totally user error. However, this is also unexpected behavior given the way the API contracts within the client stream code are phrased, so I believe this is a real bug. The proper fix may be to update documentation. The documentation for
There's no mention of buffering here. If closing the Similarly, the only documentation I see in code around needing to call
These documentation in no way imply that the message will not be sent. For the repro example and my actual current use case, which is a short-lived commandline tool, it's totally fine to leak resources. Finally, what exactly is the purpose of
|
I agree that documentation needs to be updated. We can track that with another issue (#1880) if you are OK. Re-purposing this issue might be confusing for other people.
It would make more sense if you think of a bidirectional streaming RPC, where the client could send a list of requests, stop sending (also tell the server it's done), and receive a list of responses. Also, actually, grpc-go/examples/route_guide/routeguide/route_guide.pb.go Lines 317 to 326 in 583a630
|
When doing client streaming, and if you close the connection with
CloseSend()
immediately after sending the request (fire-and-forget), the server handler may never receive the request. The request is dropped somewhere in the grpc server level.If you use
CloseAndRecv()
to close the connection though, the request will be processed successfully.This behavior is surprising because, in the case where
CloseSend()
is called, I expect the server to at least receive the request, and get an error only when it tries to write to the closed stream, rather than not getting the request at all.What version of gRPC are you using?
master: dfa1834
What version of Go are you using (
go version
)?What operating system (Linux, Windows, …) and version?
OS X High Sierra 10.13.2
What did you do?
Repro available at https://github.com/mightyguava/grpc-streaming-bug
Run
server/main.go
, then runclient/main.go
The client sends 30 requests in 10 batches, via client streaming. In each batch, every request opens and closes its own client connection. For each batch:
CloseAndRecv()
on the stream after sending and is successfulCloseSend()
on the stream after sending, and almost always failsCloseSend()
on the stream, and is always successful.What did you expect to see?
All 30 requests succeed.
What did you see instead?
20 of the requests always succeed. The remaining 10 (Request 2) sometimes do succeed but usually fail.
The text was updated successfully, but these errors were encountered: