Re: BUG #17903: There is a bug in the KeepLogSeg()

Поиск
Список
Период
Сортировка
От Nathan Bossart
Тема Re: BUG #17903: There is a bug in the KeepLogSeg()
Дата
Msg-id 20230420220242.GB1435672@nathanxps13
обсуждение исходный текст
Ответ на Re: BUG #17903: There is a bug in the KeepLogSeg()  (Kyotaro Horiguchi <horikyota.ntt@gmail.com>)
Ответы Re: BUG #17903: There is a bug in the KeepLogSeg()  (Kyotaro Horiguchi <horikyota.ntt@gmail.com>)
Список 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



В списке pgsql-bugs по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Assert failure with ICU support
Следующее
От: Tom Lane
Дата:
Сообщение: Re: BUG #17898: Build failure when strip is LLVM's version