From: Heikki Linnakangas <heikki@enterprisedb.com>
To: pgsql-jdbc@postgresql.org
Cc: jdevisser@digitalfairway.com
Subject: XA end then join fix for WebLogic
Date: Mon, 02 Oct 2006 12:46:33 +0100
Message-ID: <4520FC19.8070205@enterprisedb.com> (raw)
Jan de Visser ran into problems with our XA implementation earlier, and
traced the problem to the sequence of XADataSource method calls that
WebLogic performed. He fixed it with a simple patch that allows
start(.., TMJOIN) on a transaction that was ended earlier using the same
connection:
http://archives.postgresql.org/pgsql-jdbc/2005-12/msg00038.php
It puzzles me why WebLogic does that, but it seems valid and we should
support it, even though we can't support join in general.
Here's a more polished version of Jan's patch. I don't have WebLogic to
test this with, so I would appreciate if those that have access to
WebLogic could reproduce the original problem and confirm that this
patch fixes it.
--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.comAttachments:xa-endthenjoin.diff (text/x-patch, 3.8K) download
Index: org/postgresql/test/xa/XADataSourceTest.java
===================================================================
RCS file: /usr/local/cvsroot/pgjdbc/pgjdbc/org/postgresql/test/xa/XADataSourceTest.java,v
retrieving revision 1.6
diff -c -r1.6 XADataSourceTest.java
*** org/postgresql/test/xa/XADataSourceTest.java 26 Apr 2006 18:58:59 -0000 1.6
--- org/postgresql/test/xa/XADataSourceTest.java 2 Oct 2006 11:32:27 -0000
***************
*** 217,222 ****
--- 217,232 ----
xaRes.rollback(xid);
}
+ public void testEndThenJoin() throws XAException {+ Xid xid = new CustomXid(5);+ + xaRes.start(xid, XAResource.TMNOFLAGS);+ xaRes.end(xid, XAResource.TMSUCCESS);+ xaRes.start(xid, XAResource.TMJOIN);+ xaRes.end(xid, XAResource.TMSUCCESS);+ xaRes.commit(xid, true);+ }+
/* We don't support transaction interleaving.
public void testInterleaving1() throws Exception {
Xid xid1 = new CustomXid(1);
Index: org/postgresql/xa/PGXAConnection.java
===================================================================
RCS file: /usr/local/cvsroot/pgjdbc/pgjdbc/org/postgresql/xa/PGXAConnection.java,v
retrieving revision 1.7
diff -c -r1.7 PGXAConnection.java
*** org/postgresql/xa/PGXAConnection.java 26 Apr 2006 18:58:59 -0000 1.7
--- org/postgresql/xa/PGXAConnection.java 2 Oct 2006 11:32:28 -0000
***************
*** 79,86 ****
* 4. the TM hasn't seen the xid before
*
* Implementation deficiency preconditions:
! * 1. flags must be TMNOFLAGS
! * 2. Previous transaction using the connection must be committed or prepared or rolled back
*
* Postconditions:
* 1. Connection is associated with the transaction
--- 79,89 ----
* 4. the TM hasn't seen the xid before
*
* Implementation deficiency preconditions:
! * 1. TMRESUME not supported.
! * 2. if flags is TMJOIN, we must be in ended state,
! * and xid must be the current transaction
! * 3. unless flags is TMJOIN, previous transaction using the
! * connection must be committed or prepared or rolled back
*
* Postconditions:
* 1. Connection is associated with the transaction
***************
*** 102,110 ****
// We can't check precondition 4 easily, so we don't. Duplicate xid will be catched in prepare phase.
// Check implementation deficiency preconditions
! if (flags != TMNOFLAGS)
! throw new PGXAException(GT.tr("suspend/resume and join not implemented"), XAException.XAER_RMERR);
! if (state == STATE_ENDED)
throw new PGXAException(GT.tr("Transaction interleaving not implemented"), XAException.XAER_RMERR);
// Preconditions are met, Associate connection with the transaction
--- 105,122 ----
// We can't check precondition 4 easily, so we don't. Duplicate xid will be catched in prepare phase.
// Check implementation deficiency preconditions
! if (flags == TMRESUME)
! throw new PGXAException(GT.tr("suspend/resume not implemented"), XAException.XAER_RMERR);
!
! // It's ok to join an ended transaction. WebLogic does that.
! if (flags == TMJOIN)
! {
! if (state != STATE_ENDED)
! throw new PGXAException(GT.tr("Transaction interleaving not implemented"), XAException.XAER_RMERR);
!
! if (!xid.equals(currentXid))
! throw new PGXAException(GT.tr("Transaction interleaving not implemented"), XAException.XAER_RMERR);
! } else if(state == STATE_ENDED)
throw new PGXAException(GT.tr("Transaction interleaving not implemented"), XAException.XAER_RMERR);
// Preconditions are met, Associate connection with the transaction
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, jdevisser@digitalfairway.com
Subject: Re: XA end then join fix for WebLogic
In-Reply-To: <4520FC19.8070205@enterprisedb.com>
References: <4520FC19.8070205@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