User-assigned LWLocks (was Re: Announcing Veil) - Mailing list pgsql-hackers

From Tom Lane
Subject User-assigned LWLocks (was Re: Announcing Veil)
Date
Msg-id 7990.1128716486@sss.pgh.pa.us
Whole thread Raw
In response to Re: Announcing Veil  (Marc Munro <marc@bloodnok.com>)
Responses Re: User-assigned LWLocks (was Re: Announcing Veil)
List pgsql-hackers
Marc Munro <marc@bloodnok.com> writes:
> Thanks for this.  I am very happy that this patch will be going in.
> Thanks also for pointing out the correct header to use.

Patch applied for 8.1.

> As Tom points out, this will do nothing for users of 7.4 and 8.0.  For
> these versions I propose to continue to use MMCacheLock.  As far as I
> can see, this is safe in 7.4, and otherwise unused in 8.0.

Yeah, MMCacheLock is for long-dead code, so you can probably get away
with using it in the back versions.

> On the use of LWLockAssign():can anyone tell me if I should protect the
> call using the ShmemLock spinlock?

Hmm ... the comment for LWLockAssign is not meant to imply that the
caller could do that; in the event of being out of LWLocks, the code
would elog(FATAL) without releasing the spinlock, which would lock up
the whole database.  If we were to do it that way we'd need the spinlock
handling to be done inside LWLockAssign.  This would not be that bad,
just a marginal slowdown during database startup, but given the low
demand for this feature I'm not very eager to do it.

The alternative though would seem to be to adopt some convention about
another LWLock to take while trying to assign a new LWLock post-startup.
None of the existing locks seem very appropriate for this, and putting
the responsibility on callers might be unwise anyway.

Thoughts?
        regards, tom lane


pgsql-hackers by date:

Previous
From: "Jonah H. Harris"
Date:
Subject: Oracle buys Innobase
Next
From: "Luke Lonergan"
Date:
Subject: Re: Oracle buys Innobase