{
  "id": "go/grpc-deadline-exceeded-server-slow",
  "signature": "rpc error: code = DeadlineExceeded desc = context deadline exceeded",
  "signature_zh": "rpc 错误：code = DeadlineExceeded desc = 上下文超时",
  "regex": "rpc\\ error:\\ code\\ =\\ DeadlineExceeded\\ desc\\ =\\ context\\ deadline\\ exceeded",
  "domain": "go",
  "category": "network_error",
  "subcategory": null,
  "root_cause": "The client-side context deadline elapsed before the server responded. Usually the server handler is slow (DB query, downstream call) or the deadline is too aggressive.",
  "root_cause_type": "generic",
  "root_cause_zh": "客户端上下文截止时间在服务器响应之前耗尽。通常是因为服务器处理程序较慢（数据库查询、下游调用）或截止时间设置过于激进。",
  "versions": [
    {
      "version": "google.golang.org/grpc v1.55+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Removes the timeout but leaves slow handlers blocking goroutines indefinitely; cascading failures.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Synchronized retries amplify load on an already-overloaded server (thundering herd).",
      "fail_rate": 0.75,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.9,
      "how": "func (s *server) Get(ctx context.Context, req *pb.GetReq) (*pb.GetResp, error) {\n    ctx, span := trace.StartSpan(ctx, \"Get\")\n    defer span.End()\n    if dl, ok := ctx.Deadline(); ok {\n        log.Printf(\"deadline in %v\", time.Until(dl))\n    }\n    return s.db.Query(ctx, req.Id) // pass ctx through\n}",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "b := backoff.NewExponentialBackOff()\nb.MaxElapsedTime = 5 * time.Second\nb.InitialInterval = 100 * time.Millisecond\nreturn backoff.Retry(func() error {\n    _, err := client.Get(ctx, req)\n    return err\n}, backoff.WithContext(b, ctx))",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": null,
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.89,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-01-09",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}