Re: The same 2PC data maybe recovered twice - Mailing list pgsql-bugs

From Michael Paquier
Subject Re: The same 2PC data maybe recovered twice
Date
Msg-id aG4bu_50RhPGdwSK@paquier.xyz
Whole thread Raw
In response to Re: The same 2PC data maybe recovered twice  ("suyu.cmj" <mengjuan.cmj@alibaba-inc.com>)
List pgsql-bugs
On Wed, Jul 09, 2025 at 01:51:03PM +0800, suyu.cmj wrote:
> Currently, since restoreTwoPhaseData() is the only function that
> restores 2PC transactions from disk before the recovery starts,
> after reaching a consistent state, the 2PC transactions are only
> added from the WAL. Under normal circumstances, there should not be
> any corresponding 2PC files on the storage at that point. Therefore,
> I prefer to perform the file access checks only when the server has
> not yet reached a consistent state. Once consistency has been
> reached, if a duplicate 2PC transaction is added, it will directly
> result in an error in the subsequent replay logic.

There is a bit more going on in this code that needs to be fixed.

Please see the following thread, that also relates to the state of the
2PC recovery code when we read them from disk at the beginning of
recovery, with the bottom part being the most relevant:
https://www.postgresql.org/message-id/Z5sd5O9JO7NYNK-C%40paquier.xyz
--
Michael

Attachment

pgsql-bugs by date:

Previous
From: "Hayato Kuroda (Fujitsu)"
Date:
Subject: RE: Unexpected behavior when setting "idle_replication_slot_timeout"
Next
From: Laurenz Albe
Date:
Subject: Re: Unexpected behavior when setting "idle_replication_slot_timeout"