From: Fujii Masao <masao.fujii@oss.nttdata.com>
To: Grigory Smolkin <g.smolkin@postgrespro.ru>
To: David Zhang <david.zhang@highgo.ca>
To: Anastasia Lubennikova <a.lubennikova@postgrespro.ru>
To: Postgres hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: history file on replica and double switchover
Date: Sat, 26 Sep 2020 04:05:00 +0900
Message-ID: <ef405976-3e6d-8f67-4845-8d78a5947f12@oss.nttdata.com> (raw)
In-Reply-To: <f5431847-8fd0-8455-4d79-6f0d7c36809e@postgrespro.ru>
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>
<c4fd518c-71ef-3811-4b54-f8ece58355f3@oss.nttdata.com>
<f5431847-8fd0-8455-4d79-6f0d7c36809e@postgrespro.ru>
On 2020/09/26 2:58, Grigory Smolkin wrote:
> Fujii Masao, David Zhang, Anastasia Lubennikova, many thanks to you for efforts with this patch!
> Can I mark it as ready for committer?
Ok, but I attached the updated version of the patch. It's helpful if you review that.
In the latest patch, I changed walreceiver so that it creates .done file for the streamed timeline history file when archive_mode is NOT "always".
Walreceiver does the same thing for the streamed WAL files to prevent them from being archived later. Without this, the streamed WAL files can exist in pg_wal without any archive status files, and then they will be archived later accidentally because of lack of archive status.
OTOH, timeline history files will not be archived later even without archive status files. So there is no strong reason to make walreceiver create .doen file for the timeline history files. But at least for me it's strange to keep the file in pg_wal without archive status. So for now I'm just inclined to create .done files.... Thought?
Regards,
--
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION
Attachments:history_replica_v4.patch (text/plain, 1.5K) downloaddiff --git a/doc/src/sgml/high-availability.sgml b/doc/src/sgml/high-availability.sgmlindex beb309e668..42f01c515f 100644--- a/doc/src/sgml/high-availability.sgml+++ b/doc/src/sgml/high-availability.sgml@@ -1395,7 +1395,8 @@ synchronous_standby_names = 'ANY 2 (s1, s2, s3)'
If <varname>archive_mode</varname> is set to <literal>on</literal>, 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. To get a complete+ will not archive any WAL or timeline history files that+ it did not generate itself. To get a complete
series of WAL files in the archive, you must ensure that all WAL is
archived, before it reaches the standby. This is inherently true with
file-based log shipping, as the standby can only restore files that
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.cindex 17f1a49f87..bb1d44ccb7 100644--- a/src/backend/replication/walreceiver.c+++ b/src/backend/replication/walreceiver.c@@ -758,6 +758,15 @@ WalRcvFetchTimeLineHistoryFiles(TimeLineID first, TimeLineID last)
*/
writeTimeLineHistoryFile(tli, content, len);
+ /*+ * Mark the streamed history file as ready for archiving+ * if archive_mode is always.+ */+ if (XLogArchiveMode != ARCHIVE_MODE_ALWAYS)+ XLogArchiveForceDone(fname);+ else+ XLogArchiveNotify(fname);+
pfree(fname);
pfree(content);
}
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: masao.fujii@oss.nttdata.com, g.smolkin@postgrespro.ru, david.zhang@highgo.ca, a.lubennikova@postgrespro.ru
Subject: Re: history file on replica and double switchover
In-Reply-To: <ef405976-3e6d-8f67-4845-8d78a5947f12@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> <df697973-aca7-4e6b-2d9f-871281882904@highgo.ca> <c4fd518c-71ef-3811-4b54-f8ece58355f3@oss.nttdata.com> <f5431847-8fd0-8455-4d79-6f0d7c36809e@postgrespro.ru> <ef405976-3e6d-8f67-4845-8d78a5947f12@oss.nttdata.com>
* 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