pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Grigory Smolkin <g.smolkin@postgrespro.ru>
To: Postgres hackers <pgsql-hackers@lists.postgresql.org>
Subject: history file on replica and double switchover
Date: Thu, 27 Aug 2020 16:02:44 +0300
Message-ID: <54b059d4-2b48-13a4-6f43-95a087c92367@postgrespro.ru> (raw)

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.

-- 
Grigory Smolkin
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company

Attachments:

history_replica.patch (text/x-patch, 693B) download diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c index 7c11e1ab44..63a3d0c1e6 100644 --- a/src/backend/replication/walreceiver.c +++ b/src/backend/replication/walreceiver.c @@ -761,6 +761,10 @@ WalRcvFetchTimeLineHistoryFiles(TimeLineID first, TimeLineID last) */ writeTimeLineHistoryFile(tli, content, len); + /* Mark history file as ready for archiving */ + if (XLogArchiveMode != ARCHIVE_MODE_OFF) + XLogArchiveNotify(fname); + pfree(fname); pfree(content); }
double_switchover.sh (application/x-shellscript, 1.9K) download

view thread (10+ messages)  latest in thread

Message-ID: <54b059d4-2b48-13a4-6f43-95a087c92367@postgrespro.ru>
Permalink:  ../54b059d4-2b48-13a4-6f43-95a087c92367@postgrespro.ru/
Also on:    postgresql.org/message-id/54b059d4-2b48-13a4-6f43-95a087c92367@postgrespro.ru

 ·  · 

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: g.smolkin@postgrespro.ru
  Subject: Re: history file on replica and double switchover
  In-Reply-To: <54b059d4-2b48-13a4-6f43-95a087c92367@postgrespro.ru>
  References: <54b059d4-2b48-13a4-6f43-95a087c92367@postgrespro.ru>

* 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