amcheck: Fix ordering bug in update_cached_xid_range()
authorAndres Freund <[email protected]>
Sat, 11 Mar 2023 22:12:51 +0000 (14:12 -0800)
committerAndres Freund <[email protected]>
Sat, 11 Mar 2023 22:12:51 +0000 (14:12 -0800)
commit16327240da29b70e41a65d49212b31da9a94e177
tree8531d28cff4dfac6fa406112c78a270448d9a874
parent4e633016abe9b82053aafb2fe9d3317add73f74d
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 <[email protected]>
Discussion: https://postgr.es/m/20230108002923[email protected]
Backpatch: 14-, where heapam verification was introduced
contrib/amcheck/verify_heapam.c