From: Heikki Linnakangas <heikki@enterprisedb.com>
To: Kris Jurka <books@ejurka.com>
Cc: joël Winteregg <joel.winteregg@gmail.com>
Cc: pgsql-jdbc@postgresql.org
Cc: Ludovic Orban <ludovic.orban@gmail.com>
Subject: Re: XAResource implementation
Date: Tue, 13 Nov 2007 22:52:35 +0000
Message-ID: <473A2AB3.2040701@enterprisedb.com> (raw)
In-Reply-To: <Pine.BSO.4.64.0711131301130.21066@leary.csoft.net>
References: <1193736934.5565.40.camel@hatman>
<4727420A.4060209@enterprisedb.com>
<1193757567.5565.46.camel@hatman>
<47275A50.2050201@enterprisedb.com>
<47275BA6.3030200@enterprisedb.com>
<1194819933.5545.100.camel@hatman>
<47382418.604@enterprisedb.com>
<1194939010.5505.24.camel@hatman>
<4739D5FB.9080202@enterprisedb.com>
<Pine.BSO.4.64.0711131301130.21066@leary.csoft.net>
Kris Jurka wrote:
>
>
> On Tue, 13 Nov 2007, Heikki Linnakangas wrote:
>
>> It looks like there is indeed a bug in the Postgres driver. I believe
>> it was introduced by the recent changes to keep the connection in
>> autocommit mode when no XA-transaction is in progress.
>>
>> It's this call sequence that borks it up:
>>
>> xares.start()
>> conn = xares.getConnection()
>> // do stuff
>> conn.close();
>> conn = xares.getConnection()
>> // do more stuff
>> xares.end()
>> xares.commit()
>>
>> The 2nd getConnection call inadvertently commits the transaction, and
>> opens another one.
>
> When I raised this issue, you said it can't/shouldn't happen. What's
> different now? It's still a bug in the driver, but is the calling code
> doing something it shouldn't?
>
> http://archives.postgresql.org/pgsql-jdbc/2007-06/msg00095.php
Oh, I had forgotten about that. The difference is the close() between
the getConnection()s.
I started having second doubts about that case you posted in June, so I
tested what Derby does if you call getConnection() twice, without a
close in between. You get an error ("Cannot close a connection while a
global transaction is still active."), so at least they consider it
incorrect as well.
Throwing an error in that case would be a nice thing for us to do as
well. Currently, we just silently rollback.
>> Patch attached. I also added a test for this in the test suite.
>
> transaction_timestamp() is an 8.2 feature, but since XA is an 8.1
> feature you should use now() instead. (No need for a new patch, I've
> updated mine here.)
Thanks!
--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: heikki@enterprisedb.com, books@ejurka.com, joel.winteregg@gmail.com, ludovic.orban@gmail.com
Subject: Re: XAResource implementation
In-Reply-To: <473A2AB3.2040701@enterprisedb.com>
References: <1193736934.5565.40.camel@hatman> <4727420A.4060209@enterprisedb.com> <1193757567.5565.46.camel@hatman> <47275A50.2050201@enterprisedb.com> <47275BA6.3030200@enterprisedb.com> <1194819933.5545.100.camel@hatman> <47382418.604@enterprisedb.com> <1194939010.5505.24.camel@hatman> <4739D5FB.9080202@enterprisedb.com> <Pine.BSO.4.64.0711131301130.21066@leary.csoft.net> <473A2AB3.2040701@enterprisedb.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox