Re: The same 2PC data maybe recovered twice

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: "suyu(dot)cmj" <mengjuan(dot)cmj(at)alibaba-inc(dot)com>
Cc: "zhihui(dot)fan1213" <zhihui(dot)fan1213(at)gmail(dot)com>, pgsql-bugs <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: The same 2PC data maybe recovered twice
Date: 2023-07-17 07:59:53
Message-ID: ZLT0+RtNqRNqXKUz@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

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

In response to

Responses

Browse pgsql-bugs by date

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

Browse pgsql-hackers by date

  From Date Subject
Next Message Daniel Verite 2023-07-17 08:10:19 Re: EBCDIC sorting as a use case for ICU rules
Previous Message Alvaro Herrera 2023-07-17 07:37:41 Re: CommandStatus from insert returning when using a portal.