From: Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
To: Simon Riggs <simon@2ndQuadrant.com>
Cc: Justin Bertram <jbertram@redhat.com>
Cc: pgsql-jdbc <pgsql-jdbc@postgresql.org>
Subject: Re: Possible oversight in org.postgresql.xa.PGXAConnection.commitPrepared(Xid xid)
Date: Thu, 30 Jun 2011 15:00:30 +0300
Message-ID: <4E0C655E.8000307@enterprisedb.com> (raw)
In-Reply-To: <BANLkTinLfz4fa1sOFjiNXapjG_zU76HeYg@mail.gmail.com>
References: <4E0AEFDB.30701@enterprisedb.com>
<147817721.851047.1309377089469.JavaMail.root@zmail06.collab.prod.int.phx2.redhat.com>
<BANLkTinLfz4fa1sOFjiNXapjG_zU76HeYg@mail.gmail.com>
On 29.06.2011 23:07, Simon Riggs wrote:
> My understanding is that if the TM requests rollback of a transaction
> and then the database crashes before it can reply, the TM may request
> rollback a second time. If the first rollback did actually remove the
> transaction this then replies that the transaction is unknown. So
> XAER_RMERR is exactly the wrong error in some cases of 42704.
Well, if the transaction has been rolled back, it's clearly not in
prepared state anymore, so XAER_RMERR seems appropriate and the TM
shouldn't get upset about that. However, the situation is more ambiguous
if the TM issues COMMIT PREPARED and the connection is broken before
receiving a reply. It will retry, and if the the COMMIT succeeded the
first time, the TM will get XAER_RMERR on the second call. That's more
serious.
I believe some (all?) other databases have yet another transaction state
to handle that. After committing a transaction, the database still
remembers the transaction ID and the fact that it was successfully
committed. If the TM doesn't receive a reply to commit, it can reconnect
and check the status to see if the commit succeeded. The transaction is
forgotten about only after the TM sends another 'forget' command. Maybe
we need to implement that in PostgreSQL, too.
--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com
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, simon@2ndQuadrant.com, jbertram@redhat.com
Subject: Re: Possible oversight in org.postgresql.xa.PGXAConnection.commitPrepared(Xid xid)
In-Reply-To: <4E0C655E.8000307@enterprisedb.com>
References: <4E0AEFDB.30701@enterprisedb.com> <147817721.851047.1309377089469.JavaMail.root@zmail06.collab.prod.int.phx2.redhat.com> <BANLkTinLfz4fa1sOFjiNXapjG_zU76HeYg@mail.gmail.com> <4E0C655E.8000307@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