pgsql: amcheck: Fix ordering bug in update_cached_xid_range() - Mailing list pgsql-committers

From Andres Freund
Subject pgsql: amcheck: Fix ordering bug in update_cached_xid_range()
Date
Msg-id E1pb87H-0034zm-NM@gemulon.postgresql.org
Whole thread Raw
List 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.dilger@enterprisedb.com>
Discussion: https://postgr.es/m/20230108002923.cyoser3ttmt63bfn@awork3.anarazel.de
Backpatch: 14-, where heapam verification was introduced

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/16327240da29b70e41a65d49212b31da9a94e177

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


pgsql-committers by date:

Previous
From: Andrew Dunstan
Date:
Subject: Re: pgsql: Add standard collation UNICODE
Next
From: Andres Freund
Date:
Subject: pgsql: pg_amcheck: Minor test speedups