The attached patch fixes archiver shutdown in what seems to me to be a sane way. With the patch, we send SIGQUIT to the archiver only for panic-stop situations (backend crash or immediate-mode shutdown). This is important because the postmaster is coded to send SIGQUIT to the entire process group, meaning we'd also ungracefully terminate any currently-running archive command, which does not seem like a good idea for normal exit. Instead, the shutdown protocol is that *after* the bgwriter has quit, we send SIGUSR1 (ie, the normal archiver wakeup signal) to the archiver. This ensures that it will do a normal archiving cycle after the last possible creation of WAL entries. The archiver is also modified to fall out of its wait loop more quickly when the postmaster has died (this is the same as Simon's previous one-liner patch), and to not exit until it has completed a full archive cycle since the postmaster died. The latter eliminates a race condition that existed before --- depending on timing, the CVS-HEAD archiver might or might not do a final archiving cycle.
I also tweaked the postmaster so that the stats collector isn't told to quit until after the bgwriter finishes; this ensures that any stats reported from the bgwriter will be collected. One point needing discussion is that the postmaster is currently coded not to send SIGUSR1 to the archiver if a fast-mode shutdown is under way. I duplicated that in the added SIGUSR1 signal here, but I wonder whether it is sane or not. Comments? regards, tom lane
binEUCN9e9ool.bin
Description: archiver-shutdown.patch
---------------------------(end of broadcast)--------------------------- TIP 3: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faq