Re: SIGQUIT handling, redux
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andres Freund <andres@anarazel.de>
Cc: pgsql-hackers@lists.postgresql.org
Date: 2020-09-09T22:00:41Z
Lists: pgsql-hackers
I wrote: >> Not only DNS, but all the various auth libraries would have to be >> contended with. Lots of work there compared to the likely rewards. > Wait a minute. The entire authentication cycle happens inside > InitPostgres, using the backend's normal signal handlers. So > maybe we are overthinking the problem. What if we simply postpone > ProcessStartupPacket into that same place, and run it under the same > rules as we do for authentication? Or, continuing to look for other answers ... During BackendInitialize we have not yet touched shared memory. This is not incidental but must be so, per its header comment. Therefore it seems like we could have these signal handlers (for SIGTERM or timeout) do _exit(1), thereby resolving the signal unsafety while not provoking a database restart. We don't care whether inside-the-process state is sane, and we shouldn't have changed anything yet in shared memory. This is obviously not 100.00% safe, since maybe something could violate these assumptions, but it seems a lot safer than using proc_exit() from a signal handler. One way to help catch any such assumption-violations is to add an assertion that no on_shmem_exit handlers have been set up yet. If there are none, there should be no expectation of having to clean up shared state. regards, tom lane
Commits
-
Log a message when resorting to SIGKILL during shutdown/crash recovery.
- 10095ca634fb 14.0 landed
-
Don't run atexit callbacks during signal exits from ProcessStartupPacket.
- 6693a96b329e 14.0 landed
-
Use _exit(2) for SIGQUIT during ProcessStartupPacket, too.
- 58c6feccfae1 14.0 landed
- e2c9bedc9660 9.5.24 landed
- dc71c640985f 9.6.20 landed
- ac695b8f2d11 10.15 landed
- 93871b693c3e 11.10 landed
- 4e10c0c8a669 12.5 landed
- 3f29aa48b6df 13.0 landed
-
Make archiver's SIGQUIT handler exit via _exit().
- bedadc73220f 14.0 landed
- d038c6c6318b 12.5 landed
- b2eaddd9b00a 9.6.20 landed
- 95cd8902e62d 10.15 landed
- 67dde49a3ddb 11.10 landed
- 581855b6ae23 9.5.24 landed
- 35e59398abbb 13.0 landed