#include "utils/timeout.h"
+#ifndef USE_POSTMASTER_DEATH_SIGNAL
+/*
+ * On systems that need to make a system call to find out if the postmaster has
+ * gone away, we'll do so only every Nth call to HandleStartupProcInterrupts().
+ * This only affects how long it takes us to detect the condition while we're
+ * busy replaying WAL. Latch waits and similar which should react immediately
+ * through the usual techniques.
+ */
+#define POSTMASTER_POLL_RATE_LIMIT 1024
+#endif
+
/*
* Flags set by interrupt handlers for later service in the redo loop.
*/
void
HandleStartupProcInterrupts(void)
{
+#ifdef POSTMASTER_POLL_RATE_LIMIT
+ static uint32 postmaster_poll_count = 0;
+#endif
+
/*
* Process any requests or signals received recently.
*/
/*
* Emergency bailout if postmaster has died. This is to avoid the
- * necessity for manual cleanup of all postmaster children.
+ * necessity for manual cleanup of all postmaster children. Do this less
+ * frequently on systems for which we don't have signals to make that
+ * cheap.
*/
- if (IsUnderPostmaster && !PostmasterIsAlive())
+ if (IsUnderPostmaster &&
+#ifdef POSTMASTER_POLL_RATE_LIMIT
+ postmaster_poll_count++ % POSTMASTER_POLL_RATE_LIMIT == 0 &&
+#endif
+ !PostmasterIsAlive())
exit(1);
/* Process barrier events */