Skip site navigation (1) Skip section navigation (2)

Nested xacts, try 5

From: Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>
To: Patches <pgsql-patches(at)postgresql(dot)org>
Subject: Nested xacts, try 5
Date: 2004-05-23 22:02:12
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-patches

I attach a updated nested transactions patch.  Hopefully the list server
will actually distribute it this time.  I'd really like to get some
testing and comment.  Does this actually work on the scenarios where
those of you who would be using it expect it to work?

In this patch, relcache and catcache reference counting is handled as
previously discussed on pgsql-hackers: each item carries a stack onto
which the current refcount is pushed when a subtransaction starts, and
it is restored if the subtransaction aborts.  This is a "first cut" and
probably there some bug in the logic, but the basic cases work.

Also, Locks are released on subtrans abort based on the list of
committed child transactions, rather than relabeling at subtrans commit;
I suspect it's cheaper as we don't have to rehash the lock with the new

Main transaction commit and abort are logged with a list of committed
subtransactions.  At recovery, those are marked committed or aborted.

I added some logic to the pg_subtrans code so that a subcommitted
transaction whose parent is either committed or aborted (recursively) is
marked as committed/aborted if its Xid is lesser than a cutoff point.
The cutoff is taken from the xmin calculated at GetSnapshotData, so by
the time pg_clog is modified, no transaction is running which should see
them as in-progress.  Please comment on this, as the idea is new.  The
change is done in TransactionIdDidCommit() and TransactionIdDidAbort()
(and so the SubtransCutoffXid is kept in transam.c, which may seem
strange but it's actually the only place where it can be).

What's missing:

- deferred trigger handling
- Tom mentioned buffer manager state reversing.  I haven't investigated
  this yet.
- check that relcache and catcache code is correct.  I'm almost sure
  there's a bug.

Hopefully not much else.

Alvaro Herrera (<alvherre[a]>)
Tulio: oh, para qué servirá este boton, Juan Carlos?
Policarpo: No, aléjense, no toquen la consola!
Juan Carlos: Lo apretaré una y otra vez.

Attachment: nested-all-5.patch.gz
Description: application/octet-stream (28.7 KB)
Attachment: subtrans.c.gz
Description: application/octet-stream (3.6 KB)

pgsql-patches by date

Next:From: Neil ConwayDate: 2004-05-23 22:20:56
Subject: cosmetic psql tweaks
Previous:From: Tom LaneDate: 2004-05-23 21:32:36
Subject: Re: Tuple sampling

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group