pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@dcc.uchile.cl>
To: Patches <pgsql-patches@postgresql.org>
Subject: Nested transactions
Date: Tue, 8 Jun 2004 18:23:56 -0400
Message-ID: <20040608222356.GC13820@dcc.uchile.cl> (raw)

Hackers,

Here is the latest installment of the nested transactions patch.

What's in the current patch:

- transaction block support.  The user can start subtransactions inside
  each transaction block and rollback each one independently.  The
  nesting level has no practical limit, though each transaction tree can
  have at most 2^32 commands (subtransaction start counts as one
  command).
  
- Most subsystems have a cleanup function called at subtransaction
  abort: deferred triggers, relcache refcount, catcache refcount, smgr
  pending deletes, gist/rtree/hash scan lists, bufmgr refcount,
  on-commit actions.

- SPI closes connections opened during the aborting subtransaction.

- The lock manager releases locks taken by the aborting subtransaction,
  but _holds_ locks taken by a committing subtransaction.  This is
  needed by MVCC semantics.

- A special memory context, CommitContext is created for each
  subtransaction.  It is destroyed if the subtransaction aborts, but
  if it commits then it will be kept until main transaction commit
  (or its parent subtransaction aborts).

- The pg_subtrans module is created to keep the parent Xid of each
  subtransaction.  It's similar (and based on) the pg_clog code.

- The pg_clog Xlog code was moved to Slru and merged with pg_subtrans
  Xlog code.

- When we wait for a transaction to finish (XactLockTableWait), we
  actually wait for the topmost transaction.

- SET TRANSACTION ISOLATION LEVEL and SET READ ONLY are not allowed
  inside a subtransaction.

What's missing to complete the nested transactions work:

- Make GUC vars work correctly.
- Lots of testing.
- Documentation
- Optimizations:
  * the phantom Xid idea is not implemented here.
  * optimize TransactionIdIsInProgress
  * profile
- More regression testing.  Need additional concurrent infrastructure.

Many thanks to:

- Manfred Koizar for making the pg_subtrans code possible and discussion
  on several issues.
- Stephan Szabo for the idea on which the deferred trigger code was
  based.
- Tom Lane for asking the right questions.
- Bruce Momjian for useful ideas.


IMHO this patch should be reviewed and applied to achieve wide testing
as soon as possible before feature freeze.  More changes can be applied
later as available/needed.  (The patch is already huge and contains
several important changes that need careful review.  Adding more to the
mix will only make things more difficult.)

-- 
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"No single strategy is always right (Unless the boss says so)"
(Larry Wall)

Attachments:

  nested-all-13.patch.gz (application/octet-stream, 44.6K) download

view thread (19+ messages)  latest in thread

Message-ID: <20040608222356.GC13820@dcc.uchile.cl>
Permalink:  ../20040608222356.GC13820@dcc.uchile.cl/
Also on:    postgresql.org/message-id/20040608222356.GC13820@dcc.uchile.cl

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: alvherre@dcc.uchile.cl, pgsql-patches@postgresql.org
  Subject: Re: Nested transactions
  In-Reply-To: <20040608222356.GC13820@dcc.uchile.cl>
  References: <20040608222356.GC13820@dcc.uchile.cl>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox