Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 6FF8E9FB312 for ; Mon, 2 Oct 2006 08:46:39 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 07414-03 for ; Mon, 2 Oct 2006 11:46:32 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- Received: from webmail.enterprisedb.com (edb04.managed.contegix.com [63.246.7.176]) by postgresql.org (Postfix) with ESMTP id B65699FB30C for ; Mon, 2 Oct 2006 08:46:31 -0300 (ADT) Received: from [192.168.0.20] (unknown [62.232.55.86]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by webmail.enterprisedb.com (Postfix) with ESMTP id 86DF3A24DF6; Mon, 2 Oct 2006 06:46:28 -0500 (CDT) Message-ID: <4520FC19.8070205@enterprisedb.com> Date: Mon, 02 Oct 2006 12:46:33 +0100 From: Heikki Linnakangas User-Agent: Thunderbird 1.5.0.7 (X11/20060915) MIME-Version: 1.0 To: pgsql-jdbc@postgresql.org CC: jdevisser@digitalfairway.com Subject: XA end then join fix for WebLogic Content-Type: multipart/mixed; boundary="------------090705010006060702080207" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.135 tagged_above=0 required=5 tests=FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200610/12 X-Sequence-Number: 15895 This is a multi-part message in MIME format. --------------090705010006060702080207 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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.com --------------090705010006060702080207 Content-Type: text/x-patch; name="xa-endthenjoin.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="xa-endthenjoin.diff" 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 --------------090705010006060702080207--