Re: Condition to become the standby mode.

From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: Sawada Masahiko <sawada(dot)mshk(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Condition to become the standby mode.
Date: 2013-07-26 14:47:59
Message-ID: CAHGQGwFah26R_HW5n6S9JzSK9PTumWezNnW40YvtyaHbpX-ZPQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Jul 26, 2013 at 3:08 PM, Andres Freund <andres(at)2ndquadrant(dot)com> wrote:
> Hi,
>
> On 2013-07-26 13:19:34 +0900, Sawada Masahiko wrote:
>> When the slave server starts, the slave server perform the following
>> steps in StartupXLOG():
>> 1. Read latest CheckPoint record LSN from pg_control file.
>> 2. Try to fetch CheckPoint record from pg_xlog directory at first.
>> ( The server try to read up to prior CheckPoint record from pg_contrl file)
>> 3. If there is not in pg_xlog, the slave server requests CheckPoint
>> record to the primary server.
>
>> in #3, it works only when StandbyMode is true. For StandbyMode is to
>> true, database cluster state should be "DB_SHUTDOWNED" (it is one of
>> the conditions).
>> that is, slave server can try to fetch checkpoint record from the
>> master server after slave server was successful completion.
>
> It also will fetch the xlog from remote when we've found a backup label
> (the read_backup_label() branch in StartupXLOG() will set StandbyMode to
> true). Which will be the case if we're recovering from something like a
> base backup.
>
> The reason we don't fetch from remote if there's no backup label *and*
> the last checkpoint wasn't a shutdown checkpoint is that that's doing
> *local* crash recovery.

Yes, in that case, local crash recovery occurs first. After it ends (i.e.,
reach the end of the WAL available in local), we can enable standby
mode and fetch the WAL from remote server.

>> If this problem is solved, there is possible of that we can failback
>> by removing the all WAL record which is in pg_xlog before server
>> starts as the slave server.
>> ( And we also use "synchronous_transfer" which I'm proposing, I think
>> we can fail-back without taking full backup surely)
>
> I still have *massive* doubts about the concept. But anyway, if you want
> to do so, you should generate a backup label that specifies the startup
> location.

Generating a backup label doesn't seem to be enough because there is
no backup-end WAL record and we cannot know the consistency point.

Regards,

--
Fujii Masao

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2013-07-26 14:55:14 Re: Condition to become the standby mode.
Previous Message Andres Freund 2013-07-26 14:16:49 Re: getting rid of SnapshotNow