Re: 2PC transaction id

From: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
To: Oliver Jowett <oliver(at)opencloud(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: 2PC transaction id
Date: 2005-07-03 07:30:22
Message-ID: Pine.OSF.4.61.0507031010490.56417@kosh.hut.fi
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andreas Pflug 2005-07-03 07:46:48 Re: [HACKERS] Dbsize backend integration
Previous Message Greg Stark 2005-07-03 06:47:08 Re: Checkpoint cost, looks like it is WAL/CRC

Browse pgsql-patches by date

  From Date Subject
Next Message Andreas Pflug 2005-07-03 07:46:48 Re: [HACKERS] Dbsize backend integration
Previous Message Tom Lane 2005-07-03 05:51:31 Re: Disable WAL backup pages when fsync is off