pgsql: Fix autovacuum-induced flakiness in backwards scan test.

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix autovacuum-induced flakiness in backwards scan test.
Date: 2026-07-29 15:17:44
Message-ID: E1wp62S-00000000oPN-3Wqq@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix autovacuum-induced flakiness in backwards scan test.

Two of the permutations in backwards-scan-concurrent-splits rely on
their VACUUM step deleting the leaf pages that the waiting backwards
scan will have to recover from. VACUUM can only do that when it's able
to remove the index tuples whose heap tuples the concurrent session just
deleted. An autovacuum worker holding a snapshot holds back the
removable cutoff, which leaves the pages non-empty, and so undeleted,
causing the test to fail spuriously.

To fix, wait for the removable cutoff to advance past the deletions
before the scan acquires its snapshot. This is much like commit
1c64d2fc, which dealt with the same hazard in nbtree_half_dead_pages by
adding the wait_prunable() helper that we reuse here.

Oversight in commit e395fbd3.

Author: Peter Geoghegan <pg(at)bowt(dot)ie>
Reported-by: Alexander Lakhin <exclusion(at)gmail(dot)com>
Discussion: https://postgr.es/m/b61d9944-d7a3-45f3-b69a-f18c8bfbbbd0@gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/23a6e25593729feaafb6f3491a1222247f6e0125

Modified Files
--------------
.../expected/backwards-scan-concurrent-splits.out | 6 ++++--
.../specs/backwards-scan-concurrent-splits.spec | 24 ++++++++++++++++++++++
2 files changed, 28 insertions(+), 2 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Masahiko Sawada 2026-07-29 16:52:33 pgsql: Fix stale comment in parallel_vacuum_main().
Previous Message Álvaro Herrera 2026-07-29 15:17:03 pgsql: Fix cascading standby reconnect failure after archive fallback