[Bug fix]There is the case archive_timeout parameter is ignored afterrecovery works.

Поиск
Список
Период
Сортировка
От higuchi.daisuke@fujitsu.com
Тема [Bug fix]There is the case archive_timeout parameter is ignored afterrecovery works.
Дата
Msg-id OSBPR01MB1751EABF275BAE92EAA854FBEC6E0@OSBPR01MB1751.jpnprd01.prod.outlook.com
обсуждение исходный текст
Ответы Re: [Bug fix]There is the case archive_timeout parameter isignored after recovery works.  (Kyotaro Horiguchi <horikyota.ntt@gmail.com>)
Список pgsql-hackers
Hi,

I found the bug about archive_timeout parameter.
There is the case archive_timeout parameter is ignored after recovery works.

[Problem]
When the value of archive_timeout is smaller than that of checkpoint_timeout and recovery works, archive_timeout is
ignoredin the first WAL archiving. 
Once WAL is archived, the archive_timeout seems to be valid after that.

I attached the simple script for reproducing this problem on version 12.
I also confirmed that PostgreSQL10, 11 and 12. I think other supported versions have this problem.

[Investigation]
In the CheckpointerMain(), calculate the time (cur_timeout) to wait on WaitLatch.

-----------------------------------------------------------------
now = (pg_time_t) time(NULL);
elapsed_secs = now - last_checkpoint_time;
if (elapsed_secs >= CheckPointTimeout)
    continue;           /* no sleep for us ... */
cur_timeout = CheckPointTimeout - elapsed_secs;
if (XLogArchiveTimeout > 0 && !RecoveryInProgress())
{
    elapsed_secs = now - last_xlog_switch_time;
    if (elapsed_secs >= XLogArchiveTimeout)
        continue;       /* no sleep for us ... */
    cur_timeout = Min(cur_timeout, XLogArchiveTimeout - elapsed_secs);
}

(void) WaitLatch(MyLatch,
                 WL_LATCH_SET | WL_TIMEOUT | WL_EXIT_ON_PM_DEATH,
                 cur_timeout * 1000L /* convert to ms */ ,
                 WAIT_EVENT_CHECKPOINTER_MAIN);
-----------------------------------------------------------------

Currently, cur_timeout is set according to only checkpoint_timeout when it is during recovery.
Even during recovery, the cur_timeout should be calculated including archive_timeout as well as checkpoint_timeout, I
think.
I attached the patch to solve this problem.

Regards,
Daisuke, Higuchi

Вложения

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

Предыдущее
От: Amit Kapila
Дата:
Сообщение: Re: pgsql: Enable Unix-domain sockets support on Windows
Следующее
От: Masahiko Sawada
Дата:
Сообщение: Re: Resetting spilled txn statistics in pg_stat_replication