Hello hackers,

postgres=> select txid_status(txid_current() + 3);
ERROR:  transaction ID 627 is in the future
postgres=> select txid_status(txid_current() + 2);
ERROR:  transaction ID 627 is in the future
postgres=> select txid_status(txid_current() + 1);
 txid_status
-------------
 in progress
(1 row)

If you keep asking for txid_status(txid_current() + 1) in new
transactions, you eventually hit:

ERROR:  could not access status of transaction 32768
DETAIL:  Could not read from file "pg_xact/0000" at offset 8192: No error: 0.

I think the fix is:

--- a/src/backend/utils/adt/txid.c
+++ b/src/backend/utils/adt/txid.c
@@ -129,7 +129,7 @@ TransactionIdInRecentPast(uint64 xid_with_epoch,
TransactionId *extracted_xid)

        /* If the transaction ID is in the future, throw an error. */
        if (xid_epoch > now_epoch
-               || (xid_epoch == now_epoch && xid > now_epoch_last_xid))
+               || (xid_epoch == now_epoch && xid >= now_epoch_last_xid))
                ereport(ERROR,
                                (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
                                 errmsg("transaction ID %s is in the future",

-- 
Thomas Munro
https://enterprisedb.com


Reply via email to