[libpostgresql-jdbc-java] 03/13: Allow XAResource.start with TMJOIN in a limited set of circumstances to work with WebLogic. We allow TMJOIN only if the resource was previously ended and the Xid is the same as the current Xid.

Emmanuel Bourg ebourg-guest at moszumanska.debian.org
Mon Jan 9 10:20:03 UTC 2017


This is an automated email from the git hooks/post-receive script.

ebourg-guest pushed a commit to tag REL8_1_410
in repository libpostgresql-jdbc-java.

commit bec89bf34f53ec540ef592d43ca289f558cc65ef
Author: Kris Jurka <books at ejurka.com>
Date:   Wed Apr 25 19:36:53 2007 +0000

    Allow XAResource.start with TMJOIN in a limited set of circumstances
    to work with WebLogic.  We allow TMJOIN only if the resource was
    previously ended and the Xid is the same as the current Xid.
    
    http://archives.postgresql.org/pgsql-jdbc/2005-12/msg00038.php
    http://archives.postgresql.org/pgsql-jdbc/2006-11/msg00002.php
    
    Jan de Visser and Heikki Linnakangas
---
 org/postgresql/test/xa/XADataSourceTest.java | 10 ++++++++++
 org/postgresql/xa/PGXAConnection.java        | 22 +++++++++++++++++-----
 2 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/org/postgresql/test/xa/XADataSourceTest.java b/org/postgresql/test/xa/XADataSourceTest.java
index 2978207..ba2a4ca 100644
--- a/org/postgresql/test/xa/XADataSourceTest.java
+++ b/org/postgresql/test/xa/XADataSourceTest.java
@@ -248,6 +248,16 @@ public class XADataSourceTest extends TestCase {
         assertTrue(conn.getAutoCommit());
     }
 
+    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);
diff --git a/org/postgresql/xa/PGXAConnection.java b/org/postgresql/xa/PGXAConnection.java
index a0f8c41..7c9c1c8 100644
--- a/org/postgresql/xa/PGXAConnection.java
+++ b/org/postgresql/xa/PGXAConnection.java
@@ -75,8 +75,11 @@ public class PGXAConnection extends PooledConnectionImpl implements XAConnection
      * 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
+     * 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
@@ -98,9 +101,18 @@ public class PGXAConnection extends PooledConnectionImpl implements XAConnection
         // 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)
+        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);
 
         try

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/libpostgresql-jdbc-java.git



More information about the pkg-java-commits mailing list