Received: from localhost (unknown [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 7A5B92E1406 for ; Tue, 13 Nov 2007 16:23:50 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 82937-05 for ; Tue, 13 Nov 2007 16:23:44 -0400 (AST) Received: from fk-out-0910.google.com (fk-out-0910.google.com [209.85.128.187]) by postgresql.org (Postfix) with ESMTP id E82002E1374 for ; Tue, 13 Nov 2007 16:23:40 -0400 (AST) Received: by fk-out-0910.google.com with SMTP id b27so1943668fka for ; Tue, 13 Nov 2007 12:23:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:subject:from:to:cc:in-reply-to:references:content-type:date:message-id:mime-version:x-mailer:content-transfer-encoding; bh=FPx8rOhKQeDSkqi/h3vioWiRhhw5tYADmJbBevJ9VB4=; b=FNH/T0oKFOHM0WhURSwScgwkqeqfI65+QGfQc7ZlKR4GgkXwKriYuE56iuv6gO9yrKw5P7pe8egsPnX8YWoQJJLYWq38yIMJw8VHmYXR7ggaG1e5YLq+uDmdgvad1Q8Sh0R9IZDBFYJYLpqDxX8oKtpVK2W+V512+YSsWVnK6Yg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:subject:from:to:cc:in-reply-to:references:content-type:date:message-id:mime-version:x-mailer:content-transfer-encoding; b=Cp94odr6J9IRJPHqr3jokyaZjZjAePdPNEp26g6ZQ2vEBi/Mm7k6j4iq5o4zXU2Safu6nLJlnywD7KeGPvKrf6IUe+5diJGMokobSrVvi8bbAQ5E1IFJh9QFazxMrCxJiuXtDDL+vMG3QG63EB6MtNjAnXonydO7B3ZhRhTpjC4= Received: by 10.82.154.12 with SMTP id b12mr15971312bue.1194985414912; Tue, 13 Nov 2007 12:23:34 -0800 (PST) Received: from ?10.0.0.10? ( [83.181.101.30]) by mx.google.com with ESMTPS id j2sm13789376mue.2007.11.13.12.23.32 (version=SSLv3 cipher=RC4-MD5); Tue, 13 Nov 2007 12:23:33 -0800 (PST) Subject: Re: XAResource implementation From: =?ISO-8859-1?Q?jo=EBl?= Winteregg To: Heikki Linnakangas Cc: pgsql-jdbc@postgresql.org, Ludovic Orban In-Reply-To: <4739D5FB.9080202@enterprisedb.com> 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> Content-Type: text/plain; charset=ISO-8859-1 Date: Tue, 13 Nov 2007 21:23:31 +0100 Message-Id: <1194985411.5533.6.camel@hatman> Mime-Version: 1.0 X-Mailer: Evolution 2.10.1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200711/54 X-Sequence-Number: 17809 Hello Heikki, Many thanks for these informations ! > Patch attached. I also added a test for this in the test suite. Really cool ! > Can you check that this fixes the issue for you, please? I can send you > a patched jar if you don't have build environment, let me know if you > need it. Yes, that would be great (easier) to have it as a patched jar. Then, I will provide you a feedback about its behavior in my application... Many many thanks for your support ! Joël On Tue, 2007-11-13 at 16:51 +0000, Heikki Linnakangas wrote: > joël Winteregg wrote: > > Many thanks for your answer and for the time you took to do some > > testing ! As you can see I put Ludovic Orban as Cc because he is the BTM > > developer and he seems to be interested to this issue too... > > > >> Hmm. I downloaded the BTM newUserDemo.zip and modified it to run with > >> Postgres, and to run two queries in same transaction. Works for me. > >> > > > > Ah Yes, you're right, your transaction just looks perfect ! > > > >> Attached is the modified Test.java I used. To run: > >> 0. Download newUserDemo.zip from > >> http://docs.codehaus.org/display/BTM/NewUserGuide > >> 1. Put postgresql.jar in newUserDemo/lib > >> 2. Copy the attached Test.java to newUserDemo/src/jtatest > >> 3. Modify database/username/password in Test.java if necessary > >> 4. Run the CREATE TABLE from derby-create.sql > >> > >> Here's what I get in the Postgres log, with log_statements='all': > >> > >> LOG: execute : SELECT gid FROM pg_prepared_xacts > >> LOG: execute S_1: BEGIN > >> LOG: execute : insert into messages(content) values ($1) > >> DETAIL: parameters: $1 = 'hello, world!' > >> LOG: execute S_2: COMMIT > >> LOG: execute S_1: BEGIN > >> LOG: execute : select content from messages > >> LOG: execute : select content from messages > >> LOG: execute S_2: COMMIT > > > > On my side, I tryed the following example: > > http://docs.codehaus.org/download/attachments/9240687/HibernateBTM.zip?version=2 > > Ok, I downloaded and installed that as well, and saw similar results. > > 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. > > Patch attached. I also added a test for this in the test suite. > > Can you check that this fixes the issue for you, please? I can send you > a patched jar if you don't have build environment, let me know if you > need it. >