Behaviour of bgworker with SIGHUP

From: Guillaume Lelarge <guillaume(at)lelarge(dot)info>
To: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Behaviour of bgworker with SIGHUP
Date: 2012-12-28 15:53:21
Message-ID: 1356710001.1993.16.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

Today, I tried to make fun with the new background worker processes in
9.3, but I found something disturbing, and need help to go further.

My code is available on https://github.com/gleu/stats_recorder. If you
take a look, it is basically a copy of Alvarro's worker_spi contrib
module with a few changes. It compiles, and installs OK.

With this code, when I change my config option (stats_recorder.naptime),
I see that PostgreSQL gets the new value, but my background worker
process doesn't. See these log lines:

LOG: stats recorder, worker_spi_main loop, stats_recorder_naptime is 1
LOG: stats recorder, worker_spi_main loop, stats_recorder_naptime is 1
LOG: received SIGHUP, reloading configuration files
LOG: parameter "stats_recorder.naptime" changed to "5"
LOG: stats recorder, worker_spi_sighup
LOG: stats recorder, worker_spi_main loop, stats_recorder_naptime is 1
LOG: stats recorder, worker_spi_main loop, stats_recorder_naptime is 1

Is it the work of the function (pointed by bgw_sighup) to get the new
config values from the postmaster? and if so, how can I get these new
values?

I thought the configuration reloading would work just like a shared
library but it doesn't seem so. I wondered if it was because I had the
sighup function (initialized with bgw_sighup), so I got rid of it. The
new behaviour was actually more surprising as it launched _PG_init each
time I did a "pg_ctl reload".

LOG: stats recorder, worker_spi_main loop, stats_recorder_naptime is 1
LOG: stats recorder, worker_spi_main loop, stats_recorder_naptime is 1
LOG: received SIGHUP, reloading configuration files
LOG: stats_recorder, _PG_init
FATAL: cannot create PGC_POSTMASTER variables after startup
LOG: worker process: stats recorder (PID 5435) exited with exit code 1

Is it the expected behaviour?

Thanks.

Regards.

--
Guillaume
http://blog.guillaume.lelarge.info
http://www.dalibo.com

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2012-12-28 15:57:05 Re: enhanced error fields
Previous Message Tom Lane 2012-12-28 15:32:43 Re: multiple CREATE FUNCTION AS items for PLs