Migrate to explicitly refresh name resolution by load balancer
- Dominant language
- Java
- Stars
- 12.1k
- Forks
- 4k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 37
Description
Currently each subchannel [implicitly refreshes the name resolution](https://github.com/grpc/grpc-java/blob/5e9a7b6e2f4e5ae2789fb7efc597c6a80c8beabd/core/src/main/java/io/grpc/internal/ManagedChannelImpl.java#L1929) when its connection is broken. That is, this feature is built into subchannel's internal implementation. Although it eliminates the burden of having LoadBalancer implementations refresh the name resolution when connections to backends are broken, this is gives LoadBalancer no chance to disable or override this refresh.
We'd want to let LoadBalancer manage refreshes explicitly. The API has already been there for a long time: [`LoadBalancer.Helper.refreshNameResolution()`](https://github.com/grpc/grpc-java/blob/d4fa0ecc07495097453b0a2848765f076b9e714c/api/src/main/java/io/grpc/LoadBalancer.java#L1058). During the transition, SubchannelImpl will check if `Helper.refreshNameResolution()` is called when its connection is broken. If not, it will still refresh the resolution and log a warning. _This will be removed in the future and LoadBalancers are completely responsible for triggering the refresh._
As a side effect of this check, LoadBalancers that intentionally do not want the refresh (e.g., xDS) will cause the warning. So we are adding a temporary LoadBalancer.Helper API, `ignoreRefreshNameResolutionCheck()` to help the transition. It's been marked as deprecated, xDS should be the only LoadBalancer implementation that uses it.
Contributor guide
Assessment
This issue has not been assessed yet.