pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Heikki Linnakangas <heikki.linnakangas@iki.fi>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix multixact backwards-compatibility with CHECKPOINT race condi
Date: Mon, 23 Mar 2026 10:35:28 +0000
Message-ID: <E1w4cd5-0014HC-1f@gemulon.postgresql.org> (raw)

Fix multixact backwards-compatibility with CHECKPOINT race condition

If a CHECKPOINT record with nextMulti N is written to the WAL before
the CREATE_ID record for N, and N happens to be the first multixid on
an offset page, the backwards compatibility logic to tolerate WAL
generated by older minor versions (before commit 789d65364c) failed to
compensate for the missing XLOG_MULTIXACT_ZERO_OFF_PAGE record. In
that case, the latest_page_number was initialized at the start of WAL
replay to the page for nextMulti from the CHECKPOINT record, even if
we had not seen the CREATE_ID record for that multixid yet, which
fooled the backwards compatibility logic to think that the page was
already initialized.

To fix, track the last XLOG_MULTIXACT_ZERO_OFF_PAGE that we've seen
separately from latest_page_number. If we haven't seen any
XLOG_MULTIXACT_ZERO_OFF_PAGE records yet, use
SimpleLruDoesPhysicalPageExist() to check if the page needs to be
initialized.

Reported-by: duankunren.dkr <duankunren.dkr@alibaba-inc.com>
Analyzed-by: duankunren.dkr <duankunren.dkr@alibaba-inc.com>
Reviewed-by: Andrey Borodin <x4mmm@yandex-team.ru>
Reviewed-by: Kirill Reshke <reshkekirill@gmail.com>
Discussion: https://www.postgresql.org/message-id/c4ef1737-8cba-458e-b6fd-4e2d6011e985.duankunren.dkr@alibaba-in...
Backpatch-through: 14-18

Branch
------
REL_14_STABLE

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

Modified Files
--------------
src/backend/access/transam/multixact.c | 83 +++++++++++++++++++++++++++-------
src/include/access/slru.h              |  4 +-
2 files changed, 68 insertions(+), 19 deletions(-)



view thread (5+ messages)  latest in thread

Message-ID: <E1w4cd5-0014HC-1f@gemulon.postgresql.org>
Permalink:  ../E1w4cd5-0014HC-1f@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1w4cd5-0014HC-1f@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: heikki.linnakangas@iki.fi, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Fix multixact backwards-compatibility with CHECKPOINT race condi
  In-Reply-To: <E1w4cd5-0014HC-1f@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 DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox