pgsql: amcheck: Fix snapshot usage in bt_index_parent_check

From: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: amcheck: Fix snapshot usage in bt_index_parent_check
Date: 2026-01-21 17:56:50
Message-ID: E1vicRl-001qAw-2A@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

amcheck: Fix snapshot usage in bt_index_parent_check

We were using SnapshotAny to do some index checks, but that's wrong and
causes spurious errors when used on indexes created by CREATE INDEX
CONCURRENTLY. Fix it to use an MVCC snapshot, and add a test for it.

Backpatch of 6bd469d26aca to branches 14-16. I previously misidentified
the bug's origin: it came in with commit 7f563c09f890 (pg11-era, not
5ae2087202af as claimed previously), so all live branches are affected.

Also take the opportunity to fix some comments that we failed to update
in the original commits and apply pgperltidy. In branch 14, remove the
unnecessary test plan specification (which would have need to have been
changed anyway; c.f. commit 549ec201d613.)

Diagnosed-by: Donghang Lin <donghanglin(at)gmail(dot)com>
Author: Mihail Nikalayeu <mihailnikalayeu(at)gmail(dot)com>
Reviewed-by: Andrey Borodin <x4mmm(at)yandex-team(dot)ru>
Backpatch-through: 17
Discussion: https://postgr.es/m/CANtu0ojmVd27fEhfpST7RG2KZvwkX=dMyKUqg0KM87FkOSdz8Q@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/1f28982e409451249646910e585469076c43ba8f

Modified Files
--------------
contrib/amcheck/t/002_cic.pl | 3 ++-
contrib/amcheck/verify_nbtree.c | 4 +++-
2 files changed, 5 insertions(+), 2 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2026-01-21 18:26:33 pgsql: Remove useless flag PVC_INCLUDE_CONVERTROWTYPES.
Previous Message Peter Eisentraut 2026-01-21 13:51:22 pgsql: Remove more leftovers of AIX support