Re: recovery_min_delay casting problems lead to busy looping

Поиск
Список
Период
Сортировка
От Robert Haas
Тема Re: recovery_min_delay casting problems lead to busy looping
Дата
Msg-id CA+TgmoaVbA4xNsFwe41vXvHXYL6xNsRCBGL+wSvd+mNpCy+9ag@mail.gmail.com
обсуждение исходный текст
Ответ на recovery_min_delay casting problems lead to busy looping  (Andres Freund <andres@2ndquadrant.com>)
Ответы Re: recovery_min_delay casting problems lead to busy looping  (Andres Freund <andres@2ndquadrant.com>)
Список pgsql-hackers
On Mon, Mar 23, 2015 at 10:18 AM, Andres Freund <andres@2ndquadrant.com> wrote:
> recoveryApplyDelay() does:
>     TimestampDifference(GetCurrentTimestamp(), recoveryDelayUntilTime,
>                         &secs, µsecs);
>
>     if (secs <= 0 && microsecs <= 0)
>         break;
>
>     elog(DEBUG2, "recovery apply delay %ld seconds, %d milliseconds",
>          secs, microsecs / 1000);
>
>     WaitLatch(&XLogCtl->recoveryWakeupLatch,
>               WL_LATCH_SET | WL_TIMEOUT | WL_POSTMASTER_DEATH,
>               secs * 1000L + microsecs / 1000);
>
> The problem is that the 'microsecs <= 0' comparison is done while in
> microsecs, but the sleeping converts to milliseconds. Which will often
> be 0. I've seen this cause ~15-20 iterations per loop. Annoying, but not
> terrible.
>
> I think we should simply make the abort condition '&& microsecs / 1000
> <= 0'.

That's a subtle violation of the documented behavior, although there's
a good chance nobody would ever care.  What about just changing the
WaitLatch call to say Max(secs * 1000L + microsecs / 1000, 1)?

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



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

Предыдущее
От: Andres Freund
Дата:
Сообщение: recovery_min_delay casting problems lead to busy looping
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Display of multi-target-table Modify plan nodes in EXPLAIN