Fix handling of connectivity state error in RR.

reviewable/pr14886/r2
Mark D. Roth 7 years ago
parent 8c93fc89fb
commit b572910677
  1. 19
      src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc

@ -122,13 +122,18 @@ class RoundRobin : public LoadBalancingPolicy {
: SubchannelList(policy, tracer, addresses, combiner, : SubchannelList(policy, tracer, addresses, combiner,
client_channel_factory, args) {} client_channel_factory, args) {}
~RoundRobinSubchannelList() {
GRPC_ERROR_UNREF(last_transient_failure_error_);
}
void RefForConnectivityWatch(const char* reason); void RefForConnectivityWatch(const char* reason);
void UnrefForConnectivityWatch(const char* reason); void UnrefForConnectivityWatch(const char* reason);
void StartWatchingLocked(); void StartWatchingLocked();
void UpdateStateCountersLocked(grpc_connectivity_state old_state, void UpdateStateCountersLocked(grpc_connectivity_state old_state,
grpc_connectivity_state new_state); grpc_connectivity_state new_state,
grpc_error* transient_failure_error);
void UpdateConnectivityStateLocked(); void UpdateConnectivityStateLocked();
@ -141,6 +146,7 @@ class RoundRobin : public LoadBalancingPolicy {
size_t num_ready_ = 0; size_t num_ready_ = 0;
size_t num_connecting_ = 0; size_t num_connecting_ = 0;
size_t num_transient_failure_ = 0; size_t num_transient_failure_ = 0;
grpc_error* last_transient_failure_error_ = GRPC_ERROR_NONE;
}; };
void ShutdownLocked() override; void ShutdownLocked() override;
@ -437,7 +443,8 @@ gpr_log(GPR_INFO, "AFTER: CheckConnectivityStateLocked loop");
} }
void RoundRobin::RoundRobinSubchannelList::UpdateStateCountersLocked( void RoundRobin::RoundRobinSubchannelList::UpdateStateCountersLocked(
grpc_connectivity_state old_state, grpc_connectivity_state new_state) { grpc_connectivity_state old_state, grpc_connectivity_state new_state,
grpc_error* transient_failure_error) {
GPR_ASSERT(old_state != GRPC_CHANNEL_SHUTDOWN); GPR_ASSERT(old_state != GRPC_CHANNEL_SHUTDOWN);
GPR_ASSERT(new_state != GRPC_CHANNEL_SHUTDOWN); GPR_ASSERT(new_state != GRPC_CHANNEL_SHUTDOWN);
if (old_state == GRPC_CHANNEL_READY) { if (old_state == GRPC_CHANNEL_READY) {
@ -457,6 +464,8 @@ void RoundRobin::RoundRobinSubchannelList::UpdateStateCountersLocked(
} else if (new_state == GRPC_CHANNEL_TRANSIENT_FAILURE) { } else if (new_state == GRPC_CHANNEL_TRANSIENT_FAILURE) {
++num_transient_failure_; ++num_transient_failure_;
} }
GRPC_ERROR_UNREF(last_transient_failure_error_);
last_transient_failure_error_ = transient_failure_error;
} }
/** Sets the policy's connectivity status based on that of the passed-in \a sd /** Sets the policy's connectivity status based on that of the passed-in \a sd
@ -492,10 +501,9 @@ void RoundRobin::RoundRobinSubchannelList::UpdateConnectivityStateLocked() {
/* 3) TRANSIENT_FAILURE */ /* 3) TRANSIENT_FAILURE */
grpc_connectivity_state_set(&p->state_tracker_, grpc_connectivity_state_set(&p->state_tracker_,
GRPC_CHANNEL_TRANSIENT_FAILURE, GRPC_CHANNEL_TRANSIENT_FAILURE,
GRPC_ERROR_NONE, // FIXME: GRPC_ERROR_REF(error), GRPC_ERROR_REF(last_transient_failure_error_),
"rr_exhausted_subchannels"); "rr_exhausted_subchannels");
} }
// FIXME: GRPC_ERROR_UNREF(error);
} }
void RoundRobin::RoundRobinSubchannelList::UpdateOverallStateLocked() { void RoundRobin::RoundRobinSubchannelList::UpdateOverallStateLocked() {
@ -598,7 +606,8 @@ void RoundRobin::RoundRobinSubchannelData::ProcessConnectivityChangeLocked(
} }
// Update state counters. // Update state counters.
subchannel_list()->UpdateStateCountersLocked(prev_connectivity_state_, subchannel_list()->UpdateStateCountersLocked(prev_connectivity_state_,
connectivity_state()); connectivity_state(),
GRPC_ERROR_REF(error));
prev_connectivity_state_ = connectivity_state(); prev_connectivity_state_ = connectivity_state();
// If not initializing, update overall state and renew notification. // If not initializing, update overall state and renew notification.
if (subchannel_list()->initialized()) { if (subchannel_list()->initialized()) {

Loading…
Cancel
Save