Skip site navigation (1) Skip section navigation (2)

Re: XAResource implementation

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
Subject: Re: XAResource implementation
Date: 2007-11-12 09:59:52
Message-ID: 47382418.604@enterprisedb.com (view raw or flat)
Thread:
Lists: pgsql-jdbc
joël Winteregg wrote:
> I said that BTM TransactionManager was "mostly" working because when I
> was using the XA implementation, SQL BEGIN and COMMIT where generated
> arround each SQL query (even if several queries were located inside the
> same transaction). So at the end, I used the TransactionManager with the
> "Last Resource Commit Optimization" which allow the use of a pure jdbc
> driver during transaction (I only have a single DB (1 Phase Commit) so
> it is 100% safe to use this specificity). In this case, my BEGIN and
> COMMIT statement where just perfect:
> BEGIN
>   SELECT ..
>   SELECT ..
>   SELECT ..
> COMMIT
> 
> So I was just wondering if my XA problem (BEGIN and COMMIT location when
> using XA) could come from the postgresql XA driver ?

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.

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

-- 
   Heikki Linnakangas
   EnterpriseDB   http://www.enterprisedb.com

Attachment: Test.java
Description: text/x-java (2.1 KB)

In response to

Responses

pgsql-jdbc by date

Next:From: joël WintereggDate: 2007-11-13 07:30:10
Subject: Re: XAResource implementation
Previous:From: joël WintereggDate: 2007-11-11 22:25:33
Subject: Re: XAResource implementation

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group