From: | Nathan Bossart <nathandbossart(at)gmail(dot)com> |
---|---|
To: | Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com> |
Cc: | zhjwpku(at)gmail(dot)com, xu(dot)xw2008(at)163(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org |
Subject: | Re: BUG #17903: There is a bug in the KeepLogSeg() |
Date: | 2023-04-20 22:02:42 |
Message-ID: | 20230420220242.GB1435672@nathanxps13 |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
On Thu, Apr 20, 2023 at 05:58:14PM +0900, Kyotaro Horiguchi wrote:
> + /*
> + * Slot minimum LSN could be greater than recptr. In such cases, no
> + * segments are protected by slots but we still need to keep segno in a
> + * reasonable range for subsequent calculations to avoid underflow.
> + */
> + if (segno > currSegNo)
> + segno = currSegNo;
> +
I wonder if it'd be better to instead change
if (currSegNo - segno > slot_keep_segs)
to
if (currSegNo > segno + slot_keep_segs)
and
if (currSegNo - segno < keep_segs)
to
if (currSegNo < segNo + keep_segs)
If segno > currSegNo, the first conditional would be false as expected, and
the second would be true as expected. We could also use
pg_sub_u64_overflow() to detect underflow, but that might be excessive in
this case.
--
Nathan Bossart
Amazon Web Services: https://aws.amazon.com
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2023-04-20 22:15:38 | Re: BUG #17898: Build failure when strip is LLVM's version |
Previous Message | Tom Lane | 2023-04-20 19:53:01 | Re: Assert failure with ICU support |