public inbox for [email protected]
help / color / mirror / Atom feedFrom: Andy Fan <[email protected]>
To: PostgreSQL Hackers <[email protected]>
Subject: raise ERROR between EndPrepare and PostPrepare_Locks causes ROLLBACK 2pc PAINC
Date: Tue, 24 Mar 2026 18:04:43 +0800
Message-ID: <[email protected]> (raw)
Hi,
With the following hack in PrepareTransaction:
@@ -2697,6 +2697,8 @@ PrepareTransaction(void)
*/
EndPrepare(gxact);
+ elog(ERROR, "some error");
+
/*
* Now we clean up backend-internal state and release internal resources.
*/
Then we can do the following test:
CREATE TABLE t(a int);
begin;
insert into t values(1);
prepare transaction 'foo';
ERROR: some error. // before the lock transfer
rollback prepared 'foo';
PANIC: failed to re-find shared lock object // because lock is released
when ERROR.
One of the methods in my mind is to delay the END_CRIT_SECTION until
PostPrepare_Locks is finished, then the above case would become:
(1) ERROR
(2) Since CRIT_SECTION, error become to PAINC.
(3) client get PAINC and know the prepare failure.
(4). server does crash-recovery and the [2pc is recovered] (even client
has get error).
(5). We (as postgresql developer) should expected 2pc coordinator to run
"rollback prepared foo" anyway even the prepared failure and handle the
case where 'foo' doesn't exist.
I don't think it is a good solution because the mismatch between
(3) and (4). and the error handle in step (5).
This is not a real case to me, I just run into this with a
fault-injection testing framework. So after all is this something
which deserves a fix?
--
Best Regards
Andy Fan
view thread (4+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: raise ERROR between EndPrepare and PostPrepare_Locks causes ROLLBACK 2pc PAINC
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox