X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B47F952956 for ; Thu, 30 Jun 2005 15:43:41 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 80748-10 for ; Thu, 30 Jun 2005 18:43:31 +0000 (GMT) Received: from smtp-3.hut.fi (smtp-3.hut.fi [130.233.228.93]) by svr1.postgresql.org (Postfix) with ESMTP id 36E7052968 for ; Thu, 30 Jun 2005 15:43:23 -0300 (ADT) Received: from localhost (katosiko.hut.fi [130.233.228.115]) by smtp-3.hut.fi (8.12.10/8.12.10) with ESMTP id j5UIh2wu006959; Thu, 30 Jun 2005 21:43:02 +0300 Received: from smtp-3.hut.fi ([130.233.228.93]) by localhost (katosiko.hut.fi [130.233.228.115]) (amavisd-new, port 10024) with LMTP id 25170-29-5; Thu, 30 Jun 2005 21:43:02 +0300 (EEST) Received: from kosh.hut.fi (kosh.hut.fi [130.233.228.10]) by smtp-3.hut.fi (8.12.10/8.12.10) with ESMTP id j5UIbGfZ006131; Thu, 30 Jun 2005 21:37:16 +0300 Date: Thu, 30 Jun 2005 21:37:16 +0300 (EEST) From: Heikki Linnakangas X-X-Sender: hlinnaka@kosh.hut.fi To: Oliver Jowett Cc: pgsql-jdbc@postgresql.org Subject: Re: XA support In-Reply-To: <42C31E54.20000@opencloud.com> Message-ID: References: <42C31E54.20000@opencloud.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-TKK-Virus-Scanned: by amavisd-new-2.1.2-hutcc at katosiko.hut.fi X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200506/177 X-Sequence-Number: 13139 On Thu, 30 Jun 2005, Oliver Jowett wrote: > Heikki Linnakangas wrote: > >> B. When the second transaction starts, the first transaction is prepared >> behind the scenes, freeing the connection for the new transaction. > > This is probably the way to go initially, since it's much simpler. It > should also deal with the more common uses of XA where you're just > coordinating 2 or more resources in an otherwise straightforward > begin-do stuff-commit sequence. We can get clever later :) > > Related issues: supporting this case: > > xaRes.start(xid1, XAResource.TMNOFLAGS); > stmt.executeUpdate("..."); > xaRes.end(xid1, XAResource.TMSUSPEND); > // ... > xaRes.start(xid1, XAResource.TMRESUME); > stmt.executeUpdate("..."); > xaRes.end(xid1, XAResource.TMSUCCESS); This is essentially impossible with approach B, if the ... part uses the connection for some other xid. Otherwise, should work. > and this one: > > xaRes.start(xid1, XAResource.TMNOFLAGS); > stmt.executeUpdate("..."); > xaRes.end(xid1, XAResource.TMSUCCESS); > // ... > xaRes.start(xid1, XAResource.TMJOIN); > stmt.executeUpdate("..."); > xaRes.end(xid1, XAResource.TMSUCCESS); Practically the same as above, really. > and this one (yow!): > > (thread 1): > xaRes.start(xid1, XAResource.TMNOFLAGS); > stmt.executeUpdate("..."); > > (thread 2): > xaRes.start(xid1, XAResource.TMJOIN); > stmt.executeUpdate("..."); Note that the XA term "thread of control" actually means a connection in JTA terms. It doesn't make any difference which java thread does work. See JTA spec, section 3.4.3. I'm leaning towards approach C myself, since it's the simplest to implement and doesn't cause any unexpected prepares. Or possibly even violating the spec and not allowing to start another transaction before the previous one has been prepared. It depends on how the popular application servers behave in real life. - Heikki