Re: pg_standby: Question about truncation of trigger file in fast failover

Поиск
Список
Период
Сортировка
От Heikki Linnakangas
Тема Re: pg_standby: Question about truncation of trigger file in fast failover
Дата
Msg-id 5305255F.4000001@vmware.com
обсуждение исходный текст
Ответ на pg_standby: Question about truncation of trigger file in fast failover  (Neil Thombre <nt@heroku.com>)
Ответы Re: pg_standby: Question about truncation of trigger file in fast failover  (Neil Thombre <nt@heroku.com>)
Список pgsql-hackers
On 02/19/2014 11:15 PM, Neil Thombre wrote:
> And that is where I have a question. I noticed that in pg_standby.c when we
> detect the word "fast" in the trigger file we truncate the file.
>
> https://github.com/postgres/postgres/blob/REL9_1_11/contrib/pg_standby/pg_standby.c#L456
>
> There is also a comment above it about not "upsetting" the server.
>
> https://github.com/postgres/postgres/blob/REL9_1_11/contrib/pg_standby/pg_standby.c#L454
>
> What is the purpose of truncating the file? To do a smart failover once you
> come out of standby? But, when I look at xlog.c, when we come out of
> standby due to a failure returned by restore_command, we call
> CheckForStandbyTrigger() here:
>
> https://github.com/postgres/postgres/blob/REL9_1_11/src/backend/access/transam/xlog.c#L10441
>
> Now, CheckForStandbyTrigger() unlinks the trigger file. I noticed through
> the debugger that the unlinking happens before xlog.c makes a call to the
> next restore_command.  So, what is the reason for truncating the "fast"
> word from the trigger file if the file is going to be deleted soon after it
> is discovered? How will we "upset" the server if we don't?

At end-of-recovery, the server will fetch again the last WAL file that 
was replayed. If it can no longer find it, because restore_command now 
returns an error even though it succeeded for the same file few seconds 
earlier, it will throw an error and refuse to start up.

That's the way it used to be until 9.2, anyway. In 9.2, the behavior was 
changed, so that the server keeps all the files restored from archive, 
in pg_xlog, so that it can access them again. I haven't tried, but it's 
possible that the truncation is no longer necessary. Try it, with 9.1 
and 9.3, and see what happens.

- Heikki



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

Предыдущее
От: Emre Hasegeli
Дата:
Сообщение: Re: GiST support for inet datatypes
Следующее
От: Tom Lane
Дата:
Сообщение: Re: GiST support for inet datatypes