Re: 2PC transaction id - Mailing list pgsql-hackers

From Heikki Linnakangas
Subject Re: 2PC transaction id
Date
Msg-id Pine.OSF.4.61.0507031010490.56417@kosh.hut.fi
Whole thread Raw
In response to Re: 2PC transaction id  (Oliver Jowett <oliver@opencloud.com>)
List pgsql-hackers
On Sat, 2 Jul 2005, Oliver Jowett wrote:

> Sorry to keep beating on this, but I still don't see where the spec says
> that you must have only one RM per transaction branch.

Sure, it's important to get this right.

> 2.2.6 says:
>
>> 2.2.6 Transaction Branches
>> A global transaction has one or more transaction branches (or branches). A branch is a
>> part of the work in support of a global transaction for which the TM and the RM
>> engage in a separate but coordinated transaction commitment protocol (see Section 2.3
>> on page 8). Each of the RMs internal units of work in support of a global transaction is
>> part of exactly one branch.
>
>> A global transaction might have more than one branch when, for example, the AP uses
>> multiple processes or is involved in the same global transaction by multiple remote
>> APs.
>
> So it seems to me that branches are intended to allow independent
> processes / APs to each have an independent set of "tightly coupled
> threads" (as all work on a particular branch is tightly-coupled).
> There's no mention of having only one RM per branch, which I'd expect to
> see here if it was a requirement.

They should have been explicit about it, I agree.

The key is the clause "A branch is a part of the work in support of a 
global transaction for which the TM and the RM engage in a separate but 
coordinated transaction commitment protocol". That means that for each 
branch, there's exactly one call to prepare and commit. If you have two 
RMs, you need two prepare/commit calls, so you need two branches.

> One implication of the second paragraph is that a single-threaded AP can
> use a single transaction branch for all the work it does.

No, that paragraph says "for example". The third example is the case where 
you have more than one RM :).

As further, non-authoritative, evidence, see this DevX article on JTA:

http://archive.devx.com/java/free/articles/dd_jta/jta-2.asp

Search for "branch" in that article. It says explicitly "Requests to three 
different RDBMSs, therefore, require three transaction branches."

- Heikki


pgsql-hackers by date:

Previous
From: Greg Stark
Date:
Subject: Re: Checkpoint cost, looks like it is WAL/CRC
Next
From: Andreas Pflug
Date:
Subject: Re: [PATCHES] Dbsize backend integration