Skip site navigation (1) Skip section navigation (2)

Revised patch for fixing archiver shutdown behavior

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-patches(at)postgreSQL(dot)org
Cc: Simon Riggs <simon(at)2ndquadrant(dot)com>
Subject: Revised patch for fixing archiver shutdown behavior
Date: 2008-01-09 23:28:00
Message-ID: 20231.1199921280@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-patches
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


Attachment: archiver-shutdown.patch
Description: application/octet-stream (8.2 KB)

Responses

pgsql-patches by date

Next:From: Alvaro HerreraDate: 2008-01-10 00:30:21
Subject: Re: Revised patch for fixing archiver shutdown behavior
Previous:From: Alvaro HerreraDate: 2008-01-09 23:01:42
Subject: Re: BUG #3860: xpath crashes backend when is queryingxmlagg result

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group