Rework amcheck: 3 reports (c1/c2/c3), include system indexes, add GIN#90
Merged
Rework amcheck: 3 reports (c1/c2/c3), include system indexes, add GIN#90
Conversation
… support - c1 (quick): bt_index_check + gin_index_check (PG18+) + verify_heapam (PG14+) All AccessShareLock — safe for production primaries. - c2 (parent): bt_index_parent_check with rootdescend + checkunique (PG14+) ShareLock — detects glibc/collation corruption. Best on standbys. - c3 (full): bt_index_parent_check with heapallindexed + verify_heapam ShareLock + full heap scan — proves every tuple is indexed. Slow. - All three now check system catalog indexes (pg_catalog, pg_toast) - Big fat warnings on c2 and c3 about ShareLock blocking writes - Tested on PG13 (158 btree indexes) and PG17 (168 btree indexes, 73 tables)
| @@ -27,10 +29,15 @@ begin | |||
|
|
|||
| select current_setting('server_version_num')::int into pg_version; | |||
There was a problem hiding this comment.
On PG10 and earlier this hits bt_index_parent_check(..., heapallindexed := true) (and may fail due to signature/availability). Might be better to explicitly skip c3 on < PG11 with a clear message.
Suggested change
| select current_setting('server_version_num')::int into pg_version; | |
| select current_setting('server_version_num')::int into pg_version; | |
| if pg_version < 110000 then | |
| raise notice ''; | |
| raise notice 'ℹ️ heapallindexed checks require PostgreSQL 11+. Skipped.'; | |
| return; | |
| end if; |
| |----|--------| | ||
| | c1 | B-tree index integrity check (amcheck, non-blocking) | | ||
| | c2 | Full B-tree + heap integrity check (amcheck, takes locks — use on standby!) | | ||
| | c1 | Quick: btree + GIN (PG18) + heap (PG14) check — safe for production (AccessShareLock) | |
There was a problem hiding this comment.
Minor doc nit: this reads like it’s PG18/PG14 only, but the scripts say PG18+ / PG14+.
Suggested change
| | c1 | Quick: btree + GIN (PG18) + heap (PG14) check — safe for production (AccessShareLock) | | |
| | c1 | Quick: btree + GIN (PG18+) + heap (PG14+) check — safe for production (AccessShareLock) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #89. Reworks the corruption checks based on feedback.
Changes
3 reports instead of 2 — clearer separation by use case:
System indexes included
All three reports now check
pg_catalogandpg_toastindexes too. System catalog corruption is arguably more critical than user table corruption.GIN support (PG18+)
c1 checks GIN indexes via
gin_index_check()on PostgreSQL 18+.Big fat warnings
c2 and c3 emit prominent warnings about ShareLock blocking writes.
Testing