Re: 9.6, background worker processes, and PL/Java - Mailing list pgsql-hackers

From Craig Ringer
Subject Re: 9.6, background worker processes, and PL/Java
Date
Msg-id CAMsr+YHdHDyZVMHgLQsZ6uq9sTkeTgZBCLv3fSRMU5O4oLhY9A@mail.gmail.com
Whole thread Raw
In response to Re: 9.6, background worker processes, and PL/Java  (Chapman Flack <chap@anastigmatix.net>)
List pgsql-hackers
On 27 October 2016 at 09:22, Chapman Flack <chap@anastigmatix.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



pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: add more NLS to bin
Next
From: Julian Markwort
Date:
Subject: Re: [PATCH] pgpassfile connection option