fix: Make sure outstanding RPCs count in ChannelPool can not go negative#2185
Merged
fix: Make sure outstanding RPCs count in ChannelPool can not go negative#2185
Conversation
meltsufin
approved these changes
Oct 19, 2023
Member
meltsufin
left a comment
There was a problem hiding this comment.
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.
|
|
[java_showcase_integration_tests] SonarCloud Quality Gate failed.
|
4 tasks
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.











fixes: #2081
Add two flags
wasClosedandwasReleasedtoReleasingClientCallto 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
outstandingRPCsThe 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.