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 ZLT0+RtNqRNqXKUz@paquier.xyz
Whole thread Raw
In response to Re: The same 2PC data maybe recovered twice  ("suyu.cmj" <mengjuan.cmj@alibaba-inc.com>)
Responses Re: The same 2PC data maybe recovered twice
List pgsql-bugs
On Mon, Jul 17, 2023 at 02:26:56PM +0800, suyu.cmj wrote:
> Yes, the method you proposed is simpler and more
> efficient. Following your idea, I have modified the corresponding
> patch, hope you can review it when you have time.

I'll double-check that tomorrow, but yes, that's basically what I had
in mind.  Thanks for the patch!

+   char        path[MAXPGPATH];
+   struct stat stat_buf;
These two variables can be declared in the code block added by the
patch where start_lsn is valid.

+    ereport(FATAL,
+            (errmsg("found unexpected duplicate two-phase
transaction:%u in pg_twophase, check for data correctness.",
+                    hdr->xid)));

The last part of this sentence has no need to be IMO, because it is
misleading when building without assertions.  How about a single
FATAL/WARNING like that:
- errmsg: "could not recover two-phase state file for transaction %u"
- errdetail: "Two-phase state file has been found in WAL record %X/%X
but this transaction has already been restored from disk."

Then a WARNING simply means that we've skipped the record entirely.
--
Michael

Attachment

pgsql-bugs by date:

Previous
From: Laurenz Albe
Date:
Subject: Re: Query returns error "there is no parameter $1" but server logs that there are two parameters supplied
Next
From: Michael Paquier
Date:
Subject: Re: BUG #18025: Probably we need to change behaviour of the checkpoint failures in PG