[HACKERS] Add cassert-only checks against unlocked use of relations

2013-11-05 Thread Andres Freund
Hi, There frequently have been bugs where (heap|relation|index)_open(NoLock) was used without a previous locks which in some circumstances is an easy mistake to make and which is hard to notice. The attached patch adds --use-cassert only WARNINGs against doing so: Add cassert-only checks

Re: [HACKERS] Add cassert-only checks against unlocked use of relations

2013-11-05 Thread Tom Lane
Andres Freund and...@2ndquadrant.com writes: There frequently have been bugs where (heap|relation|index)_open(NoLock) was used without a previous locks which in some circumstances is an easy mistake to make and which is hard to notice. The attached patch adds --use-cassert only WARNINGs

Re: [HACKERS] Add cassert-only checks against unlocked use of relations

2013-11-05 Thread Andres Freund
On 2013-11-05 16:25:53 -0500, Tom Lane wrote: Andres Freund and...@2ndquadrant.com writes: There frequently have been bugs where (heap|relation|index)_open(NoLock) was used without a previous locks which in some circumstances is an easy mistake to make and which is hard to notice. The

Re: [HACKERS] Add cassert-only checks against unlocked use of relations

2013-11-05 Thread Tom Lane
Andres Freund and...@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

Re: [HACKERS] Add cassert-only checks against unlocked use of relations

2013-11-05 Thread Andres Freund
On 2013-11-05 16:45:49 -0500, Tom Lane wrote: Andres Freund and...@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

Re: [HACKERS] Add cassert-only checks against unlocked use of relations

2013-11-05 Thread Andres Freund
On 2013-11-05 22:35:41 +0100, Andres Freund wrote: We could relatively easily optimize that to a constant factor by just iterating over the possible lockmodes. Should only take a couple more lines. On that note, any chance you remember why you increased MAX_LOCKMODE by 2 to 10 back in 2001

Re: [HACKERS] Add cassert-only checks against unlocked use of relations

2013-11-05 Thread Tom Lane
Andres Freund and...@2ndquadrant.com writes: On that note, any chance you remember why you increased MAX_LOCKMODE by 2 to 10 back in 2001 although AccessExclusiveLock is 8? The relevant commit is 4fe42dfbc3bafa0ea615239d716a6b37d67da253 . Probably because it seemed like a round number, which 9

Re: [HACKERS] Add cassert-only checks against unlocked use of relations

2013-11-05 Thread Andres Freund
On 2013-11-05 17:19:21 -0500, Tom Lane wrote: Andres Freund and...@2ndquadrant.com writes: On that note, any chance you remember why you increased MAX_LOCKMODE by 2 to 10 back in 2001 although AccessExclusiveLock is 8? The relevant commit is 4fe42dfbc3bafa0ea615239d716a6b37d67da253 .