-
Notifications
You must be signed in to change notification settings - Fork 53
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
fix: Make sure outstanding RPCs count in ChannelPool can not go negative #2185
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if all of these logs should be warnings, but I think the safeguards make sense.
gax-java/gax-grpc/src/main/java/com/google/api/gax/grpc/ChannelPool.java
Outdated
Show resolved
Hide resolved
gax-java/gax-grpc/src/main/java/com/google/api/gax/grpc/ChannelPool.java
Outdated
Show resolved
Hide resolved
gax-java/gax-grpc/src/main/java/com/google/api/gax/grpc/ChannelPool.java
Outdated
Show resolved
Hide resolved
gax-java/gax-grpc/src/main/java/com/google/api/gax/grpc/ChannelPool.java
Outdated
Show resolved
Hide resolved
…lPool.java Co-authored-by: Mike Eltsufin <meltsufin@google.com>
…lPool.java Co-authored-by: Mike Eltsufin <meltsufin@google.com>
…lPool.java Co-authored-by: Mike Eltsufin <meltsufin@google.com>
…lPool.java Co-authored-by: Mike Eltsufin <meltsufin@google.com>
gax-java/gax-grpc/src/main/java/com/google/api/gax/grpc/ChannelPool.java
Show resolved
Hide resolved
gax-java/gax-grpc/src/main/java/com/google/api/gax/grpc/ChannelPool.java
Outdated
Show resolved
Hide resolved
gax-java/gax-grpc/src/main/java/com/google/api/gax/grpc/ChannelPool.java
Show resolved
Hide resolved
gax-java/gax-grpc/src/main/java/com/google/api/gax/grpc/ChannelPool.java
Outdated
Show resolved
Hide resolved
[gapic-generator-java-root] SonarCloud Quality Gate failed. 0 Bugs 61.1% Coverage Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
[java_showcase_integration_tests] SonarCloud Quality Gate failed. 0 Bugs 44.4% Coverage Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
fixes: #2081
Add two flags
wasClosed
andwasReleased
toReleasingClientCall
to check various scenarios. The combination of these two flags can make sure the count of outstanding RPCs can never go negative, and help us identify what exactly goes wrong next time it happens.More background for the purpose of
outstandingRPCs
The primary purpose of keeping a count for outstanding RPCs is to track when a channel is
safe to close. In grpc, initialization & starting of rpcs is split between 2 methods:
Channel#newCall() and ClientCall#start. gRPC already has a mechanism to safely close channels
that have rpcs that have been started. However, it does not protect calls that have been
created but not started. In the sequence: Channel#newCall() Channel#shutdown()
ClientCall#Start(), gRpc will error out the call telling the caller that the channel is
shutdown.
Hence, the increment of outstanding RPCs has to happen when the ClientCall is initialized,
as part of Channel#newCall(), not after the ClientCall is started. The decrement of
outstanding RPCs has to happen when the ClientCall is closed or the ClientCall failed to
start.