summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas Munro2020-03-17 23:43:05 +0000
committerThomas Munro2020-03-18 00:05:07 +0000
commit7bc84a1f304acc9f4705c4178eb362ddce310452 (patch)
tree74dc22acfd886c268cdac3e9c385ce432b06ba00 /src
parente6c178b5b73ac1fb822829e6d9b99e3fc1129c21 (diff)
Fix kqueue support under debugger on macOS.
While running under a debugger, macOS's getppid() can return the debugger's PID. That could cause a backend to exit because it falsely believed that the postmaster had died, since commit 815c2f09. Continue to use getppid() as a fast postmaster check after adding the postmaster's PID to a kqueue, to close a PID-reuse race, but double check that it actually exited by trying to read the pipe. The new check isn't reached in the common case. Reported-by: Alexander Korotkov <[email protected]> Discussion: https://postgr.es/m/CA%2BhUKGKhAxJ8V8RVwCo6zJaeVrdOG1kFBHGZOOjf6DzW_omeMA%40mail.gmail.com
Diffstat (limited to 'src')
-rw-r--r--src/backend/storage/ipc/latch.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/backend/storage/ipc/latch.c b/src/backend/storage/ipc/latch.c
index 046ca5c6c7e..d4c6c65baa3 100644
--- a/src/backend/storage/ipc/latch.c
+++ b/src/backend/storage/ipc/latch.c
@@ -1094,8 +1094,17 @@ WaitEventAdjustKqueue(WaitEventSet *set, WaitEvent *event, int old_events)
errmsg("%s failed: %m",
"kevent()")));
}
- else if (event->events == WL_POSTMASTER_DEATH && PostmasterPid != getppid())
+ else if (event->events == WL_POSTMASTER_DEATH &&
+ PostmasterPid != getppid() &&
+ !PostmasterIsAlive())
+ {
+ /*
+ * The extra PostmasterIsAliveInternal() check prevents false alarms on
+ * systems that give a different value for getppid() while being traced
+ * by a debugger.
+ */
set->report_postmaster_not_running = true;
+ }
}
#endif