go network_error ai_generated true

rpc错误:代码=不可用 描述=服务器当前正在关闭

rpc error: code = Unavailable desc = the server is currently shutting down

ID: go/grpc-unavailable-server-shutdown

其他格式: JSON · Markdown 中文 · English
80%修复率
84%置信度
0证据数
2025-07-30首次发现

版本兼容性

版本状态引入弃用备注
1.0 active
1.1 active

根因分析

gRPC服务器正在优雅关闭过程中,不接受新请求。

English

The gRPC server is in the process of graceful shutdown and is not accepting new requests.

generic

解决方案

  1. 80% 成功率 Implement retry with backoff to wait for the server to restart.
    for i := 0; i < 5; i++ {
        resp, err := client.SomeRPC(ctx, req)
        if err == nil { return resp }
        if status.Code(err) != codes.Unavailable { return err }
        time.Sleep(time.Duration(1<<i) * time.Second)
    }
  2. 85% 成功率 Use a load balancer to redirect requests to healthy instances.
    Configure a load balancer that detects server health and routes traffic away from shutting down instances.

无效尝试

常见但无效的做法:

  1. Retry the request immediately. 90% 失败

    The server is still shutting down; it may take some time to become available again.

  2. Force the server to stop shutdown. 100% 失败

    Shutdown is initiated by the server; clients cannot override it.