From: | Heikki Linnakangas <heikki(at)enterprisedb(dot)com> |
---|---|
To: | joël Winteregg <joel(dot)winteregg(at)gmail(dot)com> |
Cc: | pgsql-jdbc(at)postgresql(dot)org, Ludovic Orban <ludovic(dot)orban(at)gmail(dot)com> |
Subject: | Re: XAResource implementation |
Date: | 2007-11-13 16:51:07 |
Message-ID: | 4739D5FB.9080202@enterprisedb.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
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.
--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com
Attachment | Content-Type | Size |
---|---|---|
xa-getConnection-fix.patch | text/x-diff | 4.8 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Kris Jurka | 2007-11-13 18:06:22 | Re: XAResource implementation |
Previous Message | joël Winteregg | 2007-11-13 07:30:10 | Re: XAResource implementation |