Re: FOR SHARE vs FOR UPDATE locks

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Heikki Linnakangas" <heikki(at)enterprisedb(dot)com>
Cc: "Alvaro Herrera" <alvherre(at)commandprompt(dot)com>, "Simon Riggs" <simon(at)2ndquadrant(dot)com>, pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: FOR SHARE vs FOR UPDATE locks
Date: 2006-12-01 17:58:31
Message-ID: 758.1164995911@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs pgsql-hackers

"Heikki Linnakangas" <heikki(at)enterprisedb(dot)com> writes:
> Yeah. Even without a real update, I just figured you can't upgrade a
> shared lock held by an arbitrarily chosen parent to an exclusive lock.
> If that subxid aborts, and if any of the parents of that subtransaction
> held the shared lock, that lock would be released incorrectly. Which is
> essentially the same problem we began with.

Well, there's nothing "arbitrarily chosen" about it, because the lock
shown in the tuple would always be the most senior live subtransaction.
So I don't think your concern above is a real problem. Nonetheless, the
proposed hack is definitely playing some games with the semantics, and
while we might be able to get away with that for the question of "is this
lock shared or exclusive", it certainly won't do for an actual update.

> Let's throw an error for now. We have to come back to this in 8.3, I think.

I think it's OK to fix it so that we allow the pre-existing lock to be
held by a subtransaction of the current xact, but not a parent.

regards, tom lane

In response to

Browse pgsql-docs by date

  From Date Subject
Next Message Jeff Davis 2006-12-01 18:43:01 Re: [HACKERS] FOR SHARE vs FOR UPDATE locks
Previous Message Heikki Linnakangas 2006-12-01 17:46:31 Re: FOR SHARE vs FOR UPDATE locks

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeff Davis 2006-12-01 18:43:01 Re: [HACKERS] FOR SHARE vs FOR UPDATE locks
Previous Message Alvaro Herrera 2006-12-01 17:57:24 Re: 8.2 Beta3-> RC1 upgrade