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

From ITAGAKI Takahiro
Subject Re: Miscalculation in IsCheckpointOnSchedule()
Date
Msg-id 20071114144003.30E7.ITAGAKI.TAKAHIRO@oss.ntt.co.jp
Whole thread Raw
In response to Re: Miscalculation in IsCheckpointOnSchedule()  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Miscalculation in IsCheckpointOnSchedule()
List pgsql-patches
Tom Lane <tgl@sss.pgh.pa.us> 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?

Here is the dumped progres information by the attached patch
(only for debug purpose).

         cur prog.  xlog prog. time prog.
[-400ms] 0.030503   0.019247   0.031158   (diff xlogid=0, xrecoff=82665472)
[-200ms] 0.031176   0.019957   0.031839   (diff xlogid=0, xrecoff=85712896)
[*]      0.031860   1.020706   0.032521   (diff xlogid=1, xrecoff=105709568)

> recptr.xrecoff - ckpt_start_recptr.xrecoff

recptr.xrecoff is reset to 0 or so when xlogid is bumped up. At that time,
if ckpt_start_recptr.xrecoff is greater than 2G, we cannot represent
the difference with int32 because the value is less than -2G.
Casting double after int32 does not help us.

We use ( xlogid * 255 * 16MB + xrecoff ) as a base value for the calculation.
If we interprets xrecoff=105709568 at [*] as "minus uint32", we can calcurate
it correctly as below:

         without fix  with fix
[-400ms]   82665472   82665472 (same)
[-200ms]   85712896   85712896 (same)
[*]      4383899648   88932353 (= 1*255*16MB - (0xFFFFFFFF - 105709568) )

Regards,
---
ITAGAKI Takahiro
NTT Open Source Software Center


Attachment

pgsql-patches by date:

Previous
From: Tom Lane
Date:
Subject: Re: Miscalculation in IsCheckpointOnSchedule()
Next
From: Jan Urbański
Date:
Subject: Re: a tsearch2 (8.2.4) dictionary that only filters out stopwords