diff options
| author | Tom Lane | 2009-05-15 15:56:39 +0000 |
|---|---|---|
| committer | Tom Lane | 2009-05-15 15:56:39 +0000 |
| commit | 4616d57dad1d082d488e7827ffe116755166a198 (patch) | |
| tree | 6f7567502eb5e56dd9e969e546ce82db7df4d68d /src/backend/postmaster | |
| parent | abc924519a0bc7886a4b8507b03c55b2b55b2c18 (diff) | |
Fix all the server-side SIGQUIT handlers (grumble ... why so many identical
copies?) to ensure they really don't run proc_exit/shmem_exit callbacks,
as was intended. I broke this behavior recently by installing atexit
callbacks without thinking about the one case where we truly don't want
to run those callback functions. Noted in an example from Dave Page.
Diffstat (limited to 'src/backend/postmaster')
| -rw-r--r-- | src/backend/postmaster/autovacuum.c | 20 | ||||
| -rw-r--r-- | src/backend/postmaster/bgwriter.c | 20 | ||||
| -rw-r--r-- | src/backend/postmaster/walwriter.c | 20 |
3 files changed, 42 insertions, 18 deletions
diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c index 6b250f2d27e..a0a6671afff 100644 --- a/src/backend/postmaster/autovacuum.c +++ b/src/backend/postmaster/autovacuum.c @@ -55,7 +55,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.94 2009/03/31 22:12:48 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.95 2009/05/15 15:56:39 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -1337,14 +1337,22 @@ avl_quickdie(SIGNAL_ARGS) PG_SETMASK(&BlockSig); /* - * DO NOT proc_exit() -- we're here because shared memory may be - * corrupted, so we don't want to try to clean up our transaction. Just - * nail the windows shut and get out of town. - * + * We DO NOT want to run proc_exit() callbacks -- we're here because + * shared memory may be corrupted, so we don't want to try to clean up our + * transaction. Just nail the windows shut and get out of town. Now that + * there's an atexit callback to prevent third-party code from breaking + * things by calling exit() directly, we have to reset the callbacks + * explicitly to make this work as intended. + */ + on_exit_reset(); + + /* * Note we do exit(2) not exit(0). This is to force the postmaster into a * system reset cycle if some idiot DBA sends a manual SIGQUIT to a random * backend. This is necessary precisely because we don't clean up our - * shared memory state. + * shared memory state. (The "dead man switch" mechanism in pmsignal.c + * should ensure the postmaster sees this as a crash, too, but no harm + * in being doubly sure.) */ exit(2); } diff --git a/src/backend/postmaster/bgwriter.c b/src/backend/postmaster/bgwriter.c index ebeded0212f..7a23c0130da 100644 --- a/src/backend/postmaster/bgwriter.c +++ b/src/backend/postmaster/bgwriter.c @@ -37,7 +37,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/postmaster/bgwriter.c,v 1.57 2009/03/26 22:26:06 petere Exp $ + * $PostgreSQL: pgsql/src/backend/postmaster/bgwriter.c,v 1.58 2009/05/15 15:56:39 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -798,14 +798,22 @@ bg_quickdie(SIGNAL_ARGS) PG_SETMASK(&BlockSig); /* - * DO NOT proc_exit() -- we're here because shared memory may be - * corrupted, so we don't want to try to clean up our transaction. Just - * nail the windows shut and get out of town. - * + * We DO NOT want to run proc_exit() callbacks -- we're here because + * shared memory may be corrupted, so we don't want to try to clean up our + * transaction. Just nail the windows shut and get out of town. Now that + * there's an atexit callback to prevent third-party code from breaking + * things by calling exit() directly, we have to reset the callbacks + * explicitly to make this work as intended. + */ + on_exit_reset(); + + /* * Note we do exit(2) not exit(0). This is to force the postmaster into a * system reset cycle if some idiot DBA sends a manual SIGQUIT to a random * backend. This is necessary precisely because we don't clean up our - * shared memory state. + * shared memory state. (The "dead man switch" mechanism in pmsignal.c + * should ensure the postmaster sees this as a crash, too, but no harm + * in being doubly sure.) */ exit(2); } diff --git a/src/backend/postmaster/walwriter.c b/src/backend/postmaster/walwriter.c index f509a865328..414731ebc5a 100644 --- a/src/backend/postmaster/walwriter.c +++ b/src/backend/postmaster/walwriter.c @@ -34,7 +34,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/postmaster/walwriter.c,v 1.5 2009/01/01 17:23:46 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/postmaster/walwriter.c,v 1.6 2009/05/15 15:56:39 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -288,14 +288,22 @@ wal_quickdie(SIGNAL_ARGS) PG_SETMASK(&BlockSig); /* - * DO NOT proc_exit() -- we're here because shared memory may be - * corrupted, so we don't want to try to clean up our transaction. Just - * nail the windows shut and get out of town. - * + * We DO NOT want to run proc_exit() callbacks -- we're here because + * shared memory may be corrupted, so we don't want to try to clean up our + * transaction. Just nail the windows shut and get out of town. Now that + * there's an atexit callback to prevent third-party code from breaking + * things by calling exit() directly, we have to reset the callbacks + * explicitly to make this work as intended. + */ + on_exit_reset(); + + /* * Note we do exit(2) not exit(0). This is to force the postmaster into a * system reset cycle if some idiot DBA sends a manual SIGQUIT to a random * backend. This is necessary precisely because we don't clean up our - * shared memory state. + * shared memory state. (The "dead man switch" mechanism in pmsignal.c + * should ensure the postmaster sees this as a crash, too, but no harm + * in being doubly sure.) */ exit(2); } |
