grpc config_error ai_generated true

UNAVAILABLE: grpc: load balancing policy "pick_first" not found

ID: grpc/load-balancing-policy-pick-first-not-found

Also available as: JSON · Markdown · 中文
90%Fix Rate
85%Confidence
1Evidence
2024-06-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
gRPC Go 1.65.0 active
gRPC Python 1.64.0 active
gRPC Java 1.62.0 active

Root Cause

The gRPC client attempted to use a load balancing policy name that is not registered in the binary, often due to missing build tags or policy import.

generic

中文

gRPC 客户端尝试使用未在二进制文件中注册的负载均衡策略名称,通常由于缺少构建标签或策略导入。

Official Documentation

https://grpc.io/docs/guides/load-balancing/

Workarounds

  1. 95% success In gRPC Go, import the pick_first policy: `import _ "google.golang.org/grpc/balancer/pick_first"` or use `grpc.WithDefaultServiceConfig` to set policy to `"round_robin"` after importing `_ "google.golang.org/grpc/balancer/roundrobin"`
    In gRPC Go, import the pick_first policy: `import _ "google.golang.org/grpc/balancer/pick_first"` or use `grpc.WithDefaultServiceConfig` to set policy to `"round_robin"` after importing `_ "google.golang.org/grpc/balancer/roundrobin"`
  2. 85% success In gRPC Python, set `grpc.ssl_channel_credentials().load_latest_certificates()` or use a custom resolver that specifies a built-in policy like `round_robin`
    In gRPC Python, set `grpc.ssl_channel_credentials().load_latest_certificates()` or use a custom resolver that specifies a built-in policy like `round_robin`

中文步骤

  1. 在 gRPC Go 中导入 pick_first 策略:`import _ "google.golang.org/grpc/balancer/pick_first"` 或使用 `grpc.WithDefaultServiceConfig` 设置策略为 `"round_robin"` 并先导入 `_ "google.golang.org/grpc/balancer/roundrobin"`
  2. 在 gRPC Python 中,设置 `grpc.ssl_channel_credentials().load_latest_certificates()` 或使用自定义解析器指定内置策略如 `round_robin`

Dead Ends

Common approaches that don't work:

  1. Change policy name to 'round_robin' without importing the package 70% fail

    Same missing import issue for 'round_robin' policy.

  2. Manually set service config with an unknown policy string 90% fail

    gRPC validates policy names at startup; invalid names cause same error.

  3. Upgrade the gRPC library to latest version without code changes 50% fail

    The policy must be explicitly imported in code; version upgrade alone doesn't fix.