↑↓ select↵ open⌫ change scopeOpen full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

Wiki / SQLSTATE

53200 \u2014 out_of_memory

53200 is PostgreSQL's out-of-memory condition. Fixed callers include ordinary memory-context allocation, shared-memory and lock-table capacity, extension/statistics-file loading, and WAL-reading processors. The useful diagnosis is the operation and allocation context, not a claim that every memory failure has one cause.

English manual coverage begins with PostgreSQL 8.1. Source history and runtime observations have their own recorded version boundaries.

Reading PG 18·Select a recorded version

aliases
Unknown
class name
Insufficient Resources
condition name
out_of_memory
lang
en
sqlstate
53200

Definition PG 18

53200

At a glance {#at-a-glance}

53200 is PostgreSQL's out-of-memory condition. Fixed callers include ordinary memory-context allocation, shared-memory and lock-table capacity, extension/statistics-file loading, and WAL-reading processors. The useful diagnosis is the operation and allocation context, not a claim that every memory failure has one cause.

Meaning {#meaning}

The fixed source has several distinct boundaries. MemoryContextAllocationFailure reports out of memory with the requested size and memory-context name, while ShmemAlloc and lock-table setup report out of shared memory; the latter can hint at max_locks_per_transaction. Extension paths add operation details: pg_stat_statements logs out of memory with a file-reading detail, and WAL readers report the same primary with an allocation detail. The pg_stat_statements branch is LOG and returns from its loader, so it is not the same as a client ERROR that aborts the current transaction; the core and WAL-reader ERROR branches require normal transaction recovery. The two-phase source path is a WAL-reader allocation path, not evidence that reaching max_prepared_transactions itself emits 53200.

Diagnosis {#diagnosis}

Preserve severity, primary, detail, hint, operation, backend, and server log. Determine whether the path was a backend memory-context request, shared-memory/lock-table allocation, file/statistics structure, or WAL reader. For out of shared memory with a max_locks_per_transaction hint, inspect transaction lock counts and the configured lock-table capacity; increasing it consumes shared memory at startup. Check workload and relevant limits from observation; do not infer a host-wide memory diagnosis from the SQLSTATE alone.

Response {#response}

Reduce or reshape the operation, release application-side pressure, or adjust the named PostgreSQL capacity after confirming its effect and platform limits. Finish or roll back transactions that hold excessive locks before changing max_locks_per_transaction; do not treat that hint as proof of operating-system OOM. For a failed file/WAL/statistics operation, validate the object before retrying. The core/WAL-reader ERROR branches leave an explicit transaction failed, so use ROLLBACK or ROLLBACK TO SAVEPOINT before retrying; autocommit retry is appropriate only after the allocation cause is corrected. The pg_stat_statements LOG branch is a backend loader path and does not itself require client transaction recovery. OOM and corruption tests are intentionally source-only here; do not force allocator failure on a live host.

Versions {#versions}

The locked catalogue records this condition from 7.4; cited extension and core paths are PostgreSQL 18.6 source. No OOM runtime was attempted.

Related {#related}

53000, 53400, 55000

Sources {#sources}

contrib/pg_stat_statements/pg_stat_statements.c#L2340-L2350

contrib/pg_walinspect/pg_walinspect.c#L121-L124

src/backend/access/transam/twophase.c#L1417-L1420

src/backend/utils/mmgr/aset.c#L444-L453

src/backend/utils/mmgr/mcxt.c#L1157-L1167

src/backend/storage/ipc/shmem.c#L151-L162

src/backend/storage/lmgr/lock.c#L2957-L2969

The structured evidence record records fixed messages and the source/runtime boundary.

Compare versions

SQLSTATE evidence and recorded runtime versions

claims · identity
{
  "claim_id": "identity",
  "limits": "",
  "method": "Read fixed definition.",
  "position": 0,
  "runtime": [],
  "sources": [
    "src.errcodes.18.6"
  ],
  "statement": "53200 is out_of_memory in SQLSTATE Class 53."
}
claims · resolved-paths
{
  "claim_id": "resolved-paths",
  "limits": "Source confirmation is not natural runtime.",
  "method": "Read complete fixed source contexts.",
  "position": 1,
  "runtime": [],
  "sources": [
    "src.path.0",
    "src.path.1",
    "src.path.2",
    "src.path.3",
    "src.path.4",
    "src.path.5",
    "src.path.6"
  ],
  "statement": "The cited PostgreSQL 18.6 source paths support the representative resource and object-state mechanisms described."
}
claims · allocator-and-capacity
{
  "claim_id": "allocator-and-capacity",
  "limits": "",
  "method": "Read the complete fixed allocator, shared-memory, and lock-table guards.",
  "position": 2,
  "runtime": [],
  "sources": [
    "src.path.3",
    "src.path.4",
    "src.path.5",
    "src.path.6"
  ],
  "statement": "Core memory-context allocation uses 53200 for allocator failure, shared-memory allocation uses an out-of-shared-memory primary, and lock-table exhaustion can add a max_locks_per_transaction hint; these contexts are distinct from extension file/WAL allocation details."
}
claims · message-roles
{
  "claim_id": "message-roles",
  "limits": "",
  "method": "Read fixed report groups and complete source contexts.",
  "position": 3,
  "runtime": [],
  "sources": [
    "src.calls.REL_18_6"
  ],
  "statement": "The source report groups keep out of memory as the primary and the operation-specific allocation text as DETAIL; the pg_stat_statements group is LOG while the WAL reader groups are ERROR."
}
claims · history
{
  "claim_id": "history",
  "limits": "",
  "method": "Use catalogue boundary.",
  "position": 4,
  "runtime": [],
  "sources": [
    "src.errcodes.18.6"
  ],
  "statement": "The locked catalogue records 53200 from 7.4; that boundary does not prove exact implementation introduction."
}
messages · message.0
{
  "limits": "",
  "message_id": "message.0",
  "path": "",
  "position": 0,
  "raw": {
    "detail_template": "Could not allocate enough memory to read file \"%s\".",
    "id": "message.0",
    "primary_template": "out of memory",
    "severity_source": "LOG",
    "sources": [
      "src.path.0"
    ],
    "sqlstate": "53200"
  },
  "severity": "LOG",
  "sources": [
    "src.path.0"
  ],
  "templates": [
    {
      "kind": "primary",
      "literal": "out of memory",
      "position": 0,
      "role": "",
      "template": "out of memory"
    },
    {
      "kind": "detail",
      "literal": "Could not allocate enough memory to read file \" \".",
      "position": 1,
      "role": "",
      "template": "Could not allocate enough memory to read file \"%s\"."
    }
  ]
}
messages · message.1
{
  "limits": "",
  "message_id": "message.1",
  "path": "",
  "position": 1,
  "raw": {
    "detail_template": "Failed while allocating a WAL reading processor.",
    "id": "message.1",
    "primary_template": "out of memory",
    "severity_source": "ERROR",
    "sources": [
      "src.path.1"
    ],
    "sqlstate": "53200"
  },
  "severity": "ERROR",
  "sources": [
    "src.path.1"
  ],
  "templates": [
    {
      "kind": "primary",
      "literal": "out of memory",
      "position": 0,
      "role": "",
      "template": "out of memory"
    },
    {
      "kind": "detail",
      "literal": "Failed while allocating a WAL reading processor.",
      "position": 1,
      "role": "",
      "template": "Failed while allocating a WAL reading processor."
    }
  ]
}
messages · message.2
{
  "limits": "",
  "message_id": "message.2",
  "path": "",
  "position": 2,
  "raw": {
    "detail_template": "Failed while allocating a WAL reading processor.",
    "id": "message.2",
    "primary_template": "out of memory",
    "severity_source": "ERROR",
    "sources": [
      "src.path.2"
    ],
    "sqlstate": "53200"
  },
  "severity": "ERROR",
  "sources": [
    "src.path.2"
  ],
  "templates": [
    {
      "kind": "primary",
      "literal": "out of memory",
      "position": 0,
      "role": "",
      "template": "out of memory"
    },
    {
      "kind": "detail",
      "literal": "Failed while allocating a WAL reading processor.",
      "position": 1,
      "role": "",
      "template": "Failed while allocating a WAL reading processor."
    }
  ]
}
messages · message.3
{
  "limits": "",
  "message_id": "message.3",
  "path": "",
  "position": 3,
  "raw": {
    "detail_template": "Failed while creating memory context \"%s\".",
    "id": "message.3",
    "primary_template": "out of memory",
    "severity_source": "ERROR",
    "sources": [
      "src.path.3"
    ],
    "sqlstate": "53200"
  },
  "severity": "ERROR",
  "sources": [
    "src.path.3"
  ],
  "templates": [
    {
      "kind": "primary",
      "literal": "out of memory",
      "position": 0,
      "role": "",
      "template": "out of memory"
    },
    {
      "kind": "detail",
      "literal": "Failed while creating memory context \" \".",
      "position": 1,
      "role": "",
      "template": "Failed while creating memory context \"%s\"."
    }
  ]
}
messages · message.4
{
  "limits": "",
  "message_id": "message.4",
  "path": "",
  "position": 4,
  "raw": {
    "detail_template": "Failed on request of size %zu in memory context \"%s\".",
    "id": "message.4",
    "primary_template": "out of memory",
    "severity_source": "ERROR",
    "sources": [
      "src.path.4"
    ],
    "sqlstate": "53200"
  },
  "severity": "ERROR",
  "sources": [
    "src.path.4"
  ],
  "templates": [
    {
      "kind": "primary",
      "literal": "out of memory",
      "position": 0,
      "role": "",
      "template": "out of memory"
    },
    {
      "kind": "detail",
      "literal": "Failed on request of size u in memory context \" \".",
      "position": 1,
      "role": "",
      "template": "Failed on request of size %zu in memory context \"%s\"."
    }
  ]
}
messages · message.5
{
  "limits": "",
  "message_id": "message.5",
  "path": "",
  "position": 5,
  "raw": {
    "id": "message.5",
    "primary_template": "out of shared memory (%zu bytes requested)",
    "severity_source": "ERROR",
    "sources": [
      "src.path.5"
    ],
    "sqlstate": "53200"
  },
  "severity": "ERROR",
  "sources": [
    "src.path.5"
  ],
  "templates": [
    {
      "kind": "primary",
      "literal": "out of shared memory ( u bytes requested)",
      "position": 0,
      "role": "",
      "template": "out of shared memory (%zu bytes requested)"
    }
  ]
}
messages · message.6
{
  "limits": "",
  "message_id": "message.6",
  "path": "",
  "position": 6,
  "raw": {
    "hint_template": "You might need to increase \"max_locks_per_transaction\".",
    "id": "message.6",
    "primary_template": "out of shared memory",
    "severity_source": "ERROR",
    "sources": [
      "src.path.6"
    ],
    "sqlstate": "53200"
  },
  "severity": "ERROR",
  "sources": [
    "src.path.6"
  ],
  "templates": [
    {
      "kind": "primary",
      "literal": "out of shared memory",
      "position": 0,
      "role": "",
      "template": "out of shared memory"
    },
    {
      "kind": "hint",
      "literal": "You might need to increase \"max_locks_per_transaction\".",
      "position": 1,
      "role": "",
      "template": "You might need to increase \"max_locks_per_transaction\"."
    }
  ]
}
sources · src.errcodes.18.6
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/utils/errcodes.txt",
  "position": 0,
  "sha256": "6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba",
  "source_id": "src.errcodes.18.6",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/errcodes.txt#L409"
}
sources · src.path.0
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "contrib/pg_stat_statements/pg_stat_statements.c",
  "position": 1,
  "sha256": "5a732a7c5b124ba98f2e3939c2458b85757c49fdb7846276f6b96ceeb833e74b",
  "source_id": "src.path.0",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/contrib/pg_stat_statements/pg_stat_statements.c#L2346"
}
sources · src.path.1
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "contrib/pg_walinspect/pg_walinspect.c",
  "position": 2,
  "sha256": "bd6adbfd21eb9287d9e2d18ca19028d75ad00f8543256c80071e0c357e703b9e",
  "source_id": "src.path.1",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/contrib/pg_walinspect/pg_walinspect.c#L121"
}
sources · src.path.2
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/access/transam/twophase.c",
  "position": 3,
  "sha256": "52e4fc67a5c3555ca8c1f75f5e12306a93bae17ecb49fd6ef6c5136ddc0db96a",
  "source_id": "src.path.2",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/access/transam/twophase.c#L1417"
}
sources · src.path.3
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/utils/mmgr/aset.c",
  "position": 4,
  "sha256": "ae1f091f78f913a224c3659abc0e7798603dff348fe21d23d44a8789c5fd3098",
  "source_id": "src.path.3",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/mmgr/aset.c#L444"
}
sources · src.path.4
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/utils/mmgr/mcxt.c",
  "position": 5,
  "sha256": "19824d40a1b2b7f533fd7863c91117a33c0879bf776fc7fbe495f603e032344e",
  "source_id": "src.path.4",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/mmgr/mcxt.c#L1157"
}
sources · src.path.5
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/storage/ipc/shmem.c",
  "position": 6,
  "sha256": "27ee1cdd55975fbe57607d2236d117ab50d8135cca5622af6f03ccd768bb5680",
  "source_id": "src.path.5",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/storage/ipc/shmem.c#L151"
}
sources · src.path.6
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/storage/lmgr/lock.c",
  "position": 7,
  "sha256": "e7f43560bf6a8417ff46991238084b6edeb44a995b87670ed1f7fa6f1515276b",
  "source_id": "src.path.6",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/storage/lmgr/lock.c#L2957"
}
sources · src.calls.REL_18_6
{
  "commit": "",
  "docs_url": "",
  "kind": "local_artifact",
  "location": "",
  "path": "raw/calls/REL_18_6.jsonl",
  "position": 8,
  "sha256": "9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf",
  "source_id": "src.calls.REL_18_6",
  "tag": "REL_18_6",
  "url": ""
}

Source references

Full definition and evidence JSON

Definition sources

center · PostgreSQL 18 · english-manuals:f8286524248252e5312932e05cf94e94a5fb48bd72cab200e116824f095ed062

Text language: en · english-manuals:f8286524248252e5312932e05cf94e94a5fb48bd72cab200e116824f095ed062