Re: Weirdness using Executor Hooks - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Weirdness using Executor Hooks
Date
Msg-id 4584.1434663047@sss.pgh.pa.us
Whole thread Raw
In response to Re: Weirdness using Executor Hooks  (Eric Ridge <eebbrr@gmail.com>)
Responses Re: Weirdness using Executor Hooks  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Weirdness using Executor Hooks  (Eric Ridge <eebbrr@gmail.com>)
List pgsql-hackers
Eric Ridge <eebbrr@gmail.com> writes:
> On Thu, Jun 18, 2015 at 4:42 PM, Andres Freund <andres@anarazel.de> wrote:
>> How does your _PG_init() actually look like?

> static ExecutorStart_hook_type prev_ExecutorStartHook = NULL;
> static ExecutorEnd_hook_type prev_ExecutorEndHook  = NULL;

> void _PG_init(void)
> {
>    prev_ExecutorStartHook = ExecutorStart_hook;
>    prev_ExecutorEndHook = ExecutorEnd_hook;

>    ExecutorStart_hook = my_executor_start_hook;
>    ExecutorEnd_hook = my_executor_end_hook;

>    RegisterXactCallback(my_xact_callback, NULL);
> }

If that's broken, then so are most of our contrib modules.
Certainly none of them have an extra check as suggested by Andres.

> As a data point, that might be interesting to know, but I'd still be
> scratching my head about how it happened.  Postgres doesn't load an
> extension library more than once per backend session, does it?

It's not supposed to, and AFAICS internal_load_library() will treat
either an exact pathname match or an inode-number match as being
"already loaded".  I wonder if you might be doing something that
confuses those checks.  It does not look like we try terribly hard
to canonicalize library pathnames --- might you have some references
under different relative paths, for instance?  The inode number
check would perhaps fail if you'd installed a new library version,
but it's unclear to me why the pathname check would fail.
        regards, tom lane



pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: Inheritance planner CPU and memory usage change since 9.3.2
Next
From: Tom Lane
Date:
Subject: Re: Weirdness using Executor Hooks