pgsql: Don't test HEAP_XMAX_INVALID when freezing xmax.

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Don't test HEAP_XMAX_INVALID when freezing xmax.
Date: 2022-11-23 18:50:31
Message-ID: E1oxupK-000WwJ-Ud@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Don't test HEAP_XMAX_INVALID when freezing xmax.

We shouldn't ever need to rely on whether HEAP_XMAX_INVALID is set in
t_infomask when considering whether or not an xmax should be deemed
already frozen, since that status flag is just a hint. The only
acceptable representation for an "xmax_already_frozen" raw xmax field is
the transaction ID value zero (also known as InvalidTransactionId).

Adjust code that superficially appeared to rely on HEAP_XMAX_INVALID to
make the rule about xmax_already_frozen clear. Also avoid needlessly
rereading the tuple's raw xmax.

Oversight in bugfix commit d2599ecf. There is no evidence that this
ever led to incorrect behavior, so no backpatch. The worst consequence
of this bug was that VACUUM could hypothetically fail to notice and
report on certain kinds of corruption, which seems fairly benign.

Author: Peter Geoghegan <pg(at)bowt(dot)ie>
Discussion: https://postgr.es/m/CAH2-Wzkh3DMCDRPfhZxj9xCq9v3WmzvmbiCpf1dNKUBPadhCbQ@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/02d647bbf0576ebb87f9dc24e1db4dd034f04048

Modified Files
--------------
src/backend/access/heap/heapam.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Geoghegan 2022-11-23 19:11:48 pgsql: Simplify vacuum_set_xid_limits() signature.
Previous Message Greg Stark 2022-11-23 16:58:41 Re: pgsql: Prevent instability in contrib/pageinspect's regression test.