Re: [HACKERS] 9.6, background worker processes, and PL/Java

2016-10-26 Thread Craig Ringer
On 27 October 2016 at 09:22, Chapman Flack 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

Re: [HACKERS] 9.6, background worker processes, and PL/Java

2016-10-26 Thread Chapman Flack
On 10/26/16 07:04, Amit Kapila wrote: > No, parallel workers in parallel query doesn't have MyProcPort. Ok ... it turns out I was using MyProcPort as a quick way to grab database_name and user_name (very early in startup, for a purpose analogous to setting a 'ps' process title), and that seemed mo

Re: [HACKERS] 9.6, background worker processes, and PL/Java

2016-10-26 Thread Craig Ringer
On 26 October 2016 at 06:56, Chapman Flack wrote: > My main question is, what state do I need to examine at startup > in order to distinguish these cases? For loaded in shared_preload_libraries, test IsPostmasterEnvironment && !IsUnderPostmaster See src/backend/utils/init/globals.c > Do I det

Re: [HACKERS] 9.6, background worker processes, and PL/Java

2016-10-26 Thread Amit Kapila
On Wed, Oct 26, 2016 at 7:39 AM, Chapman Flack wrote: > On 10/25/16 18:56, Chapman Flack wrote: > >> If pooled, and tied to the backend that started them, do they need >> to do anything special to detect when the leader has executed >> SET ROLE or SET SESSION AUTHORIZATION? > > Let me guess ... su

Re: [HACKERS] 9.6, background worker processes, and PL/Java

2016-10-26 Thread Amit Kapila
On Wed, Oct 26, 2016 at 4:26 AM, Chapman Flack wrote: > Hi, > > I have a report of a PL/Java crash in 9.6 where the stack trace > suggests it was trying to initialize in a background worker > process (not sure why that even happened, yet), and by my first > glance, it seems to have crashed derefer

Re: [HACKERS] 9.6, background worker processes, and PL/Java

2016-10-25 Thread Chapman Flack
On 10/25/16 18:56, Chapman Flack wrote: > If pooled, and tied to the backend that started them, do they need > to do anything special to detect when the leader has executed > SET ROLE or SET SESSION AUTHORIZATION? Let me guess ... such information is *not* synchronized across workers, and that'd

[HACKERS] 9.6, background worker processes, and PL/Java

2016-10-25 Thread Chapman Flack
Hi, I have a report of a PL/Java crash in 9.6 where the stack trace suggests it was trying to initialize in a background worker process (not sure why that even happened, yet), and by my first glance, it seems to have crashed dereferencing MyProcPort, which I am guessing a BGW might not always have