Re: Excessive PostmasterIsAlive calls slow down WAL redo
Thomas Munro <thomas.munro@enterprisedb.com>
From: Thomas Munro <thomas.munro@enterprisedb.com>
To: Heikki Linnakangas <hlinnaka@iki.fi>
Cc: Michael Paquier <michael@paquier.xyz>, Andres Freund <andres@anarazel.de>, Tom Lane <tgl@sss.pgh.pa.us>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2018-07-11T01:16:31Z
Lists: pgsql-hackers
On Tue, Jul 10, 2018 at 11:39 PM, Heikki Linnakangas <hlinnaka@iki.fi> wrote: > The 'postmaster_possibly_dead' flag is not reset anywhere. So if a process > receives a spurious death signal, even though postmaster is still alive, > PostmasterIsAlive() will continue to use the slow path. +1 > postmaster_possibly_dead needs to be marked as 'volatile', no? +1 > The autoconf check for PR_SET_PDEATHSIG seems slightly misplaced. And I > think we can simplify it with AC_CHECK_HEADER(). I'd also like to avoid > adding code to c.h for this, that seems too global. +1, much nicer, thanks. > After some kibitzing, I ended up with the attached. It fixes the > postmaster_possible_dead issues mentioned above, and moves around the > autoconf and #ifdef logic a bit to make it a bit nicer, at least in my > opinion. Thanks, that looks good to me. I added your name as co-author and pushed to master. I also made a couple of minor cosmetic changes in PostmasterDeathSignalInit() to make the follow-up patch prettier (#if defined() instead of #ifdef, and a signum variable because I later need its address). > I don't have a FreeBSD machine at hand, so I didn't try fixing that > patch. I updated the FreeBSD version to use the header test approach you showed, and pushed that too. FWIW the build farm has some FreeBSD animals with and without PROC_PDEATHSIG_CTL. I suppose it's possibly that we might want to reconsider the choice of signal in the future (SIGINFO or SIGPWR). (Random archeological note: TIL that Linux stole <sys/prctl.h> from Irix (RIP), but it had PR_TERMCHILD instead of PR_SET_PRDEATHSIG.) -- Thomas Munro http://www.enterprisedb.com
Commits
-
Poll postmaster less frequently in recovery.
- 57dcc2ef3320 14.0 landed
-
Use signals for postmaster death on FreeBSD.
- f98b8476cd4a 12.0 landed
-
Use signals for postmaster death on Linux.
- 9f09529952ac 12.0 landed
-
Introduce a pipe between postmaster and each backend, which can be used to
- 89fd72cbf26f 9.2.0 cited