Re: An improvement of ProcessTwoPhaseBuffer logic

From: Давыдов Виталий <v(dot)davydov(at)postgrespro(dot)ru>
To: "Michael Paquier" <michael(at)paquier(dot)xyz>
Cc: "pgsql-hackers" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: An improvement of ProcessTwoPhaseBuffer logic
Date: 2024-12-26 15:11:25
Message-ID: 152dda-676d7200-61-659acf0@102179597
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Michael,

> Here are two patches to address both issues:

Thank you for the preparing the patches and test simplification. My bad, I overcompilcated it.

I concerned about twophase file name generation. The function TwoPhaseFilePath() is pretty straitforward and unambiguous in 16 and earlier versions. The logic of this function in 17+ seems to be more complex. I do not understand it clearly. But, I guess, it will work incorrectly after turning to a newer epoch, because the epoch is calculated from TransamVariables->nextXid, but not from problem xid. The same problem may happen if we are in epoch 1 or greater. It will produce a wrong file name, because the epoch will be obtained from the last xid, not from file name xid. In another words, the function AdjustToFullTransactionId assumes that if xid > TransamVariables->nextXid, then the xid from the previous epoch. I may be not the case in our scenario.

> I suspect that this can be still dangerous as-is while complicating the code with more possible paths for the removal of the 2PC files
Agree, but we may pass file name into TwoPhaseFilePath if any, instead of creation of two functions as in the patch. The cost - two new if conditions. Using file names is pretty safe. Once we read the file and extract xid from its name, just pass this file name to TwoPhaseFilePath(). If not, try to generate it. Anyway, I do not insist on it, just try to discuss.

With best regards,
Vitaly

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Treat 2024-12-26 15:23:41 Re: PoC: history of recent vacuum/checkpoint runs (using new hooks)
Previous Message Benoit Lobréau 2024-12-26 14:25:46 Re: Logging parallel worker draught