Skip to content

Commit 70516a1

Browse files
committed
Handle EACCES errors from kevent() better.
While registering for postmaster exit events, we have to handle a couple of edge cases where the postmaster is already gone. Commit 815c2f0 missed one: EACCES must surely imply that PostmasterPid no longer belongs to our postmaster process (or alternatively an unexpected permissions model has been imposed on us). Like ESRCH, this should be treated as a WL_POSTMASTER_DEATH event, rather than being raised with ereport(). No known problems reported in the wild. Per code review from Tom Lane. Back-patch to 13. Reported-by: Tom Lane <[email protected]> Discussion: https://postgr.es/m/3624029.1602701929%40sss.pgh.pa.us
1 parent d7eb52d commit 70516a1

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/backend/storage/ipc/latch.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -1148,7 +1148,8 @@ WaitEventAdjustKqueue(WaitEventSet *set, WaitEvent *event, int old_events)
11481148

11491149
if (rc < 0)
11501150
{
1151-
if (event->events == WL_POSTMASTER_DEATH && errno == ESRCH)
1151+
if (event->events == WL_POSTMASTER_DEATH &&
1152+
(errno == ESRCH || errno == EACCES))
11521153
set->report_postmaster_not_running = true;
11531154
else
11541155
ereport(ERROR,

0 commit comments

Comments
 (0)