Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U5ENg-0002FZ-0I for pgsql-jdbc@arkaria.postgresql.org; Tue, 12 Feb 2013 11:50:36 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1U5ENf-000375-HG for pgsql-jdbc@arkaria.postgresql.org; Tue, 12 Feb 2013 11:50:35 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U5ENf-000370-0r for pgsql-jdbc@postgresql.org; Tue, 12 Feb 2013 11:50:35 +0000 Received: from smtp-outbound-2.vmware.com ([208.91.2.13]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U5ENb-000450-FX for pgsql-jdbc@postgresql.org; Tue, 12 Feb 2013 11:50:34 +0000 Received: from sc9-mailhost2.vmware.com (sc9-mailhost2.vmware.com [10.113.161.72]) by smtp-outbound-2.vmware.com (Postfix) with ESMTP id 28FFF28664; Tue, 12 Feb 2013 03:50:28 -0800 (PST) Received: from zcs-prod-mta-2.vmware.com (zcs-prod-mta-2.vmware.com [10.113.163.64]) by sc9-mailhost2.vmware.com (Postfix) with ESMTP id 24E29B07D5; Tue, 12 Feb 2013 03:50:28 -0800 (PST) Received: from zcs-prod-mta-2.vmware.com (localhost.localdomain [127.0.0.1]) by zcs-prod-mta-2.vmware.com (Postfix) with ESMTP id 143B9E0033; Tue, 12 Feb 2013 03:50:28 -0800 (PST) Received: from [10.113.226.223] (unknown [10.113.160.14]) by zcs-prod-mta-2.vmware.com (Postfix) with ESMTPSA; Tue, 12 Feb 2013 03:50:26 -0800 (PST) Message-ID: <511A2C7F.1040104@vmware.com> Date: Tue, 12 Feb 2013 13:50:23 +0200 From: Heikki Linnakangas Organization: VMware User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.12) Gecko/20130116 Icedove/10.0.12 MIME-Version: 1.0 To: Bryan Varner CC: "pgsql-jdbc@postgresql.org" Subject: Re: PostgreSQL XAResource & GlassFish 3.1.2.2 References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -6.9 (------) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org On 12.02.2013 05:36, Bryan Varner wrote: > * Race conditions as multiple threads are participating in the same transaction, invoking XAResource methods. Status checks in PGXAConnection.java are throwing exceptions (if state == ACTIVE) throw) by the time in invokes the throw, the state is != ACTIVE) Before you start telling me I shouldn't be using threads in a JEE environment let me remind you that EJBs by default are served out of thread pools, and allow for concurrent threads to participate within a single TX scope. This is outlined as part of the transaction context in the JTS spec (section 2.2 and 2.3) and synchronized thread-safe access to XAResources is described (without being explicitly called out) by the JTA 1.0.1 spec. We could fairly easily just add "synchronized" to all the public methods. I wonder how sane it is for Glassfish to be doing that in the first place, though. AFAICS, in any combination of two XAResource methods, called concurrently, one of the threads will get an error anyway. For example, if two threads try to call start() at the same time, one of them has to fail because an XAResource can only be associated with a one transaction at a time. > * It appears that a second thread attempting to join an existing XAResource's scope with start(XID, TMJOIN) is going to be refused, even if it's attempting to participate in the same XID. The exception thrown is one complaining about interleaving, even though it's the -same- XID, not a sub-set of work in another TX. Hmm, so the application server is trying to do something like this: xares.start(1234, 0); xares.start(1234, TMJOIN); We could easily allow that in the driver (ie. do nothing), but that doesn't seem like valid sequence of calls to begin with. You must disassociate the XAResource from the current transaction with end(), before re-associating it with start(). If you have a simple stand-alone test application that reproduces the problems, I could take a closer look. - Heikki -- Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc