Skip to content

core: SubchannelStateListener continues to receive updates after LoadBalancer is shutdown.#5883

Merged
zhangkun83 merged 4 commits intogrpc:masterfrom
zhangkun83:subchannel_state_listener_receives_updates_after_shutdown
Jun 14, 2019
Merged

core: SubchannelStateListener continues to receive updates after LoadBalancer is shutdown.#5883
zhangkun83 merged 4 commits intogrpc:masterfrom
zhangkun83:subchannel_state_listener_receives_updates_after_shutdown

Conversation

@zhangkun83
Copy link
Copy Markdown
Contributor

@zhangkun83 zhangkun83 commented Jun 14, 2019

No more methods on the LoadBalancer will be called after
LoadBalancer#shutdown() is called. This includes
LoadBalancer#handleSubchannelState() too. SubchannelStateListener
inherited this restriction. However, this special case makes
onSubchannelState(SHUTDOWN) an unreliable way of being notified
about Subchannel SHUTDOWN, and may confuse/complicate a
wrapping LoadBalancer that expects the full notification (e.g., #5875).

The javadoc isn't clear whether this restriction applies. I think
it's more useful to make it no apply.

…Balancer is shutdown.

No more methods on the LoadBalancer will be called after
LoadBalancer#shutdown() is called.  This includes
LoadBalancer#handleSubchannelState() too.  SubchannelStateListener
inherited this restriction.  However, this special case makes
onSubchannelState(SHUTDOWN) a unreliable way of being notified
about Subchannel SHUTDOWN, and may confuse/complicate a
wrapping LoadBalancer that expects the full notification.

The javadoc isn't clear whether this restriction applies.  I think
it's more useful to make it no apply.
@zhangkun83 zhangkun83 requested a review from ejona86 June 14, 2019 18:45
@zhangkun83 zhangkun83 merged commit c92c9e7 into grpc:master Jun 14, 2019
@zhangkun83 zhangkun83 deleted the subchannel_state_listener_receives_updates_after_shutdown branch June 14, 2019 21:44
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.
@lock lock bot locked as resolved and limited conversation to collaborators Sep 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants