Skip to content

Commit 6cfebfe

Browse files
committed
Make WaitForLSNReplay() issue FATAL on postmaster death
Reported-by: Michael Paquier Discussion: https://postgr.es/m/ZvY2C8N4ZqgCFaLu%40paquier.xyz Reviewed-by: Pavel Borisov
1 parent 5035172 commit 6cfebfe

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/backend/access/transam/xlogwait.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ WaitForLSNReplay(XLogRecPtr targetLSN, int64 timeout)
222222
{
223223
XLogRecPtr currentLSN;
224224
TimestampTz endtime = 0;
225-
int wake_events = WL_LATCH_SET | WL_EXIT_ON_PM_DEATH;
225+
int wake_events = WL_LATCH_SET | WL_POSTMASTER_DEATH;
226226

227227
/* Shouldn't be called when shmem isn't initialized */
228228
Assert(waitLSNState);
@@ -313,6 +313,16 @@ WaitForLSNReplay(XLogRecPtr targetLSN, int64 timeout)
313313
rc = WaitLatch(MyLatch, wake_events, delay_ms,
314314
WAIT_EVENT_WAIT_FOR_WAL_REPLAY);
315315

316+
/*
317+
* Emergency bailout if postmaster has died. This is to avoid the
318+
* necessity for manual cleanup of all postmaster children.
319+
*/
320+
if (rc & WL_POSTMASTER_DEATH)
321+
ereport(FATAL,
322+
(errcode(ERRCODE_ADMIN_SHUTDOWN),
323+
errmsg("terminating connection due to unexpected postmaster exit"),
324+
errcontext("while waiting for LSN replay")));
325+
316326
if (rc & WL_LATCH_SET)
317327
ResetLatch(MyLatch);
318328
}

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