mirror of
https://github.com/postgres/postgres.git
synced 2025-12-06 00:02:13 +03:00
Improve tests for postmaster death in auxiliary processes.
In checkpointer and walwriter, avoid calling PostmasterIsAlive unless WaitLatch has reported WL_POSTMASTER_DEATH. This saves a kernel call per iteration of the process's outer loop, which is not all that much, but a cycle shaved is a cycle earned. I had already removed the unconditional PostmasterIsAlive calls in bgwriter and pgstat in previous patches, but forgot that WL_POSTMASTER_DEATH is supposed to be treated as untrustworthy (per comment in unix_latch.c); so adjust those two cases to match. There are a few other places where the same idea might be applied, but only after substantial code rearrangement, so I didn't bother.
This commit is contained in:
@@ -3225,8 +3225,13 @@ PgstatCollectorMain(int argc, char *argv[])
|
||||
pgStatSock,
|
||||
-1L);
|
||||
|
||||
/* Check for postmaster death */
|
||||
if (wr & WL_POSTMASTER_DEATH)
|
||||
/*
|
||||
* Emergency bailout if postmaster has died. This is to avoid the
|
||||
* necessity for manual cleanup of all postmaster children. Note
|
||||
* that we mustn't trust the WL_POSTMASTER_DEATH result flag entirely;
|
||||
* if it is set, recheck with PostmasterIsAlive before believing it.
|
||||
*/
|
||||
if ((wr & WL_POSTMASTER_DEATH) && !PostmasterIsAlive())
|
||||
break;
|
||||
} /* end of outer loop */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user