xds: fix ring hash childLB acceptResolvedAddress not in syncContext (#10664)

This commit is contained in:
yifeizhuang 2023-11-13 14:58:30 -08:00 committed by GitHub
parent d5544bbb02
commit ae62785e0b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 8 deletions

View File

@ -425,12 +425,14 @@ final class RingHashLoadBalancer extends MultiChildLoadBalancer {
return PickResult.withNoResult(); return PickResult.withNoResult();
} }
if (subchannelView.connectivityState == IDLE || childLbState.isDeactivated()) { if (subchannelView.connectivityState == IDLE) {
if (childLbState.isDeactivated()) { syncContext.execute(() -> {
childLbState.activate(); if (childLbState.isDeactivated()) {
} else { childLbState.activate();
syncContext.execute(() -> childLbState.getLb().requestConnection()); } else {
} childLbState.getLb().requestConnection();
}
});
return PickResult.withNoResult(); // Indicates that this should be retried after backoff return PickResult.withNoResult(); // Indicates that this should be retried after backoff
} }
@ -531,11 +533,10 @@ final class RingHashLoadBalancer extends MultiChildLoadBalancer {
if (!isDeactivated()) { if (!isDeactivated()) {
return; return;
} }
currentConnectivityState = CONNECTING; currentConnectivityState = CONNECTING;
getLb().switchTo(pickFirstLbProvider); getLb().switchTo(pickFirstLbProvider);
markReactivated(); markReactivated();
getLb().acceptResolvedAddresses(this.getResolvedAddresses()); // Time to get a subchannel getLb().acceptResolvedAddresses(this.getResolvedAddresses());
logger.log(XdsLogLevel.DEBUG, "Child balancer {0} reactivated", getKey()); logger.log(XdsLogLevel.DEBUG, "Child balancer {0} reactivated", getKey());
} }