Skip to content

Commit

Permalink
xds:fix cdsLoadBalancer2 childLb shutdown (grpc#7976)
Browse files Browse the repository at this point in the history
Add missing childLb shutdown at cdsLoadBalancer state. The bug would cause xds client channels to be shutdown prematurely before childLb, e.g. ClusterResolverLoadBalancer. The resources referencing the client channel would be causing unexpected exceptions triggering channel panic, e.g. when EdsClusterState internal of ClusterResolverLoadBalancer can still be updated upon xds responses.
  • Loading branch information
YifeiZhuang committed Mar 17, 2021
1 parent c530094 commit e3dd9ad
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions xds/src/main/java/io/grpc/xds/CdsLoadBalancer2.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ private void start() {

private void shutdown() {
root.shutdown();
if (childLb != null) {
childLb.shutdown();
}
}

private void handleClusterDiscovered() {
Expand Down
1 change: 1 addition & 0 deletions xds/src/test/java/io/grpc/xds/CdsLoadBalancer2Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ public void tearDown() {
loadBalancer.shutdown();
assertThat(xdsClient.watchers).isEmpty();
assertThat(xdsClientRefs).isEqualTo(0);
assertThat(childBalancers).isEmpty();
}

@Test
Expand Down

0 comments on commit e3dd9ad

Please sign in to comment.