From: Heikki Linnakangas <heikki.linnakangas@iki.fi>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Never store 0 as the nextMXact
Date: Fri, 12 Dec 2025 08:51:18 +0000
Message-ID: <E1vTyrt-000J4v-2U@gemulon.postgresql.org> (raw)
Never store 0 as the nextMXact
Before this commit, when multixid wraparound happens,
MultiXactState->nextMXact goes to 0, which is invalid. All the readers
need to deal with that possibility and skip over the 0. That's
error-prone and we've missed it a few times in the past. This commit
changes the responsibility so that all the writers of
MultiXactState->nextMXact skip over the zero already, and readers can
trust that it's never 0.
We were already doing that for MultiXactState->oldestMultiXactId; none
of its writers would set it to 0. ReadMultiXactIdRange() was
nevertheless checking for that possibility. For clarity, remove that
check.
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Reviewed-by: Maxim Orlov <orlovmg@gmail.com>
Discussion: https://www.postgresql.org/message-id/3624730d-6dae-42bf-9458-76c4c965fb27@iki.fi
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/87a350e1f284bb99591f9185c0be0ae28899f38a
Modified Files
--------------
src/backend/access/transam/multixact.c | 79 ++++++++--------------------------
src/bin/pg_resetwal/pg_resetwal.c | 2 +
src/bin/pg_resetwal/t/001_basic.pl | 15 ++-----
3 files changed, 24 insertions(+), 72 deletions(-)
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: Never store 0 as the nextMXact
In-Reply-To: <E1vTyrt-000J4v-2U@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