grpc config_error ai_generated true

UNAVAILABLE: grpc: 未找到负载均衡策略 "pick_first"

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

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

其他格式: JSON · Markdown 中文 · English
90%修复率
85%置信度
1证据数
2024-06-01首次发现

版本兼容性

版本状态引入弃用备注
gRPC Go 1.65.0 active
gRPC Python 1.64.0 active
gRPC Java 1.62.0 active

根因分析

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

English

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

官方文档

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

解决方案

  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`

无效尝试

常见但无效的做法:

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

    Same missing import issue for 'round_robin' policy.

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

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

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

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