pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: 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: Fri, 18 Sep 2020 02:18:45 +0900
Message-ID: <2823800f-897e-0799-a89a-75aa43f44e5d@oss.nttdata.com> (raw)
In-Reply-To: <4f7379a6-b196-70fe-708d-84a2672b3c22@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>



On 2020/09/04 13:53, Fujii Masao wrote:
> 
> 
> On 2020/09/04 8:29, Anastasia Lubennikova wrote:
>> On 27.08.2020 16:02, Grigory Smolkin wrote:
>>> Hello!
>>>
>>> I`ve noticed, that when running switchover replica to master and back to replica, new history file is streamed to replica, but not archived,
>>> which is not great, because it breaks PITR if archiving is running on replica. The fix looks trivial.
>>> Bash script to reproduce the problem and patch are attached.
>>>
>> Thanks for the report. I agree that it looks like a bug.
> 
> +1
> 
> +            /* Mark history file as ready for archiving */
> +            if (XLogArchiveMode != ARCHIVE_MODE_OFF)
> +                XLogArchiveNotify(fname);
> 
> I agree that history file should be archived in the standby when
> archive_mode=always. But why do we need to do when archive_mode=on?
> I'm just concerned about the case where the primary and standby
> have the shared archive area, and archive_mode is on.

So I updated the patch so that walreceiver marks the streamed history file
as ready for archiving only when archive_mode=always. Patch attached.
Thought?

Regards,

-- 
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION

Attachments:

history_replica_v2.patch (text/plain, 537B) download diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c index 17f1a49f87..32693c56db 100644 --- a/src/backend/replication/walreceiver.c +++ b/src/backend/replication/walreceiver.c @@ -758,6 +758,10 @@ WalRcvFetchTimeLineHistoryFiles(TimeLineID first, TimeLineID last) */ writeTimeLineHistoryFile(tli, content, len); + /* Mark history file as ready for archiving */ + if (XLogArchiveMode == ARCHIVE_MODE_ALWAYS) + XLogArchiveNotify(fname); + pfree(fname); pfree(content); }

view thread (10+ messages)  latest in thread

Message-ID: <2823800f-897e-0799-a89a-75aa43f44e5d@oss.nttdata.com>
Permalink:  ../2823800f-897e-0799-a89a-75aa43f44e5d@oss.nttdata.com/
Also on:    postgresql.org/message-id/2823800f-897e-0799-a89a-75aa43f44e5d@oss.nttdata.com

 ·  · 

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: 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: <2823800f-897e-0799-a89a-75aa43f44e5d@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>

* 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