Skip to content
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

GracefulStop doesn't wait for RPC to finish #1110

Closed
btoews opened this issue Mar 8, 2017 · 6 comments
Closed

GracefulStop doesn't wait for RPC to finish #1110

btoews opened this issue Mar 8, 2017 · 6 comments

Comments

@btoews
Copy link

btoews commented Mar 8, 2017

I don't think this is a duplicate of #848, so I'm opening a new issue.

I'm trying to figure out how to gracefully shutdown my GRPC server so RPCs aren't cancelled during server deployments. From reading the docs, it sounds like I want func (*Server) GracefulStop, but in practice it seems to cancel in-flight RPCs.

I'm testing this by triggering a GracefulStop() while the server is processing a long-running RPC (sleeping). This is being output to stderr

2017/03/08 14:10:24 grpc: addrConn.resetTransport failed to create client transport: connection error: desc = "transport: dial tcp :5543: getsockopt: connection refused"; Reconnecting to {:5543 <nil>}

and the client is receiving this error: rpc error: code = 13 desc = transport is closing

Am I doing something wrong, or is this a bug?

I threw together an example server/client to demonstrate this behavior: https://github.com/mastahyeti/grace

Thanks.

@btoews
Copy link
Author

btoews commented Mar 8, 2017

Ah. This is because the main goroutine is exiting when Serve returns. I guess the main thread should call GracefulStop() also then to wait on the RPC to finish?

I'll close this, since it doesn't seem to be a bug.

@btoews btoews closed this as completed Mar 8, 2017
@btoews
Copy link
Author

btoews commented Mar 8, 2017

For posterity, here's how I fixed my example app.

@pawelkowalak
Copy link

@mastahyeti how does it fix your issue? I've just cloned your repo with the fix, and the client is still getting transport is closing.

@btoews
Copy link
Author

btoews commented Dec 7, 2017

It looks like the behavior was changed in #1485. Maybe there's a regression in how clients deal with the server closing.

@dfawley
Copy link
Member

dfawley commented Dec 16, 2017

I think it's possible that's #1738.

@hypnoglow
Copy link
Contributor

This is finally fixed in #1734

@lock lock bot locked as resolved and limited conversation to collaborators Sep 26, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants