pgsql: Never store 0 as the nextMXact

From: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Never store 0 as the nextMXact
Date: 2025-12-12 08:51:18
Message-ID: E1vTyrt-000J4v-2U@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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(dot)bapat(dot)oss(at)gmail(dot)com>
Reviewed-by: Maxim Orlov <orlovmg(at)gmail(dot)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(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Eisentraut 2025-12-12 09:11:26 pgsql: Replace most StaticAssertStmt() with StaticAssertDecl()
Previous Message Michael Paquier 2025-12-12 00:10:16 pgsql: tests: Rename conflicting role names