@@ -162,16 +162,17 @@ func (p *rlsPicker) Pick(info balancer.PickInfo) (balancer.PickResult, error) {
162162
163163// delegateToChildPolicies is a helper function which iterates through the list
164164// of child policy wrappers in a cache entry and attempts to find a child policy
165- // to which this RPC can be routed to. If there is no child policy in READY
166- // state , we delegate to the first child policy arbitrarily.
165+ // to which this RPC can be routed to. If all child policies are in
166+ // TRANSIENT_FAILURE , we delegate to the first child policy arbitrarily.
167167//
168168// Caller must hold at least a read-lock on p.lb.cacheMu.
169169func (p * rlsPicker ) delegateToChildPolicies (dcEntry * cacheEntry , info balancer.PickInfo ) (balancer.PickResult , error ) {
170170 for _ , cpw := range dcEntry .childPolicyWrappers {
171- ok , res , err := p . pickIfFeasible ( cpw , info )
172- if ok {
173- return res , err
171+ state := ( * balancer . State )( atomic . LoadPointer ( & cpw . state ) )
172+ if state . ConnectivityState == connectivity . TransientFailure {
173+ continue
174174 }
175+ return state .Picker .Pick (info )
175176 }
176177 if len (dcEntry .childPolicyWrappers ) != 0 {
177178 state := (* balancer .State )(atomic .LoadPointer (& dcEntry .childPolicyWrappers [0 ].state ))
@@ -249,8 +250,8 @@ func (p *rlsPicker) sendRequestAndReturnPick(cacheKey cacheKey, bs *backoffState
249250// target if one is configured, or fails the pick with the given error.
250251func (p * rlsPicker ) useDefaultPickIfPossible (info balancer.PickInfo , errOnNoDefault error ) (balancer.PickResult , error ) {
251252 if p .defaultPolicy != nil {
252- _ , res , err := p . pickIfFeasible ( p .defaultPolicy , info )
253- return res , err
253+ state := ( * balancer . State )( atomic . LoadPointer ( & p .defaultPolicy . state ) )
254+ return state . Picker . Pick ( info )
254255 }
255256 return balancer.PickResult {}, errOnNoDefault
256257}
@@ -275,27 +276,6 @@ func (p *rlsPicker) sendRouteLookupRequest(cacheKey cacheKey, bs *backoffState,
275276 return throttled
276277}
277278
278- // pickIfFeasible determines if a pick can be delegated to child policy based on
279- // its connectivity state.
280- // - If state is CONNECTING, the pick is to be queued
281- // - If state is IDLE, the child policy is instructed to exit idle, and the pick
282- // is to be queued
283- // - If state is READY, pick it delegated to the child policy's picker
284- func (p * rlsPicker ) pickIfFeasible (cpw * childPolicyWrapper , info balancer.PickInfo ) (bool , balancer.PickResult , error ) {
285- state := (* balancer .State )(atomic .LoadPointer (& cpw .state ))
286- switch state .ConnectivityState {
287- case connectivity .Connecting :
288- return true , balancer.PickResult {}, balancer .ErrNoSubConnAvailable
289- case connectivity .Idle :
290- p .bg .ExitIdleOne (cpw .target )
291- return true , balancer.PickResult {}, balancer .ErrNoSubConnAvailable
292- case connectivity .Ready :
293- r , e := state .Picker .Pick (info )
294- return true , r , e
295- }
296- return false , balancer.PickResult {}, balancer .ErrNoSubConnAvailable
297- }
298-
299279// handleRouteLookupResponse is the callback invoked by the control channel upon
300280// receipt of an RLS response. Modifies the data cache and pending requests map
301281// and sends a new picker.
0 commit comments