Skip to content

Commit eb5f07c

Browse files
committed
Update amcheck warnings: recommend clones over standbys
Clones (e.g., restored from backup) are the ideal target for heavy corruption checks — no replication lag concerns, no risk to production, and you verify backup integrity at the same time.
1 parent 2bd4318 commit eb5f07c

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ Then connect to any Postgres server via psql and type `:dba` to open the interac
4747
| ID | Report |
4848
|----|--------|
4949
| c1 | Quick: btree + GIN (PG18) + heap (PG14) check — safe for production (AccessShareLock) |
50-
| c2 | Parent: btree parent-child check — detects glibc/collation corruption (⚠️ ShareLock) |
51-
| c3 | Full: heapallindexed + parent + heap — proves every tuple is indexed (⚠️⚠️ slow + ShareLock) |
50+
| c2 | Parent: btree parent-child check — detects glibc/collation corruption (⚠️ ShareLock — use on clones) |
51+
| c3 | Full: heapallindexed + parent + heap — proves every tuple is indexed (⚠️⚠️ slow + ShareLock — use on clones) |
5252

5353
### Memory
5454
| ID | Report |

sql/c2_amcheck_parent.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
-- Corruption: B-tree parent check — detects collation/glibc corruption. ⚠️ ShareLock!
1+
-- Corruption: B-tree parent check — detects glibc/collation corruption (⚠️ ShareLock, use on clones)
22
-- Requires: CREATE EXTENSION amcheck
33
-- ⚠️ Takes ShareLock on each index — blocks writes while checking!
4-
-- ⚠️ Best used on STANDBYS or during maintenance windows.
4+
-- ⚠️ Best used on clones (e.g., restored from backup) or standbys.
55
--
66
-- Uses bt_index_parent_check() which verifies parent-child key ordering.
77
-- This is the most reliable way to detect corruption caused by glibc/ICU
@@ -27,7 +27,7 @@ begin
2727

2828
raise warning '';
2929
raise warning '⚠️ WARNING: This check takes ShareLock on each index — blocks writes!';
30-
raise warning '⚠️ Recommended: run on a STANDBY or during a maintenance window.';
30+
raise warning '⚠️ Recommended: run on a clone (e.g., restored from backup), standby, or during maintenance.';
3131
raise warning '';
3232
raise notice '=== B-tree parent check (bt_index_parent_check, ShareLock) ===';
3333
raise notice 'Detects: collation/glibc corruption, parent-child inconsistency, sibling pointer errors';

sql/c3_amcheck_full.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
-- Corruption: FULL check — heapallindexed + parent + heap. ⚠️⚠️ SLOW + ShareLock!
1+
-- Corruption: FULL check — heapallindexed + parent + heap (⚠️⚠️ SLOW + ShareLock, use on clones)
22
-- Requires: CREATE EXTENSION amcheck
33
-- ⚠️⚠️ HEAVY: Takes ShareLock AND scans entire heap for each index!
4-
-- ⚠️⚠️ This WILL be slow on large databases. Use on STANDBYS only.
4+
-- ⚠️⚠️ This WILL be slow on large databases. Use on clones (e.g., restored from backup).
55
--
66
-- bt_index_parent_check with heapallindexed=true: verifies that every single
77
-- heap tuple has a corresponding index entry. Catches silent data loss where
@@ -32,7 +32,7 @@ begin
3232
raise warning '';
3333
raise warning '⚠️⚠️ WARNING: This is the HEAVIEST corruption check!';
3434
raise warning '⚠️⚠️ Takes ShareLock on each index (blocks writes) AND scans entire heap.';
35-
raise warning '⚠️⚠️ On large databases this can take HOURS. Use on standbys only.';
35+
raise warning '⚠️⚠️ On large databases this can take HOURS. Use on clones (e.g., restored from backup).';
3636
raise warning '';
3737

3838
-- === Full B-tree check ===

start.psql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
\echo ' b4 – B-tree indexes bloat (requires pgstattuple; expensive)'
1212
\echo ' b5 – Tables and columns without stats (so bloat cannot be estimated)'
1313
\echo ' c1 – Corruption: quick check — btree, GIN (PG18+), heap (PG14+). Safe for production.'
14-
\echo ' c2 – Corruption: B-tree parent check — detects collation/glibc corruption. ⚠️ ShareLock!'
15-
\echo ' c3 – Corruption: FULL check — heapallindexed + parent + heap. ⚠️⚠️ SLOW + ShareLock!'
14+
\echo ' c2 – Corruption: B-tree parent check — detects glibc/collation corruption (⚠️ ShareLock, use on clones)'
15+
\echo ' c3 – Corruption: FULL check — heapallindexed + parent + heap (⚠️⚠️ SLOW + ShareLock, use on clones)'
1616
\echo ' e1 – Extensions installed in current database'
1717
\echo ' i1 – Unused and rarely used indexes'
1818
\echo ' i2 – Redundant indexes'

0 commit comments

Comments
 (0)