Re: 2PC transaction id

From: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
To: Oliver Jowett <oliver(at)opencloud(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Dave Cramer <pg(at)fastcrypt(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: 2PC transaction id
Date: 2005-07-01 06:43:11
Message-ID: Pine.OSF.4.61.0507010936160.475909@kosh.hut.fi
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Satoshi Nagayasu 2005-07-01 07:15:50 enable/disable trigger (Re: Fwd: [HACKERS] Open items)
Previous Message Qingqing Zhou 2005-07-01 06:05:44 Re: Checkpoint cost, looks like it is WAL/CRC

Browse pgsql-patches by date

  From Date Subject
Next Message Satoshi Nagayasu 2005-07-01 07:15:50 enable/disable trigger (Re: Fwd: [HACKERS] Open items)
Previous Message Neil Conway 2005-07-01 05:14:29 Re: ecpg: numeric_div error handling