Re: Enable WAL archiving even in standby - Mailing list pgsql-hackers

From Fujii Masao
Subject Re: Enable WAL archiving even in standby
Date
Msg-id CAHGQGwEfZLnm6SovnUF--gr+OUhhrogR_Mq+Y=EiEfSSA9W_3g@mail.gmail.com
Whole thread Raw
In response to Re: Enable WAL archiving even in standby  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: Enable WAL archiving even in standby
List pgsql-hackers
On Fri, Aug 15, 2014 at 4:30 AM, Robert Haas <robertmhaas@gmail.com> wrote:
> On Wed, Aug 13, 2014 at 6:42 AM, Fujii Masao <masao.fujii@gmail.com> wrote:
>> I'd propose the attached WIP patch which allows us to enable WAL archiving
>> even in standby. The patch adds "always" as the valid value of archive_mode.
>> If it's set to "always", the archiver is started when the server is in standby
>> mode and all the WAL files that walreceiver wrote to the disk are archived by
>> using archive_command. Then, even after the server is promoted to master,
>> the archiver keeps archiving WAL files. The patch doesn't change the meanings
>> of the setting values "on" and "off" of archive_mode.
>
> I like the feature, but I don't much like this as a control mechanism.
> Having archive_command and standby_archive_command, as you propose
> further down, seems saner.

Okay, that's fine. One question is; Which WAL files should be archived by
standby_archive_command? There are following kinds of WAL files.

(1) WAL files which were fully written and closed by walreceiver    Curently they are not archived at all.

(2) WAL file which is being written by walreceiver    This file will be closed before it's fully written because of,
forexample, standby promotion.    Currently this is archived by archive_command.
 

(3) WAL file with new timeline, which is copied from (2)     At the end of recovery, after new timeline is assigned,
this latest WAL file with new timeline is created by being copied     from (2) (i.e., latest WAL file with old
timeline).WAL data of     end-of-recovery checkpoint is written to this latest WAL file.     Currently this is archived
byarchive_command.
 

(4) Timeline history files    When standby is promoted to the master, the imeline is incremented    and the timeline
historyfile is created.    Currently the timeline history files are archived by archive_command.
 

(5) WAL files generated in normal processing mode     Currently they are archived by archive_command.

I'm thinking to use standby_archive_command only for (1) because
the others are currently archived by archive_command. That means
that even if there are type (1) WAL files which have not been archived
yet after the standby promotion (i.e., the situation where WAL archiving
was delayed for some reasons in the standby), they are archived by
standby_archive_command. IOW, the archiver uses both archive commands
as the situation demands.

OTOH, maybe there are people who want to use standby_archive_command
for all the WAL files with old timeline, i.e., (1) and (2). Thought?

Regards,

-- 
Fujii Masao



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: Reporting the commit LSN at commit time
Next
From: 鈴木 幸市
Date:
Subject: Re: [Postgres-xc-developers] Trove with PostgreSQL-XC