[BUG] Checkpointer on hot standby runs without looking checkpoint_segments
Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp>
From: Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp>
To: pgsql-hackers@postgresql.org
Date: 2012-04-16T12:05:48Z
Lists: pgsql-hackers
Attachments
- standby_checkpoint_segments_9.2dev_fix_20120416.patch (text/x-patch) patch
- standby_checkpoint_segments_9.1.3_fix_20120416.patch (text/x-patch) patch
Hello, this is bug report and a patch for it. The first patch in the attachments is for 9.2dev and next one is for 9.1.3. On the current 9.2dev, IsCheckpointOnSchedule@checkpointer.c does not check against WAL segments written. This makes checkpointer always run at the speed according to checkpoint_timeout regardless of WAL advancing rate. This leads to unexpected imbalance in the numbers of WAL segment files between the master and the standby(s) for high advance rate of WALs. And what is worse, the master would have much higher chance to remove some WAL segments before the standby receives them. XLogPageRead()@xlog.c triggers checkpoint referring to WAL segment advance. So I think this is a bug of bgwriter in 9.1. The attached patches fix that on 9.2dev and 9.1.3 respctively. In the backported version to 9.1.3, bgwriter.c is modified instead of checkpointer.c in 9.2. And GetWalRcvWriteRecPtr() is used as the equivalent of GetStandbyFlushRecPtr() in 9.2. By the way, GetStandbyFlushRecPtr() acquires spin lock within. It might be enough to read XLogCtl->recoveryLastRecPtr without lock to make rough estimation, but I can't tell it is safe or not. Same discussion could be for GetWalRcvWriteRecPtr() on 9.1.3. However, it seems to work fine on a simple test. regards, -- Kyotaro Horiguchi NTT Open Source Software Center == My e-mail address has been changed since Apr. 1, 2012.