Re: subtransactions -- storage manager

From: Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>
To: Simon Riggs <simon(at)2ndquadrant(dot)com>
Cc: Patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: subtransactions -- storage manager
Date: 2004-04-30 15:17:07
Message-ID: 20040430151707.GB3799@dcc.uchile.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

On Thu, Apr 29, 2004 at 11:38:52PM +0100, Simon Riggs wrote:
> On Sun, 2004-04-25 at 19:06, Alvaro Herrera wrote:

> > - pg_clog/pg_subtrans. Need a solution.

> As you're aware, our current work overlaps.
> pg_clog doesn't seem like the place to record subtransactions, though
> maybe it is... could we not give subtransactions a txnid just as with
> flat transactions? That way we can record everything in pg_clog AND
> recovery will work without further modification - as long as the failure
> of a top level transaction causes failure of every subtransaction EVEN
> if the subtrans originally committed.
>
> If you add pg_subtrans, you will need to make recovery work all over
> again...really, you don't want to be doing that, do you?

I'm not sure if I follow you. I suppose you haven't read the previous
discussions on this issue. pg_subtrans will have, for each Xid, the Xid
of its parent xact; if it's toplevel (as all xacts are implicitly in the
current implementation), it will have 0. In pg_clog, a committed
subxact will be marked with 11; committed top-level xact will still be
10. Aborted xact (toplevel and subxact) will have 01.

So whenever you see a xact with 10 in pg_clog, you know it committed.
Whenever you see 11, you know you have to fetch pg_subtrans and check
its parent (which could in turn be 11 so you have to recurse; or 10 so
you know it's committed; or 01 so you know if it's aborted; or 00 so you
know it's in progress).

After "a suitable time" (after the parent xact commits) the 11 can be
changed to 10.

I don't think there's really a change in how recovery works. There
will likely be more traffic to pg_xlog involving writes to pg_clog and
pg_subtrans but it shouldn't affect much, should it?

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"Linux transformó mi computadora, de una `máquina para hacer cosas',
en un aparato realmente entretenido, sobre el cual cada día aprendo
algo nuevo" (Jaime Salinas)

In response to

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2004-04-30 15:57:59 Re: width_bucket() per SQL2003 (WIP)
Previous Message Bruce Momjian 2004-04-30 14:37:46 Re: FW: Timezone library