# 40000 — transaction_rollback

> Source-backed reference for PostgreSQL SQLSTATE 40000, with explicit mechanism boundaries.
---

# 40000 — transaction_rollback

## At a glance {#at-a-glance}

`40000` is an umbrella transaction-rollback condition. The fixed 18.6 source contains an internal system-catalog-scan path with `transaction aborted during system catalog scan`; reproducing that path would require an internal fault or visibility condition outside a safe SQL-only case. Do not turn a serialization failure, deadlock, or arbitrary client cancellation into 40000.

<!-- BEGIN SQLSTATE FACTS: generated by scripts/generate.py; do not edit -->

| Field | Value |
| --- | --- |
| SQLSTATE | `40000` |
| Condition | `transaction_rollback` |
| Status | `active` |
| Known present by | `7.4` |
| Locked snapshots | `9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3` |
| Macros | `ERRCODE_TRANSACTION_ROLLBACK` |
| Aliases | `—` |

<!-- source facts: data/errcodes/40000.json -->
<!-- END SQLSTATE FACTS -->

## Meaning {#meaning}

`40000` is the broad transaction rollback condition. The resolved core path in `genam.c` is a defensive internal error: a transaction aborted during a system catalog scan. It is not the normal client-visible retry path represented by `40001`, and it is not a deadlock report.

## Diagnosis {#diagnosis}

For a real `40000`, preserve the server log, backend PID, operation, and source diagnostics; the fixed primary template is `transaction aborted during system catalog scan`. Check whether the log points to an internal catalog/index visibility failure or a server fault. A client-side `ROLLBACK`, serialization failure, or canceled statement is insufficient evidence for this code, and the selected scan has no safe SQL-only reproduction.

## Response {#response}

Let the failed transaction end as the server requires, then investigate the catalog/index and server health before retrying. Reconnect only when the session is unusable, and verify durable state before repeating a write. Do not turn `40001`/`40P01` or a generic rollback into `40000`; this page records the internal source boundary only.

## Versions {#versions}

The locked facts table records catalogue presence across the project snapshot range. The fixed source evidence is limited to the path stated below; no exact behavioral introduction or broader runtime coverage is inferred from the definition alone.

## Related {#related}

Compare [40001 serialization failure](../40001/) and [40P01 deadlock detected](../40p01/) for retryable transaction rollback mechanisms with concrete SQL paths.

## Sources {#sources}

- [`src.errcodes.18.6`](https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/errcodes.txt) (SHA-256 `6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba`)
- [`source path`](https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/access/index/genam.c#L496-L498) (SHA-256 `11897b1d8b1ae1f4a1bef9a72e740da7aa83579abf84e4ca5ebacd6530874c28`)
