Improve tests for postmaster death in auxiliary processes.
Tom Lane <tgl@sss.pgh.pa.us>
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.
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/postmaster/bgwriter.c | modified | +4 −2 |
| src/backend/postmaster/checkpointer.c | modified | +13 −10 |
| src/backend/postmaster/pgstat.c | modified | +7 −2 |
| src/backend/postmaster/walwriter.c | modified | +13 −10 |