From: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
To: Mike Lissner <mlissner@michaeljaylissner.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: Is it safe to transfer logical replication publication/subscription?
Date: Wed, 8 Jan 2020 23:46:46 +0100
Message-ID: <70822442-b8dc-1394-382b-ed8a024c89d8@2ndquadrant.com> (raw)
In-Reply-To: <CAMp9=EwMa=LVtFhFZeYUyO7EzLLKiy3A6vA5tG-pyBq4S52QFw@mail.gmail.com>
References: <CAMp9=EwMa=LVtFhFZeYUyO7EzLLKiy3A6vA5tG-pyBq4S52QFw@mail.gmail.com>
On 2020-01-08 22:22, Mike Lissner wrote:
> Hi all, this is a follow up from an earlier question I asked about
> shortening a chain of logically replicating servers. Right now we have
> three servers replicating like this:
>
> A --> B --> C
>
> And we want to remove B so that we have:
>
> A --> C
>
> Is it possible to DROP the subscription on B to A and then to
> SUBSCRIBE C to the previously used publication on A without losing
> data?
What you are not taking into account here are replication slots, which
are the low-level mechanism to keep track of what a replication client
has consumed. When you drop the subscription on B, that (by default)
also drops the associated replication slot on A, and therefore you lose
the information of how much B has consumed from A. (This assumes that
there is concurrent write activity on A, otherwise this is uninteresting.)
What you need to do instead is disassociate the B-from-A subscription
from the replication slot on A, then let all changes from B trickle to
C, then change the C-from-B subscription to replicate from A and use the
existing replication slot on A.
See
https://www.postgresql.org/docs/current/logical-replication-subscription.html#LOGICAL-REPLICATION-SU...
for details.
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
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: peter.eisentraut@2ndquadrant.com, mlissner@michaeljaylissner.com
Subject: Re: Is it safe to transfer logical replication publication/subscription?
In-Reply-To: <70822442-b8dc-1394-382b-ed8a024c89d8@2ndquadrant.com>
References: <CAMp9=EwMa=LVtFhFZeYUyO7EzLLKiy3A6vA5tG-pyBq4S52QFw@mail.gmail.com> <70822442-b8dc-1394-382b-ed8a024c89d8@2ndquadrant.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