commit | 417442a753748fba8b9fade9953a9355ad570906 | [log] [tgz] |
---|---|---|
author | Rhys Hiltner <rhys.hiltner@gmail.com> | Wed Nov 30 19:39:40 2016 -0600 |
committer | Qi Zhao <toqizhao@gmail.com> | Wed Nov 30 17:39:40 2016 -0800 |
tree | 041dd220c55c89deb368feb0aa47c9f335cca3b8 | |
parent | deb01f422a11e3ca17cfe1ec8a3596debda9c473 [diff] |
transport: fix logical race in flow control (#1005) Remove the add and cancel methods of quotaPool. Their use is not required, and leads to logical races when used concurrently from multiple goroutines. Rename the reset method to add. The typical way that a goroutine claims quota is to call the add method and then to select on the channel returned by the acquire method. If two goroutines are both trying to claim quota from a single quotaPool, the second call to the add method can happen before the first attempt to read from the channel. When that happens the second goroutine to attempt the channel read will end up waiting for a very long time, in spite of its efforts to prepare the channel for reading. The quotaPool will always behave correctly when any positive quota is on the channel rather than stored in the struct field. In the opposite case, when positive quota is only in the struct field and not on the channel, users of the quotaPool can fail to access available quota. Err on the side of storing any positive quota in the channel. This includes a reproducer for #632, which fails on many runs with this package at v1.0.4. The frequency of the test failures depends on how stressed the server is, since it's now effectively checking for weird interleavings of goroutines. It passes reliably with these changes to the transport package. The behavior described in #734 (an RPC with a streaming response hangs unexpectedly) matches what I've seen in my programs, and what I see in the test case added here. If it's a logical flow control bug, this change may well fix it. Updates #632 Updates #734
#gRPC-Go
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.5 or later.
A note on the version used: significant performance improvements in benchmarks of grpc-go have been seen by upgrading the go version from 1.5 to the latest 1.7.1.
From https://golang.org/doc/install, one way to install the latest version of go is:
$ GO_VERSION=1.7.1 $ OS=linux $ ARCH=amd64 $ curl -O https://storage.googleapis.com/golang/go${GO_VERSION}.${OS}-${ARCH}.tar.gz $ sudo tar -C /usr/local -xzf go$GO_VERSION.$OS-$ARCH.tar.gz $ # Put go on the PATH, keep the usual installation dir $ sudo ln -s /usr/local/go/bin/go /usr/bin/go $ rm go$GO_VERSION.$OS-$ARCH.tar.gz
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.
GA
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