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

Re: Cancel/Kill backend functions

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>
Cc: Neil Conway <neilc(at)samurai(dot)com>,Magnus Hagander <mha(at)sollentuna(dot)net>,Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, pgsql-patches(at)postgresql(dot)org
Subject: Re: Cancel/Kill backend functions
Date: 2004-05-28 06:24:45
Message-ID: 15592.1085725485@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-patches
Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl> writes:
> I could write it to save the xid's in PGPROC in a first pass, then
> release the SInvalLock, then look at pg_subtrans.  But I think doing it
> this way has a ("is a?") race condition.

The way that would be technically correct is to *first* look in
pg_subtrans to resolve the xid up to a main xid, then look in PGPROC
to see if that main xact is still active.  (You can return "no"
immediately if the sub-xact is aborted, but that would require yet
another probe into pg_clog, which might not be worth the trouble.)

Of course that's likely to be unpleasantly slow.  Making it faster is an
exercise for the student ;-).

It's worth considering here that the normal case might very soon be that
most tuples are in fact modified by subtransactions.  So I would not
advise optimizing on the assumption that you won't normally have to look
at pg_subtrans.

IIRC there was some discussion of keeping subtrans IDs up to some
limited nesting depth right in PGPROC.  I'm not sure that would help a
whole lot (it helps with a positive answer, but not with a negative).

			regards, tom lane

In response to

pgsql-patches by date

Next:From: Serguei MokhovDate: 2004-05-28 06:35:05
Subject: Russian translation updates for 7.5
Previous:From: Sean ChittendenDate: 2004-05-28 05:48:41
Subject: Small doc patch for area() function...

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