Fix wrong logic in TransactionIdInRecentPast()

Alexander Korotkov <akorotkov@postgresql.org>

Commit: 18388291aab8038b6abb6a9109ab6763e7a5b630
Author: Alexander Korotkov <akorotkov@postgresql.org>
Date: 2024-02-09T10:39:42Z
Releases: 14.12
Fix wrong logic in TransactionIdInRecentPast()

The TransactionIdInRecentPast() should return false for all the transactions
older than TransamVariables->oldestClogXid.  However, the function contains
a bug in comparison FullTransactionId to TransactionID allowing full
transactions between nextXid - 2^32 and oldestClogXid - 2^31.

This commit fixes TransactionIdInRecentPast() by turning the oldestClogXid into
FullTransactionId first, then performing the comparison.

Backpatch to all supported versions.

Reported-by: Egor Chindyaskin
Bug: 18212
Discussion: https://postgr.es/m/18212-547307f8adf57262%40postgresql.org
Author: Karina Litskevich
Reviewed-by: Kyotaro Horiguchi
Backpatch-through: 12

Files

PathChange+/−
src/backend/utils/adt/xid8funcs.c modified +19 −11

Discussion