1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-03 15:22:11 +03:00

Separate multixact freezing parameters from xid's

Previously we were piggybacking on transaction ID parameters to freeze
multixacts; but since there isn't necessarily any relationship between
rates of Xid and multixact consumption, this turns out not to be a good
idea.

Therefore, we now have multixact-specific freezing parameters:

vacuum_multixact_freeze_min_age: when to remove multis as we come across
them in vacuum (default to 5 million, i.e. early in comparison to Xid's
default of 50 million)

vacuum_multixact_freeze_table_age: when to force whole-table scans
instead of scanning only the pages marked as not all visible in
visibility map (default to 150 million, same as for Xids).  Whichever of
both which reaches the 150 million mark earlier will cause a whole-table
scan.

autovacuum_multixact_freeze_max_age: when for cause emergency,
uninterruptible whole-table scans (default to 400 million, double as
that for Xids).  This means there shouldn't be more frequent emergency
vacuuming than previously, unless multixacts are being used very
rapidly.

Backpatch to 9.3 where multixacts were made to persist enough to require
freezing.  To avoid an ABI break in 9.3, VacuumStmt has a couple of
fields in an unnatural place, and StdRdOptions is split in two so that
the newly added fields can go at the end.

Patch by me, reviewed by Robert Haas, with additional input from Andres
Freund and Tom Lane.
This commit is contained in:
Alvaro Herrera
2014-02-13 19:30:30 -03:00
parent de4b6558be
commit 801c2dc72c
19 changed files with 379 additions and 29 deletions

View File

@@ -108,7 +108,8 @@
<listitem>
<simpara>To protect against loss of very old data due to
<firstterm>transaction ID wraparound</>.</simpara>
<firstterm>transaction ID wraparound</> or
<firstterm>multixact ID wraparound</>.</simpara>
</listitem>
</orderedlist>
@@ -379,6 +380,11 @@
<secondary>wraparound</secondary>
</indexterm>
<indexterm>
<primary>wraparound</primary>
<secondary>of transaction IDs</secondary>
</indexterm>
<para>
<productname>PostgreSQL</productname>'s MVCC transaction semantics
depend on being able to compare transaction ID (<acronym>XID</>)
@@ -597,6 +603,54 @@ HINT: Stop the postmaster and vacuum that database in single-user mode.
page for details about using single-user mode.
</para>
<sect3 id="vacuum-for-multixact-wraparound">
<title>Multixacts and Wraparound</title>
<indexterm>
<primary>MultiXactId</primary>
</indexterm>
<indexterm>
<primary>wraparound</primary>
<secondary>of multixact IDs</secondary>
</indexterm>
<para>
<firstterm>Multixacts</> are used to implement row locking by
multiple transactions: since there is limited space in the tuple
header to store lock information, that information is stored as a
multixact separately in the <filename>pg_multixact</> subdirectory,
and only its ID is in the <structfield>xmax</> field
in the tuple header.
Similar to transaction IDs, multixact IDs are implemented as a
32-bit counter and corresponding storage, all of which requires
careful aging management, storage cleanup, and wraparound handling.
</para>
<para>
During a <command>VACUUM</> table scan, either partial or of the whole
table, any multixact ID older than
<xref linkend="guc-vacuum-multixact-freeze-min-age">
is replaced by a different value, which can be the zero value, a single
transaction ID, or a newer multixact ID. For each table,
<structname>pg_class</>.<structfield>relminmxid</> stores the oldest
possible value still stored in any tuple of that table. Every time this
value is older than
<xref linkend="guc-vacuum-multixact-freeze-table-age">, a whole-table
scan is forced. Whole-table <command>VACUUM</> scans, regardless of
what causes them, enable advancing the value for that table.
Eventually, as all tables in all databases are scanned and their
oldest multixact values are advanced, on-disk storage for older
multixacts can be removed.
</para>
<para>
As a safety device, a whole-table vacuum scan will occur for any table
whose multixact-age is greater than
<xref linkend="guc-autovacuum-multixact-freeze-max-age">.
This will occur even if autovacuum is nominally disabled.
</para>
</sect3>
</sect2>
<sect2 id="autovacuum">