Skip to content

Commit e095013

Browse files
committed
Make WL_POSTMASTER_DEATH level-triggered on kqueue builds.
If WaitEventSetWait() reports that the postmaster has gone away, later calls to WaitEventSetWait() should continue to report that. Otherwise further waits that occur in the proc_exit() path after we already noticed the postmaster's demise could block forever. Back-patch to 13, where the kqueue support landed. Reported-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/3624029.1602701929%40sss.pgh.pa.us
1 parent 855b6f2 commit e095013

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/backend/storage/ipc/latch.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1429,7 +1429,10 @@ WaitEventSetWaitBlock(WaitEventSet *set, int cur_timeout,
14291429
timeout_p = &timeout;
14301430
}
14311431

1432-
/* Report events discovered by WaitEventAdjustKqueue(). */
1432+
/*
1433+
* Report postmaster events discovered by WaitEventAdjustKqueue() or an
1434+
* earlier call to WaitEventSetWait().
1435+
*/
14331436
if (unlikely(set->report_postmaster_not_running))
14341437
{
14351438
if (set->exit_on_postmaster_death)
@@ -1500,6 +1503,13 @@ WaitEventSetWaitBlock(WaitEventSet *set, int cur_timeout,
15001503
cur_kqueue_event->filter == EVFILT_PROC &&
15011504
(cur_kqueue_event->fflags & NOTE_EXIT) != 0)
15021505
{
1506+
/*
1507+
* The kernel will tell this kqueue object only once about the exit
1508+
* of the postmaster, so let's remember that for next time so that
1509+
* we provide level-triggered semantics.
1510+
*/
1511+
set->report_postmaster_not_running = true;
1512+
15031513
if (set->exit_on_postmaster_death)
15041514
proc_exit(1);
15051515
occurred_events->fd = PGINVALID_SOCKET;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy