pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: joël Winteregg <joel.winteregg@gmail.com>
To: Heikki Linnakangas <heikki@enterprisedb.com>
Cc: pgsql-jdbc@postgresql.org
Cc: Ludovic Orban <ludovic.orban@gmail.com>
Subject: Re: XAResource implementation
Date: Tue, 13 Nov 2007 21:23:31 +0100
Message-ID: <1194985411.5533.6.camel@hatman> (raw)
In-Reply-To: <4739D5FB.9080202@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>

Hello Heikki,

Many thanks for these informations !

> Patch attached. I also added a test for this in the test suite.

Really cool !

> Can you check that this fixes the issue for you, please? I can send you 
> a patched jar if you don't have build environment, let me know if you 
> need it.

Yes, that would be great (easier) to have it as a patched jar. Then, I will provide you a feedback about its behavior in my application... 

Many many thanks for your support !

Joël


On Tue, 2007-11-13 at 16:51 +0000, Heikki Linnakangas wrote:
> joël Winteregg wrote:
> > Many thanks for your answer and for the time you took to do some
> > testing ! As you can see I put Ludovic Orban as Cc because he is the BTM
> > developer and he seems to be interested to this issue too...
> > 
> >> Hmm. I downloaded the BTM newUserDemo.zip and modified it to run with 
> >> Postgres, and to run two queries in same transaction. Works for me.
> >>
> > 
> > Ah Yes, you're right, your transaction just looks perfect !
> > 
> >> Attached is the modified Test.java I used. To run:
> >> 0. Download newUserDemo.zip from 
> >> http://docs.codehaus.org/display/BTM/NewUserGuide
> >> 1. Put postgresql.jar in newUserDemo/lib
> >> 2. Copy the attached Test.java to newUserDemo/src/jtatest
> >> 3. Modify database/username/password in Test.java if necessary
> >> 4. Run the CREATE TABLE from derby-create.sql
> >>
> >> Here's what I get in the Postgres log, with log_statements='all':
> >>
> >> LOG:  execute <unnamed>: SELECT gid FROM pg_prepared_xacts
> >> LOG:  execute S_1: BEGIN
> >> LOG:  execute <unnamed>: insert into messages(content) values ($1)
> >> DETAIL:  parameters: $1 = 'hello, world!'
> >> LOG:  execute S_2: COMMIT
> >> LOG:  execute S_1: BEGIN
> >> LOG:  execute <unnamed>: select content from messages
> >> LOG:  execute <unnamed>: select content from messages
> >> LOG:  execute S_2: COMMIT
> > 
> > On my side, I tryed the following example:
> > http://docs.codehaus.org/download/attachments/9240687/HibernateBTM.zip?version=2
> 
> Ok, I downloaded and installed that as well, and saw similar results.
> 
> 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.
> 
> Patch attached. I also added a test for this in the test suite.
> 
> Can you check that this fixes the issue for you, please? I can send you 
> a patched jar if you don't have build environment, let me know if you 
> need it.
> 




view thread (18+ messages)  latest in thread

Message-ID: <1194985411.5533.6.camel@hatman>
Permalink:  ../1194985411.5533.6.camel@hatman/
Also on:    postgresql.org/message-id/1194985411.5533.6.camel@hatman

 · 

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 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: joel.winteregg@gmail.com, heikki@enterprisedb.com, ludovic.orban@gmail.com
  Subject: Re: XAResource implementation
  In-Reply-To: <1194985411.5533.6.camel@hatman>
  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> <1194985411.5533.6.camel@hatman>

* 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