Re: Question about Restart point and checkpoint_segments

From: Benoit Lobréau <benoit(dot)lobreau(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Question about Restart point and checkpoint_segments
Date: 2016-02-18 16:47:12
Message-ID: CAPE8EZ7PpUtAtKKH3EqEon+Pyz1nsV7+1Nz157VFV0R6HttLKg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Sorry for the noise, I got my answer.

2016-02-16 18:02 GMT+01:00 Benoit Lobréau <benoit(dot)lobreau(at)gmail(dot)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_Rtzi2vw@mail.gmail.com
> [2] http://www.postgresql.org/docs/9.1/static/wal-configuration.html
>

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Sridhar N Bamandlapally 2016-02-18 16:57:24 Re: JDBC behaviour
Previous Message Tom Lane 2016-02-18 15:51:57 Re: Relaxing SSL key permission checks