]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix another empty nbtree index SSI race.
authorPeter Geoghegan <pg@bowt.ie>
Sat, 25 Jul 2026 16:01:35 +0000 (12:01 -0400)
committerPeter Geoghegan <pg@bowt.ie>
Sat, 25 Jul 2026 16:01:35 +0000 (12:01 -0400)
commitce3f19e26218283eaff6436e28113b532bfc4a6f
treef4f823d19b32e8a6423c80d9850bf2f7e4a773fb
parent38afc3dcb25c45b744d4025029ce0a6c90b7059f
Fix another empty nbtree index SSI race.

Commit f9b7fc65 fixed a race when predicate-locking completely empty
btrees: without a buffer lock held, a matching key could be inserted
between _bt_search and the PredicateLockRelation call, so the scan would
miss concurrently inserted tuples while the writer wouldn't see the
reader's predicate lock.  That commit only fixed _bt_first's _bt_search
path, though.  Scans without useful insertion scan keys return early
from _bt_first via _bt_endpoint, which still didn't recheck if the
relation was empty.

To fix, add handling to _bt_endpoint that is analogous to the handling
added to _bt_search by commit f9b7fc65.

Author: Peter Geoghegan <pg@bowt.ie>
Discussion: https://postgr.es/m/CAH2-WzkNoTn3yXY0iGkSuavJ+sL8EROf+kitW+_2v2tJVWuKmA@mail.gmail.com
Backpatch-through: 14
src/backend/access/nbtree/nbtsearch.c