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 <[email protected]>
Reviewed-by: Ashutosh Bapat <[email protected]>
Reviewed-by: Alexander Korotkov <[email protected]>
Reviewed-by: wenhui qiu <[email protected]>
Discussion: 
https://www.postgresql.org/message-id/cacg%[email protected]

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(-)

Reply via email to