-
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
Possible leak of net.Conn #4632
Comments
I tried an experiment of adding a runtime.SetFinalizer call for the conns returned by LimitListener.Accept and this appears to resolve the issue. This strongly suggests to me that there is a code path in the grpc server where a |
It is working with #4633. Thanks! |
https://github.com/grpc/grpc-go/releases/tag/v1.39.1 published with this fixed |
What version of gRPC are you using?
Go Server using v1.39.0 also tried #4627 in case that fixed the issue.
v1.38.0 does not exhibit this issue.
What version of Go are you using (
go version
)?go1.16.6
What operating system (Linux, Windows, …) and version?
GOOS=linux GOARCH=386
Linux 4.19.134
What did you do?
If possible, provide a recipe for reproducing the error.
I haven't quite narrowed this down yet. We have a test that involves a long running python gRPC client using an grpc-core v1.21.3 that makes several requests.
Importantly, our server is using https://pkg.go.dev/golang.org/x/net/netutil#LimitListener to limit to 100 concurrent connections.
What did you expect to see?
Clients able to connect and make requests. Networks connections are cleaned up.
What did you see instead?
After some time running with the python client described above, it and other grpc clients can no longer connect and make RPCs. The stack trace shows that the gRPC Server is stuck in LimitListener
acquire
when callingAccept
. This function is intended to block when over the configured number of concurrent connections allowed. However, there is only one client and the limit is set to 100.This suggests to me that connections that are returned from
Accept()
are not always having theirClose()
function called, ie. a leak. That would explain why the LimitListener thinks it is at max connections, but really there is only 1 outstanding connection. I can confirm this with output fromss
that shows only 1 connection open to the grpc server's port.I added some logging to the limit listener when a connection is Accepted and when it is Closed, along with a count of how many outstanding connections there are:
The increasing count shows a pattern of an occasional leak of a connection. (When the connection is closed, it appears that Close is called twice.)
The text was updated successfully, but these errors were encountered: