Skip to content

Commit a8142c2

Browse files
authored
Merge pull request #2916 from murgatroid99/grpc-js-xds_ring_hash_fix
grpc-js-xds: ring_hash: Fix proactive connect logic when already connecting
2 parents fbd13e8 + abcf430 commit a8142c2

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

packages/grpc-js-xds/src/load-balancer-ring-hash.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -249,16 +249,20 @@ class RingHashLoadBalancer implements LoadBalancer {
249249
if (!(this.currentState === connectivityState.TRANSIENT_FAILURE || this.currentState === connectivityState.CONNECTING)) {
250250
return;
251251
}
252+
let firstIdleChild: LeafLoadBalancer | null = null;
252253
for (const leaf of this.leafMap.values()) {
253254
const leafState = leaf.getConnectivityState();
254255
if (leafState === connectivityState.CONNECTING) {
256+
firstIdleChild = null;
255257
break;
256258
}
257-
if (leafState === connectivityState.IDLE) {
258-
leaf.startConnecting();
259-
break;
259+
if (leafState === connectivityState.IDLE && !firstIdleChild) {
260+
firstIdleChild = leaf;
260261
}
261262
}
263+
if (firstIdleChild) {
264+
firstIdleChild.startConnecting();
265+
}
262266
}
263267

264268
private calculateAndUpdateState() {

0 commit comments

Comments
 (0)