Skip to content

Commit 20fbb71

Browse files
Add contrib/amcheck debug message.
Add a DEBUG1 message indicating that verification of the index structure is underway. Also reduce the severity level of the existing "tree level" debug message to DEBUG1. It should never have been made DEBUG2. Any B-Tree index with more than a couple of levels will generally also have so many pages that the per-page DEBUG2 messages will become completely unmanageable. In passing, add a new "Tip" to the docs that advises users that run into corruption that the debug messages might provide useful additional context.
1 parent f333d35 commit 20fbb71

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

contrib/amcheck/verify_nbtree.c

+8-1
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,13 @@ bt_check_every_level(Relation rel, Relation heaprel, bool heapkeyspace,
411411
BtreeLevel current;
412412
Snapshot snapshot = SnapshotAny;
413413

414+
if (!readonly)
415+
elog(DEBUG1, "verifying consistency of tree structure for index \"%s\"",
416+
RelationGetRelationName(rel));
417+
else
418+
elog(DEBUG1, "verifying consistency of tree structure for index \"%s\" with cross-level checks",
419+
RelationGetRelationName(rel));
420+
414421
/*
415422
* RecentGlobalXmin assertion matches index_getnext_tid(). See note on
416423
* RecentGlobalXmin/B-Tree page deletion.
@@ -654,7 +661,7 @@ bt_check_level_from_leftmost(BtreeCheckState *state, BtreeLevel level)
654661
/* Use page-level context for duration of this call */
655662
oldcontext = MemoryContextSwitchTo(state->targetcontext);
656663

657-
elog(DEBUG2, "verifying level %u%s", level.level,
664+
elog(DEBUG1, "verifying level %u%s", level.level,
658665
level.istruerootlevel ?
659666
" (true root level)" : level.level == 0 ? " (leaf level)" : "");
660667

doc/src/sgml/amcheck.sgml

+21
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,27 @@ ORDER BY c.relpages DESC LIMIT 10;
166166
</listitem>
167167
</varlistentry>
168168
</variablelist>
169+
<tip>
170+
<para>
171+
<function>bt_index_parent_check</function> and
172+
<function>bt_index_parent_check</function> both output log
173+
messages about the verification process at
174+
<literal>DEBUG1</literal> and <literal>DEBUG2</literal> severity
175+
levels. These messages provide detailed information about the
176+
verification process that may be of interest to
177+
<productname>PostgreSQL</productname> developers. Advanced users
178+
may also find this information helpful, since it provides
179+
additional context should verification actually detect an
180+
inconsistency. Running:
181+
<programlisting>
182+
SET client_min_messages = DEBUG1;
183+
</programlisting>
184+
in an interactive <application>psql</application> session before
185+
running a verification query will display messages about the
186+
progress of verification with a manageable level of detail.
187+
</para>
188+
</tip>
189+
169190
</sect2>
170191

171192
<sect2>

0 commit comments

Comments
 (0)