RE: SIGQUIT handling, redux

tsunakawa.takay@fujitsu.com <tsunakawa.takay@fujitsu.com>

From: "tsunakawa.takay@fujitsu.com" <tsunakawa.takay@fujitsu.com>
To: 'Tom Lane' <tgl@sss.pgh.pa.us>
Cc: "pgsql-hackers@lists.postgresql.org" <pgsql-hackers@lists.postgresql.org>
Date: 2020-09-10T02:56:37Z
Lists: pgsql-hackers
From: Tom Lane <tgl@sss.pgh.pa.us>
> This is straying a bit from the stated topic of this thread, but ...
> I did some further looking around to see whether there were any
> unsafe signal handlers besides SIGQUIT ones.  The situation is not
> too awful, but I did find several issues not already mentioned
> in this thread:

Wow, your eyes catch this many issues.  (I was just wondering about one or two of them.)

I'm not sure if this is related, but I had been wondering if the following can be what it is now.


(1)
When logical replication is used, pg_ctl stop with the default fast mode emits the message about termination of logical replication launcher.  Although it's not FATAL or ERROR, but I was a bit startled when I saw this message for the first time.  Why should this message be emitted while nothing about other postmaster children are reported?  The logical rep launcher ignores SIGINT (SIG_IGN).

LOG:  received fast shutdown request
LOG:  aborting any active transactions
LOG:  background worker "logical replication launcher" (PID 10056) exited with exit code 1
LOG:  shutting down
LOG:  database system is shut down


(2)
When the physical standby stops, a FATAL message is output.  It may be annoying to the DBA that monitors messages with high severity.

LOG:  received fast shutdown request
LOG:  aborting any active transactions
FATAL:  terminating walreceiver process due to administrator command
LOG:  shutting down
LOG:  database system is shut down


(3)
When WaitLatch(EXIT_ON_POSTMASTER_DEATH) detects postmaster death, it calls proc_exit(1).  Can we call _exit(1) here likewise?


Regards
Takayuki Tsunakawa





Commits

  1. Log a message when resorting to SIGKILL during shutdown/crash recovery.

  2. Don't run atexit callbacks during signal exits from ProcessStartupPacket.

  3. Use _exit(2) for SIGQUIT during ProcessStartupPacket, too.

  4. Make archiver's SIGQUIT handler exit via _exit().