Re: raise ERROR between EndPrepare and PostPrepare_Locks causes ROLLBACK 2pc PAINC

From: Andy Fan <zhihuifan1213(at)163(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: raise ERROR between EndPrepare and PostPrepare_Locks causes ROLLBACK 2pc PAINC
Date: 2026-03-25 00:39:07
Message-ID: 87h5q468us.fsf@163.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Andy Fan <zhihuifan1213(at)163(dot)com> writes:

> 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.

I found a similar but not exactly same case at 2014 [1] which
might be helpful to recall a boarder understanding on this area.

[1] https://www.postgresql.org/message-id/534AF601.1030007%40vmware.com

--
Best Regards
Andy Fan

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Langote 2026-03-25 00:41:11 Re: Eliminating SPI / SQL from some RI triggers - take 3
Previous Message Tatsuo Ishii 2026-03-25 00:36:20 Re: Add GoAway protocol message for graceful but fast server shutdown/switchover