Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 6BB26B5DBE9 for ; Thu, 30 Jun 2011 09:00:45 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 66140-01 for ; Thu, 30 Jun 2011 12:00:39 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from exprod7og106.obsmtp.com (exprod7og106.obsmtp.com [64.18.2.165]) by mail.postgresql.org (Postfix) with ESMTP id 7726BB5DBEF for ; Thu, 30 Jun 2011 09:00:38 -0300 (ADT) Received: from mail-fx0-f52.google.com ([209.85.161.52]) (using TLSv1) by exprod7ob106.postini.com ([64.18.6.12]) with SMTP ID DSNKTgxlZTEeTxUUsms98BzTygUJ3OD5MRaB@postini.com; Thu, 30 Jun 2011 05:00:39 PDT Received: by fxd18 with SMTP id 18so1953640fxd.39 for ; Thu, 30 Jun 2011 05:00:36 -0700 (PDT) Received: by 10.223.58.145 with SMTP id g17mr2851569fah.77.1309435236142; Thu, 30 Jun 2011 05:00:36 -0700 (PDT) Received: from [90.190.247.247] (247.247.190.90.dyn.estpak.ee [90.190.247.247]) by mx.google.com with ESMTPS id m26sm1565340fab.10.2011.06.30.05.00.33 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 30 Jun 2011 05:00:34 -0700 (PDT) Message-ID: <4E0C655E.8000307@enterprisedb.com> Date: Thu, 30 Jun 2011 15:00:30 +0300 From: Heikki Linnakangas User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; fi-FI; rv:1.9.2.17) Gecko/20110606 Icedove/3.1.10 MIME-Version: 1.0 To: Simon Riggs CC: Justin Bertram , pgsql-jdbc Subject: Re: Possible oversight in org.postgresql.xa.PGXAConnection.commitPrepared(Xid xid) References: <4E0AEFDB.30701@enterprisedb.com> <147817721.851047.1309377089469.JavaMail.root@zmail06.collab.prod.int.phx2.redhat.com> In-Reply-To: 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=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201106/80 X-Sequence-Number: 22004 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