IsUnderPostmaster with shared_preload_libraries on Windows

Started by Joe Conwayover 9 years ago3 messages
#1Joe Conway
mail@joeconway.com

Is it expected that IsUnderPostmaster is true during postmaster startup
in an extension's _PG_init() when preloading under Windows? On Linux it
is false at this point AFAICT.

Thanks,

Joe

--
Crunchy Data - http://crunchydata.com
PostgreSQL Support for Secure Enterprises
Consulting, Training, & Open Source Development

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Joe Conway (#1)
Re: IsUnderPostmaster with shared_preload_libraries on Windows

Joe Conway <mail@joeconway.com> writes:

Is it expected that IsUnderPostmaster is true during postmaster startup
in an extension's _PG_init() when preloading under Windows? On Linux it
is false at this point AFAICT.

AFAIK it will be false in the *postmaster's* execution of _PG_init().
But keep in mind that on Windows each exec'd child process will have to
load the shared_preload_libraries again for itself, and those executions
should see IsUnderPostmaster = true. I think what you are seeing is
additional executions in the startup process or other background
processes, which don't happen in a forked-children environment.

You can probably duplicate this behavior for testing purposes on Unix
by compiling with EXEC_BACKEND defined, if that helps.

regards, tom lane

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#3Joe Conway
mail@joeconway.com
In reply to: Tom Lane (#2)
Re: IsUnderPostmaster with shared_preload_libraries on Windows

On 06/13/2016 01:57 PM, Tom Lane wrote:

Joe Conway <mail@joeconway.com> writes:

Is it expected that IsUnderPostmaster is true during postmaster startup
in an extension's _PG_init() when preloading under Windows? On Linux it
is false at this point AFAICT.

AFAIK it will be false in the *postmaster's* execution of _PG_init().
But keep in mind that on Windows each exec'd child process will have to
load the shared_preload_libraries again for itself, and those executions
should see IsUnderPostmaster = true. I think what you are seeing is
additional executions in the startup process or other background
processes, which don't happen in a forked-children environment.

You can probably duplicate this behavior for testing purposes on Unix
by compiling with EXEC_BACKEND defined, if that helps.

Thanks, definitely easier to debug on Linux. It appears the best answer
is to use process_shared_preload_libraries_in_progress rather than
trying to derive that information using IsUnderPostmaster.

Joe

--
Crunchy Data - http://crunchydata.com
PostgreSQL Support for Secure Enterprises
Consulting, Training, & Open Source Development