]> granicus.if.org Git - postgresql/commit
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)
commitd5249bb409ed3f13602bfa24b4c48acedd8783ec
treeb49a0c0abc11c5785e848224e011777906041234
parent95b7a876f6cc29f871a9cae0d66cea91bb76b504
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