Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id EF2686347BD for ; Wed, 23 Dec 2009 04:36:19 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 71293-03-5 for ; Wed, 23 Dec 2009 08:36:10 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from exprod7og127.obsmtp.com (exprod7og127.obsmtp.com [64.18.2.210]) by mail.postgresql.org (Postfix) with SMTP id 825356334F6 for ; Wed, 23 Dec 2009 04:36:03 -0400 (AST) Received: from source ([209.85.219.213]) by exprod7ob127.postini.com ([64.18.6.12]) with SMTP ID DSNKSzHWcZrXCu2wS8D9oeSkBSGWjhF71l/j@postini.com; Wed, 23 Dec 2009 00:36:03 PST Received: by ewy5 with SMTP id 5so7761732ewy.14 for ; Wed, 23 Dec 2009 00:36:01 -0800 (PST) Received: by 10.213.45.134 with SMTP id e6mr1335607ebf.15.1261557360769; Wed, 23 Dec 2009 00:36:00 -0800 (PST) Received: from ?192.168.1.117? ([88.195.103.165]) by mx.google.com with ESMTPS id 7sm14331729eyb.18.2009.12.23.00.35.58 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 23 Dec 2009 00:35:59 -0800 (PST) Message-ID: <4B31D66D.8010809@enterprisedb.com> Date: Wed, 23 Dec 2009 10:35:57 +0200 From: Heikki Linnakangas Organization: EnterpriseDB User-Agent: Mozilla-Thunderbird 2.0.0.22 (X11/20090706) MIME-Version: 1.0 To: Justin Bertram CC: pgsql-jdbc@postgresql.org Subject: Re: Possible oversight in org.postgresql.xa.PGXAConnection.commitPrepared(Xid xid) References: <553112194.2096301261510459113.JavaMail.root@zmail06.collab.prod.int.phx2.redhat.com> In-Reply-To: <553112194.2096301261510459113.JavaMail.root@zmail06.collab.prod.int.phx2.redhat.com> Content-Type: multipart/mixed; boundary="------------020406000300020005050200" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-6.599 tagged_above=-10 required=5 tests=BAYES_00=-2.599, RCVD_IN_DNSWL_MED=-4 X-Spam-Level: X-Archive-Number: 200912/92 X-Sequence-Number: 20173 This is a multi-part message in MIME format. --------------020406000300020005050200 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Justin Bertram wrote: > I work with JBoss Transactions (JBossTS) and I noticed something recently in org.postgresql.xa.PGXAConnection.commitPrepared(Xid xid) [1] when working with some transaction recovery scenarios after a database failure. commitPrepared calls: > > throw new XAException(ex.toString()); > > The Java XA interface assumes that a thrown javax.transaction.xa.XAException [2] will contain one of the standard XA error codes [3] to identify exactly the nature of the error. Unfortunately Java allows an XAException to be constructed using a default constructor and a String constructor. Using these constructors results in an errorCode value of 0 for the XAException which is not valid. > > In the latest PostgreSQL JDBC3 driver (8.4-701) this is what org.postgresql.xa.PGXAConnection.commitPrepared(Xid xid) does so the exception cannot be handled cleanly. JBossTS does not know what this error signifies so it has to assume the worst (i.e. that the resource is in an indeterminate state and it should not attempt to recover the transaction). Any reset of the database state will require manual intervention. > > Can this be changed to throw an XAException with the appropriate XAER error code? Yeah, seems like an oversight. Patch attached. We use XAER_RMERR error code in similar places in all the other functions. Does that work for JBoss? -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com --------------020406000300020005050200 Content-Type: text/x-diff; name="jdbc-commitprepared-xa-error-code-1.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="jdbc-commitprepared-xa-error-code-1.patch" Index: org/postgresql/xa/PGXAConnection.java =================================================================== RCS file: /cvsroot/jdbc/pgjdbc/org/postgresql/xa/PGXAConnection.java,v retrieving revision 1.13 diff -u -r1.13 PGXAConnection.java --- org/postgresql/xa/PGXAConnection.java 14 Nov 2007 22:03:36 -0000 1.13 +++ org/postgresql/xa/PGXAConnection.java 23 Dec 2009 08:34:19 -0000 @@ -441,7 +441,7 @@ } catch (SQLException ex) { - throw new XAException(ex.toString()); + throw new PGXAException(GT.tr("Error committing prepared transaction"), ex, XAException.XAER_RMERR); } } --------------020406000300020005050200--