Skip to content

Commit bd8d9c9

Browse files
committed
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
1 parent bb3b1c4 commit bd8d9c9

File tree

29 files changed

+1609
-522
lines changed

29 files changed

+1609
-522
lines changed

doc/src/sgml/ref/pg_resetwal.sgml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -267,14 +267,17 @@ PostgreSQL documentation
267267
A safe value for the next multitransaction ID (first part) can be
268268
determined by looking for the numerically largest file name in the
269269
directory <filename>pg_multixact/offsets</filename> under the data directory,
270-
adding one, and then multiplying by 65536 (0x10000). Conversely, a safe
270+
adding one, and then multiplying by 32768 (0x8000). Conversely, a safe
271271
value for the oldest multitransaction ID (second part of
272272
<option>-m</option>) can be determined by looking for the numerically smallest
273-
file name in the same directory and multiplying by 65536. The file
274-
names are in hexadecimal, so the easiest way to do this is to specify
275-
the option value in hexadecimal and append four zeroes.
273+
file name in the same directory and multiplying by 32768 (0x8000).
274+
Note that the file names are in hexadecimal. It is usually easiest
275+
to specify the option value in hexadecimal too. For example, if
276+
<filename>000F</filename> and <filename>0007</filename> are the greatest and
277+
smallest entries in <filename>pg_multixact/offsets</filename>,
278+
<literal>-m 0x80000,0x38000</literal> will work.
276279
</para>
277-
<!-- 65536 = SLRU_PAGES_PER_SEGMENT * BLCKSZ / sizeof(MultiXactOffset) -->
280+
<!-- 32768 = SLRU_PAGES_PER_SEGMENT * BLCKSZ / sizeof(MultiXactOffset) -->
278281
</listitem>
279282
</varlistentry>
280283

src/backend/access/rmgrdesc/mxactdesc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ multixact_desc(StringInfo buf, XLogReaderState *record)
6565
xl_multixact_create *xlrec = (xl_multixact_create *) rec;
6666
int i;
6767

68-
appendStringInfo(buf, "%u offset %u nmembers %d: ", xlrec->mid,
68+
appendStringInfo(buf, "%u offset %" PRIu64 " nmembers %d: ", xlrec->mid,
6969
xlrec->moff, xlrec->nmembers);
7070
for (i = 0; i < xlrec->nmembers; i++)
7171
out_member(buf, &xlrec->members[i]);
@@ -74,7 +74,7 @@ multixact_desc(StringInfo buf, XLogReaderState *record)
7474
{
7575
xl_multixact_truncate *xlrec = (xl_multixact_truncate *) rec;
7676

77-
appendStringInfo(buf, "offsets [%u, %u), members [%u, %u)",
77+
appendStringInfo(buf, "offsets [%u, %u), members [%" PRIu64 ", %" PRIu64 ")",
7878
xlrec->startTruncOff, xlrec->endTruncOff,
7979
xlrec->startTruncMemb, xlrec->endTruncMemb);
8080
}

src/backend/access/rmgrdesc/xlogdesc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ xlog_desc(StringInfo buf, XLogReaderState *record)
6666
CheckPoint *checkpoint = (CheckPoint *) rec;
6767

6868
appendStringInfo(buf, "redo %X/%08X; "
69-
"tli %u; prev tli %u; fpw %s; wal_level %s; xid %u:%u; oid %u; multi %u; offset %u; "
69+
"tli %u; prev tli %u; fpw %s; wal_level %s; xid %u:%u; oid %u; multi %u; offset %" PRIu64 "; "
7070
"oldest xid %u in DB %u; oldest multi %u in DB %u; "
7171
"oldest/newest commit timestamp xid: %u/%u; "
7272
"oldest running xid %u; %s",

0 commit comments

Comments
 (0)