]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Add test coverage for nbtree backwards scans.
authorPeter Geoghegan <pg@bowt.ie>
Sat, 25 Jul 2026 21:13:00 +0000 (17:13 -0400)
committerPeter Geoghegan <pg@bowt.ie>
Sat, 25 Jul 2026 21:13:00 +0000 (17:13 -0400)
commite395fbd32a07557de4ac98088928c1749d4845d8
treea4d16c45af80de8f6b83542114d9e2a1a62b212d
parent62c05d6f2fa64cce44e57871b4cfcd7b34589fcf
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
src/backend/access/nbtree/nbtsearch.c
src/test/modules/nbtree/Makefile
src/test/modules/nbtree/expected/backwards-scan-concurrent-splits.out [new file with mode: 0644]
src/test/modules/nbtree/meson.build
src/test/modules/nbtree/specs/backwards-scan-concurrent-splits.spec [new file with mode: 0644]