Re: [COMMITTERS] pgsql: Change how first WAL segment on new timeline after promotion is

Поиск
Список
Период
Сортировка
От Heikki Linnakangas
Тема Re: [COMMITTERS] pgsql: Change how first WAL segment on new timeline after promotion is
Дата
Msg-id 54AABFA2.3050409@vmware.com
обсуждение исходный текст
Ответы Re: [COMMITTERS] pgsql: Change how first WAL segment on new timeline after promotion is  (Andres Freund <andres@2ndquadrant.com>)
Список pgsql-hackers
On 01/03/2015 08:59 PM, Andres Freund wrote:
> Hi Heikki,
>
> While writing a test script for
> http://archives.postgresql.org/message-id/20141205002854.GE21964%40awork2.anarazel.de
> I noticed that this commit broke starting a pg_basebackup -X * without a
> recovery.conf present. Which might not be the best idea, but imo is a
> perfectly valid thing to do.
>
> To me the changes to StartupXLOG() in that commit look a bit bogus. The
> new startLogSegNo is initialized to XLByteToSeg(EndOfLog)? Which points
> to the end of the record +1? Which thus isn't guaranteed to exist as a
> segment (e.g. never if the last record was a XLOG_SWITCH).

Ah, good point.

> Did you perhaps intend to use XLogFileInit(use_existing = true)
> instead of XLogFileOpen()? That works for me.

Hmm, that doesn't sound right either. XLogFileInit is used when you
switch to a new segment, not to open an old segment for writing. It
happens to work, because with use_existing = true it will in fact always
open the old segment, instead of creating a new one, but I don't think
that's in the spirit of how that function's intended to be used.

A very simple fix is to not try opening the segment at all. There isn't
actually any requirement to have the segment open at that point,
XLogWrite() will open it the first time the WAL is flushed. The WAL is
flushed after writing the initial checkpoint or end-of-recovery record,
which happens pretty soon anyway. Any objections to the attached?

> I've attached my preliminary testscript (note it's really not that
> interesting at this point) that reliably reproduces the problem for me.

Thanks!

- Heikki

Вложения

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

Предыдущее
От: Guillaume Lelarge
Дата:
Сообщение: Re: Publish autovacuum informations
Следующее
От: Robert Haas
Дата:
Сообщение: Re: Additional role attributes && superuser review