go runtime_error ai_generated partial

rpc error: code = DeadlineExceeded desc = context deadline exceeded

ID: go/grpc-deadline-exceeded-server

Also available as: JSON · Markdown · 中文
80%Fix Rate
87%Confidence
0Evidence
2024-02-08First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
google.golang.org/grpc 1.40+ active — — —

Root Cause

The client-side context deadline elapsed before the server responded; the server may still be processing, or the network is slow.

generic

中文

客户端上下文截止时间在服务端响应前已耗尽;服务端可能仍在处理,或网络较慢。

Workarounds

  1. 90% success
    Propagate deadlines from the caller and add per-RPC timeout at the client:
    ctx, cancel := context.WithTimeout(ctx, 2*time.Second)
    defer cancel()
    resp, err := client.Get(ctx, req)
  2. 85% success
    Instrument server-side handler duration (otelgrpc / prometheus) to distinguish slow processing from network latency, then tune deadline accordingly.

Dead Ends

Common approaches that don't work:

  1. 70% fail

    Removes the safety net; hung servers block callers forever and exhaust connection pools.

  2. 75% fail

    Without jitter/backoff, retries amplify load on an already-slow server, causing cascading timeouts.