pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Laurenz Albe <laurenz.albe@cybertec.at>
To: Mike Lissner <mlissner@michaeljaylissner.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: How to shorten a chain of logically replicated servers
Date: Tue, 07 Jan 2020 12:11:54 +0100
Message-ID: <a918c694e76b5214b7e82abe6dc7d70a55c22143.camel@cybertec.at> (raw)
In-Reply-To: <CAMp9=EzU5cBXSwaH=Somx6QTuH_pkN=pgYjSzZdVMs_+RnAveA@mail.gmail.com>
References: <CAMp9=EzU5cBXSwaH=Somx6QTuH_pkN=pgYjSzZdVMs_+RnAveA@mail.gmail.com>

On Tue, 2019-12-31 at 15:51 -0800, Mike Lissner wrote:
> Hi, I'm trying to figure out how to shorten a chain of logically
> replicating servers. Right now we have three servers replicating like
> so:
> 
> A --> B --> C
> 
> And I'd like to remove B from the chain of replication so that I only have:
> 
> A --> C
> 
> Of course, doing this without losing data is the goal. If the
> replication to C breaks temporarily, that's fine, so long as all the
> changes on A make it to C eventually.
> 
> I'm not sure how to proceed with this. My best theory is:
> 
> 1. In a transaction, DISABLE the replication from A to B and start a
> new PUBLICATION on A that C will subscribe to in step ③ below. The
> hope is that this will simultaneously stop sending changes to B while
> starting a log of new changes that can later be sent to C.
> 
> 2. Let any changes queued on B flush to C. (How to know when they're
> all flushed?)
> 
> 3. Subscribe C to the new PUBLICATION created in step ①. Create the
> subscription with copy_data=False. This should send all changes to C
> that hadn't been sent to B, without sending the complete tables.
> 
> 4. DROP all replication to/from B (this is just cleanup; the incoming
> changes to B were disabled in step ①, and outgoing changes from B were
> flushed in step ②).
> 
> Does this sound even close to the right approach? Logical replication
> can be a bit finicky, so I'd love to have some validation of the
> general approach before I go down this road.

I don't think that will work.

Any changes on A that take place between step 1 and step 3 wouldn't be
replicated to C.

You'd have to suspend all data modification on A in that interval.

Yours,
Laurenz Albe
-- 
Cybertec | https://www.cybertec-postgresql.com






view thread (6+ messages)  latest in thread

Message-ID: <a918c694e76b5214b7e82abe6dc7d70a55c22143.camel@cybertec.at>
Permalink:  ../a918c694e76b5214b7e82abe6dc7d70a55c22143.camel@cybertec.at/
Also on:    postgresql.org/message-id/a918c694e76b5214b7e82abe6dc7d70a55c22143.camel@cybertec.at

 · 

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-general@postgresql.org
  Cc: laurenz.albe@cybertec.at, mlissner@michaeljaylissner.com
  Subject: Re: How to shorten a chain of logically replicated servers
  In-Reply-To: <a918c694e76b5214b7e82abe6dc7d70a55c22143.camel@cybertec.at>
  References: <CAMp9=EzU5cBXSwaH=Somx6QTuH_pkN=pgYjSzZdVMs_+RnAveA@mail.gmail.com> <a918c694e76b5214b7e82abe6dc7d70a55c22143.camel@cybertec.at>

* 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