Repair two places where SIGTERM exit could leave shared memory state
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 16 Apr 2008 23:59:51 +0000 (23:59 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 16 Apr 2008 23:59:51 +0000 (23:59 +0000)
commit4dd1529c83faa08efa1031b257728e26dec31c5f
tree649c57edadd94ef385cb5187441096b25fafb1f0
parentf2e77b98d74b5b913f2bf2675c86ab33d40b1bf1
Repair two places where SIGTERM exit could leave shared memory state
corrupted.  (Neither is very important if SIGTERM is used to shut down the
whole database cluster together, but there's a problem if someone tries to
SIGTERM individual backends.)  To do this, introduce new infrastructure
macros PG_ENSURE_ERROR_CLEANUP/PG_END_ENSURE_ERROR_CLEANUP that take care
of transiently pushing an on_shmem_exit cleanup hook.  Also use this method
for createdb cleanup --- that wasn't a shared-memory-corruption problem,
but SIGTERM abort of createdb could leave orphaned files lying around.

Backpatch as far as 8.2.  The shmem corruption cases don't exist in 8.1,
and the createdb usage doesn't seem important enough to risk backpatching
further.
src/backend/access/nbtree/nbtree.c
src/backend/access/nbtree/nbtutils.c
src/backend/access/transam/xlog.c
src/backend/commands/dbcommands.c
src/backend/port/ipc_test.c
src/backend/storage/ipc/ipc.c
src/include/access/nbtree.h
src/include/storage/ipc.h
src/include/utils/elog.h