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 <[email protected]>
Reviewed-by: Andrey Borodin <[email protected]>
Discussion: 
https://postgr.es/m/CAH2-WzmD+jUBOpFS2jrnqqrdPSAjoxqyL9FPKaE1BtnY=8n...@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(-)

Reply via email to