Re: Add cassert-only checks against unlocked use of relations - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Add cassert-only checks against unlocked use of relations
Date
Msg-id 31989.1383687949@sss.pgh.pa.us
Whole thread Raw
In response to Re: Add cassert-only checks against unlocked use of relations  (Andres Freund <andres@2ndquadrant.com>)
Responses Re: Add cassert-only checks against unlocked use of relations  (Andres Freund <andres@2ndquadrant.com>)
List pgsql-hackers
Andres Freund <andres@2ndquadrant.com> writes:
> On 2013-11-05 16:25:53 -0500, Tom Lane wrote:
>> If we're sufficiently worried by this type of bug, ISTM we'd be better off
>> just disallowing heap_open(NoLock).  At the time we invented that, every
>> lock request went to shared memory; but now that we have the local lock
>> table, re-locking just requires a local hash lookup followed by
>> incrementing a local counter.  That's probably pretty cheap --- certainly
>> a lot cheaper than what you've got here.

> Hm. That only works though if we're using the same lockmode as before -
> often enough the *_open(NoLock) checks would use a weaker locklevel than
> the previous lock. So I think the cost of doing so would probably be
> noticeable.

If you're not using the same lockmode as before, it's probably a bug anyway.
As I said already, the entire NoLock coding technique is dependent on
having a very clear idea of which previous lock-taking you're riding
on the coattails of.  Why wouldn't you duplicate that lock level, 
if we say you can't use NoLock anymore?
        regards, tom lane



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: Add cassert-only checks against unlocked use of relations
Next
From: Kevin Grittner
Date:
Subject: Re: missing locking in at least INSERT INTO view WITH CHECK