Обсуждение: pgsql: Widen MultiXactOffset to 64 bits

Поиск
Список
Период
Сортировка

pgsql: Widen MultiXactOffset to 64 bits

От
Heikki Linnakangas
Дата:
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@gmail.com>
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com>
Reviewed-by: wenhui qiu <qiuwenhuifx@gmail.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(-)


Re: pgsql: Widen MultiXactOffset to 64 bits

От
Peter Geoghegan
Дата:
On Tue, Dec 9, 2025 at 6:57 AM Heikki Linnakangas
<heikki.linnakangas@iki.fi> wrote:
> Widen MultiXactOffset to 64 bits

Thanks for working on this!

Noticed a minor issue. This seems to have broken MULTIXACT_DEBUG builds, here:

../source/src/backend/access/transam/multixact.c:2195:61: error: expected ')'
 2195 |         debug_elog3(DEBUG2, "MultiXact: setting next offset to
%" PRIU64,
      |                                                                   ^

--
Peter Geoghegan



Re: pgsql: Widen MultiXactOffset to 64 bits

От
Peter Geoghegan
Дата:
On Wed, Dec 10, 2025 at 5:14 PM Peter Geoghegan <pg@bowt.ie> wrote:
> Noticed a minor issue. This seems to have broken MULTIXACT_DEBUG builds, here:

Never mind. Pushed a fix for this myself just now.

Thanks
--
Peter Geoghegan