Re: 9.6, background worker processes, and PL/Java

From: Craig Ringer <craig(at)2ndquadrant(dot)com>
To: Chapman Flack <chap(at)anastigmatix(dot)net>
Cc: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: 9.6, background worker processes, and PL/Java
Date: 2016-10-27 01:47:05
Message-ID: CAMsr+YHdHDyZVMHgLQsZ6uq9sTkeTgZBCLv3fSRMU5O4oLhY9A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 27 October 2016 at 09:22, Chapman Flack <chap(at)anastigmatix(dot)net> wrote:

> Hmm, IsUnderPostmaster is PGDLLIMPORTed but IsPostmasterEnvironment isn't,
> so I'm out of luck on Windows. Is there another way I can check?
>
>>> Do I detect I'm in a BGW by a non-null MyBgworkerEntry?
>>
>> Use IsBackgroundWorker, same place as above.
>
> Also not PGDLLIMPORTed. MyBgworkerEntry is, though. It does appear to be
> initialized to NULL. Can I get away with checking that, since I can't see
> IsBackgroundWorker?
>
> I now see what caused the reported crash. It was a parallel query that
> did not make any use of PL/Java functions, but the group leader had used
> them before so the library was loaded, so ParallelWorkerMain loaded it
> in the worker process, so _PG_init got called and was going to refer to
> stuff that wasn't set up yet, because the library loading comes pretty
> early in ParallelWorkerMain.
>
> I think I could easily fix that by having the library init code just bail
> right after defining the custom GUCs, if InitializingParallelWorker
> is true.
>
> Alas, InitializingParallelWorker isn't PGDLLIMPORTed either. This isn't
> my day. Is there a way I can successfully infer that on Windows?

Please submit a patch to make them all PGDLLIMPORT. They clearly
should be, for use in bgworkers.

I'd consider that a bugfix personally and hope it can be backpatched
to the stable branches. It's not going to break anything since nothing
external that runs on Windows can previously have been referring to
these symbols.

--
Craig Ringer http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Julian Markwort 2016-10-27 01:58:07 Re: [PATCH] pgpassfile connection option
Previous Message Michael Paquier 2016-10-27 01:45:10 Re: add more NLS to bin