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

Re: [PATCHES] [pgsql-patches] Phantom Command IDs, updated patch

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Bruce Momjian <bruce(at)momjian(dot)us>, Heikki Linnakangas <heikki(at)enterprisedb(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [PATCHES] [pgsql-patches] Phantom Command IDs, updated patch
Date: 2007-02-08 21:03:45
Message-ID: 19656.1170968625@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-patches
Alvaro Herrera <alvherre(at)commandprompt(dot)com> writes:
> Humm, sorry, obviously this makes no sense at all because I mentally
> mixed the Xid locker and the Cids.

After thinking a bit, I have a sketch of a solution.

Assume that we extend the MultiXact infrastructure so that it can track
whether each member of a MultiXact holds shared or exclusive lock.
(There are a couple ways you could do that --- add a parallel bit-array,
or separate the members into two groups.  Details not important for now.)
The only way you could have both shared- and exclusive-lock members is
if they are subtransactions of the same backend, but that fact isn't
real relevant to the MultiXact code.

Then extend MultiXactIdWait() so that you can tell it to wait for all
members to die, or just the exclusive members.

Then the representation of the problem situation would be that a locked
tuple would have as XMAX a MultiXact containing the upper XID as shared
locker and the subtransaction as exclusive locker.  Onlookers could wait
for one or both to die as appropriate depending on what kind of lock
they needed to get.  HEAP_XMAX_EXCL_LOCK would have to be a hint rather
than the truth, ie, once all the exclusive-lock members of the MultiXact
are dead it's really only a shared lock, but I don't see that this poses
any real difficulty.

I don't particularly want to go implement this now; I just want a
proof-of-concept sketch proving that we don't need separate cmin and
cmax to support this.

As for what I think we *should* do near-term, I'm pretty strongly
tempted to suggest that we just throw an error if a subtransaction tries
to upgrade an upper transaction's shared lock to exclusive.  When and if
we get a ton of complaints about that, it'd be time to put forth effort
to fix it.  I suspect the situation doesn't really arise much in
practice, else we'd have heard complaints from the field about the fact
that the shared lock can become lost.

Comments?

			regards, tom lane

In response to

Responses

pgsql-hackers by date

Next:From: Tom LaneDate: 2007-02-08 21:10:25
Subject: Re: [PATCHES] [pgsql-patches] Phantom Command IDs, updated patch
Previous:From: Bruce MomjianDate: 2007-02-08 21:03:14
Subject: Re: [PATCHES] [pgsql-patches] Phantom Command IDs, updated patch

pgsql-patches by date

Next:From: Tom LaneDate: 2007-02-08 21:08:36
Subject: Re: Feature: POSIX Shared memory support
Previous:From: Bruce MomjianDate: 2007-02-08 21:03:14
Subject: Re: [PATCHES] [pgsql-patches] Phantom Command IDs, updated patch

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