pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
To: Jesper Pedersen <jesper.pedersen@jboss.org>
Cc: pgsql-jdbc@postgresql.org <pgsql-jdbc@postgresql.org>
Subject: Re: Possible oversight in org.postgresql.xa.PGXAConnection.commitPrepared(Xid xid)
Date: Wed, 29 Jun 2011 19:09:44 +0300
Message-ID: <4E0B4E48.9030909@enterprisedb.com> (raw)
In-Reply-To: <201106290904.58581.jesper.pedersen@jboss.org>
References: <500446595.828372.1309301560262.JavaMail.root@zmail06.collab.prod.int.phx2.redhat.com>
	<4E0AEFDB.30701@enterprisedb.com>
	<201106290904.58581.jesper.pedersen@jboss.org>

On 29.06.2011 16:04, Jesper Pedersen wrote:
> Hey Heikki,
>
> On Wednesday, June 29, 2011 05:26:51 AM Heikki Linnakangas wrote:
>> Attached patch implements that. I don't have a transaction manager
>> environment for this at hand right now, so this is completely untested.
>> Do you have a setup ready where you could test this?
>
> You forgot to update the actual exception with 'xaerrcode'.

Oops. Here's a patch with that fixed.

-- 
   Heikki Linnakangas
   EnterpriseDB   http://www.enterprisedb.com

Attachments:

xaer_rmerr-only-if-xact-does-not-exist-2.patch (text/x-diff, 2.9K) download ? xaer_rmerr-only-if-xact-does-not-exist-1.patch ? xaer_rmerr-only-if-xact-does-not-exist-2.patch Index: org/postgresql/util/PSQLState.java =================================================================== RCS file: /cvsroot/jdbc/pgjdbc/org/postgresql/util/PSQLState.java,v retrieving revision 1.14 diff -c -r1.14 PSQLState.java *** org/postgresql/util/PSQLState.java 31 Mar 2011 03:06:39 -0000 1.14 --- org/postgresql/util/PSQLState.java 29 Jun 2011 16:07:57 -0000 *************** *** 88,93 **** --- 88,94 ---- public final static PSQLState SYNTAX_ERROR = new PSQLState("42601"); public final static PSQLState UNDEFINED_COLUMN = new PSQLState("42703"); + public final static PSQLState UNDEFINED_OBJECT = new PSQLState("42704"); public final static PSQLState WRONG_OBJECT_TYPE = new PSQLState("42809"); public final static PSQLState NUMERIC_CONSTANT_OUT_OF_RANGE = new PSQLState("42820"); public final static PSQLState DATA_TYPE_MISMATCH = new PSQLState("42821"); Index: org/postgresql/xa/PGXAConnection.java =================================================================== RCS file: /cvsroot/jdbc/pgjdbc/org/postgresql/xa/PGXAConnection.java,v retrieving revision 1.17 diff -c -r1.17 PGXAConnection.java *** org/postgresql/xa/PGXAConnection.java 31 Mar 2011 06:25:42 -0000 1.17 --- org/postgresql/xa/PGXAConnection.java 29 Jun 2011 16:07:57 -0000 *************** *** 498,504 **** } catch (SQLException ex) { ! throw new PGXAException(GT.tr("Error committing prepared transaction"), ex, XAException.XAER_RMERR); } } --- 498,525 ---- } catch (SQLException ex) { ! // Per JTA spec, we should return XAER_RMERR only if the ! // prepared transaction has permanently failed and can never be ! // committed. In that case the fundamental contract of two-phase ! // commit that if a transaction has been prepared, it can ! // eventually be committed, has been broken. In all other cases, ! // where the commit fails but the transaction stays in prepared ! // state, we should return XA_RETRY. ! // ! // If the prepared transaction exists, but commit fails for any ! // other reason, we assume that the commit might succeed if ! // retried later. The server uses sqlstate UNDEFINED_OBJECT ! // (42704) if the prepared transcation doesn't exist, so we ! // check for that. The same sqlstate is used for all kinds of ! // missing object errors, but in case of COMMIT PREPARED, it's ! // reasonable to assume that if you get that error code, it's the ! // prepared transaction that's missing. ! int xaerrcode; ! if (ex.getSQLState().equals(PSQLState.UNDEFINED_OBJECT)) ! xaerrcode = XAException.XAER_RMERR; ! else ! xaerrcode = XAException.XA_RETRY; ! throw new PGXAException(GT.tr("Error committing prepared transaction"), ex, xaerrcode); } }

view thread (12+ messages)  latest in thread

Message-ID: <4E0B4E48.9030909@enterprisedb.com>
Permalink:  ../4E0B4E48.9030909@enterprisedb.com/
Also on:    postgresql.org/message-id/4E0B4E48.9030909@enterprisedb.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: heikki.linnakangas@enterprisedb.com, jesper.pedersen@jboss.org
  Subject: Re: Possible oversight in org.postgresql.xa.PGXAConnection.commitPrepared(Xid xid)
  In-Reply-To: <4E0B4E48.9030909@enterprisedb.com>
  References: <500446595.828372.1309301560262.JavaMail.root@zmail06.collab.prod.int.phx2.redhat.com> <4E0AEFDB.30701@enterprisedb.com> <201106290904.58581.jesper.pedersen@jboss.org> <4E0B4E48.9030909@enterprisedb.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