Skip to content

Commit b94109c

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 a04daa9 commit b94109c

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
@@ -1492,7 +1492,10 @@ WaitEventSetWaitBlock(WaitEventSet *set, int cur_timeout,
14921492
timeout_p = &timeout;
14931493
}
14941494

1495-
/* Report events discovered by WaitEventAdjustKqueue(). */
1495+
/*
1496+
* Report postmaster events discovered by WaitEventAdjustKqueue() or an
1497+
* earlier call to WaitEventSetWait().
1498+
*/
14961499
if (unlikely(set->report_postmaster_not_running))
14971500
{
14981501
if (set->exit_on_postmaster_death)
@@ -1563,6 +1566,13 @@ WaitEventSetWaitBlock(WaitEventSet *set, int cur_timeout,
15631566
cur_kqueue_event->filter == EVFILT_PROC &&
15641567
(cur_kqueue_event->fflags & NOTE_EXIT) != 0)
15651568
{
1569+
/*
1570+
* The kernel will tell this kqueue object only once about the exit
1571+
* of the postmaster, so let's remember that for next time so that
1572+
* we provide level-triggered semantics.
1573+
*/
1574+
set->report_postmaster_not_running = true;
1575+
15661576
if (set->exit_on_postmaster_death)
15671577
proc_exit(1);
15681578
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