Re: Miscalculation in IsCheckpointOnSchedule() - Mailing list pgsql-patches

From Heikki Linnakangas
Subject Re: Miscalculation in IsCheckpointOnSchedule()
Date
Msg-id 473AE546.6080703@enterprisedb.com
Whole thread Raw
In response to Re: Miscalculation in IsCheckpointOnSchedule()  (Heikki Linnakangas <heikki@enterprisedb.com>)
List pgsql-patches
Heikki Linnakangas wrote:
> Tom Lane wrote:
>> ITAGAKI Takahiro <itagaki.takahiro@oss.ntt.co.jp> writes:
>>> -         ((double) (int32) (recptr.xrecoff -
>>> ckpt_start_recptr.xrecoff)) / XLogSegSize) /
>>> +         ((double) recptr.xrecoff - (double)
>>> ckpt_start_recptr.xrecoff) / XLogSegSize) /
>>
>> Surely this makes matters worse, not better.  What happens near a segment
>> boundary crossing?
>
> Hmm. There seems to be another little bug in there. XLogSegsPerFile is
> defined as 0xffffffff/XLogSegSize, which is 255 with default settings.
> It should be 256. That leads to negative elapsed_xlogs estimates at xlog
> file boundaries. XLogCheckpointNeeded suffers from it too; the number of
> segments consumed since last checkpoint is off by one per each xlogid,
> so we trigger the checkpoint a little bit too late.

I'll take that back. We intentionally don't use the last possible
segment of each xlog file, to avoid overflows. Sorry for the noise.

--
   Heikki Linnakangas
   EnterpriseDB   http://www.enterprisedb.com

pgsql-patches by date:

Previous
From: Heikki Linnakangas
Date:
Subject: Re: Miscalculation in IsCheckpointOnSchedule()
Next
From: Zdenek Kotala
Date:
Subject: Re: Fix pg_dump dependency on postgres.h