{"schema": "pgtrue.report/1", "url": "https://pgtrue.postgres.ai/shared/brief/d44845a1-484a-4f98-9401-6eb9d4594e1c", "published": "2026-10-19T06:39:00Z", "publisher": "PostgresAI", "article": {"title": "PostgreSQL subtransactions considered harmful", "url": "https://postgres.ai/blog/20210831-postgresql-subtransactions-considered-harmful", "date_published": "2021-08-31T12:06:00Z", "author": "Nikolay Samokhvalov", "publisher": "postgres.ai"}, "grade": "B", "axes": [{"axis": "Factual", "summary": "B+ \u00b7 1 wrong of 21 checked \u00b7 0 caveats"}, {"axis": "Applicable", "summary": "A \u00b7 0 wrong of 12 checked \u00b7 0 caveats"}, {"axis": "Consistent", "summary": "A \u00b7 0 wrong of 21 checked \u00b7 0 caveats"}, {"axis": "Transparent", "summary": "D \u00b7 0 wrong of 10 checked \u00b7 0 caveats \u00b7 reproducibility: D (source not linked)"}, {"axis": "Safe", "summary": "A \u00b7 0 wrong of 11 checked \u00b7 0 caveats"}], "findings": [{"anchor": "F1", "url": "https://pgtrue.postgres.ai/shared/brief/d44845a1-484a-4f98-9401-6eb9d4594e1c#F1", "claim": "\u2026no degradation happens when passing the threshold defined by PGPROC_MAX_CACHED_SUBXIDS\u2026", "title": "RELEASE SAVEPOINT does not prevent the 64-XID cache overflow", "explanation": "Released children remain non-aborted children until the top-level transaction ends. xact.c:4814-4816 retains their XIDs, and varsup.c:227-234 sets overflow on the next uncached child. A nesting depth of 1 can exceed 64 child XIDs. Relying on RELEASE can waste mitigation work.", "verdict": "Misleading", "sources": [{"url": "https://github.com/postgres/postgres/blob/de835071fda945fb5e40340d3ea8dd2ca13e725c/src/include/storage/proc.h#L25-L36", "label": "REL_12_8 \u00b7 src/include/storage/proc.h:25-36"}, {"url": "https://github.com/postgres/postgres/blob/de835071fda945fb5e40340d3ea8dd2ca13e725c/src/backend/access/transam/varsup.c#L224-L234", "label": "REL_12_8 \u00b7 src/backend/access/transam/varsup.c:224-234"}, {"url": "https://github.com/postgres/postgres/blob/de835071fda945fb5e40340d3ea8dd2ca13e725c/src/backend/access/transam/xact.c#L1517-L1552", "label": "REL_12_8 \u00b7 src/backend/access/transam/xact.c:1517-1552"}, {"url": "https://github.com/postgres/postgres/blob/de835071fda945fb5e40340d3ea8dd2ca13e725c/src/include/storage/proc.h#L25-L36", "label": "REL_12_8 \u00b7 src/include/storage/proc.h:25-36"}, {"url": "https://github.com/postgres/postgres/blob/de835071fda945fb5e40340d3ea8dd2ca13e725c/src/backend/access/transam/xact.c#L4814-L4817", "label": "REL_12_8 \u00b7 src/backend/access/transam/xact.c:4814-4817"}]}, {"anchor": "F2", "url": "https://pgtrue.postgres.ai/shared/brief/d44845a1-484a-4f98-9401-6eb9d4594e1c#F2", "claim": "\u2026all of them get their own XID assigned\u2026", "title": "XID assignment also assigns unidentified ancestors", "explanation": "AssignTransactionId assigns XIDs to ancestors before assigning the child. PostgreSQL 12.8 documents this invariant in xact.c:548-552.", "verdict": "Accurate", "sources": [{"url": "https://github.com/postgres/postgres/blob/de835071fda945fb5e40340d3ea8dd2ca13e725c/src/backend/access/transam/xact.c#L548-L552", "label": "REL_12_8 \u00b7 src/backend/access/transam/xact.c:548-552"}]}, {"anchor": "F3", "url": "https://pgtrue.postgres.ai/shared/brief/d44845a1-484a-4f98-9401-6eb9d4594e1c#F3", "claim": "\u2026BEGIN / EXCEPTION WHEN .. / END blocks in PL/pgSQL code\u2026", "title": "PL/pgSQL exception blocks create subtransactions", "explanation": "pl_exec.c:1683-1707 executes an exception block inside an internal subtransaction. PostgreSQL 12.8 documents the same behavior in plpgsql.sgml:310-313.", "verdict": "Accurate", "sources": [{"url": "https://github.com/postgres/postgres/blob/de835071fda945fb5e40340d3ea8dd2ca13e725c/doc/src/sgml/plpgsql.sgml#L305-L314", "label": "REL_12_8 \u00b7 doc/src/sgml/plpgsql.sgml:305-314"}, {"url": "https://github.com/postgres/postgres/blob/de835071fda945fb5e40340d3ea8dd2ca13e725c/src/pl/plpgsql/src/pl_exec.c#L1683-L1708", "label": "REL_12_8 \u00b7 src/pl/plpgsql/src/pl_exec.c:1683-1708"}]}, {"anchor": "F4", "url": "https://pgtrue.postgres.ai/shared/brief/d44845a1-484a-4f98-9401-6eb9d4594e1c#F4", "claim": "\u2026plpy.subtransaction() in PL/Python code\u2026", "title": "PL/Python supports explicit subtransaction contexts", "explanation": "plpython.sgml:1294-1298 documents plpy.subtransaction(). Its context-entry implementation calls BeginInternalSubTransaction in plpy_subxactobject.c:117.", "verdict": "Accurate", "sources": [{"url": "https://github.com/postgres/postgres/blob/de835071fda945fb5e40340d3ea8dd2ca13e725c/src/pl/plpython/plpy_subxactobject.c#L108-L120", "label": "REL_12_8 \u00b7 src/pl/plpython/plpy_subxactobject.c:108-120"}, {"url": "https://github.com/postgres/postgres/blob/de835071fda945fb5e40340d3ea8dd2ca13e725c/doc/src/sgml/plpython.sgml#L1294-L1299", "label": "REL_12_8 \u00b7 doc/src/sgml/plpython.sgml:1294-1299"}]}, {"anchor": "F5", "url": "https://pgtrue.postgres.ai/shared/brief/d44845a1-484a-4f98-9401-6eb9d4594e1c#F5", "claim": "\u2026look up their top-level parent in pg_subtrans\u2026", "title": "The revised standby lookup conditions match PostgreSQL 12.8", "explanation": "snapmgr.c:2253-2258 returns before parent lookup for XIDs outside [xmin, xmax). The recovery branch calls SubTransGetTopmostTransaction when suboverflowed is set. That branch accepts both top-level and child XIDs.", "verdict": "Accurate", "sources": [{"url": "https://github.com/postgres/postgres/blob/de835071fda945fb5e40340d3ea8dd2ca13e725c/src/backend/utils/time/snapmgr.c#L2253-L2258", "label": "REL_12_8 \u00b7 src/backend/utils/time/snapmgr.c:2253-2258"}, {"url": "https://github.com/postgres/postgres/blob/de835071fda945fb5e40340d3ea8dd2ca13e725c/src/backend/utils/time/snapmgr.c#L2308-L2338", "label": "REL_12_8 \u00b7 src/backend/utils/time/snapmgr.c:2308-2338"}]}, {"anchor": "F6", "url": "https://pgtrue.postgres.ai/shared/brief/d44845a1-484a-4f98-9401-6eb9d4594e1c#F6", "claim": "\u2026NUM_SUBTRANS_BUFFERS 32\u2026", "title": "The default Subtrans cache contains 32 pages", "explanation": "PostgreSQL 12.8 defines 32 Subtrans buffers and 4-byte TransactionIds. Default BLCKSZ is 8 KiB. The cache covers 65,536 XID positions (derived: 32 \u00d7 8,192 / 4). subtrans.c:52-55 maps global XID positions to pages and entries.", "verdict": "Accurate", "sources": [{"url": "https://github.com/postgres/postgres/blob/de835071fda945fb5e40340d3ea8dd2ca13e725c/src/include/access/subtrans.h#L13-L16", "label": "REL_12_8 \u00b7 src/include/access/subtrans.h:13-16"}, {"url": "https://github.com/postgres/postgres/blob/de835071fda945fb5e40340d3ea8dd2ca13e725c/src/backend/access/transam/subtrans.c#L50-L55", "label": "REL_12_8 \u00b7 src/backend/access/transam/subtrans.c:50-55"}, {"url": "https://github.com/postgres/postgres/blob/de835071fda945fb5e40340d3ea8dd2ca13e725c/configure.in#L250-L258", "label": "REL_12_8 \u00b7 configure.in:250-258"}, {"url": "https://github.com/postgres/postgres/blob/de835071fda945fb5e40340d3ea8dd2ca13e725c/src/include/c.h#L519-L519", "label": "REL_12_8 \u00b7 src/include/c.h:519-519"}, {"url": "https://github.com/postgres/postgres/blob/de835071fda945fb5e40340d3ea8dd2ca13e725c/src/backend/access/transam/subtrans.c#L318-L351", "label": "REL_12_8 \u00b7 src/backend/access/transam/subtrans.c:318-351"}, {"url": "https://github.com/postgres/postgres/blob/de835071fda945fb5e40340d3ea8dd2ca13e725c/src/backend/access/transam/slru.c#L1-L30", "label": "REL_12_8 \u00b7 src/backend/access/transam/slru.c:1-30"}]}, {"anchor": "F7", "url": "https://pgtrue.postgres.ai/shared/brief/d44845a1-484a-4f98-9401-6eb9d4594e1c#F7", "claim": "\u2026entries are immutable\u2026", "title": "MultiXact expansion creates a replacement identifier", "explanation": "multixact.c:424-426 states that expansion creates another MultiXact instead of changing existing membership. The implementation copies still-relevant members before adding the new member.", "verdict": "Accurate", "sources": [{"url": "https://github.com/postgres/postgres/blob/de835071fda945fb5e40340d3ea8dd2ca13e725c/src/backend/access/transam/multixact.c#L418-L426", "label": "REL_12_8 \u00b7 src/backend/access/transam/multixact.c:418-426"}]}, {"anchor": "F8", "url": "https://pgtrue.postgres.ai/shared/brief/d44845a1-484a-4f98-9401-6eb9d4594e1c#F8", "claim": "\u2026using periodical sampling of pg_stat_activity\u2026", "title": "pg_stat_activity exposes current wait events for sampling", "explanation": "PostgreSQL 12.8 exposes wait_event_type and wait_event through pg_stat_activity. monitoring.sgml:769 identifies wait_event as the current wait, or NULL. External sampling must retain historical observations.", "verdict": "Accurate", "sources": [{"url": "https://github.com/postgres/postgres/blob/de835071fda945fb5e40340d3ea8dd2ca13e725c/src/backend/catalog/system_views.sql#L732-L756", "label": "REL_12_8 \u00b7 src/backend/catalog/system_views.sql:732-756"}, {"url": "https://github.com/postgres/postgres/blob/de835071fda945fb5e40340d3ea8dd2ca13e725c/doc/src/sgml/monitoring.sgml#L767-L776", "label": "REL_12_8 \u00b7 doc/src/sgml/monitoring.sgml:767-776"}]}, {"anchor": "F9", "url": "https://pgtrue.postgres.ai/shared/brief/d44845a1-484a-4f98-9401-6eb9d4594e1c#F9", "claim": "\u2026pg_sleep_for ( '5 minutes' )\u2026", "title": "The sleep-and-watch recipe creates the described transaction cadence", "explanation": "pg_sleep_for accepts an interval and sleeps for that interval. txid_current assigns a top-level XID when needed. psql's documented watch interval waits between executions. The article's 300-second interval adds a five-minute break after each five-minute query.", "verdict": "Accurate", "sources": [{"url": "https://github.com/postgres/postgres/blob/de835071fda945fb5e40340d3ea8dd2ca13e725c/src/include/catalog/pg_proc.dat#L6085-L6088", "label": "REL_12_8 \u00b7 src/include/catalog/pg_proc.dat:6085-6088"}, {"url": "https://github.com/postgres/postgres/blob/de835071fda945fb5e40340d3ea8dd2ca13e725c/doc/src/sgml/ref/psql-ref.sgml#L3245-L3257", "label": "REL_12_8 \u00b7 doc/src/sgml/ref/psql-ref.sgml:3245-3257"}, {"url": "https://github.com/postgres/postgres/blob/de835071fda945fb5e40340d3ea8dd2ca13e725c/doc/src/sgml/func.sgml#L19523-L19533", "label": "REL_12_8 \u00b7 doc/src/sgml/func.sgml:19523-19533"}]}, {"anchor": "F10", "url": "https://pgtrue.postgres.ai/shared/brief/d44845a1-484a-4f98-9401-6eb9d4594e1c#F10", "claim": "\u2026statement_timeout\u2026", "title": "statement_timeout can cancel statements slowed by contention", "explanation": "PostgreSQL 12.8 aborts statements exceeding a positive statement_timeout. postgres.c:4716-4721 arms the timer only when the setting exceeds 0. The default 0 disables this timeout.", "verdict": "Accurate", "sources": [{"url": "https://github.com/postgres/postgres/blob/de835071fda945fb5e40340d3ea8dd2ca13e725c/doc/src/sgml/config.sgml#L7888-L7918", "label": "REL_12_8 \u00b7 doc/src/sgml/config.sgml:7888-7918"}, {"url": "https://github.com/postgres/postgres/blob/de835071fda945fb5e40340d3ea8dd2ca13e725c/src/backend/tcop/postgres.c#L4704-L4727", "label": "REL_12_8 \u00b7 src/backend/tcop/postgres.c:4704-4727"}]}, {"anchor": "F11", "url": "https://pgtrue.postgres.ai/shared/brief/d44845a1-484a-4f98-9401-6eb9d4594e1c#F11", "claim": "\u2026use txid_current() in Postgres 12 or older\u2026", "title": "The transaction-ID example provides the PostgreSQL 12 fallback", "explanation": "PostgreSQL 12.8 documents txid_current(), including its XID-allocation behavior. PostgreSQL 13.0 defines pg_current_xact_id in pg_proc.dat:9579-9582. The article distinguishes these versions.", "verdict": "Accurate", "sources": [{"url": "https://github.com/postgres/postgres/blob/29be9983a64c011eac0b9ee29895cce71e15ea77/src/include/catalog/pg_proc.dat#L9579-L9582", "label": "REL_13_0 \u00b7 src/include/catalog/pg_proc.dat:9579-9582"}, {"url": "https://github.com/postgres/postgres/blob/de835071fda945fb5e40340d3ea8dd2ca13e725c/doc/src/sgml/func.sgml#L19523-L19533", "label": "REL_12_8 \u00b7 doc/src/sgml/func.sgml:19523-19533"}]}, {"anchor": "F12", "url": "https://pgtrue.postgres.ai/shared/brief/d44845a1-484a-4f98-9401-6eb9d4594e1c#F12", "claim": "\u2026if PostgreSQL version is 13 or newer\u2026", "title": "PostgreSQL 13 provides pg_stat_slru block counters", "explanation": "PostgreSQL 13.0 defines pg_stat_slru in system_views.sql:793 onward. The view includes each SLRU's name, block hits, block reads, and block writes.", "verdict": "Accurate", "sources": [{"url": "https://github.com/postgres/postgres/blob/29be9983a64c011eac0b9ee29895cce71e15ea77/src/backend/catalog/system_views.sql#L793-L799", "label": "REL_13_0 \u00b7 src/backend/catalog/system_views.sql:793-799"}]}, {"anchor": "F14", "url": "https://pgtrue.postgres.ai/shared/brief/d44845a1-484a-4f98-9401-6eb9d4594e1c#F14", "claim": "This feature allows users to partially rollback a transaction\u2026", "explanation": "PostgreSQL 18 documentation confirms partial rollback through ROLLBACK TO. It preserves work preceding the savepoint. This citation verifies current documentation, not PostgreSQL 12.8 documentation.", "verdict": "Accurate", "sources": [{"url": "https://www.postgresql.org/docs/current/sql-savepoint.html", "label": "https://www.postgresql.org/docs/current/sql-savepoint.html"}]}, {"anchor": "F15", "url": "https://pgtrue.postgres.ai/shared/brief/d44845a1-484a-4f98-9401-6eb9d4594e1c#F15", "claim": "\u2026ROLLBACK [ WORK | TRANSACTION ] TO [ SAVEPOINT ] savepoint_name\u2026", "explanation": "PostgreSQL 18 documentation permits ROLLBACK TO savepoint_name without SAVEPOINT. The cited synopsis confirms current syntax. It does not independently verify the PostgreSQL 12.8 syntax.", "verdict": "Accurate", "sources": [{"url": "https://www.postgresql.org/docs/current/sql-rollback-to.html", "label": "https://www.postgresql.org/docs/current/sql-rollback-to.html"}]}, {"anchor": "F16", "url": "https://pgtrue.postgres.ai/shared/brief/d44845a1-484a-4f98-9401-6eb9d4594e1c#F16", "claim": "\u2026RELEASE [ SAVEPOINT ] savepoint_name\u2026", "explanation": "PostgreSQL 18 documentation permits RELEASE savepoint_name and preserves changes while removing the savepoints. This verifies the current documented behavior. The cited page does not independently establish PostgreSQL 12.8 behavior.", "verdict": "Accurate", "sources": [{"url": "https://www.postgresql.org/docs/current/sql-release-savepoint.html", "label": "https://www.postgresql.org/docs/current/sql-release-savepoint.html"}]}, {"anchor": "F17", "url": "https://pgtrue.postgres.ai/shared/brief/d44845a1-484a-4f98-9401-6eb9d4594e1c#F17", "claim": "\u2026Sentry , Mailchimp\u2026", "title": "Sentry and Mailchimp documented XID wraparound outages", "explanation": "Sentry documented its 2015 XID outage. Mailchimp documented Mandrill entering safety shutdown on February 4, 2019. Both references support the article's wraparound examples.", "verdict": "Accurate", "sources": [{"url": "https://blog.sentry.io/transaction-id-wraparound-in-postgres/", "label": "https://blog.sentry.io/transaction-id-wraparound-in-postgres/"}, {"url": "https://mailchimp.com/what-we-learned-from-the-recent-mandrill-outage/", "label": "https://mailchimp.com/what-we-learned-from-the-recent-mandrill-outage/"}]}, {"anchor": "F18", "url": "https://pgtrue.postgres.ai/shared/brief/d44845a1-484a-4f98-9401-6eb9d4594e1c#F18", "claim": "\u2026it uses subtransactions by default\u2026", "title": "Django creates savepoints for nested atomic blocks", "explanation": "Django 3.2 creates a savepoint when entering an inner atomic block. The article's nested transaction.atomic example matches that documented default.", "verdict": "Accurate", "sources": [{"url": "https://docs.djangoproject.com/en/3.2/topics/db/transactions/", "label": "https://docs.djangoproject.com/en/3.2/topics/db/transactions/"}]}, {"anchor": "F20", "url": "https://pgtrue.postgres.ai/shared/brief/d44845a1-484a-4f98-9401-6eb9d4594e1c#F20", "claim": "\u2026pg_current_xact_id -------------------- 1549100656\u2026", "explanation": "The displayed XID advances by 4 (derived: 1549100660 \u2212 1549100656). E-59 and E-60 establish this arithmetic. They do not verify tuple headers or execution.", "verdict": "Accurate", "sources": []}, {"anchor": "F21", "url": "https://pgtrue.postgres.ai/shared/brief/d44845a1-484a-4f98-9401-6eb9d4594e1c#F21", "claim": "\u20261000 writing transactions per second\u2026", "title": "The corrected XID rate includes top-level transactions", "explanation": "The workload consumes 11,000 XIDs per second (derived: 1,000 \u00d7 11). The total includes 1,000 top-level XIDs and 10,000 subtransaction XIDs.", "verdict": "Accurate", "sources": []}, {"anchor": "F22", "url": "https://pgtrue.postgres.ai/shared/brief/d44845a1-484a-4f98-9401-6eb9d4594e1c#F22", "claim": "\u202632 * 8 * 1024 / 4 = 65536\u2026", "explanation": "Assuming 32 pages of 8 KiB and 4 bytes per entry, capacity is 65,536 entries across 256 KiB. Each page holds 2,048 entries. This verifies the stated arithmetic, not implementation constants or occupancy.", "verdict": "Accurate", "sources": []}, {"anchor": "F23", "url": "https://pgtrue.postgres.ai/shared/brief/d44845a1-484a-4f98-9401-6eb9d4594e1c#F23", "claim": "\u2026TPS went down ~10.5x during 5 minutes\u2026", "title": "The corrected throughput ratio is 10.5", "explanation": "The stated throughput falls by a factor of 10.5 (derived: 210,000 / 20,000). This verifies the calculation. It does not verify either measurement or the five-minute duration.", "verdict": "Accurate", "sources": []}]}