Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 2EC9F9FB4E5 for ; Mon, 9 Oct 2006 07:36:18 -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 02958-08 for ; Mon, 9 Oct 2006 10:36:11 +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 358CA9FB202 for ; Mon, 9 Oct 2006 07:36:11 -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 68265A24BB9; Mon, 9 Oct 2006 05:36:08 -0500 (CDT) Message-ID: <452A261B.6030501@enterprisedb.com> Date: Mon, 09 Oct 2006 11:36:11 +0100 From: Heikki Linnakangas User-Agent: Thunderbird 1.5.0.7 (X11/20060915) MIME-Version: 1.0 To: Allan Saddi CC: pgsql-jdbc@postgresql.org Subject: Re: XA transactions and autocommit References: <4EA0BEEF-A4F2-43CD-82A3-C8888155E06E@saddi.com> In-Reply-To: <4EA0BEEF-A4F2-43CD-82A3-C8888155E06E@saddi.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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/48 X-Sequence-Number: 15931 Allan Saddi wrote: > > I've been playing around with JTA using Apache Geronimo and the > postgresql-8.1-407.jdbc3.jar driver. I've noticed a minor problem. The > driver's XA code disables autocommit and assumes it will remain so > indefinitely. tranql-connection (used by Geronimo for pooling) enables > autocommit whenever the connection is returned to the pool. > (Specifically in its ManagedXAConnection.cleanup method.) According to > the J2EE Connector spec, this is apparently the correct thing to do. Specifically, the spec says that: A resource adapter must manage the auto-commit mode as follows: * A transactional resource adapter, either at XATransaction or LocalTransaction level, must set the auto-commit mode to false within transaction, either local or XA, on a connection participating in the transaction. This requirement holds for both container-managed and bean-managed transaction demarcation. * A transactional resource adapter must set the auto-commit mode to true, on connections that are used outside a transaction. What's the resource adapter in this scenario? Is it the PostgreSQL JDBC driver or TranQL? If it's TranQL, then it's not properly calling setAutoCommit(false) when the connection is used in a global transaction. If it's the JDBC driver, then we're not doing our job properly, but then TranQL shouldn't be messing with setAutoCommit in the first place. > I didn't notice the problem until I tried rolling back a transaction, > where I discovered it was being committed instead. Eventually I traced > it to the fact that autocommit was on. > > Arguably, if you follow what the connector spec has to say about > autocommit and XA transactions, autocommit should be on by default and > should only be explicitly disabled during the duration of a transaction. Yeah, I agree that's what we should do. Even if the spec isn't 100% clear on this, it looks like the safest thing to do. Furthermore, we should probably throw an exception if you try to set auto commit to true within a global transaction. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com