pgsql: Update FSM during prune/freeze replay even if freespace is zero

From: Melanie Plageman <melanieplageman(at)gmail(dot)com>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Update FSM during prune/freeze replay even if freespace is zero
Date: 2026-04-16 16:13:11
Message-ID: E1wDPL4-001Gzq-1C@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Update FSM during prune/freeze replay even if freespace is zero

add323da40a started updating the visibility map in the same WAL record
as pruning and freezing. This included updating the freespace map during
replay of a record setting the VM, which we've done since ab7dbd681.

add323da40a, however, conditioned doing so on there being > 0 freespace
on the page, which differed from the previous state for records updating
the VM.

The FSM is not WAL-logged and is instead updated heuristically on
standbys. In rare cases, this heuristic could lead to pages with 0
freespace having outdated entries in the FSM. If the standby is later
promoted and vacuum skips these pages because they are marked
all-visible/all-frozen, overly optimistic values would be propagated up
the FSM tree, causing slowness when searching for freespace for new
tuples.

Fix it by always updating the FSM during replay when setting VM bits.

Author: Melanie Plageman <melanieplageman(at)gmail(dot)com>
Reported-by: Alexey Makhmutov <a(dot)makhmutov(at)postgrespro(dot)ru>
Discussion: https://postgr.es/m/ead2f110-c736-48f5-99e1-023dc9acbf0b%40postgrespro.ru

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/b4c1b2be300e619aebc3a2c00198009af256bfee

Modified Files
--------------
src/backend/access/heap/heapam_xlog.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Bruce Momjian 2026-04-16 16:46:03 pgsql: doc PG 19 relnotes: add author and move items
Previous Message Bruce Momjian 2026-04-16 15:24:17 pgsql: doc PG 19 relnotes: update author