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

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

> Ok, so how do we get XA working when a single global transaction
> involves two databases on the same cluster?
>
> The scenario is:
>
> - there are two independent resource managers participating in a single
> global transaction
> - each resource manager has a connection to the database it is managing,
> and a SQL-level transaction running against that database
> - the global TM tells both resource managers to prepare their part of
> the global transaction, passing the same XID to both

If the TM does that, it's broken.

The XID consists of three parts:

format id: a constant. Not interesting.

gtrid: Global Transaction Identifier. This identifies the global 
transaction in the TM. All XIDs that have the same gtrid should be 
completed atomically by the TM

branch id: Branch Identifier. Every RM involved in the global transaction 
is given a *different* branch id.

In the above case, the TM would give the two resource managers XIDs that 
have the same gtrid but different branch ids.

From the RM point of view, those fields have no significance and the XID 
as whole is used to identify the transaction.

So the RM should never see the same XID twice, except when the TM 
specifically uses the TMJOIN or the TMSUSPEND/TMRESUME flags. If the TM 
uses those flags, it'll only issue one prepare.

- Heikki


pgsql-hackers by date:

Previous
From: "Qingqing Zhou"
Date:
Subject: Re: Checkpoint cost, looks like it is WAL/CRC
Next
From: "Dave Page"
Date:
Subject: Re: [PATCHES] Dbsize backend integration