Re: An improvement of ProcessTwoPhaseBuffer logic
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Vitaly Davydov <v.davydov@postgrespro.ru>
Cc: pgsql-hackers@postgresql.org
Date: 2025-01-28T05:02:43Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Integrate FullTransactionIds deeper into two-phase code
- 62a17a92833d 19 (unreleased) landed
-
Merge copies of converting an XID to a FullTransactionId.
- 1587f7b9fc1a 17.3 landed
- 81772a495ec9 18.0 landed
-
Revert recent changes related to handling of 2PC files at recovery
- 4d6d7bdc0642 13.19 landed
- 060f9f5ea537 14.16 landed
- 42c900d31e57 15.11 landed
- 4d72357c40ee 16.7 landed
- d1bf86a62211 17.3 landed
- a6c70f68cdeb 18.0 landed
-
Fix failures with incorrect epoch handling for 2PC files at recovery
- c3de0f9eed38 17.3 landed
- 7e125b20eed6 18.0 landed
On Wed, Jan 22, 2025 at 03:45:30PM +0300, Vitaly Davydov wrote: > I hope you may find this patch worth to consider. You may consider > this patch as one more step to a complete migration to > FullTransactionId in twophase.c for 17+ versions. Heavy refactorings are only going to be something for 18~, as far as my analysis goes. > I assume that if a xid is coming from in-memory states, it has to be > in the current xid range. Based on this assumption, I would conclude > that if the xid is coming via the interface (external) functions > which are defined in twophase.h, AdjustToFullTransactionId can be > applied to such xid. > > There is another story when we define xid from two phase file names, > when reading pg_twophase directory. In 17+ twophase file names was > changed to contain tx epoch as well. Once we work with twophase > files, we have to use full xids. Function AdjustToFullTransactionId > is not applicable in this case, because pg_twophase directory may > contain any garbage files with future or past full xids which are > outside of the current range. > > Based on these assumptions (AdjustToFullTransactionId or use full > xids) some other functions were modified as shown in the patch. Yeah, we need to do something here. Anyway, I don't think what you are posting here is ambitious enough for two reasons: - We should try to limit the number of times where we do maths between TransactionId and FullTransactionId. It's going to be cleaner if we make the 2PC interface require FullTransactionIds all the time (note that the point of storing a fxid or an xid is different). Noah's proposal at [1] is much closer to the long-term picture that would look adapted. - The CLOG lookups that can happen in ProcessTwoPhaseBuffer() during recovery while a consistent state is not reached are still possible (planning to start a different thread about this specific issue). [1]: https://www.postgresql.org/message-id/20250116205254.65.nmisch@google.com -- Michael