{
  "id": "go/grpc-failed-precondition-state-mismatch",
  "signature": "rpc error: code = FailedPrecondition desc = resource version conflict: expected 3, got 5",
  "signature_zh": "rpc错误：代码=先决条件失败 描述=资源版本冲突：期望3，得到5",
  "regex": "rpc\\ error:\\ code\\ =\\ FailedPrecondition\\ desc\\ =\\ resource\\ version\\ conflict:\\ expected\\ 3,\\ got\\ 5",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "The request violates a precondition, such as an outdated resource version in an optimistic concurrency control scenario.",
  "root_cause_type": "generic",
  "root_cause_zh": "请求违反了先决条件，例如在乐观并发控制场景中资源版本过时。",
  "versions": [
    {
      "version": "1.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "1.1",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Retry the same request without updating the version.",
      "why_fails": "The version mismatch will persist, causing the same error.",
      "fail_rate": 1.0,
      "condition": "",
      "sources": []
    },
    {
      "action": "Ignore the version and force the update.",
      "why_fails": "This can lead to data corruption or lost updates.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Fetch the latest resource version and retry the update.",
      "success_rate": 0.9,
      "how": "currentResource, err := client.GetResource(ctx, &pb.GetRequest{Id: id})\nif err != nil { return err }\nreq.Version = currentResource.Version\nresp, err := client.UpdateResource(ctx, req)",
      "condition": "",
      "sources": []
    },
    {
      "action": "Implement a retry loop with backoff to handle concurrent updates.",
      "success_rate": 0.85,
      "how": "for i := 0; i < 3; i++ {\n    resp, err := client.UpdateResource(ctx, req)\n    if err == nil { return resp }\n    if status.Code(err) != codes.FailedPrecondition { return err }\n    time.Sleep(100 * time.Millisecond)\n    // Refresh resource\n}",
      "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.84,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-10-05",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}