Use an shmem_exit callback to remove backend from PMChildFlags on exit

Heikki Linnakangas <heikki.linnakangas@iki.fi>

Commit: 2bbc261ddbdfee2def5d14ee9fcc09c70bdf84e6
Author: Heikki Linnakangas <heikki.linnakangas@iki.fi>
Date: 2024-10-08T12:06:34Z
Releases: 18.0
Use an shmem_exit callback to remove backend from PMChildFlags on exit

This seems nicer than having to duplicate the logic between
InitProcess() and ProcKill() for which child processes have a
PMChildFlags slot.

Move the MarkPostmasterChildActive() call earlier in InitProcess(),
out of the section protected by the spinlock.

Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://www.postgresql.org/message-id/a102f15f-eac4-4ff2-af02-f9ff209ec66f@iki.fi

Files

PathChange+/−
src/backend/storage/ipc/pmsignal.c modified +13 −4
src/backend/storage/lmgr/proc.c modified +13 −25
src/include/storage/pmsignal.h modified +1 −2

Discussion