Skip to content

Commit

Permalink
[clusterimpl_pick_sc_wrong_type] xds/clusterimpl: fix SubConn wrapper…
Browse files Browse the repository at this point in the history
… returned by picker during race

The previous logic is that the picker updated with a non-Ready state
should always return error, so the clusterimpl picker doesn't try to
unwrap the SubConn.

The assumption is not true, in cases like ring_hash (where the picker is
mutable, and could start to return SubConns before the overall state is
updated to Ready during races).
  • Loading branch information
menghanl committed Oct 15, 2021
1 parent 7e5fcc6 commit 42d071f
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions xds/internal/balancer/clusterimpl/picker.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,15 @@ func newPicker(s balancer.State, config *dropConfigs, loadStore load.PerClusterR
func (d *picker) Pick(info balancer.PickInfo) (balancer.PickResult, error) {
// Don't drop unless the inner picker is READY. Similar to
// https://github.com/grpc/grpc-go/issues/2622.
if d.s.ConnectivityState != connectivity.Ready {
return d.s.Picker.Pick(info)
}

// Check if this RPC should be dropped by category.
for _, dp := range d.drops {
if dp.drop() {
if d.loadStore != nil {
d.loadStore.CallDropped(dp.category)
if d.s.ConnectivityState == connectivity.Ready {
// Check if this RPC should be dropped by category.
for _, dp := range d.drops {
if dp.drop() {
if d.loadStore != nil {
d.loadStore.CallDropped(dp.category)
}
return balancer.PickResult{}, status.Errorf(codes.Unavailable, "RPC is dropped")
}
return balancer.PickResult{}, status.Errorf(codes.Unavailable, "RPC is dropped")
}
}

Expand Down

0 comments on commit 42d071f

Please sign in to comment.