pgsql: Use standard SIGHUP and SIGTERM signal handlers in worker_spi. - Mailing list pgsql-committers

From Fujii Masao
Subject pgsql: Use standard SIGHUP and SIGTERM signal handlers in worker_spi.
Date
Msg-id E1kiWzj-00089O-9c@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Use standard SIGHUP and SIGTERM signal handlers in worker_spi.

Previously worker_spi used its custom signal handlers for SIGHUP and
SIGTERM. This commit makes worker_spi use the standard signal handlers,
to simplify the code.

Note that die() is used as the standard SIGTERM signal handler in
worker_spi instead of SignalHandlerForShutdownRequest() or bgworker_die().
Previously the exit handling was only able to exit from within the main loop,
and not from within the backend code it calls. This is why die() needs to
be used here, so worker_spi can respond to SIGTERM signal while it's
executing a query.

Maybe we can say that it's a bug that worker_spi could not respond to
SIGTERM during query execution. But since worker_spi is a just example
of the background worker code, we don't do the back-patch.

Thanks to Craig Ringer for the report and investigation of the issue.

Author: Bharath Rupireddy
Reviewed-by: Fujii Masao
Discussion: https://postgr.es/m/CALj2ACXDEZhAFOTDcqO9cFSRvrFLyYOnPKrcA1UG4uZn9hUAVg@mail.gmail.com
Discussion: https://postgr.es/m/CAGRY4nxsAe_1k_9g5b47orA0S011iBoHsXHFMH7cg7HV0O1bwQ@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/2a0847720ae6fa4180bfbe404e4e6bbf2f737708

Modified Files
--------------
src/test/modules/worker_spi/worker_spi.c | 52 ++++++--------------------------
1 file changed, 9 insertions(+), 43 deletions(-)


pgsql-committers by date:

Previous
From: Amit Kapila
Date:
Subject: pgsql: Fix replication of in-progress transactions in tablesync worker.
Next
From: Fujii Masao
Date:
Subject: pgsql: Use standard SIGTERM signal handler die() in test_shm_mq worker.