{
  "schema": 1,
  "sqlstate": "53300",
  "condition_name": "too_many_connections",
  "runner": "scripts/verify_cases.py",
  "targets": {
    "latest": {
      "binary": "Homebrew PostgreSQL 18.6",
      "required": true
    },
    "pg10": {
      "image": "postgres:10",
      "required": true
    }
  },
  "cases": [
    {
      "id": "role_connection_limit",
      "versions": [
        "10",
        "18"
      ],
      "preconditions": [
        "A disposable login role",
        "The role connection limit is set to one while one session is already connected"
      ],
      "trigger": "Open a second connection for that role.",
      "assertions": [
        "The new connection receives FATAL SQLSTATE 53300",
        "The existing owner connection can restore the limit and continue"
      ],
      "repair": "Pool and bound connections, reserve capacity for administration, and investigate the role/database/server limit that was reached.",
      "cleanup": "Restore the role limit, drop the role, and drop the case schema."
    }
  ],
  "evidence_status": "authored",
  "snippets": [
    {
      "id": "role_connection_limit",
      "case_id": "role_connection_limit",
      "language": "sql",
      "statements": {
        "set_limit": "ALTER ROLE limited_user CONNECTION LIMIT 1",
        "reset_limit": "ALTER ROLE limited_user CONNECTION LIMIT -1",
        "probe": "SELECT 1"
      }
    }
  ],
  "runtime": [
    {
      "cases": [
        "role_connection_limit"
      ],
      "id": "runtime.53300-registry-final-20260909.latest",
      "observed": {
        "collector_message": "too many connections for role <generated-role>",
        "collector_severity": "FATAL",
        "collector_source": "miscinit.c:880",
        "collector_sqlstate": "53300",
        "driver_sqlstate": null,
        "driver_text": "FATAL: too many connections for role <generated-role>",
        "restored_query": 1,
        "transaction": "none opened for rejected startup"
      },
      "raw_sha256": "5fbcf85150b62d596ca4b2356639fdcd89ca2a910447e2be9029b90de108a635",
      "run_id": "53300-registry-final-20260909",
      "server_version": "18.6 (Homebrew)",
      "server_version_num": 180006,
      "snippet_registry": {
        "sha256": "a83d740917ef53c3bf24494c12fe87f4c9cbb38f1e23c17991f2431ba13fa243"
      },
      "status": "passed",
      "summary_sha256": "e5505e6d644d9f68ba723c9af63fe069e69d030d1f554b8e8d37316b441f55a9",
      "target": "latest",
      "result": {
        "status": "passed",
        "environment": {
          "TimeZone": "Asia/Shanghai",
          "backend_pid": 29137,
          "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": "53300",
                "name": "connection-limit sqlstate",
                "observed": {
                  "collector": "53300",
                  "driver": null
                },
                "passed": true
              },
              {
                "expected": "too many connections",
                "name": "FATAL message identifies role limit",
                "observed": "connection failed: connection to server at \"127.0.0.1\", port 58078 failed: FATAL:  too many connections for role \"u53300_dc69901596\"",
                "passed": true
              },
              {
                "expected": 1,
                "name": "restored role can connect",
                "observed": 1,
                "passed": true
              }
            ],
            "case_id": "role_connection_limit",
            "cleanup": {
              "errors": [],
              "passed": true
            },
            "elapsed_seconds": 0.016,
            "observed": {
              "collector": {
                "csv": {
                  "application_name": "",
                  "backend_type": "client backend",
                  "command_tag": "startup",
                  "connection_from": "127.0.0.1:58088",
                  "context": "",
                  "database_name": "postgres",
                  "detail": "",
                  "error_severity": "FATAL",
                  "hint": "",
                  "internal_query": "",
                  "internal_query_pos": "",
                  "leader_pid": "",
                  "location": "InitializeSessionUserId, miscinit.c:880",
                  "log_time": "2026-09-09 17:05:16.989 CST",
                  "message": "too many connections for role \"u53300_dc69901596\"",
                  "process_id": "29144",
                  "query": "",
                  "query_id": "0",
                  "query_pos": "",
                  "session_id": "6aa1214c.71d8",
                  "session_line_num": "1",
                  "session_start_time": "2026-09-09 17:05:16 CST",
                  "sql_state_code": "53300",
                  "transaction_id": "0",
                  "user_name": "u53300_dc69901596",
                  "virtual_transaction_id": "7/1"
                },
                "json": {
                  "backend_type": "client backend",
                  "dbname": "postgres",
                  "error_severity": "FATAL",
                  "file_line_num": 880,
                  "file_name": "miscinit.c",
                  "func_name": "InitializeSessionUserId",
                  "line_num": 1,
                  "message": "too many connections for role \"u53300_dc69901596\"",
                  "pid": 29144,
                  "ps": "startup",
                  "query_id": 0,
                  "remote_host": "127.0.0.1",
                  "remote_port": 58088,
                  "session_id": "6aa1214c.71d8",
                  "session_start": "2026-09-09 17:05:16 CST",
                  "state_code": "53300",
                  "timestamp": "2026-09-09 17:05:16.989 CST",
                  "txid": 0,
                  "user": "u53300_dc69901596",
                  "vxid": "7/1"
                }
              },
              "diagnostic": {
                "column_name": null,
                "constraint_name": null,
                "context": null,
                "datatype_name": null,
                "exception_type": "OperationalError",
                "internal_position": null,
                "internal_query": null,
                "message_detail": null,
                "message_hint": null,
                "message_primary": null,
                "schema_name": null,
                "severity": null,
                "severity_nonlocalized": null,
                "source_file": null,
                "source_function": null,
                "source_line": null,
                "sqlstate": null,
                "statement_position": null,
                "table_name": null,
                "text": "connection failed: connection to server at \"127.0.0.1\", port 58078 failed: FATAL:  too many connections for role \"u53300_dc69901596\""
              },
              "restored_query": 1,
              "role": "u53300_dc69901596"
            },
            "schema": "c53300_role_connection_limit",
            "status": "passed"
          }
        ]
      }
    },
    {
      "cases": [
        "role_connection_limit"
      ],
      "id": "runtime.53300-registry-final-20260909.pg10",
      "image": "postgres@sha256:b2baf8998630663d21370da06387c950e587071bdd307ee34e661cdcc7442bcc",
      "observed": {
        "collector_message": "too many connections for role <generated-role>",
        "collector_severity": "FATAL",
        "collector_source": "miscinit.c:575",
        "collector_sqlstate": "53300",
        "driver_sqlstate": null,
        "driver_text": "FATAL: too many connections for role <generated-role>",
        "restored_query": 1,
        "transaction": "none opened for rejected startup"
      },
      "raw_sha256": "b03ea276f638c91efadd0791a9818993fc21620ec27ef643c60b7a9904fac6c3",
      "run_id": "53300-registry-final-20260909",
      "server_version": "10.21 (Debian 10.21-1.pgdg90+1)",
      "server_version_num": 100021,
      "snippet_registry": {
        "sha256": "a83d740917ef53c3bf24494c12fe87f4c9cbb38f1e23c17991f2431ba13fa243"
      },
      "status": "passed",
      "summary_sha256": "2ed0896c1548c0a3115e55381e03b0ccd392abe241552b574c64e88cca052f59",
      "target": "pg10",
      "result": {
        "status": "passed",
        "environment": {
          "TimeZone": "Etc/UTC",
          "backend_pid": 80,
          "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": "53300",
                "name": "connection-limit sqlstate",
                "observed": {
                  "collector": "53300",
                  "driver": null
                },
                "passed": true
              },
              {
                "expected": "too many connections",
                "name": "FATAL message identifies role limit",
                "observed": "connection failed: connection to server at \"127.0.0.1\", port 58097 failed: FATAL:  too many connections for role \"u53300_84266e8bec\"",
                "passed": true
              },
              {
                "expected": 1,
                "name": "restored role can connect",
                "observed": 1,
                "passed": true
              }
            ],
            "case_id": "role_connection_limit",
            "cleanup": {
              "errors": [],
              "passed": true
            },
            "elapsed_seconds": 0.079,
            "observed": {
              "collector": {
                "csv": {
                  "application_name": "",
                  "command_tag": "startup",
                  "connection_from": "172.17.0.1:61920",
                  "context": "",
                  "database_name": "postgres",
                  "detail": "",
                  "error_severity": "FATAL",
                  "hint": "",
                  "internal_query": "",
                  "internal_query_pos": "",
                  "location": "InitializeSessionUserId, miscinit.c:575",
                  "log_time": "2026-09-09 09:05:18.279 UTC",
                  "message": "too many connections for role \"u53300_84266e8bec\"",
                  "process_id": "85",
                  "query": "",
                  "query_pos": "",
                  "session_id": "6aa1214e.55",
                  "session_line_num": "1",
                  "session_start_time": "2026-09-09 09:05:18 UTC",
                  "sql_state_code": "53300",
                  "transaction_id": "0",
                  "user_name": "u53300_84266e8bec",
                  "virtual_transaction_id": "4/1"
                },
                "json": null
              },
              "diagnostic": {
                "column_name": null,
                "constraint_name": null,
                "context": null,
                "datatype_name": null,
                "exception_type": "OperationalError",
                "internal_position": null,
                "internal_query": null,
                "message_detail": null,
                "message_hint": null,
                "message_primary": null,
                "schema_name": null,
                "severity": null,
                "severity_nonlocalized": null,
                "source_file": null,
                "source_function": null,
                "source_line": null,
                "sqlstate": null,
                "statement_position": null,
                "table_name": null,
                "text": "connection failed: connection to server at \"127.0.0.1\", port 58097 failed: FATAL:  too many connections for role \"u53300_84266e8bec\""
              },
              "restored_query": 1,
              "role": "u53300_84266e8bec"
            },
            "schema": "c53300_role_connection_limit",
            "status": "passed"
          }
        ]
      }
    }
  ]
}
