OSDN Git Service

Repair two places where SIGTERM exit could leave shared memory state
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 16 Apr 2008 23:59:40 +0000 (23:59 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 16 Apr 2008 23:59:40 +0000 (23:59 +0000)
commitd1cbd26ded664bf2d3ace87036b822dedba28077
treeb991c0196d5abe92d4d77e79449b44ced35b7d5f
parent74be86847c8cdd274a274fc9384988cb81756d87
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