Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0b018fa

Browse files
Set relfrozenxid to oldest extant XID seen by VACUUM.
When VACUUM set relfrozenxid before now, it set it to whatever value wasused to determine which tuples to freeze -- the FreezeLimit cutoff.This approach was very naive. The relfrozenxid invariant only requiresthat new relfrozenxid values be <= the oldest extant XID remaining inthe table (at the point that the VACUUM operation ends), which ingeneral might be much more recent than FreezeLimit.VACUUM now carefully tracks the oldest remaining XID/MultiXactId as itgoes (the oldest remaining values _after_ lazy_scan_prune processing).The final values are set as the table's new relfrozenxid and newrelminmxid in pg_class at the end of each VACUUM. The oldest XID mightcome from a tuple's xmin, xmax, or xvac fields. It might even come fromone of the table's remaining MultiXacts.Final relfrozenxid values must still be >= FreezeLimit in an aggressiveVACUUM (FreezeLimit still acts as a lower bound on the final value thataggressive VACUUM can set relfrozenxid to). Since standard VACUUMsstill make no guarantees about advancing relfrozenxid, they might aswell set relfrozenxid to a value from well before FreezeLimit when theopportunity presents itself. In general standard VACUUMs may now setrelfrozenxid to any value > the original relfrozenxid and <= OldestXmin.Credit for the general idea of using the oldest extant XID to setpg_class.relfrozenxid at the end of VACUUM goes to Andres Freund.Author: Peter Geoghegan <pg@bowt.ie>Reviewed-By: Andres Freund <andres@anarazel.de>Reviewed-By: Robert Haas <robertmhaas@gmail.com>Discussion:https://postgr.es/m/CAH2-WzkymFbz6D_vL+jmqSn_5q1wsFvFrE+37yLgL_Rkfd6Gzg@mail.gmail.com
1 parent05023a2 commit0b018fa

File tree

13 files changed

+717
-305
lines changed

13 files changed

+717
-305
lines changed

‎doc/src/sgml/maintenance.sgml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -586,11 +586,11 @@
586586
statistics in the system tables <structname>pg_class</structname> and
587587
<structname>pg_database</structname>. In particular,
588588
the <structfield>relfrozenxid</structfield> column of a table's
589-
<structname>pg_class</structname> row contains thefreeze cutoff XID that was used
590-
bythelast aggressive<command>VACUUM</command>forthattable. All rows
591-
inserted by transactions with XIDs older than this cutoff XID are
592-
guaranteed to have been frozen. Similarly,
593-
the<structfield>datfrozenxid</structfield> column of a database's
589+
<structname>pg_class</structname> row contains theoldest remaining unfrozen
590+
XID attheend of the most recent<command>VACUUM</command> thatsuccessfully
591+
advanced <structfield>relfrozenxid</structfield> (typically the most recent
592+
aggressive VACUUM). Similarly, the
593+
<structfield>datfrozenxid</structfield> column of a database's
594594
<structname>pg_database</structname> row is a lower bound on the unfrozen XIDs
595595
appearing in that database &mdash; it is just the minimum of the
596596
per-table <structfield>relfrozenxid</structfield> values within the database.
@@ -638,7 +638,11 @@ SELECT datname, age(datfrozenxid) FROM pg_database;
638638
set <literal>age(relfrozenxid)</literal> to a value just a little more than the
639639
<varname>vacuum_freeze_min_age</varname> setting
640640
that was used (more by the number of transactions started since the
641-
<command>VACUUM</command> started). If no <structfield>relfrozenxid</structfield>-advancing
641+
<command>VACUUM</command> started). <command>VACUUM</command>
642+
will set <structfield>relfrozenxid</structfield> to the oldest XID
643+
that remains in the table, so it's possible that the final value
644+
will be much more recent than strictly required.
645+
If no <structfield>relfrozenxid</structfield>-advancing
642646
<command>VACUUM</command> is issued on the table until
643647
<varname>autovacuum_freeze_max_age</varname> is reached, an autovacuum will soon
644648
be forced for the table.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp