Re: [HACKERS] Two phase commit in ECPG

Lists: pgsql-bugspgsql-hackers
From: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, pgsql-bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Two phase commit in ECPG
Date: 2017-03-02 17:16:32
Message-ID: CAD21AoDZTi+C06oF3-i15r-ZMx+cCx7PjK_m859YKA-08CbyHw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

Hi all,

I found that ecpg has not been supporting COMMIT PREPARED and ROLLBACK
PREPARED since version 9.0.2.
For example, if the test code does,
EXEC SQL BEGIN;
EXEC SQL INSERT INTO t1 VALUES(1);
EXEC SQL PREPARE TRANSACTION 'gxid';
EXEC SQL COMMIT PREPARED 'gxid';
I got error "COMMIT PREPARED cannot run inside a transaction block".

This cause is that the "begin transaction" is issued automatically
before executing COMMIT PREPARED if we're not in auto commit. The
Commit 816b008eaf1a1ff1069f3bafff363a9a8bf04a21 fixed bug of incorrect
status calculation but at the same time it became the cause of this
behavior.
Is this a bug?

Attached 001 patch fixes this issue and add regression test for two
phase commit in ecpg.

Also, in spite of ecpg identifies these two commands as transaction
command similar to other transaction commands like commit and rollback
the documentation doesn't mentioned about these at all. Attached 002
patch add description about these to documentation.

Regards,

--
Masahiko Sawada
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center

Attachment Content-Type Size
002_ecpg_commit_rollback_prepared_doc.patch application/octet-stream 934 bytes
001_ecpg_commit_rollback_prepared.patch application/octet-stream 7.9 KB

From: Michael Meskes <meskes(at)postgresql(dot)org>
To: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, pgsql-bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: [HACKERS] Two phase commit in ECPG
Date: 2017-03-03 19:11:32
Message-ID: [email protected]
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

Dear Sawada-san,

> This cause is that the "begin transaction" is issued automatically
> before executing COMMIT PREPARED if we're not in auto commit. The
> Commit 816b008eaf1a1ff1069f3bafff363a9a8bf04a21 fixed bug of
> incorrect
> status calculation but at the same time it became the cause of this
> behavior.
> Is this a bug?

I'd say so, yes.

As soon as I find time I'll get to it including back porting your
patch.

Thank you very much for spotting and fixing.

Michael
--
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Meskes at (Debian|Postgresql) dot Org
Jabber: michael at xmpp dot meskes dot org
VfL Borussia! Força Barça! SF 49ers! Use Debian GNU/Linux, PostgreSQL


From: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
To: Michael Meskes <meskes(at)postgresql(dot)org>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, pgsql-bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: Two phase commit in ECPG
Date: 2017-03-07 10:55:58
Message-ID: CAD21AoDta1-HQ5KAF6K=kTZz5Lxr-D2dHYixqwc=ZYp5AMLb3Q@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

On Sat, Mar 4, 2017 at 4:11 AM, Michael Meskes <meskes(at)postgresql(dot)org> wrote:
> Dear Sawada-san,
>
>> This cause is that the "begin transaction" is issued automatically
>> before executing COMMIT PREPARED if we're not in auto commit. The
>> Commit 816b008eaf1a1ff1069f3bafff363a9a8bf04a21 fixed bug of
>> incorrect
>> status calculation but at the same time it became the cause of this
>> behavior.
>> Is this a bug?
>
> I'd say so, yes.
>
> As soon as I find time I'll get to it including back porting your
> patch.

Thanks

Previous 002 patch lacked to add describing PREPARE TRANSACTION.
Attached updated 002 patch.

Regards,

--
Masahiko Sawada
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center

Attachment Content-Type Size
002_ecpg_commit_rollback_prepared_doc_v2.patch application/octet-stream 1.2 KB

From: Michael Meskes <meskes(at)postgresql(dot)org>
To: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, pgsql-bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: [HACKERS] Two phase commit in ECPG
Date: 2017-03-13 20:05:41
Message-ID: [email protected]
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

> Previous 002 patch lacked to add describing PREPARE TRANSACTION.
> Attached updated 002 patch.

I just committed both patches and a backport of the bug fix itself.
Thanks again for finding and fixing.

Michael
--
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Meskes at (Debian|Postgresql) dot Org
Jabber: michael at xmpp dot meskes dot org
VfL Borussia! Força Barça! SF 49ers! Use Debian GNU/Linux, PostgreSQL


From: Kuntal Ghosh <kuntalghosh(dot)2007(at)gmail(dot)com>
To: Michael Meskes <meskes(at)postgresql(dot)org>
Cc: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, pgsql-bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: [HACKERS] Two phase commit in ECPG
Date: 2017-03-17 09:17:56
Message-ID: CAGz5QC+0-dPU1Ggf7121ePbEOyV9nAt2veZv+Tu3dSsqXmhvNg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

On Tue, Mar 14, 2017 at 1:35 AM, Michael Meskes <meskes(at)postgresql(dot)org> wrote:
>> Previous 002 patch lacked to add describing PREPARE TRANSACTION.
>> Attached updated 002 patch.
>
> I just committed both patches and a backport of the bug fix itself.
> Thanks again for finding and fixing.
Regression tests for sql/twophase is failing while performing the test
with make installcheck.
+ [NO_PID]: ecpg_check_PQresult on line 32: bad response - ERROR:
prepared transactions are disabled
+ HINT: Set max_prepared_transactions to a nonzero value.

Setting max_prepared_transactions accordingly fixes the issue. But,
I'm not sure whether this test should be performed by installcheck by
default or should only be performed by make
installcheck-prepared-txns.

--
Thanks & Regards,
Kuntal Ghosh
EnterpriseDB: http://www.enterprisedb.com


From: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
To: Kuntal Ghosh <kuntalghosh(dot)2007(at)gmail(dot)com>
Cc: Michael Meskes <meskes(at)postgresql(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, pgsql-bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: Two phase commit in ECPG
Date: 2017-03-17 11:04:38
Message-ID: CAD21AoDoCCLVpADeo60UhiZv5LbGnU_QeAp2r+n42p_cdeW_Pg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

On Fri, Mar 17, 2017 at 12:17 PM, Kuntal Ghosh
<kuntalghosh(dot)2007(at)gmail(dot)com> wrote:
> On Tue, Mar 14, 2017 at 1:35 AM, Michael Meskes <meskes(at)postgresql(dot)org> wrote:
>>> Previous 002 patch lacked to add describing PREPARE TRANSACTION.
>>> Attached updated 002 patch.
>>
>> I just committed both patches and a backport of the bug fix itself.
>> Thanks again for finding and fixing.
> Regression tests for sql/twophase is failing while performing the test
> with make installcheck.
> + [NO_PID]: ecpg_check_PQresult on line 32: bad response - ERROR:
> prepared transactions are disabled
> + HINT: Set max_prepared_transactions to a nonzero value.
>
> Setting max_prepared_transactions accordingly fixes the issue. But,
> I'm not sure whether this test should be performed by installcheck by
> default or should only be performed by make
> installcheck-prepared-txns.
>

Thank you for pointing out.
Yeah, I agree that the twophase regression test should not be
performed by default as long as the default value of
max_prepared_transactions is 0. Similar to this, the isolation check
regression test does same thing. Attached patch removes sql/twophase
from schedule file and add new type of regression test.

Regards,

--
Masahiko Sawada
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center

Attachment Content-Type Size
ecpg_prepared_txns_test.patch application/octet-stream 1.4 KB

From: Kuntal Ghosh <kuntalghosh(dot)2007(at)gmail(dot)com>
To: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Cc: Michael Meskes <meskes(at)postgresql(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, pgsql-bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: [HACKERS] Two phase commit in ECPG
Date: 2017-03-17 11:44:53
Message-ID: CAGz5QCKH2Hc__E7GY1MdZajUCtjFg-fUby+Hob3GUKx1AaRExw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

On Fri, Mar 17, 2017 at 4:34 PM, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> wrote:
> On Fri, Mar 17, 2017 at 12:17 PM, Kuntal Ghosh
> <kuntalghosh(dot)2007(at)gmail(dot)com> wrote:
>> On Tue, Mar 14, 2017 at 1:35 AM, Michael Meskes <meskes(at)postgresql(dot)org> wrote:
>>>> Previous 002 patch lacked to add describing PREPARE TRANSACTION.
>>>> Attached updated 002 patch.
>>>
>>> I just committed both patches and a backport of the bug fix itself.
>>> Thanks again for finding and fixing.
>> Regression tests for sql/twophase is failing while performing the test
>> with make installcheck.
>> + [NO_PID]: ecpg_check_PQresult on line 32: bad response - ERROR:
>> prepared transactions are disabled
>> + HINT: Set max_prepared_transactions to a nonzero value.
>>
>> Setting max_prepared_transactions accordingly fixes the issue. But,
>> I'm not sure whether this test should be performed by installcheck by
>> default or should only be performed by make
>> installcheck-prepared-txns.
>>
>
> Thank you for pointing out.
> Yeah, I agree that the twophase regression test should not be
> performed by default as long as the default value of
> max_prepared_transactions is 0. Similar to this, the isolation check
> regression test does same thing. Attached patch removes sql/twophase
> from schedule file and add new type of regression test.
>
The patch looks good. I've performed installcheck and
installcheck-prepared-txns. It's working as it should be.

--
Thanks & Regards,
Kuntal Ghosh
EnterpriseDB: http://www.enterprisedb.com


From: Michael Meskes <meskes(at)postgresql(dot)org>
To: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, Kuntal Ghosh <kuntalghosh(dot)2007(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, pgsql-bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: Two phase commit in ECPG
Date: 2017-03-17 14:50:48
Message-ID: [email protected]
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

> Thank you for pointing out.
> Yeah, I agree that the twophase regression test should not be
> performed by default as long as the default value of
> max_prepared_transactions is 0. Similar to this, the isolation check
> regression test does same thing. Attached patch removes sql/twophase
> from schedule file and add new type of regression test.

Would it be possible to include it in "make check"? Any check that
needs manual interaction will not be executed nearly is often as the
others and become much less useful imo.

Michael
--
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Meskes at (Debian|Postgresql) dot Org
Jabber: michael at xmpp dot meskes dot org
VfL Borussia! Força Barça! SF 49ers! Use Debian GNU/Linux, PostgreSQL


From: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
To: Michael Meskes <meskes(at)postgresql(dot)org>
Cc: Kuntal Ghosh <kuntalghosh(dot)2007(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, pgsql-bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: Two phase commit in ECPG
Date: 2017-03-17 22:01:31
Message-ID: CAD21AoDPmy=uSVcY1=FXuG4KE_dBWAF-mYgQp5DsfnLAF88X7g@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

On Fri, Mar 17, 2017 at 5:50 PM, Michael Meskes <meskes(at)postgresql(dot)org> wrote:
>> Thank you for pointing out.
>> Yeah, I agree that the twophase regression test should not be
>> performed by default as long as the default value of
>> max_prepared_transactions is 0. Similar to this, the isolation check
>> regression test does same thing. Attached patch removes sql/twophase
>> from schedule file and add new type of regression test.
>
> Would it be possible to include it in "make check"? Any check that
> needs manual interaction will not be executed nearly is often as the
> others and become much less useful imo.
>

Yes. I added two-phase commit test to "make check" test schedule while
adding new two type of test.

Regards,

--
Masahiko Sawada
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center

Attachment Content-Type Size
ecpg_prepared_txns_test_v2.patch application/octet-stream 1.9 KB

From: Michael Meskes <meskes(at)postgresql(dot)org>
To: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Cc: Kuntal Ghosh <kuntalghosh(dot)2007(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, pgsql-bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: Two phase commit in ECPG
Date: 2017-03-18 09:37:48
Message-ID: [email protected]
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-bugs pgsql-hackers

> Yes. I added two-phase commit test to "make check" test schedule
> while
> adding new two type of test.

Thank you, committed.

Michael
--
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Meskes at (Debian|Postgresql) dot Org
Jabber: michael at xmpp dot meskes dot org
VfL Borussia! Força Barça! SF 49ers! Use Debian GNU/Linux, PostgreSQL