commit | e90ffa3e4e017f7442091036fb5992650a10f0ef | [log] [tgz] |
---|---|---|
author | Gyu-Ho Lee <gyuhox@gmail.com> | Wed Jun 14 14:35:09 2017 -0700 |
committer | Menghan Li <menghanl@google.com> | Wed Jun 14 14:46:35 2017 -0700 |
tree | e05af374567de1a17ab01a39c265cdbf398dff80 | |
parent | de34174b470982066e7aaa4538b716367fdb4852 [diff] |
transport: fix error handling on Stream deletion (#1275) This patch writes client-side error before closing the active stream to fix blocking `RecvMsg` issue on `grpc.ClientStream` [1]. Previous gRPC client stream just exits on `ClientTransport.Error` [2]. And latest gRPC added another select case on client connection context cancel [3]. Now when client stream closes from client connection context cancel, it calls `CloseStream` with `ErrClientConnClosing` error. And then the stream gets deleted from `*http2Client.activeStreams`, without processing the error [4]. Then in-flight `RecvMsg` call on this client will block on `*parser.Reader.recvMsg` [5]. In short, 1. `ClientConn.Close`. 2. in-flight streams will receive case `<-cc.ctx.Done()` https://github.com/grpc/grpc-go/blob/master/stream.go#L253-L255. 3. `cs.closeTransportStream(ErrClientConnClosing)` calls `cs.t.CloseStream(cs.s, err)`. 4. `CloseStream(cs.s, err)` calls `delete(t.activeStreams, s.id)` without handling the error. 5. in-flight streams will never receive error, left hanging. I can reproduce in etcd tests with in-flight `recvMsg` calls to `Observe` RPC. --- [1] https://github.com/coreos/etcd/pull/7896#issuecomment-305241742 [2] https://github.com/grpc/grpc-go/blob/v1.2.x/stream.go#L235-L238 [3] https://github.com/grpc/grpc-go/pull/1136 [4] https://github.com/grpc/grpc-go/blob/master/transport/http2_client.go#L569 [5] https://github.com/grpc/grpc-go/blob/master/rpc_util.go#L280 Signed-off-by: Gyu-Ho Lee <gyuhox@gmail.com>
The Go implementation of gRPC: A high performance, open source, general RPC framework that puts mobile and HTTP/2 first. For more information see the gRPC Quick Start guide.
To install this package, you need to install Go and setup your Go workspace on your computer. The simplest way to install the library is to run:
$ go get google.golang.org/grpc
This requires Go 1.6 or later.
The grpc package should only depend on standard Go packages and a small number of exceptions. If your contribution introduces new dependencies which are NOT in the list, you need a discussion with gRPC-Go authors and consultants.
See API documentation for package and API descriptions and find examples in the examples directory.
See the current benchmarks for some of the languages supported in this dashboard.
General Availability Google Cloud Platform Launch Stages.
Please update proto package, gRPC package and rebuild the proto files:
go get -u github.com/golang/protobuf/{proto,protoc-gen-go}
go get -u google.golang.org/grpc
protoc --go_out=plugins=grpc:. *.proto