Re: Correct comment in RemoveNonParentXlogFiles()

From: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
To: ashu(dot)coek88(at)gmail(dot)com
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Correct comment in RemoveNonParentXlogFiles()
Date: 2022-08-04 06:05:51
Message-ID: 20220804.150551.2055549007399729576.horikyota.ntt@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

At Thu, 04 Aug 2022 15:00:06 +0900 (JST), Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com> wrote in
> At Wed, 3 Aug 2022 18:16:33 +0530, Ashutosh Sharma <ashu(dot)coek88(at)gmail(dot)com> wrote in
> > Following comment in RemoveNonParentXlogFiles() says that we are trying to
> > remove any WAL file whose segment number is >= the segment number of the
> > first WAL file on the new timeline. However, looking at the code, I can say
> > that we are trying to remove the WAL files from the previous timeline whose
> > segment number is just greater than (not equal to) the segment number of
> > the first WAL file in the new timeline. I think we should improve this
> > comment, thoughts?
> >
> > /*
> > * Remove files that are on a timeline older than the new one we're
> > * switching to, but with a segment number >= the first segment on
> > the
> > * new timeline.
> > */
> > if (strncmp(xlde->d_name, switchseg, 8) < 0 &&
> > strcmp(xlde->d_name + 8, switchseg + 8) > 0)
>
> I'm not sure I'm fully getting your point. The current comment is
> correctly saying that it removes the segments "on a timeline older
> than the new one". I agree about segment comparison.
>
> So, if I changed that comment, I would finish with the following change.
>
> - * switching to, but with a segment number >= the first segment on
> + * switching to, but with a segment number greater than the first segment on
>
> That disagreement started at the time the code was introduced by
> b2a5545bd6. Leaving the last segment in the old timeline is correct
> since it is renamed to .partial later. If timeline switch happened
> just at segment boundary, that segment would not not be created.

"the last segment in the old timeline" here means "the segment in the
old timeline, with the segment number == the first segmetn on the new
timeline".

regards.

--
Kyotaro Horiguchi
NTT Open Source Software Center

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Munro 2022-08-04 06:07:35 Re: Cygwin cleanup
Previous Message Kyotaro Horiguchi 2022-08-04 06:00:06 Re: Correct comment in RemoveNonParentXlogFiles()