Re: FOR SHARE vs FOR UPDATE locks - Mailing list pgsql-hackers

From Tom Lane
Subject Re: FOR SHARE vs FOR UPDATE locks
Date
Msg-id 758.1164995911@sss.pgh.pa.us
Whole thread Raw
In response to Re: FOR SHARE vs FOR UPDATE locks  ("Heikki Linnakangas" <heikki@enterprisedb.com>)
List pgsql-hackers
"Heikki Linnakangas" <heikki@enterprisedb.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


pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: 8.2 Beta3-> RC1 upgrade
Next
From: Jeff Davis
Date:
Subject: Re: FOR SHARE vs FOR UPDATE locks