{"schema": "pgtrue.report/1", "url": "https://pgtrue.postgres.ai/shared/brief/99b3ea63-b79a-405b-a861-091721c96cf7", "published": "2026-10-31T02:31:04Z", "publisher": "PostgresAI", "article": {"title": "How a read replica almost took down its primary database and other database tales", "url": "https://www.photoroom.com/inside-photoroom/how-a-read-replica-almost-took-down-its-primary-database", "date_published": "2026-10-26T00:00:00Z", "author": "Marek Zaremba-Pike", "publisher": "Photoroom"}, "grade": "A", "axes": [{"axis": "Factual", "summary": "A \u00b7 0 wrong of 22 checked \u00b7 0 caveats"}, {"axis": "Applicable", "summary": "A \u00b7 0 wrong of 22 checked \u00b7 0 caveats"}, {"axis": "Consistent", "summary": "A \u00b7 0 wrong of 22 checked \u00b7 0 caveats"}, {"axis": "Transparent", "summary": "A \u00b7 0 wrong of 10 checked \u00b7 0 caveats"}, {"axis": "Safe", "summary": "A \u00b7 0 wrong of 22 checked \u00b7 0 caveats"}], "findings": [{"anchor": "F1", "url": "https://pgtrue.postgres.ai/shared/brief/99b3ea63-b79a-405b-a861-091721c96cf7#F1", "claim": "\u2026limit on the WAL retained by replication slots using max_slot_wal_keep_size\u2026", "explanation": "max_slot_wal_keep_size limits slot-based WAL retention at checkpoints. KeepLogSeg caps the retention horizon. Checkpoint cleanup can invalidate slots whose WAL becomes unavailable. The setting does not impose a hard ceiling on total pg_wal disk use.", "verdict": "Accurate", "sources": [{"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/doc/src/sgml/config.sgml#L4717-L4720", "label": "REL_18_6 \u00b7 doc/src/sgml/config.sgml:4717-4720"}, {"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/access/transam/xlog.c#L8019-L8027", "label": "REL_18_6 \u00b7 src/backend/access/transam/xlog.c:8019-8027"}, {"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/access/transam/xlog.c#L7359-L7363", "label": "REL_18_6 \u00b7 src/backend/access/transam/xlog.c:7359-7363"}, {"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/doc/src/sgml/high-availability.sgml#L953-L957", "label": "REL_18_6 \u00b7 doc/src/sgml/high-availability.sgml:953-957"}, {"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/doc/src/sgml/config.sgml#L4724-L4725", "label": "REL_18_6 \u00b7 doc/src/sgml/config.sgml:4724-4725"}]}, {"anchor": "F2", "url": "https://pgtrue.postgres.ai/shared/brief/99b3ea63-b79a-405b-a861-091721c96cf7#F2", "claim": "\u2026lock_timeout bounds waiting\u2026", "explanation": "REL_18_6 documents that lock_timeout can occur only while waiting for locks (E-20). It does not bound acquired-lock duration. E-21 shows code disabling LOCK_TIMEOUT.", "verdict": "Accurate", "sources": [{"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/doc/src/sgml/config.sgml#L10308-L10309", "label": "REL_18_6 \u00b7 doc/src/sgml/config.sgml:10308-10309"}, {"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/storage/lmgr/proc.c#L1699-L1707", "label": "REL_18_6 \u00b7 src/backend/storage/lmgr/proc.c:1699-1707"}]}, {"anchor": "F3", "url": "https://pgtrue.postgres.ai/shared/brief/99b3ea63-b79a-405b-a861-091721c96cf7#F3", "claim": "Adding a foreign key takes a SHARE ROW EXCLUSIVE lock on both tables\u2026", "explanation": "ALTER TABLE ADD FOREIGN KEY requests ShareRowExclusiveLock on the referencing table. It opens the referenced table with the same mode. RowExclusiveLock conflicts with that mode.", "verdict": "Accurate", "sources": [{"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/commands/tablecmds.c#L4753-L4761", "label": "REL_18_6 \u00b7 src/backend/commands/tablecmds.c:4753-4761"}, {"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/commands/tablecmds.c#L10111-L10111", "label": "REL_18_6 \u00b7 src/backend/commands/tablecmds.c:10111-10111"}, {"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/storage/lmgr/lock.c#L74-L76", "label": "REL_18_6 \u00b7 src/backend/storage/lmgr/lock.c:74-76"}]}, {"anchor": "F4", "url": "https://pgtrue.postgres.ai/shared/brief/99b3ea63-b79a-405b-a861-091721c96cf7#F4", "claim": "\u2026writes then queued behind the migration\u2019s lock request\u2026", "explanation": "REL_18_6 checks pending incompatible lock requests before checking held locks (E-25). RowExclusiveLock conflicts with ShareRowExclusiveLock (E-24). A pending incompatible request can delay writes. These excerpts do not verify the incident's lock history.", "verdict": "Accurate", "sources": [{"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/storage/lmgr/lock.c#L74-L76", "label": "REL_18_6 \u00b7 src/backend/storage/lmgr/lock.c:74-76"}, {"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/storage/lmgr/lock.c#L1093-L1096", "label": "REL_18_6 \u00b7 src/backend/storage/lmgr/lock.c:1093-1096"}]}, {"anchor": "F5", "url": "https://pgtrue.postgres.ai/shared/brief/99b3ea63-b79a-405b-a861-091721c96cf7#F5", "claim": "\u2026but not when it is preventing transaction-ID wraparound\u2026", "explanation": "ProcSleep excludes PROC_VACUUM_FOR_WRAPAROUND workers from automatic cancellation. Ordinary blocking autovacuum can receive cancellation. The article correctly distinguishes the two cases.", "verdict": "Accurate", "sources": [{"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/storage/lmgr/proc.c#L1535-L1536", "label": "REL_18_6 \u00b7 src/backend/storage/lmgr/proc.c:1535-1536"}, {"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/doc/src/sgml/maintenance.sgml#L1024-L1027", "label": "REL_18_6 \u00b7 doc/src/sgml/maintenance.sgml:1024-1027"}]}, {"anchor": "F6", "url": "https://pgtrue.postgres.ai/shared/brief/99b3ea63-b79a-405b-a861-091721c96cf7#F6", "claim": "\u2026ACCESS EXCLUSIVE , which blocks even reads\u2026", "explanation": "AccessExclusiveLock conflicts with AccessShareLock, which ordinary SELECT acquires. PostgreSQL documents this lock for many ALTER TABLE forms.", "verdict": "Accurate", "sources": [{"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/doc/src/sgml/mvcc.sgml#L1089-L1090", "label": "REL_18_6 \u00b7 doc/src/sgml/mvcc.sgml:1089-1090"}, {"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/storage/lmgr/lock.c#L68-L69", "label": "REL_18_6 \u00b7 src/backend/storage/lmgr/lock.c:68-69"}]}, {"anchor": "F7", "url": "https://pgtrue.postgres.ai/shared/brief/99b3ea63-b79a-405b-a861-091721c96cf7#F7", "claim": "Building an index without CONCURRENTLY can block writes until it finishes\u2026", "explanation": "CREATE INDEX takes ShareLock unless it uses the concurrent path. ShareLock conflicts with writers' RowExclusiveLock. PostgreSQL documents that writers wait until an ordinary index build finishes.", "verdict": "Accurate", "sources": [{"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/storage/lmgr/lock.c#L74-L76", "label": "REL_18_6 \u00b7 src/backend/storage/lmgr/lock.c:74-76"}, {"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/commands/indexcmds.c#L681-L682", "label": "REL_18_6 \u00b7 src/backend/commands/indexcmds.c:681-682"}, {"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/doc/src/sgml/ref/create_index.sgml#L611-L612", "label": "REL_18_6 \u00b7 doc/src/sgml/ref/create_index.sgml:611-612"}]}, {"anchor": "F8", "url": "https://pgtrue.postgres.ai/shared/brief/99b3ea63-b79a-405b-a861-091721c96cf7#F8", "claim": "\u2026adding a constraint can involve validating existing rows\u2026", "explanation": "REL_18_6 documents that adding a constraint normally scans existing rows (E-33). The foreign-key condition tests skip_validation and is_enforced (E-32). The article correctly says constraint addition can involve validating existing rows.", "verdict": "Accurate", "sources": [{"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/commands/tablecmds.c#L11094-L11095", "label": "REL_18_6 \u00b7 src/backend/commands/tablecmds.c:11094-11095"}, {"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/doc/src/sgml/ref/alter_table.sgml#L478-L479", "label": "REL_18_6 \u00b7 doc/src/sgml/ref/alter_table.sgml:478-479"}]}, {"anchor": "F9", "url": "https://pgtrue.postgres.ai/shared/brief/99b3ea63-b79a-405b-a861-091721c96cf7#F9", "claim": "\u2026one should stop using a column before dropping it\u2026", "explanation": "PostgreSQL raises UNDEFINED_COLUMN when a query references a missing column. Retaining the physical column until all dependent application versions stop querying it avoids that failure.", "verdict": "Accurate", "sources": [{"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/parser/parse_relation.c#L3861-L3865", "label": "REL_18_6 \u00b7 src/backend/parser/parse_relation.c:3861-3865"}]}, {"anchor": "F10", "url": "https://pgtrue.postgres.ai/shared/brief/99b3ea63-b79a-405b-a861-091721c96cf7#F10", "claim": "\u2026the pooler\u2019s connections to PostgreSQL have their own budget\u2026", "explanation": "PgBouncer separates max_client_conn from default_pool_size. The first limits clients. The second limits server connections per user/database pair. Application pool demand does not directly equal PostgreSQL connection demand.", "verdict": "Accurate", "sources": [{"url": "https://github.com/pgbouncer/pgbouncer/blob/f03e9bf263d7ccd5d1d152a61811bf3258dd6b87/doc/config.md#L97-L99", "label": "pgbouncer@pgbouncer_1_26_1 \u00b7 doc/config.md:97-99"}, {"url": "https://github.com/pgbouncer/pgbouncer/blob/f03e9bf263d7ccd5d1d152a61811bf3258dd6b87/doc/config.md#L124-L126", "label": "pgbouncer@pgbouncer_1_26_1 \u00b7 doc/config.md:124-126"}]}, {"anchor": "F11", "url": "https://pgtrue.postgres.ai/shared/brief/99b3ea63-b79a-405b-a861-091721c96cf7#F11", "claim": "A plan checked with EXPLAIN against representative data\u2026", "explanation": "EXPLAIN displays the chosen plan. PostgreSQL warns against extrapolating plans from tiny tables to large tables. These facts support inspecting generated SQL against representative data.", "verdict": "Accurate", "sources": [{"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/doc/src/sgml/perform.sgml#L34-L35", "label": "REL_18_6 \u00b7 doc/src/sgml/perform.sgml:34-35"}, {"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/doc/src/sgml/perform.sgml#L1125-L1127", "label": "REL_18_6 \u00b7 doc/src/sgml/perform.sgml:1125-1127"}]}, {"anchor": "F12", "url": "https://pgtrue.postgres.ai/shared/brief/99b3ea63-b79a-405b-a861-091721c96cf7#F12", "claim": "\u2026an OR does not imply a full-table scan in every PostgreSQL query\u2026", "explanation": "PostgreSQL generates BitmapOrPaths for suitable OR clauses. It can combine multiple index scans. An OR expression alone does not require a sequential scan.", "verdict": "Accurate", "sources": [{"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/optimizer/path/indxpath.c#L318-L321", "label": "REL_18_6 \u00b7 src/backend/optimizer/path/indxpath.c:318-321"}, {"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/doc/src/sgml/indices.sgml#L667-L668", "label": "REL_18_6 \u00b7 doc/src/sgml/indices.sgml:667-668"}]}, {"anchor": "F13", "url": "https://pgtrue.postgres.ai/shared/brief/99b3ea63-b79a-405b-a861-091721c96cf7#F13", "claim": "\u2026ordering and data distribution can make an ordinary-looking query expensive\u2026", "explanation": "PostgreSQL considers index scans and explicit sorts for ORDER BY. cost_index uses estimated index correlation when calculating heap I/O costs. Ordering and data distribution can change plan costs.", "verdict": "Accurate", "sources": [{"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/doc/src/sgml/indices.sgml#L577-L580", "label": "REL_18_6 \u00b7 doc/src/sgml/indices.sgml:577-580"}, {"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/optimizer/path/costsize.c#L795-L797", "label": "REL_18_6 \u00b7 src/backend/optimizer/path/costsize.c:795-797"}]}, {"anchor": "F14", "url": "https://pgtrue.postgres.ai/shared/brief/99b3ea63-b79a-405b-a861-091721c96cf7#F14", "claim": "\u2026audit timeouts across the whole system, not one setting at a time\u2026", "explanation": "PgBouncer recommends setting its query_timeout above PostgreSQL statement_timeout. PostgreSQL also distinguishes statement_timeout from lock_timeout. These settings act on different stages and require coordinated values.", "verdict": "Accurate", "sources": [{"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/doc/src/sgml/config.sgml#L10308-L10309", "label": "REL_18_6 \u00b7 doc/src/sgml/config.sgml:10308-10309"}, {"url": "https://github.com/pgbouncer/pgbouncer/blob/f03e9bf263d7ccd5d1d152a61811bf3258dd6b87/doc/config.md#L1079-L1083", "label": "pgbouncer@pgbouncer_1_26_1 \u00b7 doc/config.md:1079-1083"}]}, {"anchor": "F15", "url": "https://pgtrue.postgres.ai/shared/brief/99b3ea63-b79a-405b-a861-091721c96cf7#F15", "claim": "Small batches help\u2026", "explanation": "PostgreSQL documents replica lag and lock contention from large updates. It recommends smaller batches for those conditions. Locks normally remain until transaction end. Separate bounded transactions address that lock duration.", "verdict": "Accurate", "sources": [{"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/doc/src/sgml/ref/update.sgml#L481-L484", "label": "REL_18_6 \u00b7 doc/src/sgml/ref/update.sgml:481-484"}, {"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/doc/src/sgml/mvcc.sgml#L1107-L1107", "label": "REL_18_6 \u00b7 doc/src/sgml/mvcc.sgml:1107-1107"}]}, {"anchor": "F16", "url": "https://pgtrue.postgres.ai/shared/brief/99b3ea63-b79a-405b-a861-091721c96cf7#F16", "claim": "\u2026it is not an instantaneous ceiling on disk use.", "title": "max_slot_wal_keep_size is a checkpoint limit", "explanation": "REL_18_6 documents the retention limit at checkpoint time in doc/src/sgml/config.sgml:4717. Removing required WAL can prevent a standby from continuing replication. The article states both qualifications.", "verdict": "Accurate", "sources": [{"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/doc/src/sgml/config.sgml#L4717-L4720", "label": "REL_18_6 \u00b7 doc/src/sgml/config.sgml:4717-4720"}, {"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/doc/src/sgml/config.sgml#L4723-L4725", "label": "REL_18_6 \u00b7 doc/src/sgml/config.sgml:4723-4725"}]}, {"anchor": "F17", "url": "https://pgtrue.postgres.ai/shared/brief/99b3ea63-b79a-405b-a861-091721c96cf7#F17", "claim": "\u2026lock_timeout bounds waiting, not how long an acquired lock is held\u2026", "title": "lock_timeout limits lock acquisition waits", "explanation": "lock_timeout does not limit how long a transaction holds an acquired lock. REL_18_6 states this distinction in doc/src/sgml/config.sgml:10308.", "verdict": "Accurate", "sources": [{"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/doc/src/sgml/config.sgml#L10308-L10309", "label": "REL_18_6 \u00b7 doc/src/sgml/config.sgml:10308-10309"}]}, {"anchor": "F19", "url": "https://pgtrue.postgres.ai/shared/brief/99b3ea63-b79a-405b-a861-091721c96cf7#F19", "claim": "\u2026an OR does not imply a full-table scan in every PostgreSQL query.", "title": "OR conditions can use indexes", "explanation": "OR does not force a sequential scan. REL_18_6 doc/src/sgml/indices.sgml:665 documents combining multiple index scans for OR conditions.", "verdict": "Accurate", "sources": [{"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/doc/src/sgml/indices.sgml#L665-L668", "label": "REL_18_6 \u00b7 doc/src/sgml/indices.sgml:665-668"}]}, {"anchor": "F20", "url": "https://pgtrue.postgres.ai/shared/brief/99b3ea63-b79a-405b-a861-091721c96cf7#F20", "claim": "\u2026PgBouncer queues\u2026", "title": "PgBouncer exposes waiting clients", "explanation": "PgBouncer 1.26.1 exposes cl_waiting through SHOW POOLS. doc/usage.md:430 defines clients awaiting a server connection after submitting queries.", "verdict": "Accurate", "sources": [{"url": "https://github.com/pgbouncer/pgbouncer/blob/f03e9bf263d7ccd5d1d152a61811bf3258dd6b87/doc/usage.md#L430-L431", "label": "pgbouncer@pgbouncer_1_26_1 \u00b7 doc/usage.md:430-431"}]}, {"anchor": "F21", "url": "https://pgtrue.postgres.ai/shared/brief/99b3ea63-b79a-405b-a861-091721c96cf7#F21", "claim": "Counting queries on a tiny test database didn\u2019t tell us what those queries would cost in production.", "title": "Small-table tests cannot establish production query costs", "explanation": "PostgreSQL can choose different plans as table size changes. REL_18_6 doc/src/sgml/perform.sgml:1127 warns against extrapolating small-table results. A one-page table usually favors a sequential scan.", "verdict": "Accurate", "sources": [{"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/doc/src/sgml/perform.sgml#L1127-L1131", "label": "REL_18_6 \u00b7 doc/src/sgml/perform.sgml:1127-1131"}]}, {"anchor": "F22", "url": "https://pgtrue.postgres.ai/shared/brief/99b3ea63-b79a-405b-a861-091721c96cf7#F22", "claim": "\u2026it can block production before changing anything.", "title": "A waiting migration can block conflicting requests", "explanation": "A pending lock request can block later conflicting requests before its transaction changes data. REL_18_6 src/backend/storage/lmgr/lock.c:1093 checks conflicts against waiting requests.", "verdict": "Accurate", "sources": [{"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/storage/lmgr/lock.c#L1086-L1104", "label": "REL_18_6 \u00b7 src/backend/storage/lmgr/lock.c:1086-1104"}]}, {"anchor": "F23", "url": "https://pgtrue.postgres.ai/shared/brief/99b3ea63-b79a-405b-a861-091721c96cf7#F23", "claim": "At roughly twenty entitlement checks per second, that demanded about twenty-six CPU-seconds of work every second\u2026", "title": "The stated lookup workload requires 26 CPU-seconds per second", "explanation": "The CPU calculation is correct: 26 CPU-seconds per second (derived: 1.3 CPU-seconds per lookup \u00d7 20 lookups per second). This subtotal excludes other application work. It does not independently verify either input.", "verdict": "Accurate", "sources": []}]}