server/grpc: improve graceful stop behavior#2892
Open
jejefferson wants to merge 3 commits intomicro:masterfrom
Open
server/grpc: improve graceful stop behavior#2892jejefferson wants to merge 3 commits intomicro:masterfrom
jejefferson wants to merge 3 commits intomicro:masterfrom
Conversation
6061c68 to
2d6555c
Compare
0d1510a to
7d79cca
Compare
7d79cca to
4b4ce50
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This changes the gRPC server shutdown path to behave more like a real graceful stop for long-lived RPCs and streams.
Current behavior in
server/grpc/grpc.gois:wggrpc.Server.GracefulStop()Stop()after1sThat makes graceful shutdown difficult for services with long-running gRPC calls.
What this patch changes
grpc.Server.GracefulStop()immediately when shutdown beginsGracefulStopTimeout(time.Duration)Stop()after that timeoutWhy
For gRPC graceful shutdown, the expected behavior is:
With the previous order,
GracefulStop()starts too late and the hardcoded1sfallback is too aggressive for long-lived calls.Compatibility
GracefulStopTimeout(...)is not configuredValidation
I verified the package still compiles with: