Re: Proper way to reload config files in backend SIGHUP handler

From: Mike Palmiotto <mike(dot)palmiotto(at)crunchydata(dot)com>
To: Euler Taveira <euler(at)timbira(dot)com(dot)br>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Proper way to reload config files in backend SIGHUP handler
Date: 2018-05-04 04:47:09
Message-ID: 48518af6-53be-f7e7-7871-8a2899ec16d3@crunchydata.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 05/03/2018 08:43 PM, Euler Taveira wrote:
> 2018-05-03 19:25 GMT-03:00 Mike Palmiotto <mike(dot)palmiotto(at)crunchydata(dot)com>:
>> I am writing a PostgreSQL extension and need to reload certain
>> extension-managed files whenever the postmaster is reloaded/receives SIGHUP,
>> but cannot find anything that looks like a standard way to do that. Is there a
>> hook or recommended method or something else I am missing?
>>
> Signals are initially blocked in bgworker. You have to unblock them
> (see BackgroundWorkerUnblockSignals) to allow your extension to
> customize its signal handlers. See an example in worker_spi test
> module.

I don't seem to have any problem catching the SIGHUP in my extension without
BackgroundWorkerUnblockSignals a la:

----

pqsignal_sighup(SIGHUP, sighup_handler);
.
.
.
static void
sighup_handler(SIGNAL_ARGS)
{
<parse configs>
}

----

Perhaps the signal is already unblocked at this point. Unblocking signals
first doesn't appear to have any affect. Am I missing something here?

I noticed that 6e1dd27
(https://github.com/postgres/postgres/commit/6e1dd2773eb60a6ab87b27b8d9391b756e904ac3)
introduced a ConfigReloadPending flag that can be set by calling
PostgresSigHupHandler inside the extension's handler, which seemingly allows
things to work as they usually would, and then we can go on to do other config
processing.

Is this approach kosher, or is there another preferred route?

Thanks,

--
Mike Palmiotto
Software Engineer
Crunchy Data Solutions
https://crunchydata.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Gierth 2018-05-04 04:59:41 Re: ignore_system_indexes affects DROP SCHEMA ... CASCADE reported number of objects dropped
Previous Message Peter Geoghegan 2018-05-04 03:19:49 Re: ignore_system_indexes affects DROP SCHEMA ... CASCADE reported number of objects dropped