pgsql: Restructure the shutdown procedure for the archiver process to

From: tgl(at)postgresql(dot)org (Tom Lane)
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Restructure the shutdown procedure for the archiver process to
Date: 2008-01-11 00:54:09
Message-ID: 20080111005409.3B423754108@cvs.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Log Message:
-----------
Restructure the shutdown procedure for the archiver process to allow it to
finish archiving everything (when there's no error), and to eliminate various
hazards as best we can. This fixes a previous 8.3 patch that caused the
postmaster to kill and then restart the archiver during shutdown (!?).

The new behavior is that the archiver is allowed to run unmolested until
the bgwriter has exited; then it is sent SIGUSR2 to tell it to do a final
archiving cycle and quit. We only SIGQUIT the archiver if we want a panic
stop; this is important since SIGQUIT will also be sent to any active
archive_command. The postmaster also now doesn't SIGQUIT the stats collector
until the bgwriter is done, since the bgwriter can send stats messages in 8.3.
The postmaster will not exit until both the archiver and stats collector are
gone; this provides some defense (not too bulletproof) against conflicting
archiver or stats collector processes being started by a new postmaster
instance. We continue the prior practice that the archiver will check
for postmaster death immediately before issuing any archive_command; that
gives some additional protection against conflicting archivers.

Also, modify the archiver process to notice SIGTERM and refuse to issue any
more archive commands if it gets it. The postmaster doesn't ever send it
SIGTERM; we assume that any such signal came from init and is a notice of
impending whole-system shutdown. In this situation it seems imprudent to try
to start new archive commands --- if they aren't extremely quick they're
likely to get SIGKILL'd by init.

All per discussion.

Modified Files:
--------------
pgsql/src/backend/postmaster:
pgarch.c (r1.37 -> r1.38)
(http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/postmaster/pgarch.c?r1=1.37&r2=1.38)
postmaster.c (r1.550 -> r1.551)
(http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/postmaster/postmaster.c?r1=1.550&r2=1.551)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2008-01-11 04:02:18 pgsql: Fix a conceptual error in my patch of 2007-10-26 that avoided
Previous Message User Nickg 2008-01-10 23:24:47 press - pr: Added features83.html.ru.