Re: raise ERROR between EndPrepare and PostPrepare_Locks causes ROLLBACK 2pc PAINC - Mailing list pgsql-hackers

From Andy Fan
Subject Re: raise ERROR between EndPrepare and PostPrepare_Locks causes ROLLBACK 2pc PAINC
Date
Msg-id 87h5q468us.fsf@163.com
Whole thread Raw
In response to raise ERROR between EndPrepare and PostPrepare_Locks causes ROLLBACK 2pc PAINC  (Andy Fan <zhihuifan1213@163.com>)
Responses Re: raise ERROR between EndPrepare and PostPrepare_Locks causes ROLLBACK 2pc PAINC
List pgsql-hackers
Andy Fan <zhihuifan1213@163.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




pgsql-hackers by date:

Previous
From: Tatsuo Ishii
Date:
Subject: Re: Add GoAway protocol message for graceful but fast server shutdown/switchover
Next
From: Amit Langote
Date:
Subject: Re: Eliminating SPI / SQL from some RI triggers - take 3