Sorry for the noise, I got my answer. 2016-02-16 18:02 GMT+01:00 Benoit Lobréau <benoit.lobr...@gmail.com>:
> Hello, > > I am using a hot_standby setup on PostgreSQL 9.1 > While I was testing, I found out that only checkpoint_timeout (+ a > checkpoint since the last restart point) could trigger a restart point. > > The code (bgwriter.c) seems to confirm this: > > /* > * Check progress against WAL segments written and checkpoint_segments. > * > * We compare the current WAL insert location against the location > * computed before calling CreateCheckPoint. The code in XLogInsert that > * actually triggers a checkpoint when checkpoint_segments is exceeded > * compares against RedoRecptr, so this is not completely accurate. > * However, it's good enough for our purposes, we're only calculating an > * estimate anyway. > */ > if (!RecoveryInProgress()) ===> Only in case of primary > { > recptr = GetInsertRecPtr(); > elapsed_xlogs = > (((double) (int32) (recptr.xlogid - > ckpt_start_recptr.xlogid)) * XLogSegsPerFile + > ((double) recptr.xrecoff - (double) > ckpt_start_recptr.xrecoff) / XLogSegSize) / > CheckPointSegments; > > if (progress < elapsed_xlogs) ===> progress in volume > { > ckpt_cached_elapsed = elapsed_xlogs; > return false; > } > } > > /* > * Check progress against time elapsed and checkpoint_timeout. > */ > gettimeofday(&now, NULL); > elapsed_time = ((double) ((pg_time_t) now.tv_sec - ckpt_start_time) + > > now.tv_usec / 1000000.0) / CheckPointTimeout; > > > if (progress < elapsed_time) ===> progress in time > { > ckpt_cached_elapsed = elapsed_time; > return false; > } > > /* It looks like we're on schedule. */ > return true; > > I also found a post from Simon Riggs [1]: "checkpoint_segments is ignored > on standby." > > The documentation is stating the opposite [2]: "In standby mode, a > restartpoint is also triggered if checkpoint_segments log segments have > been replayed since last restartpoint and at least one checkpoint record > has been replayed." > > Since I am not a native english speaker, maybe I misunderstood the > documentation. But to me, it looks wrong. > If it's indeed wrong. Could you explain why checkpoint_segments doesn't > trigger a restart_point in standby mode ? > > Thank you > Benoit > > [1] > http://www.postgresql.org/message-id/CA+U5nMKdf7odZzYNnoRkkCZmJpGEy=oqbu9nan_zva_rtzi...@mail.gmail.com > [2] http://www.postgresql.org/docs/9.1/static/wal-configuration.html >