agora inbox for pgsql-committers@postgresql.org  
help / color / mirror / Atom feed
From: Melanie Plageman <melanieplageman@gmail.com>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Handle no-op visibility map set during redo
Date: Mon, 14 Sep 2026 15:34:20 +0000
Message-ID: <E1x68hI-00000000J0x-2ReB@gemulon.postgresql.org> (raw)

Handle no-op visibility map set during redo

add323da40a consolidated visibility map updates into XLOG_HEAP2_PRUNE
records. It assumed that a record setting the visibility map would
always modify the VM page during replay. That is not true when the
requested bits are already set on the standby.

Primary and standby visibility maps can diverge for several reasons.
This issue was exposed by a CREATE DATABASE ... STRATEGY WAL_LOG bug.
After a standby with an out-of-date VM is promoted, VACUUM may set bits
that were already present on the former primary. When the former primary
later replays that record as a standby, visibilitymap_set() is a no-op.

Restore visibilitymap_set()'s former API, which returns the state of the
VM bits before setting the requested flags. Use that result to set the
VM page LSN only when the visibilitymap_set() updates the page.

Reported-by: Rogers Wang <rogers.ww@qq.com>
Discussion: https://postgr.es/m/tencent_2E870046716FD94285045E96505A2D4E2908%40qq.com
Backpatch-through: 19

Branch
------
REL_19_STABLE

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

Modified Files
--------------
src/backend/access/heap/heapam.c        | 10 +++++-----
src/backend/access/heap/heapam_xlog.c   | 18 ++++++------------
src/backend/access/heap/pruneheap.c     |  5 +++--
src/backend/access/heap/vacuumlazy.c    | 16 ++++++++--------
src/backend/access/heap/visibilitymap.c |  6 +++++-
src/include/access/visibilitymap.h      |  6 +++---
6 files changed, 30 insertions(+), 31 deletions(-)



view thread (2+ messages)

Message-ID: <E1x68hI-00000000J0x-2ReB@gemulon.postgresql.org>
Permalink:  ../E1x68hI-00000000J0x-2ReB@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1x68hI-00000000J0x-2ReB@gemulon.postgresql.org

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: melanieplageman@gmail.com, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Handle no-op visibility map set during redo
  In-Reply-To: <E1x68hI-00000000J0x-2ReB@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox