agora inbox for pgsql-committers@postgresql.org  
help / color / mirror / Atom feed
From: Peter Geoghegan <pg@bowt.ie>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Add test coverage for nbtree backwards scans.
Date: Sat, 25 Jul 2026 21:13:32 +0000
Message-ID: <E1wnjga-00000000IlC-2Kyl@gemulon.postgresql.org> (raw)

Add test coverage for nbtree backwards scans.

Backwards scans have unique concurrency rules: rather than unreservedly
trusting a saved left link, the scan optimistically rechecks its
pointed-to leaf page's right link (i.e. whether it still points back to
the page that _bt_readpage just read).  Usually, the left sibling of the
just-read page won't have changed, in which case the scan can proceed
with reading the left sibling as planned.  But it's possible that the
key space that the scan needs to read next is no longer covered by the
original left sibling page due to concurrent page splits and/or page
deletions.  When that happens, the scan must recover by relocating the
new/current left sibling of the just-read page.

Test coverage for backwards scans was limited to the happy path.  Add an
isolation test (and associated injection points) that test the recovery
path.  This covers several distinct recovery scenarios (concurrent page
splits, concurrent page deletions, and minor variants thereof).

Author: Peter Geoghegan <pg@bowt.ie>
Reviewed-by: Andrey Borodin <x4mmm@yandex-team.ru>
Discussion: https://postgr.es/m/CAH2-WzmD+jUBOpFS2jrnqqrdPSAjoxqyL9FPKaE1BtnY=8Nntg@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/e395fbd32a07557de4ac98088928c1749d4845d8

Modified Files
--------------
src/backend/access/nbtree/nbtsearch.c              |  21 ++
src/test/modules/nbtree/Makefile                   |   3 +-
.../expected/backwards-scan-concurrent-splits.out  | 304 +++++++++++++++++++++
src/test/modules/nbtree/meson.build                |   2 +
.../specs/backwards-scan-concurrent-splits.spec    | 123 +++++++++
5 files changed, 452 insertions(+), 1 deletion(-)



Message-ID: <E1wnjga-00000000IlC-2Kyl@gemulon.postgresql.org>
Permalink:  ../E1wnjga-00000000IlC-2Kyl@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1wnjga-00000000IlC-2Kyl@gemulon.postgresql.org

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: pg@bowt.ie, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Add test coverage for nbtree backwards scans.
  In-Reply-To: <E1wnjga-00000000IlC-2Kyl@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox