Re: The same 2PC data maybe recovered twice
suyu.cmj <mengjuan.cmj@alibaba-inc.com>
From: "suyu.cmj" <mengjuan.cmj@alibaba-inc.com>
To: "Michael Paquier" <michael@paquier.xyz>
Cc: "pgsql-bugs" <pgsql-bugs@lists.postgresql.org>
Date: 2025-07-09T01:57:08Z
Lists: pgsql-bugs, pgsql-hackers
Hi, all. I would like to sync up on an issue I've recently encountered. Previously, the following logic was added to the PrepareRedoAdd() when fixing this 2PC recovery bug: ------------------------------------------------------------------ From:Michael Paquier <michael@paquier.xyz> Send Time:2023 Jul. 18 (Tue.) 13:14 To:"蔡梦娟(玊于)"<mengjuan.cmj@alibaba-inc.com> CC:"zhihui.fan1213"<zhihui.fan1213@gmail.com>; "pgsql-bugs"<pgsql-bugs@lists.postgresql.org> Subject:Re: The same 2PC data maybe recovered twice On Mon, Jul 17, 2023 at 05:20:00PM +0800, suyu.cmj wrote: > Thanks for the feedback! I have updated the patch, hope you can check it. I have looked at v3, and noticed that the stat() call is actually a bit incorrect in its error handling because it would miss any errors that happen when checking for the existence of the file. The only error that we should safely expect is ENOENT, for a missing entry. All the other had better fail like the other code paths restoring 2PC entries from the shared state. At the end, I have made the choice of relying only on access() to check the existence of the file as this is an internal place, simplified a bit the comment. Finally, I have made the choice to remove the assert-only check. After sleeping on it, it would have value in very limited cases while a bunch of recovery cases would take a hit, including developers with large 2PC setups, so there are a lot of downsides with limited upsides. -- Michael
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Fix recovery of 2PC transaction during crash recovery
- bc0581f8fb8b 11.21 landed
- d2ee542a2bbe 12.16 landed
- db59108a2b67 13.12 landed
- 442749100d34 14.9 landed
- a878eff6b4b9 15.4 landed
- f88bc9f38839 16.0 landed
- cb0cca188072 17.0 landed