Re: Race condition in TransactionIdIsInProgress
Robert Haas <robertmhaas@gmail.com>
From: Robert Haas <robertmhaas@gmail.com>
To: Konstantin Knizhnik <knizhnik@garret.ru>
Cc: PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2022-02-10T20:21:27Z
Lists: pgsql-hackers
On Thu, Feb 10, 2022 at 11:46 AM Konstantin Knizhnik <knizhnik@garret.ru> wrote: > Postgres first records state transaction in CLOG, then removes > transaction from procarray and finally releases locks. > But it can happen that transaction is marked as committed in CLOG, > XMAX_COMMITTED bit is set in modified tuple but > TransactionIdIsInProgress still returns true. As a result "t_xmin %u is > uncommitted in tuple (%u,%u) to be updated in table" > error is reported. This is exactly why the HeapTupleSatisfiesFOO() functions all test TransactionIdIsInProgress() first and TransactionIdDidCommit() only if it returns false. I don't think it's really legal to test TransactionIdDidCommit() without checking TransactionIdIsInProgress() first. And I bet that's exactly what this code is doing... -- Robert Haas EDB: http://www.enterprisedb.com
Commits
-
Fix visibility check when XID is committed in CLOG but not in procarray.
- 4822b4627261 10.22 landed
- b49889f3c0fa 11.17 landed
- af530898ebc8 12.12 landed
- 7ba325fd7fd4 13.8 landed
- e24615a0057a 14.5 landed
- adf6d5dfb209 15.0 landed
-
Fix possible HOT corruption when RECENTLY_DEAD changes to DEAD while pruning.
- 18b87b201f73 15.0 cited
-
Make TransactionIdIsInProgress check transam.c's single-item XID status cache
- 611b4393f22f 8.4.0 cited