services: fix HealthCheckingLoadBalancer.shutdown().#5848
Merged
zhangkun83 merged 2 commits intogrpc:masterfrom Jun 7, 2019
Merged
services: fix HealthCheckingLoadBalancer.shutdown().#5848zhangkun83 merged 2 commits intogrpc:masterfrom
zhangkun83 merged 2 commits intogrpc:masterfrom
Conversation
HealthCheckingLoadBalancer.shutdown() calls hcState.onSubchannelState(SHUTDOWN) which removes that hcState from helper.hcStates. Therefore, if more than one Subchannels are present, ConcurrentModificationException will be thrown. Since HealthCheckingLoadBalancer.shutdown() will clear the hcStates set after the loop, it's unnecessary to do the deletion within the loop. However, when a Subchannel is shutdown by LoadBalancer, its HcState still needs to be removed. To do that, change moves the deletion to Subchannel.shutdown().
dapengzhang0
reviewed
Jun 7, 2019
| @Override | ||
| public void shutdown() { | ||
| helperImpl.getSynchronizationContext().throwIfNotInThisSynchronizationContext(); | ||
| helperImpl.hcStates.remove(hcState); |
Contributor
There was a problem hiding this comment.
No need to call delegate.shutdown()?
Contributor
Author
There was a problem hiding this comment.
Good catch. Fixed.
Contributor
|
I would also make the similar change for Update: |
dapengzhang0
approved these changes
Jun 7, 2019
ejona86
added a commit
to ejona86/grpc-java
that referenced
this pull request
Jun 13, 2019
…)" This reverts commit c6f1516. It broke an internal health checking test because the server wouldn't shut down. We assume the health checking RPC isn't getting closed.
ejona86
added a commit
that referenced
this pull request
Jun 13, 2019
This reverts commit c6f1516. It broke an internal health checking test because the server wouldn't shut down. We assume the health checking RPC isn't getting closed.
zhangkun83
added a commit
to zhangkun83/grpc-java
that referenced
this pull request
Jun 13, 2019
HealthCheckingLoadBalancer.shutdown() calls hcState.onSubchannelState(SHUTDOWN) which removes that hcState from helper.hcStates. Therefore, if more than one Subchannels are present, ConcurrentModificationException will be thrown. Since HealthCheckingLoadBalancer.shutdown() will clear the hcStates set after the loop, it's unnecessary to do the deletion within the loop. However, when a Subchannel is shutdown by LoadBalancer, its HcState still needs to be removed. To do that, change moves the deletion to Subchannel.shutdown().
zhangkun83
added a commit
that referenced
this pull request
Jun 14, 2019
The issue: HealthCheckingLoadBalancer.shutdown() calls hcState.onSubchannelState(SHUTDOWN) which removes that hcState from helper.hcStates. Therefore, if more than one Subchannels are present, ConcurrentModificationException will be thrown. This is an alternative approach from #5848 that was reverted in #5875. Thanks to #5883, HealthCheckingLoadBalancer.shutdown() no longer has to fake SHUTDOWN notifications, and can completely rely on Subchannels' real SHUTDOWN notifications for triggering the clean-up.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
HealthCheckingLoadBalancer.shutdown() calls
hcState.onSubchannelState(SHUTDOWN) which removes that hcState from
helper.hcStates. Therefore, if more than one Subchannels are present,
ConcurrentModificationException will be thrown.
Since HealthCheckingLoadBalancer.shutdown() will clear the hcStates
set after the loop, it's unnecessary to do the deletion within the
loop. However, when a Subchannel is shutdown by LoadBalancer, its
HcState still needs to be removed. To do that, change moves the
deletion to Subchannel.shutdown().