Re: Skip checkpoint on promoting from streaming replication
Heikki Linnakangas <hlinnakangas@vmware.com>
From: Heikki Linnakangas <hlinnakangas@vmware.com>
To: Simon Riggs <simon@2ndQuadrant.com>
Cc: Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp>, masao.fujii@gmail.com, pgsql-hackers@postgresql.org
Date: 2013-01-25T12:15:12Z
Lists: pgsql-hackers
On 24.01.2013 19:44, Simon Riggs wrote: > On 24 January 2013 16:52, Heikki Linnakangas<hlinnakangas@vmware.com> wrote: >> I may be missing something, but it looks like after a "fast" promotion, you >> don't request a new checkpoint. So it can take quite a while for the next >> checkpoint to be triggered by checkpoint_timeout/segments. That shouldn't be >> a problem, but I feel that it'd be prudent to request a new checkpoint >> immediately (not necessarily an "immediate" checkpoint, though). > > I thought of that and there is a long comment to explain why I didn't. > > Two problems: > > 1) an immediate checkpoint can cause a disk/resource usage spike, > which is definitely not what you need just when a spike of connections > and new SQL hits the system. It doesn't need to be an "immediate" checkpoint, ie. you don't need to rush through it with checkpoint_completion_target=0. I think you should initiate a regular, slow, checkpoint, right after writing the end-of-recovery record. It can take some time for it to finish, which is ok. There's no hard correctness reason here for any particular behavior, I just feel that that would make most sense. It seems prudent to initiate a checkpoint right after timeline switch, so that you get a new checkpoint on the new timeline fairly soon - it could take up to checkpoint_timeout otherwise, but there's no terrible rush to finish it ASAP. - Heikki