Re: Why clearing the VM doesn't require registering vm buffer in wal record

From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: Melanie Plageman <melanieplageman(at)gmail(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Andrey Borodin <x4mmm(at)yandex-team(dot)ru>, Andres Freund <andres(at)anarazel(dot)de>, Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Subject: Re: Why clearing the VM doesn't require registering vm buffer in wal record
Date: 2026-07-16 01:30:55
Message-ID: CAHGQGwF_PzOv5y7ucFh7Fqqqa8ar83zYwvWugqarRD6+7GCtEQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Jul 16, 2026 at 6:58 AM Melanie Plageman
<melanieplageman(at)gmail(dot)com> wrote:
>
> On Tue, Jul 14, 2026 at 3:42 PM Melanie Plageman
> <melanieplageman(at)gmail(dot)com> wrote:
> >
> > I've also finished all branch versions of this. Each one's code
> > differs, but I've managed to keep the commit messages the same, which
> > should help release notes. Note that REL_19_STABLE bumps
> > XLOG_PAGE_MAGIC. This would keep us from having to maintain the
> > backwards compatibility code there, which I think is what we want.
> > Here are those branches.
>
> I've pushed the main commits to all branches where needed.

Thanks for working on them!

In commit ed62d26caca

- if (!BufferIsValid(vmbuf) || BufferGetBlockNumber(vmbuf) != mapBlock)
- elog(ERROR, "wrong buffer passed to visibilitymap_clear");
+ Assert(BufferIsValid(vmbuf) && BufferGetBlockNumber(vmbuf) == mapBlock);

Isn't it be better to keep the elog(ERROR) in addition to the Assert()
so that wrong buffer is detected even in non-assert builds?

Otherwise, a non-assert build could silently modify the wrong VM page
if a caller passes the wrong buffer. Since this commit increased the number
of callers and introduced visibilitymap_clear() into WAL redo paths,
it seems safer to retain the runtime check.

Regards,

--
Fujii Masao

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Sami Imseih 2026-07-16 01:40:21 Re: pgstat: add pgstat_prep_pending() for entry ref pending setup
Previous Message Masahiko Sawada 2026-07-16 01:21:57 Re: Fix "unexpected logical decoding status change" error; from concurrent logical decoding activation