{
  "id": "database/postgresql-checkpoint-wait-timeout",
  "signature": "psycopg2.OperationalError: ERROR: could not send data to server: Broken pipe",
  "signature_zh": "psycopg2.OperationalError: 错误：无法向服务器发送数据：管道破裂",
  "regex": "psycopg2\\.OperationalError: ERROR: could not send data to server: Broken pipe",
  "domain": "database",
  "category": "connection_error",
  "subcategory": null,
  "root_cause": "The PostgreSQL server closed the connection unexpectedly, often due to a timeout (e.g., statement_timeout, idle_in_transaction_session_timeout) or a server crash, causing a broken pipe on the client side.",
  "root_cause_type": "generic",
  "root_cause_zh": "PostgreSQL 服务器意外关闭连接，通常是由于超时（如 statement_timeout、idle_in_transaction_session_timeout）或服务器崩溃，导致客户端出现管道破裂。",
  "versions": [
    {
      "version": "PostgreSQL 13",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "PostgreSQL 14",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "PostgreSQL 15",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Increasing connection pool size in the application",
      "why_fails": "The error is not about pool exhaustion but about an existing connection being terminated; more connections don't fix broken pipes.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "Restarting the application without checking server logs",
      "why_fails": "The underlying cause (e.g., server-side timeout) is not addressed; the error will recur.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Check PostgreSQL logs for the reason the connection was terminated (e.g., statement_timeout, idle_in_transaction_session_timeout). Adjust the relevant timeout parameters in postgresql.conf:\nstatement_timeout = 0  # disable or increase\nidle_in_transaction_session_timeout = 0",
      "success_rate": 0.8,
      "how": "Check PostgreSQL logs for the reason the connection was terminated (e.g., statement_timeout, idle_in_transaction_session_timeout). Adjust the relevant timeout parameters in postgresql.conf:\nstatement_timeout = 0  # disable or increase\nidle_in_transaction_session_timeout = 0",
      "condition": "",
      "sources": []
    },
    {
      "action": "Enable TCP keepalives on the client side to detect broken connections earlier and automatically reconnect:\nimport psycopg2\nconn = psycopg2.connect(\"host=... keepalives=1 keepalives_idle=30 keepalives_interval=10 keepalives_count=5\")",
      "success_rate": 0.75,
      "how": "Enable TCP keepalives on the client side to detect broken connections earlier and automatically reconnect:\nimport psycopg2\nconn = psycopg2.connect(\"host=... keepalives=1 keepalives_idle=30 keepalives_interval=10 keepalives_count=5\")",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Check PostgreSQL logs for the reason the connection was terminated (e.g., statement_timeout, idle_in_transaction_session_timeout). Adjust the relevant timeout parameters in postgresql.conf:\nstatement_timeout = 0  # disable or increase\nidle_in_transaction_session_timeout = 0",
    "Enable TCP keepalives on the client side to detect broken connections earlier and automatically reconnect:\nimport psycopg2\nconn = psycopg2.connect(\"host=... keepalives=1 keepalives_idle=30 keepalives_interval=10 keepalives_count=5\")"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNECT-KEEPALIVES",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.82,
  "fix_success_rate": 0.78,
  "resolvable": "partial",
  "first_seen": "2024-01-10",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}