pgsql: amcheck: Fix ordering bug in update_cached_xid_range()

From: Andres Freund <andres(at)anarazel(dot)de>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: amcheck: Fix ordering bug in update_cached_xid_range()
Date: 2023-03-11 22:55:08
Message-ID: E1pb87H-0034zw-QU@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

amcheck: Fix ordering bug in update_cached_xid_range()

The initialization order in update_cached_xid_range() was wrong, calling
FullTransactionIdFromXidAndCtx() before setting
->next_xid. FullTransactionIdFromXidAndCtx() uses ->next_xid.

In most situations this will not cause visible issues, because the next call
to update_cached_xid_range() will use a less wrong ->next_xid. It's rare that
xids advance fast enough for this to be a problem.

Found while adding more asserts to the 64bit xid infrastructure.

Reviewed-by: Mark Dilger <mark(dot)dilger(at)enterprisedb(dot)com>
Discussion: https://postgr.es/m/20230108002923.cyoser3ttmt63bfn@awork3.anarazel.de
Backpatch: 14-, where heapam verification was introduced

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/a42f515d6b45ea19b96fb2868d8acb77251d911d

Modified Files
--------------
contrib/amcheck/verify_heapam.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Andres Freund 2023-03-11 23:44:39 pgsql: pg_amcheck: Minor test speedups
Previous Message Andrew Dunstan 2023-03-11 22:42:59 Re: pgsql: Add standard collation UNICODE