Thread: When is a shared library unloaded?

When is a shared library unloaded?

From
"Jon Horsman"
Date:
I have a shared library loaded into postgresql using

CREATE FUNCTION medbevent() RETURNS trigger as
'/usr/lib/pgsql/libmedbevent.so' language 'C';

I'm randomly having issues with my triggers not firing (it turns out
they are getting removed) and when i turned INFO logs on i saw the
following

2007-08-14 13:41:44.740305500 LOCATION:  _fini, medbevent_init.c:129
2007-08-14 13:41:45.790850500 INFO:  00000: medbeventlib -Unloading
library _fini() is called

Could someone please explain when a shared library gets
loaded/unloaded and how this all works?  I'm getting the above logs
when i wouldn't expect to see the library be unloaded which is causing
me problems.  Could the library get unloaded in this manner due to an
internal error in the library?

Thanks,

Jon.


Re: When is a shared library unloaded?

From
Tom Lane
Date:
"Jon Horsman" <horshaq@gmail.com> writes:
> I'm randomly having issues with my triggers not firing (it turns out
> they are getting removed) and when i turned INFO logs on i saw the
> following

> 2007-08-14 13:41:44.740305500 LOCATION:  _fini, medbevent_init.c:129
> 2007-08-14 13:41:45.790850500 INFO:  00000: medbeventlib -Unloading
> library _fini() is called

> Could someone please explain when a shared library gets
> loaded/unloaded and how this all works?

Are you sure the above doesn't just occur during server process
termination?  AFAIK Postgres never unloads a library, except when you
specifically command it to load an updated version via the LOAD command.
        regards, tom lane


Re: When is a shared library unloaded?

From
"Jon Horsman"
Date:
> "Jon Horsman" <horshaq@gmail.com> writes:
> > I'm randomly having issues with my triggers not firing (it turns out
> > they are getting removed) and when i turned INFO logs on i saw the
> > following
>
> > 2007-08-14 13:41:44.740305500 LOCATION:  _fini, medbevent_init.c:129
> > 2007-08-14 13:41:45.790850500 INFO:  00000: medbeventlib -Unloading
> > library _fini() is called
>
> > Could someone please explain when a shared library gets
> > loaded/unloaded and how this all works?
>
> Are you sure the above doesn't just occur during server process
> termination?  AFAIK Postgres never unloads a library, except when you
> specifically command it to load an updated version via the LOAD command.
>
>                         regards, tom lane

Yup, the server process is still up and going, i have other clients
connected to postgres that still function when this happens.  I'm not
using the LOAD command anywhere so thats not the problem.  One of my
colleagues was doing some reading and said he found something that
stating that the fini() function is "unreliable", i'm not sure where
he read that though...

Jon.


Re: When is a shared library unloaded?

From
"Jon Horsman"
Date:
Here is a little more information about my problem.

There is a library( that has stored procedures) for processing trigger
events.  The library is loaded on first access( i.e when there is a
trigger event to be sent).  Normally, it gets unloaded during a
postgres server shutdown but the library seems to be getting unloaded
occasionally.    We have logs in the _init( ) and _fini( ) of the
library and we see that there are times when _fini( ) is getting
called when you wouldn't expect it to be.

Has anyone else had issues similar to this?

Thanks,

Jon.



On 8/15/07, Jon Horsman <horshaq@gmail.com> wrote:
> > "Jon Horsman" <horshaq@gmail.com> writes:
> > > I'm randomly having issues with my triggers not firing (it turns out
> > > they are getting removed) and when i turned INFO logs on i saw the
> > > following
> >
> > > 2007-08-14 13:41:44.740305500 LOCATION:  _fini, medbevent_init.c:129
> > > 2007-08-14 13:41:45.790850500 INFO:  00000: medbeventlib -Unloading
> > > library _fini() is called
> >
> > > Could someone please explain when a shared library gets
> > > loaded/unloaded and how this all works?
> >
> > Are you sure the above doesn't just occur during server process
> > termination?  AFAIK Postgres never unloads a library, except when you
> > specifically command it to load an updated version via the LOAD command.
> >
> >                         regards, tom lane
>
> Yup, the server process is still up and going, i have other clients
> connected to postgres that still function when this happens.  I'm not
> using the LOAD command anywhere so thats not the problem.  One of my
> colleagues was doing some reading and said he found something that
> stating that the fini() function is "unreliable", i'm not sure where
> he read that though...
>
> Jon.
>