On Thu, Jun 5, 2014 at 5:39 PM, Gurjeet Singh <gurj...@singh.im> wrote:
> On Wed, Jun 4, 2014 at 12:54 AM, Amit Kapila <amit.kapil...@gmail.com>
> > On Tue, Jun 3, 2014 at 5:43 PM, Gurjeet Singh <gurj...@singh.im> wrote:
> >>
> >> For sizeable shared_buffers size, the restoration of the shared
> >> buffers can take several seconds.
> >
> > Incase of recovery, the shared buffers saved by this utility are
> > from previous shutdown which doesn't seem to be of more use
> > than buffers loaded by recovery.
> I feel the need to enumerate the recovery scenarios we're talking
> about so that we're all on the same page.
> 1) Hot backup (cp/rsync/pg_basebackup/.. while the master was running)
> followed by
>   1a) recovery using archives or streaming replication.
>     1a.i) database in hot-standby mode
>     1a.ii) database not in hot-standby mode, i.e. it's in warm-standby
>   1b) minimal recovery, that is, recover only the WAL available in
> pg_xlog, then come online.
> 2) Cold backup of a crashed master, followed by startup of the copy
> (causing crash recovery; IMHO same as case 1b above.).
> 3) Cold backup of clean-shutdown master, followed by startup of the
> copy (no recovery).
> In cases 1.x there won't be any save-files (*), because the
> BlockReader processes remove their respective save-file when they are
> done restoring the buffers, So the hot/warm-standby created thus will
> not inherit the save-files, and hence post-recovery will not cause any
> buffer restores.
> Case 2 also won't cause any buffer restores because the save-files are
> created only on clean shutdowons; not on a crash or immediate
> shutdown.

How do you ensure that buffers are saved only on clean shutdown?
Buffer saver process itself can crash while saving or restoring

IIUC on shutdown request, postmaster will send signal to BG Saver
and BG Saver will save the buffers and then postmaster will send
signal to checkpointer to shutdown.  So before writing Checkpoint
record, BG Saver can crash (it might have saved half the buffers)
or may BG saver saves buffers, but checkpointer crashes (due to
power outage or any such thing).

Another thing is don't you want to handle SIGQUIT signal in bg saver?

With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com

Reply via email to