From: | Heikki Linnakangas <hlinnakangas(at)vmware(dot)com> |
---|---|
To: | Neil Thombre <nt(at)heroku(dot)com> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: pg_standby: Question about truncation of trigger file in fast failover |
Date: | 2014-02-19 21:42:55 |
Message-ID: | 5305255F.4000001@vmware.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2014-02-19 23:37:42 | Re: GiST support for inet datatypes |
Previous Message | Emre Hasegeli | 2014-02-19 21:39:41 | Re: GiST support for inet datatypes |