@@ -214,39 +214,28 @@ protected void updateOverallBalancingState() {
214214 overallState = TRANSIENT_FAILURE ;
215215 }
216216
217- // gRFC A61: trigger lazy initialization outside picker when no READY child exists,
218- // at least one child is in TRANSIENT_FAILURE, and no child is currently CONNECTING
219- maybeTriggerIdleChildConnection (numReady , numTF , numConnecting , numIdle );
217+ // gRFC A61: if the aggregated connectivity state is TRANSIENT_FAILURE or CONNECTING and
218+ // there are no endpoints in CONNECTING state, the ring_hash policy will choose one of
219+ // the endpoints in IDLE state (if any) to trigger a connection attempt on
220+ if (numReady == 0 && numTF > 0 && numConnecting == 0 && numIdle > 0 ) {
221+ triggerIdleChildConnection ();
222+ }
220223
221224 RingHashPicker picker =
222225 new RingHashPicker (syncContext , ring , getChildLbStates (), requestHashHeaderKey , random );
223226 getHelper ().updateBalancingState (overallState , picker );
224227 this .currentConnectivityState = overallState ;
225228 }
226229
230+
227231 /**
228- * Triggers proactive connection of an IDLE child load balancer when the following conditions are
229- * met.
230- *
231- * <ul>
232- * <li>there is no READY child
233- * <li>at least one child is in TRANSIENT_FAILURE
234- * <li>no child is currently CONNECTING
235- * <li>there exists at least one IDLE child
236- * </ul>
237- *
238- * <p>This corresponds to the proactive connection logic described in gRFC A61, where recovery
239- * from TRANSIENT_FAILURE must be triggered outside the picker when no active connection attempt
240- * is in progress.
232+ * Triggers a connection attempt for the first IDLE child load balancer.
241233 */
242- private void maybeTriggerIdleChildConnection (
243- int numReady , int numTF , int numConnecting , int numIdle ) {
244- if (numReady == 0 && numTF > 0 && numConnecting == 0 && numIdle > 0 ) {
245- for (ChildLbState child : getChildLbStates ()) {
246- if (child .getCurrentState () == ConnectivityState .IDLE ) {
247- child .getLb ().requestConnection ();
248- return ;
249- }
234+ private void triggerIdleChildConnection () {
235+ for (ChildLbState child : getChildLbStates ()) {
236+ if (child .getCurrentState () == ConnectivityState .IDLE ) {
237+ child .getLb ().requestConnection ();
238+ return ;
250239 }
251240 }
252241 }
0 commit comments