34
34
#include "utils/timeout.h"
35
35
36
36
37
+ #ifndef USE_POSTMASTER_DEATH_SIGNAL
38
+ /*
39
+ * On systems that need to make a system call to find out if the postmaster has
40
+ * gone away, we'll do so only every Nth call to HandleStartupProcInterrupts().
41
+ * This only affects how long it takes us to detect the condition while we're
42
+ * busy replaying WAL. Latch waits and similar which should react immediately
43
+ * through the usual techniques.
44
+ */
45
+ #define POSTMASTER_POLL_RATE_LIMIT 1024
46
+ #endif
47
+
37
48
/*
38
49
* Flags set by interrupt handlers for later service in the redo loop.
39
50
*/
@@ -134,6 +145,10 @@ StartupRereadConfig(void)
134
145
void
135
146
HandleStartupProcInterrupts (void )
136
147
{
148
+ #ifdef POSTMASTER_POLL_RATE_LIMIT
149
+ static uint32 postmaster_poll_count = 0 ;
150
+ #endif
151
+
137
152
/*
138
153
* Process any requests or signals received recently.
139
154
*/
@@ -151,9 +166,15 @@ HandleStartupProcInterrupts(void)
151
166
152
167
/*
153
168
* Emergency bailout if postmaster has died. This is to avoid the
154
- * necessity for manual cleanup of all postmaster children.
169
+ * necessity for manual cleanup of all postmaster children. Do this less
170
+ * frequently on systems for which we don't have signals to make that
171
+ * cheap.
155
172
*/
156
- if (IsUnderPostmaster && !PostmasterIsAlive ())
173
+ if (IsUnderPostmaster &&
174
+ #ifdef POSTMASTER_POLL_RATE_LIMIT
175
+ postmaster_poll_count ++ % POSTMASTER_POLL_RATE_LIMIT == 0 &&
176
+ #endif
177
+ !PostmasterIsAlive ())
157
178
exit (1 );
158
179
159
180
/* Process barrier events */
0 commit comments