Re: pre_load_libraries - Mailing list pgsql-hackers

From Marc Munro
Subject Re: pre_load_libraries
Date
Msg-id 1152755276.7928.107.camel@bloodnok.com
Whole thread Raw
In response to pre_load_libraries  (Marc Munro <marc@bloodnok.com>)
Responses Re: pre_load_libraries  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: pre_load_libraries  (Martijn van Oosterhout <kleptog@svana.org>)
List pgsql-hackers
On Wed, 2006-07-12 at 02:18 -0300, I wrote:
> I am trying to create an initialisation function that is called using
> the  preload_libraries option.
>
> The purpose of this is to set up shared memory for Veil, independant
> of postgres' own shared memory.  Simple init functions work fine, but
> as soon as I place calls to ShemAlloc, or LWLockAssign, the server
> startup simply halts.

To answer my own question, yes I am being unreasonable.  Shared memory
has not been set up at the time that process_preload_libraries is
called.

Since lwlocks are allocated from postgres shared memory, I cannot assign
an lwlock from Veil's initialisation code.  Instead, I can make the
allocation of the lwlock the responsibility of the first session that
uses a Veil function but I need a lock to prevent a race.

My current thinking is to simply subvert one of the existing lwlocks
while I assign my own.  A better solution from my point of view would be
to simply move the call to process_preload_libraries to a point after
shared memory has been set up.  Is there some reason this could not be
done?

On a related note, I can see no way to release Veil's shared memory
segment when postgres is shut down.   Perhaps I should be thinking about
making the management of such shared memory segments something that
postgres does on behalf of its add-ins, though that seems presumptious.

I'd appreciate any suggestions, pointers, random thoughts, etc.
__
Marc

pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: lastval exposes information that currval does not
Next
From: "Qingqing Zhou"
Date:
Subject: Re: postgresql.conf basic analysis tool