pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: David Zhang <david.zhang@highgo.ca>
To: Fujii Masao <masao.fujii@oss.nttdata.com>
To: Anastasia Lubennikova <a.lubennikova@postgrespro.ru>
To: Grigory Smolkin <g.smolkin@postgrespro.ru>
To: Postgres hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: history file on replica and double switchover
Date: Thu, 24 Sep 2020 21:00:19 -0700
Message-ID: <df697973-aca7-4e6b-2d9f-871281882904@highgo.ca> (raw)
In-Reply-To: <7ef22f86-1232-2516-afaa-f31441d25504@oss.nttdata.com>
References: <54b059d4-2b48-13a4-6f43-95a087c92367@postgrespro.ru>
	<b3a3ff0c-eabd-58ad-94be-846b067fed33@postgrespro.ru>
	<4f7379a6-b196-70fe-708d-84a2672b3c22@oss.nttdata.com>
	<2823800f-897e-0799-a89a-75aa43f44e5d@oss.nttdata.com>
	<1c1a7d07-272b-7ced-1a1c-9a16aff33d54@highgo.ca>
	<7ef22f86-1232-2516-afaa-f31441d25504@oss.nttdata.com>

On 2020-09-24 5:00 p.m., Fujii Masao wrote:
>
>
> On 2020/09/25 8:15, David Zhang wrote:
>> Hi,
>>
>> My understanding is that the "archiver" won't even start if 
>> "archive_mode = on" has been set on a "replica". Therefore, either 
>> (XLogArchiveMode == ARCHIVE_MODE_ALWAYS) or (XLogArchiveMode != 
>> ARCHIVE_MODE_OFF) will produce the same result.
>
> Yes, the archiver isn't invoked in the standby when archive_mode=on.
> But, with the original patch, walreceiver creates .ready archive 
> status file
> even when archive_mode=on and no archiver is running. This causes
> the history file to be archived after the standby is promoted and
> the archiver is invoked.
>
> With my patch, walreceiver creates .ready archive status for the 
> history file
> only when archive_mode=always, like it does for the streamed WAL files.
> This is the difference between those two patches. To prevent the streamed
> timeline history file from being archived, IMO we should use the 
> condition
> archive_mode==always in the walreceiver.
+1
>
>
>>
>> Please see how the "archiver" is started in 
>> src/backend/postmaster/postmaster.c
>>
>> 5227                 /*
>> 5228                  * Start the archiver if we're responsible for 
>> (re-)archiving received
>> 5229                  * files.
>> 5230                  */
>> 5231                 Assert(PgArchPID == 0);
>> 5232                 if (XLogArchivingAlways())
>> 5233                         PgArchPID = pgarch_start();
>>
>> I did run the nice script "double_switchover.sh" using either 
>> "always" or "on" on patch v1 and v2. They all generate the same 
>> results below. In other words, whether history file 
>> (00000003.history) is archived or not depends on "archive_mode" 
>> settings.
>>
>> echo "archive_mode = always" >> ${PGDATA_NODE2}/postgresql.auto.conf
>>
>> $ ls -l archive
>> -rw------- 1 david david 16777216 Sep 24 14:40 000000010000000000000002
>> ... ...
>> -rw------- 1 david david 16777216 Sep 24 14:40 00000002000000000000000A
>> -rw------- 1 david david       41 Sep 24 14:40 00000002.history
>> -rw------- 1 david david       83 Sep 24 14:40 00000003.history
>>
>> echo "archive_mode = on" >> ${PGDATA_NODE2}/postgresql.auto.conf
>>
>> $ ls -l archive
>> -rw------- 1 david david 16777216 Sep 24 14:47 000000010000000000000002
>> ... ...
>> -rw------- 1 david david 16777216 Sep 24 14:47 00000002000000000000000A
>> -rw------- 1 david david       41 Sep 24 14:47 00000002.history
>>
>>
>> Personally, I prefer patch v2 since it allies to the statement here, 
>> https://www.postgresql.org/docs/13/warm-standby.html#CONTINUOUS-ARCHIVING-IN-STANDBY
>>
>> "If archive_mode is set to on, the archiver is not enabled during 
>> recovery or standby mode. If the standby server is promoted, it will 
>> start archiving after the promotion, but will not archive any WAL it 
>> did not generate itself."
>>
>> By the way, I think the last part of the sentence should be changed 
>> to something like below:
>>
>> "but will not archive any WAL, which was not generated by itself."
>
> I'm not sure if this change is an improvement or not. But if we apply
> the patch I proposed, maybe we should mention also history file here.
> For example, "but will not archive any WAL or timeline history files
> that it did not generate itself".
make sense for me
>
> Regards,
>
-- 
David

Software Engineer
Highgo Software Inc. (Canada)
www.highgo.ca






view thread (10+ messages)  latest in thread

Message-ID: <df697973-aca7-4e6b-2d9f-871281882904@highgo.ca>
Permalink:  ../df697973-aca7-4e6b-2d9f-871281882904@highgo.ca/
Also on:    postgresql.org/message-id/df697973-aca7-4e6b-2d9f-871281882904@highgo.ca

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: david.zhang@highgo.ca, masao.fujii@oss.nttdata.com, a.lubennikova@postgrespro.ru, g.smolkin@postgrespro.ru
  Subject: Re: history file on replica and double switchover
  In-Reply-To: <df697973-aca7-4e6b-2d9f-871281882904@highgo.ca>
  References: <54b059d4-2b48-13a4-6f43-95a087c92367@postgrespro.ru> <b3a3ff0c-eabd-58ad-94be-846b067fed33@postgrespro.ru> <4f7379a6-b196-70fe-708d-84a2672b3c22@oss.nttdata.com> <2823800f-897e-0799-a89a-75aa43f44e5d@oss.nttdata.com> <1c1a7d07-272b-7ced-1a1c-9a16aff33d54@highgo.ca> <7ef22f86-1232-2516-afaa-f31441d25504@oss.nttdata.com> <df697973-aca7-4e6b-2d9f-871281882904@highgo.ca>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox