Re: Weirdness using Executor Hooks

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Eric Ridge <eebbrr(at)gmail(dot)com>
Cc: Andres Freund <andres(at)anarazel(dot)de>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Weirdness using Executor Hooks
Date: 2015-06-18 21:30:47
Message-ID: 4584.1434663047@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Eric Ridge <eebbrr(at)gmail(dot)com> writes:
> On Thu, Jun 18, 2015 at 4:42 PM, Andres Freund <andres(at)anarazel(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2015-06-18 21:39:48 Re: Weirdness using Executor Hooks
Previous Message Robert Haas 2015-06-18 21:20:31 Re: Inheritance planner CPU and memory usage change since 9.3.2