pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Justin Bertram <jbertram@redhat.com>
To: pgsql-jdbc@postgresql.org
Subject: Possible oversight in org.postgresql.xa.PGXAConnection.commitPrepared(Xid xid)
Date: Tue, 22 Dec 2009 14:34:19 -0500 (EST)
Message-ID: <553112194.2096301261510459113.JavaMail.root@zmail06.collab.prod.int.phx2.redhat.com> (raw)
In-Reply-To: <1542801081.2095931261510256414.JavaMail.root@zmail06.collab.prod.int.phx2.redhat.com>

I searched the mailing list, but I couldn't find anything addressing this issue.

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?


Justin

[1] http://cvs.pgfoundry.org/cgi-bin/cvsweb.cgi/jdbc/pgjdbc/org/postgresql/xa/PGXAConnection.java?rev=1....
[2] http://java.sun.com/javaee/5/docs/api/javax/transaction/xa/XAException.html
[3] http://java.sun.com/javaee/5/docs/api/constant-values.html#javax.transaction.xa.XAException.XA_HEURC...



view thread (12+ messages)  latest in thread

Message-ID: <553112194.2096301261510459113.JavaMail.root@zmail06.collab.prod.int.phx2.redhat.com>
Permalink:  ../553112194.2096301261510459113.JavaMail.root@zmail06.collab.prod.int.phx2.redhat.com/
Also on:    postgresql.org/message-id/553112194.2096301261510459113.JavaMail.root@zmail06.collab.prod.int.phx2.redhat.com

 · 

reply

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: jbertram@redhat.com
  Subject: Re: Possible oversight in org.postgresql.xa.PGXAConnection.commitPrepared(Xid xid)
  In-Reply-To: <553112194.2096301261510459113.JavaMail.root@zmail06.collab.prod.int.phx2.redhat.com>
  References: <1542801081.2095931261510256414.JavaMail.root@zmail06.collab.prod.int.phx2.redhat.com> <553112194.2096301261510459113.JavaMail.root@zmail06.collab.prod.int.phx2.redhat.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