Assert consistency of currPage that ended scan.

Peter Geoghegan <pg@bowt.ie>

Commit: caca6d8d276ce57473e97050d19dfe84e59482c8
Author: Peter Geoghegan <pg@bowt.ie>
Date: 2024-11-08T21:34:41Z
Releases: 18.0
Assert consistency of currPage that ended scan.

When _bt_readnextpage is called with our nbtree parallel scan already
seized (i.e. when it is directly called by _bt_first), we never expect a
prior call to _bt_readpage for lastcurrblkno to already indicate that
the scan should end -- the _bt_first caller's blkno must always be read.
After all, the "prior" _bt_readpage call (the call for lastcurrblkno)
probably took place in some other backend (and it might not even have
finished by the time our backend reaches _bt_first/_bt_readnextpage).

Add a documenting assertion to the path where _bt_readnextpage ends the
parallel scan based on information about lastcurrblkno from so->currPos.
Assert that the most recent _bt_readpage call that set so->currPos is in
fact lastcurrblkno's _bt_readpage call.

Follow-up to bugfix commit b5ee4e52.

Files

PathChange+/−
src/backend/access/nbtree/nbtsearch.c modified +2 −1