1
0
mirror of https://github.com/postgres/postgres.git synced 2025-12-19 17:02:53 +03:00

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
This commit is contained in:
Heikki Linnakangas
2025-12-09 13:53:03 +02:00
parent bb3b1c4f64
commit bd8d9c9bdf
29 changed files with 1607 additions and 520 deletions

View File

@@ -37,7 +37,7 @@ my $slru_pages_per_segment = $1;
# initialize the 'offsets' SLRU file containing the new next multixid
# with zeros
my $multixact_offsets_per_page = $blcksz / 4; # sizeof(MultiXactOffset) == 4
my $multixact_offsets_per_page = $blcksz / 8; # sizeof(MultiXactOffset) == 8
my $segno =
int(0xFFFFFFF8 / $multixact_offsets_per_page / $slru_pages_per_segment);
my $slru_file = sprintf('%s/pg_multixact/offsets/%04X', $node_pgdata, $segno);

View File

@@ -230,18 +230,23 @@ Executes a query in the current session and returns the output in scalar
context and (output, error) in list context where error is 1 in case there
was output generated on stderr when executing the query.
By default, the query and its results are printed to the test output. This
can be disabled by passing the keyword parameter verbose => false.
=cut
sub query
{
my ($self, $query) = @_;
my ($self, $query, %params) = @_;
my $ret;
my $output;
my $query_cnt = $self->{query_cnt}++;
$params{verbose} = 1 unless defined $params{verbose};
local $Test::Builder::Level = $Test::Builder::Level + 1;
note "issuing query $query_cnt via background psql: $query";
note "issuing query $query_cnt via background psql: $query" unless !$params{verbose};
$self->{timeout}->start() if (defined($self->{query_timer_restart}));
@@ -280,7 +285,7 @@ sub query
explain {
stdout => $self->{stdout},
stderr => $self->{stderr},
};
} unless !$params{verbose};
# Remove banner from stdout and stderr, our caller doesn't care. The
# first newline is optional, as there would not be one if consuming an
@@ -308,9 +313,9 @@ Query failure is determined by it producing output on stderr.
sub query_safe
{
my ($self, $query) = @_;
my ($self, $query, %params) = @_;
my $ret = $self->query($query);
my $ret = $self->query($query, %params);
if ($self->{stderr} ne "")
{

View File

@@ -1793,13 +1793,20 @@ sub _get_env
return (%inst_env);
}
# Private routine to get an installation path qualified command.
#
# IPC::Run maintains a cache, %cmd_cache, mapping commands to paths. Tests
# which use nodes spanning more than one postgres installation path need to
# avoid confusing which installation's binaries get run. Setting $ENV{PATH} is
# insufficient, as IPC::Run does not check to see if the path has changed since
# caching a command.
=pod
=item $node->installed_command(cmd)
Get an installation path qualified command.
IPC::Run maintains a cache, %cmd_cache, mapping commands to paths. Tests
which use nodes spanning more than one postgres installation path need to
avoid confusing which installation's binaries get run. Setting $ENV{PATH} is
insufficient, as IPC::Run does not check to see if the path has changed since
caching a command.
=cut
sub installed_command
{
my ($self, $cmd) = @_;