File tree 4 files changed +37
-24
lines changed
4 files changed +37
-24
lines changed Original file line number Diff line number Diff line change @@ -323,9 +323,11 @@ BackgroundWriterMain(void)
323
323
324
324
/*
325
325
* Emergency bailout if postmaster has died. This is to avoid the
326
- * necessity for manual cleanup of all postmaster children.
326
+ * necessity for manual cleanup of all postmaster children. Note
327
+ * that we mustn't trust the WL_POSTMASTER_DEATH result flag entirely;
328
+ * if it is set, recheck with PostmasterIsAlive before believing it.
327
329
*/
328
- if (rc & WL_POSTMASTER_DEATH )
330
+ if (( rc & WL_POSTMASTER_DEATH ) && ! PostmasterIsAlive () )
329
331
exit (1 );
330
332
331
333
prev_hibernate = can_hibernate ;
Original file line number Diff line number Diff line change @@ -374,17 +374,11 @@ CheckpointerMain(void)
374
374
pg_time_t now ;
375
375
int elapsed_secs ;
376
376
int cur_timeout ;
377
+ int rc ;
377
378
378
379
/* Clear any already-pending wakeups */
379
380
ResetLatch (& MyProc -> procLatch );
380
381
381
- /*
382
- * Emergency bailout if postmaster has died. This is to avoid the
383
- * necessity for manual cleanup of all postmaster children.
384
- */
385
- if (!PostmasterIsAlive ())
386
- exit (1 );
387
-
388
382
/*
389
383
* Process any requests or signals received recently.
390
384
*/
@@ -581,9 +575,18 @@ CheckpointerMain(void)
581
575
cur_timeout = Min (cur_timeout , XLogArchiveTimeout - elapsed_secs );
582
576
}
583
577
584
- (void ) WaitLatch (& MyProc -> procLatch ,
585
- WL_LATCH_SET | WL_TIMEOUT | WL_POSTMASTER_DEATH ,
586
- cur_timeout * 1000L /* convert to ms */ );
578
+ rc = WaitLatch (& MyProc -> procLatch ,
579
+ WL_LATCH_SET | WL_TIMEOUT | WL_POSTMASTER_DEATH ,
580
+ cur_timeout * 1000L /* convert to ms */ );
581
+
582
+ /*
583
+ * Emergency bailout if postmaster has died. This is to avoid the
584
+ * necessity for manual cleanup of all postmaster children. Note
585
+ * that we mustn't trust the WL_POSTMASTER_DEATH result flag entirely;
586
+ * if it is set, recheck with PostmasterIsAlive before believing it.
587
+ */
588
+ if ((rc & WL_POSTMASTER_DEATH ) && !PostmasterIsAlive ())
589
+ exit (1 );
587
590
}
588
591
}
589
592
Original file line number Diff line number Diff line change @@ -3225,8 +3225,13 @@ PgstatCollectorMain(int argc, char *argv[])
3225
3225
pgStatSock ,
3226
3226
-1L );
3227
3227
3228
- /* Check for postmaster death */
3229
- if (wr & WL_POSTMASTER_DEATH )
3228
+ /*
3229
+ * Emergency bailout if postmaster has died. This is to avoid the
3230
+ * necessity for manual cleanup of all postmaster children. Note
3231
+ * that we mustn't trust the WL_POSTMASTER_DEATH result flag entirely;
3232
+ * if it is set, recheck with PostmasterIsAlive before believing it.
3233
+ */
3234
+ if ((wr & WL_POSTMASTER_DEATH ) && !PostmasterIsAlive ())
3230
3235
break ;
3231
3236
} /* end of outer loop */
3232
3237
Original file line number Diff line number Diff line change @@ -246,6 +246,7 @@ WalWriterMain(void)
246
246
for (;;)
247
247
{
248
248
long cur_timeout ;
249
+ int rc ;
249
250
250
251
/*
251
252
* Advertise whether we might hibernate in this cycle. We do this
@@ -265,13 +266,6 @@ WalWriterMain(void)
265
266
/* Clear any already-pending wakeups */
266
267
ResetLatch (& MyProc -> procLatch );
267
268
268
- /*
269
- * Emergency bailout if postmaster has died. This is to avoid the
270
- * necessity for manual cleanup of all postmaster children.
271
- */
272
- if (!PostmasterIsAlive ())
273
- exit (1 );
274
-
275
269
/*
276
270
* Process any requests or signals received recently.
277
271
*/
@@ -305,9 +299,18 @@ WalWriterMain(void)
305
299
else
306
300
cur_timeout = WalWriterDelay * HIBERNATE_FACTOR ;
307
301
308
- (void ) WaitLatch (& MyProc -> procLatch ,
309
- WL_LATCH_SET | WL_TIMEOUT | WL_POSTMASTER_DEATH ,
310
- cur_timeout );
302
+ rc = WaitLatch (& MyProc -> procLatch ,
303
+ WL_LATCH_SET | WL_TIMEOUT | WL_POSTMASTER_DEATH ,
304
+ cur_timeout );
305
+
306
+ /*
307
+ * Emergency bailout if postmaster has died. This is to avoid the
308
+ * necessity for manual cleanup of all postmaster children. Note
309
+ * that we mustn't trust the WL_POSTMASTER_DEATH result flag entirely;
310
+ * if it is set, recheck with PostmasterIsAlive before believing it.
311
+ */
312
+ if ((rc & WL_POSTMASTER_DEATH ) && !PostmasterIsAlive ())
313
+ exit (1 );
311
314
}
312
315
}
313
316
You can’t perform that action at this time.
0 commit comments