{
  "schema": 1,
  "sqlstate": "25P03",
  "condition_name": "idle_in_transaction_session_timeout",
  "runner": "scripts/verify_cases.py",
  "targets": {
    "latest": {
      "binary": "Homebrew PostgreSQL 18.6",
      "required": true
    },
    "pg10": {
      "image": "postgres:10",
      "required": true
    }
  },
  "cases": [
    {
      "id": "idle_in_transaction_timeout",
      "versions": [
        "10",
        "18"
      ],
      "preconditions": [
        "A runner-owned disposable target is provisioned."
      ],
      "trigger": "Set idle_in_transaction_session_timeout, BEGIN, wait idle, and probe the terminated session.",
      "assertions": [
        "The original session is terminated by the timeout",
        "The collector records FATAL 25P03 for the matching backend PID",
        "A fresh connection can execute SELECT 1"
      ],
      "repair": "Use the state-specific recovery documented on the page; do not reuse a terminated connection.",
      "cleanup": "Drop the case schema with an owner connection."
    }
  ],
  "evidence_status": "authored",
  "snippets": [
    {
      "id": "idle_in_transaction_timeout",
      "case_id": "idle_in_transaction_timeout",
      "language": "sql",
      "statements": {
        "set_timeout": "SET idle_in_transaction_session_timeout = '300ms'",
        "backend_pid": "SELECT pg_backend_pid()",
        "begin": "BEGIN",
        "probe": "SELECT 1"
      }
    }
  ],
  "runtime": [
    {
      "id": "runtime.25P03-batch2c-latest-20260909.latest",
      "run_id": "25P03-batch2c-latest-20260909",
      "target": "latest",
      "server_version": "18.6 (Homebrew)",
      "server_version_num": 180006,
      "status": "passed",
      "case_status": "passed",
      "target_status": "passed",
      "cases": [
        "idle_in_transaction_timeout"
      ],
      "summary_sha256": "ec210989486eb92bda87e874942b5987d23f121f914c780e30851f3fe04e9379",
      "raw_sha256": "eeb467a1908730a03d6eb9cf1e1319a5d658dcb4a0bb42d0907f8045682778bf",
      "snippet_registry": {
        "sha256": "95fd079c8bca77c6e3ffc398e404a218e4f810e5fa36e30127cbc6470a6d6eb2"
      },
      "case_manifest": {
        "sha256": "e6c8d08f3b964c308d1a2c87f64919aa7d914db438456658afa230383c7f27eb"
      },
      "observed": {
        "sqlstate": "25P03",
        "severity": "FATAL",
        "primary": "terminating connection due to idle-in-transaction timeout",
        "backend_pid": 26447,
        "status_before_timeout": "INTRANS",
        "original_connection_closed": true,
        "collector_csv_sqlstate": "25P03",
        "collector_csv_error_severity": "FATAL",
        "collector_json_sqlstate": "25P03",
        "collector_json_error_severity": "FATAL",
        "fresh_connection_probe": 1,
        "fresh_connection_status": "IDLE",
        "recovery_requires_new_connection": true
      },
      "result": {
        "status": "passed",
        "environment": {
          "TimeZone": "Asia/Shanghai",
          "backend_pid": 26421,
          "binary": {
            "bindir": "/opt/homebrew/Cellar/postgresql@18/18.6/bin",
            "pg_config": "/opt/homebrew/bin/pg_config",
            "pg_config_version": "PostgreSQL 18.6 (Homebrew)",
            "postgres": "/opt/homebrew/Cellar/postgresql@18/18.6/bin/postgres"
          },
          "connection_scope": "runner-owned localhost port",
          "current_user": "runner",
          "docker": {},
          "lc_messages": "C",
          "libpq_version": "18.6",
          "locale": "en_US.UTF-8",
          "log_destination": "csvlog,jsonlog",
          "log_error_verbosity": "verbose",
          "log_min_error_statement": "error",
          "log_min_messages": "error",
          "logging_collector": "on",
          "machine": "arm64",
          "max_connections": "100",
          "platform": "macOS-26.6.2-arm64-arm-64bit-Mach-O",
          "psycopg_version": "3.3.5",
          "python_version": "3.14.6 (main, Jun 10 2026, 10:03:53) [Clang 21.0.0 (clang-2100.0.123.102)]",
          "server_encoding": "UTF8",
          "server_version": "18.6 (Homebrew)",
          "server_version_num": "180006",
          "target_kind": "latest",
          "wal_level": "logical"
        },
        "cases": [
          {
            "assertions": [
              {
                "expected": "driver observes a closed connection",
                "name": "timeout terminates original session",
                "observed": {
                  "attempts": 1,
                  "closed": true,
                  "error": {
                    "column_name": null,
                    "constraint_name": null,
                    "context": null,
                    "datatype_name": null,
                    "exception_type": "IdleInTransactionSessionTimeout",
                    "internal_position": null,
                    "internal_query": null,
                    "message_detail": null,
                    "message_hint": null,
                    "message_primary": "terminating connection due to idle-in-transaction timeout",
                    "schema_name": null,
                    "severity": "FATAL",
                    "severity_nonlocalized": "FATAL",
                    "source_file": "postgres.c",
                    "source_function": "ProcessInterrupts",
                    "source_line": "3487",
                    "sqlstate": "25P03",
                    "statement_position": null,
                    "table_name": null,
                    "text": "terminating connection due to idle-in-transaction timeout"
                  }
                },
                "passed": true
              },
              {
                "expected": "INTRANS",
                "name": "timeout began inside transaction",
                "observed": "INTRANS",
                "passed": true
              },
              {
                "expected": {
                  "csv": "25P03",
                  "error_severity": "FATAL",
                  "json": "25P03"
                },
                "name": "collector records SQLSTATE and exact FATAL",
                "observed": {
                  "csv": [
                    {
                      "application_name": "",
                      "backend_type": "client backend",
                      "command_tag": "idle in transaction",
                      "connection_from": "127.0.0.1:54618",
                      "context": "",
                      "database_name": "postgres",
                      "detail": "",
                      "error_severity": "FATAL",
                      "hint": "",
                      "internal_query": "",
                      "internal_query_pos": "",
                      "leader_pid": "",
                      "location": "ProcessInterrupts, postgres.c:3487",
                      "log_time": "2026-09-09 19:29:35.203 CST",
                      "message": "terminating connection due to idle-in-transaction timeout",
                      "process_id": "26447",
                      "query": "",
                      "query_id": "0",
                      "query_pos": "",
                      "session_id": "6aa1431e.674f",
                      "session_line_num": "1",
                      "session_start_time": "2026-09-09 19:29:34 CST",
                      "sql_state_code": "25P03",
                      "transaction_id": "0",
                      "user_name": "runner",
                      "virtual_transaction_id": "4/4"
                    }
                  ],
                  "json": [
                    {
                      "backend_type": "client backend",
                      "dbname": "postgres",
                      "error_severity": "FATAL",
                      "file_line_num": 3487,
                      "file_name": "postgres.c",
                      "func_name": "ProcessInterrupts",
                      "line_num": 1,
                      "message": "terminating connection due to idle-in-transaction timeout",
                      "pid": 26447,
                      "ps": "idle in transaction",
                      "query_id": 0,
                      "remote_host": "127.0.0.1",
                      "remote_port": 54618,
                      "session_id": "6aa1431e.674f",
                      "session_start": "2026-09-09 19:29:34 CST",
                      "state_code": "25P03",
                      "timestamp": "2026-09-09 19:29:35.203 CST",
                      "txid": 0,
                      "user": "runner",
                      "vxid": "4/4"
                    }
                  ]
                },
                "passed": true
              },
              {
                "expected": "SELECT 1 and IDLE on a fresh connection",
                "name": "fresh session can recover",
                "observed": {
                  "probe": 1,
                  "status": "IDLE"
                },
                "passed": true
              }
            ],
            "case_id": "idle_in_transaction_timeout",
            "cleanup": {
              "errors": [],
              "passed": true
            },
            "elapsed_seconds": 0.835,
            "observed": {
              "backend_pid": 26447,
              "collector": {
                "csv": [
                  {
                    "application_name": "",
                    "backend_type": "client backend",
                    "command_tag": "idle in transaction",
                    "connection_from": "127.0.0.1:54618",
                    "context": "",
                    "database_name": "postgres",
                    "detail": "",
                    "error_severity": "FATAL",
                    "hint": "",
                    "internal_query": "",
                    "internal_query_pos": "",
                    "leader_pid": "",
                    "location": "ProcessInterrupts, postgres.c:3487",
                    "log_time": "2026-09-09 19:29:35.203 CST",
                    "message": "terminating connection due to idle-in-transaction timeout",
                    "process_id": "26447",
                    "query": "",
                    "query_id": "0",
                    "query_pos": "",
                    "session_id": "6aa1431e.674f",
                    "session_line_num": "1",
                    "session_start_time": "2026-09-09 19:29:34 CST",
                    "sql_state_code": "25P03",
                    "transaction_id": "0",
                    "user_name": "runner",
                    "virtual_transaction_id": "4/4"
                  }
                ],
                "json": [
                  {
                    "backend_type": "client backend",
                    "dbname": "postgres",
                    "error_severity": "FATAL",
                    "file_line_num": 3487,
                    "file_name": "postgres.c",
                    "func_name": "ProcessInterrupts",
                    "line_num": 1,
                    "message": "terminating connection due to idle-in-transaction timeout",
                    "pid": 26447,
                    "ps": "idle in transaction",
                    "query_id": 0,
                    "remote_host": "127.0.0.1",
                    "remote_port": 54618,
                    "session_id": "6aa1431e.674f",
                    "session_start": "2026-09-09 19:29:34 CST",
                    "state_code": "25P03",
                    "timestamp": "2026-09-09 19:29:35.203 CST",
                    "txid": 0,
                    "user": "runner",
                    "vxid": "4/4"
                  }
                ]
              },
              "driver_diagnostic": {
                "column_name": null,
                "constraint_name": null,
                "context": null,
                "datatype_name": null,
                "exception_type": "IdleInTransactionSessionTimeout",
                "internal_position": null,
                "internal_query": null,
                "message_detail": null,
                "message_hint": null,
                "message_primary": "terminating connection due to idle-in-transaction timeout",
                "schema_name": null,
                "severity": "FATAL",
                "severity_nonlocalized": "FATAL",
                "source_file": "postgres.c",
                "source_function": "ProcessInterrupts",
                "source_line": "3487",
                "sqlstate": "25P03",
                "statement_position": null,
                "table_name": null,
                "text": "terminating connection due to idle-in-transaction timeout"
              },
              "driver_sqlstate": "25P03",
              "fresh_connection_probe": 1,
              "fresh_connection_status": "IDLE",
              "original_connection_closed": true,
              "recovery_requires_new_connection": true,
              "setting": "idle_in_transaction_session_timeout",
              "status_before_timeout": "INTRANS",
              "timeout_ms": 300
            },
            "schema": "c25p03_idle_in_transaction_timeout",
            "status": "passed"
          }
        ]
      }
    },
    {
      "id": "runtime.25P03-batch2c-pg10-20260909.pg10",
      "run_id": "25P03-batch2c-pg10-20260909",
      "target": "pg10",
      "server_version": "10.21 (Debian 10.21-1.pgdg90+1)",
      "server_version_num": 100021,
      "status": "passed",
      "case_status": "passed",
      "target_status": "passed",
      "cases": [
        "idle_in_transaction_timeout"
      ],
      "summary_sha256": "a76cbc2408369f7baca614ed533cba18d8b7f105d7fd3319107be5c01143917d",
      "raw_sha256": "cc716ef184879dac6e0e6885922e940faa0bfed5ef22ef64e479403db499c7e8",
      "snippet_registry": {
        "sha256": "95fd079c8bca77c6e3ffc398e404a218e4f810e5fa36e30127cbc6470a6d6eb2"
      },
      "case_manifest": {
        "sha256": "e6c8d08f3b964c308d1a2c87f64919aa7d914db438456658afa230383c7f27eb"
      },
      "observed": {
        "sqlstate": "25P03",
        "severity": "FATAL",
        "primary": "terminating connection due to idle-in-transaction timeout",
        "backend_pid": 81,
        "status_before_timeout": "INTRANS",
        "original_connection_closed": true,
        "collector_csv_sqlstate": "25P03",
        "collector_csv_error_severity": "FATAL",
        "collector_json_sqlstate": null,
        "collector_json_error_severity": null,
        "fresh_connection_probe": 1,
        "fresh_connection_status": "IDLE",
        "recovery_requires_new_connection": true
      },
      "result": {
        "status": "passed",
        "environment": {
          "TimeZone": "Etc/UTC",
          "backend_pid": 79,
          "binary": {},
          "connection_scope": "runner-owned localhost port",
          "current_user": "postgres",
          "docker": {
            "architecture": "arm64",
            "command": "/usr/local/bin/docker",
            "id": "sha256:b2baf8998630663d21370da06387c950e587071bdd307ee34e661cdcc7442bcc",
            "image": "postgres:10",
            "image_created": "2022-06-23T09:11:18.374607054Z",
            "os": "linux",
            "repo_digests": [
              "postgres@sha256:b2baf8998630663d21370da06387c950e587071bdd307ee34e661cdcc7442bcc"
            ]
          },
          "lc_messages": "en_US.utf8",
          "libpq_version": "18.6",
          "locale": "en_US.UTF-8",
          "log_destination": "csvlog",
          "log_error_verbosity": "verbose",
          "log_min_error_statement": "error",
          "log_min_messages": "error",
          "logging_collector": "on",
          "machine": "arm64",
          "max_connections": "100",
          "platform": "macOS-26.6.2-arm64-arm-64bit-Mach-O",
          "psycopg_version": "3.3.5",
          "python_version": "3.14.6 (main, Jun 10 2026, 10:03:53) [Clang 21.0.0 (clang-2100.0.123.102)]",
          "server_encoding": "UTF8",
          "server_version": "10.21 (Debian 10.21-1.pgdg90+1)",
          "server_version_num": "100021",
          "target_kind": "pg10",
          "wal_level": "logical"
        },
        "cases": [
          {
            "assertions": [
              {
                "expected": "driver observes a closed connection",
                "name": "timeout terminates original session",
                "observed": {
                  "attempts": 1,
                  "closed": true,
                  "error": {
                    "column_name": null,
                    "constraint_name": null,
                    "context": null,
                    "datatype_name": null,
                    "exception_type": "IdleInTransactionSessionTimeout",
                    "internal_position": null,
                    "internal_query": null,
                    "message_detail": null,
                    "message_hint": null,
                    "message_primary": "terminating connection due to idle-in-transaction timeout",
                    "schema_name": null,
                    "severity": "FATAL",
                    "severity_nonlocalized": "FATAL",
                    "source_file": "postgres.c",
                    "source_function": "ProcessInterrupts",
                    "source_line": "3058",
                    "sqlstate": "25P03",
                    "statement_position": null,
                    "table_name": null,
                    "text": "terminating connection due to idle-in-transaction timeout"
                  }
                },
                "passed": true
              },
              {
                "expected": "INTRANS",
                "name": "timeout began inside transaction",
                "observed": "INTRANS",
                "passed": true
              },
              {
                "expected": {
                  "csv": "25P03",
                  "error_severity": "FATAL",
                  "json": "not applicable"
                },
                "name": "collector records SQLSTATE and exact FATAL",
                "observed": {
                  "csv": [
                    {
                      "application_name": "",
                      "command_tag": "idle in transaction",
                      "connection_from": "172.17.0.1:62342",
                      "context": "",
                      "database_name": "postgres",
                      "detail": "",
                      "error_severity": "FATAL",
                      "hint": "",
                      "internal_query": "",
                      "internal_query_pos": "",
                      "location": "ProcessInterrupts, postgres.c:3058",
                      "log_time": "2026-09-09 11:29:43.557 UTC",
                      "message": "terminating connection due to idle-in-transaction timeout",
                      "process_id": "81",
                      "query": "",
                      "query_pos": "",
                      "session_id": "6aa14327.51",
                      "session_line_num": "1",
                      "session_start_time": "2026-09-09 11:29:43 UTC",
                      "sql_state_code": "25P03",
                      "transaction_id": "0",
                      "user_name": "postgres",
                      "virtual_transaction_id": "3/26"
                    }
                  ],
                  "json": []
                },
                "passed": true
              },
              {
                "expected": "SELECT 1 and IDLE on a fresh connection",
                "name": "fresh session can recover",
                "observed": {
                  "probe": 1,
                  "status": "IDLE"
                },
                "passed": true
              }
            ],
            "case_id": "idle_in_transaction_timeout",
            "cleanup": {
              "errors": [],
              "passed": true
            },
            "elapsed_seconds": 1.021,
            "observed": {
              "backend_pid": 81,
              "collector": {
                "csv": [
                  {
                    "application_name": "",
                    "command_tag": "idle in transaction",
                    "connection_from": "172.17.0.1:62342",
                    "context": "",
                    "database_name": "postgres",
                    "detail": "",
                    "error_severity": "FATAL",
                    "hint": "",
                    "internal_query": "",
                    "internal_query_pos": "",
                    "location": "ProcessInterrupts, postgres.c:3058",
                    "log_time": "2026-09-09 11:29:43.557 UTC",
                    "message": "terminating connection due to idle-in-transaction timeout",
                    "process_id": "81",
                    "query": "",
                    "query_pos": "",
                    "session_id": "6aa14327.51",
                    "session_line_num": "1",
                    "session_start_time": "2026-09-09 11:29:43 UTC",
                    "sql_state_code": "25P03",
                    "transaction_id": "0",
                    "user_name": "postgres",
                    "virtual_transaction_id": "3/26"
                  }
                ],
                "json": []
              },
              "driver_diagnostic": {
                "column_name": null,
                "constraint_name": null,
                "context": null,
                "datatype_name": null,
                "exception_type": "IdleInTransactionSessionTimeout",
                "internal_position": null,
                "internal_query": null,
                "message_detail": null,
                "message_hint": null,
                "message_primary": "terminating connection due to idle-in-transaction timeout",
                "schema_name": null,
                "severity": "FATAL",
                "severity_nonlocalized": "FATAL",
                "source_file": "postgres.c",
                "source_function": "ProcessInterrupts",
                "source_line": "3058",
                "sqlstate": "25P03",
                "statement_position": null,
                "table_name": null,
                "text": "terminating connection due to idle-in-transaction timeout"
              },
              "driver_sqlstate": "25P03",
              "fresh_connection_probe": 1,
              "fresh_connection_status": "IDLE",
              "original_connection_closed": true,
              "recovery_requires_new_connection": true,
              "setting": "idle_in_transaction_session_timeout",
              "status_before_timeout": "INTRANS",
              "timeout_ms": 300
            },
            "schema": "c25p03_idle_in_transaction_timeout",
            "status": "passed"
          }
        ]
      }
    }
  ]
}
