Received: from localhost (unknown [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 83D1D2E1275 for ; Tue, 13 Nov 2007 18:52:50 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 40944-07 for ; Tue, 13 Nov 2007 18:52:42 -0400 (AST) Received: from nf-out-0910.google.com (nf-out-0910.google.com [64.233.182.188]) by postgresql.org (Postfix) with ESMTP id 29D812E072B for ; Tue, 13 Nov 2007 18:52:46 -0400 (AST) Received: by nf-out-0910.google.com with SMTP id f5so1300108nfh for ; Tue, 13 Nov 2007 14:52:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:user-agent:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding:sender; bh=F9Pt6dydZugofyO743SV+oQujzNfp54BP86Oeo9ktBc=; b=Gb8QvaY1Ie5VYOgemZSGWrTpesB2Cv9eTE2bbI/hCJLJKjP37mCq5pXOgtl1VhUPrdWd7KL+yFNbRGsYRRKDbQYCJieId6RWq0cwYHhkWQY/xzbxzHjJEsMgozkKdWZR/GdJlGgmT72ih5nbTgBdGC7k8f78xRMdRI1hgTpmAI4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:user-agent:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding:sender; b=NAdsuanFH16wED5eR+M26l8Oc/jPOfz71flm/7KxEdmz5aBZU6pBhpCFbKQKGFQa/AoWKfBO9ZgyRy5qhpDTsDyRdBlXTklcxdeXwpcMqsSbmuOf82zU4YLT1cwy5AJ6rv6ShKEwijiRnGrTz17Nsa7qV9DOtV7S8HiS1cgRZKc= Received: by 10.78.132.2 with SMTP id f2mr1215730hud.1194994364641; Tue, 13 Nov 2007 14:52:44 -0800 (PST) Received: from ?192.168.1.33? ( [82.26.22.93]) by mx.google.com with ESMTPS id c5sm42803nfi.2007.11.13.14.52.38 (version=SSLv3 cipher=RC4-MD5); Tue, 13 Nov 2007 14:52:40 -0800 (PST) Message-ID: <473A2AB3.2040701@enterprisedb.com> Date: Tue, 13 Nov 2007 22:52:35 +0000 From: Heikki Linnakangas User-Agent: Icedove 1.5.0.12 (X11/20070730) MIME-Version: 1.0 To: Kris Jurka CC: =?ISO-8859-1?Q?jo=EBl_Winteregg?= , pgsql-jdbc@postgresql.org, Ludovic Orban Subject: Re: XAResource implementation References: <1193736934.5565.40.camel@hatman> <4727420A.4060209@enterprisedb.com> <1193757567.5565.46.camel@hatman> <47275A50.2050201@enterprisedb.com> <47275BA6.3030200@enterprisedb.com> <1194819933.5545.100.camel@hatman> <47382418.604@enterprisedb.com> <1194939010.5505.24.camel@hatman> <4739D5FB.9080202@enterprisedb.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-Archive-Number: 200711/58 X-Sequence-Number: 17813 Kris Jurka wrote: > > > On Tue, 13 Nov 2007, Heikki Linnakangas wrote: > >> It looks like there is indeed a bug in the Postgres driver. I believe >> it was introduced by the recent changes to keep the connection in >> autocommit mode when no XA-transaction is in progress. >> >> It's this call sequence that borks it up: >> >> xares.start() >> conn = xares.getConnection() >> // do stuff >> conn.close(); >> conn = xares.getConnection() >> // do more stuff >> xares.end() >> xares.commit() >> >> The 2nd getConnection call inadvertently commits the transaction, and >> opens another one. > > When I raised this issue, you said it can't/shouldn't happen. What's > different now? It's still a bug in the driver, but is the calling code > doing something it shouldn't? > > http://archives.postgresql.org/pgsql-jdbc/2007-06/msg00095.php Oh, I had forgotten about that. The difference is the close() between the getConnection()s. I started having second doubts about that case you posted in June, so I tested what Derby does if you call getConnection() twice, without a close in between. You get an error ("Cannot close a connection while a global transaction is still active."), so at least they consider it incorrect as well. Throwing an error in that case would be a nice thing for us to do as well. Currently, we just silently rollback. >> Patch attached. I also added a test for this in the test suite. > > transaction_timestamp() is an 8.2 feature, but since XA is an 8.1 > feature you should use now() instead. (No need for a new patch, I've > updated mine here.) Thanks! -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com