From: Peter Geoghegan <pg@bowt.ie>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Set relfrozenxid to oldest extant XID seen by VACUUM.
Date: Sun, 03 Apr 2022 16:57:55 +0000
Message-ID: <E1nb3Y3-0009q6-5y@gemulon.postgresql.org> (raw)
Set relfrozenxid to oldest extant XID seen by VACUUM.
When VACUUM set relfrozenxid before now, it set it to whatever value was
used to determine which tuples to freeze -- the FreezeLimit cutoff.
This approach was very naive. The relfrozenxid invariant only requires
that new relfrozenxid values be <= the oldest extant XID remaining in
the table (at the point that the VACUUM operation ends), which in
general might be much more recent than FreezeLimit.
VACUUM now carefully tracks the oldest remaining XID/MultiXactId as it
goes (the oldest remaining values _after_ lazy_scan_prune processing).
The final values are set as the table's new relfrozenxid and new
relminmxid in pg_class at the end of each VACUUM. The oldest XID might
come from a tuple's xmin, xmax, or xvac fields. It might even come from
one of the table's remaining MultiXacts.
Final relfrozenxid values must still be >= FreezeLimit in an aggressive
VACUUM (FreezeLimit still acts as a lower bound on the final value that
aggressive VACUUM can set relfrozenxid to). Since standard VACUUMs
still make no guarantees about advancing relfrozenxid, they might as
well set relfrozenxid to a value from well before FreezeLimit when the
opportunity presents itself. In general standard VACUUMs may now set
relfrozenxid to any value > the original relfrozenxid and <= OldestXmin.
Credit for the general idea of using the oldest extant XID to set
pg_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
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/0b018fabaaba77e39539ce7eb71e34a90ceb0825
Modified Files
--------------
doc/src/sgml/maintenance.sgml | 16 +-
src/backend/access/heap/heapam.c | 332 +++++++++++++++------
src/backend/access/heap/vacuumlazy.c | 156 ++++++----
src/backend/commands/cluster.c | 11 +-
src/backend/commands/vacuum.c | 39 ++-
src/include/access/heapam.h | 6 +-
src/include/access/heapam_xlog.h | 4 +-
src/include/commands/vacuum.h | 1 +
.../isolation/expected/vacuum-no-cleanup-lock.out | 189 ++++++++++++
src/test/isolation/expected/vacuum-reltuples.out | 67 -----
src/test/isolation/isolation_schedule | 2 +-
.../isolation/specs/vacuum-no-cleanup-lock.spec | 150 ++++++++++
src/test/isolation/specs/vacuum-reltuples.spec | 49 ---
13 files changed, 717 insertions(+), 305 deletions(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: pg@bowt.ie
Subject: Re: pgsql: Set relfrozenxid to oldest extant XID seen by VACUUM.
In-Reply-To: <E1nb3Y3-0009q6-5y@gemulon.postgresql.org>
References: <E1nb3Y3-0009q6-5y@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox