pgsql: Widen MultiXactOffset to 64 bits

From: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Widen MultiXactOffset to 64 bits
Date: 2025-12-09 11:57:04
Message-ID: E1vSwL2-003byD-0O@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Widen MultiXactOffset to 64 bits

This eliminates MultiXactOffset wraparound and the 2^32 limit on the
total number of multixid members. Multixids are still limited to 2^31,
but this is a nice improvement because 'members' can grow much faster
than the number of multixids. On such systems, you can now run longer
before hitting hard limits or triggering anti-wraparound vacuums.

Not having to deal with MultiXactOffset wraparound also simplifies the
code and removes some gnarly corner cases.

We no longer need to perform emergency anti-wraparound freezing
because of running out of 'members' space, so the offset stop limit is
gone. But you might still not want 'members' to consume huge amounts
of disk space. For that reason, I kept the logic for lowering vacuum's
multixid freezing cutoff if a large amount of 'members' space is
used. The thresholds for that are roughly the same as the "safe" and
"danger" thresholds used before, 2 billion transactions and 4 billion
transactions. This keeps the behavior for the freeze cutoff roughly
the same as before. It might make sense to make this smarter or
configurable, now that the threshold is only needed to manage disk
usage, but that's left for the future.

Add code to pg_upgrade to convert multitransactions from the old to
the new format, rewriting the pg_multixact SLRU files. Because
pg_upgrade now rewrites the files, we can get rid of some hacks we had
put in place to deal with old bugs and upgraded clusters. Bump catalog
version for the pg_multixact/offsets format change.

Author: Maxim Orlov <orlovmg(at)gmail(dot)com>
Reviewed-by: Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>
Reviewed-by: Alexander Korotkov <aekorotkov(at)gmail(dot)com>
Reviewed-by: wenhui qiu <qiuwenhuifx(at)gmail(dot)com>
Discussion: https://www.postgresql.org/message-id/CACG%3DezaWg7_nt-8ey4aKv2w9LcuLthHknwCawmBgEeTnJrJTcw@mail.gmail.com

Branch
------
master

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

Modified Files
--------------
doc/src/sgml/ref/pg_resetwal.sgml | 13 +-
src/backend/access/rmgrdesc/mxactdesc.c | 4 +-
src/backend/access/rmgrdesc/xlogdesc.c | 2 +-
src/backend/access/transam/multixact.c | 554 +++++----------------
src/backend/access/transam/xlog.c | 6 +-
src/backend/access/transam/xlogrecovery.c | 2 +-
src/backend/commands/vacuum.c | 6 +-
src/backend/postmaster/autovacuum.c | 4 +-
src/bin/pg_controldata/pg_controldata.c | 2 +-
src/bin/pg_resetwal/pg_resetwal.c | 38 +-
src/bin/pg_resetwal/t/001_basic.pl | 2 +-
src/bin/pg_upgrade/Makefile | 3 +
src/bin/pg_upgrade/meson.build | 4 +
src/bin/pg_upgrade/multixact_read_v18.c | 340 +++++++++++++
src/bin/pg_upgrade/multixact_read_v18.h | 37 ++
src/bin/pg_upgrade/multixact_rewrite.c | 191 +++++++
src/bin/pg_upgrade/pg_upgrade.c | 84 +++-
src/bin/pg_upgrade/pg_upgrade.h | 12 +-
src/bin/pg_upgrade/slru_io.c | 268 ++++++++++
src/bin/pg_upgrade/slru_io.h | 52 ++
src/bin/pg_upgrade/t/007_multixact_conversion.pl | 427 ++++++++++++++++
src/include/access/multixact.h | 7 +-
src/include/access/multixact_internal.h | 28 +-
src/include/c.h | 2 +-
src/include/catalog/catversion.h | 2 +-
.../test_slru/t/002_multixact_wraparound.pl | 2 +-
src/test/perl/PostgreSQL/Test/BackgroundPsql.pm | 15 +-
src/test/perl/PostgreSQL/Test/Cluster.pm | 21 +-
src/tools/pgindent/typedefs.list | 3 +
29 files changed, 1609 insertions(+), 522 deletions(-)

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Heikki Linnakangas 2025-12-09 12:12:35 pgsql: Fix warning about wrong format specifier for off_t type
Previous Message Dean Rasheed 2025-12-09 10:54:47 pgsql: doc: Fix statement about ON CONFLICT and deferrable constraints.