Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ipK6L-0003E2-Mq for pgsql-general@arkaria.postgresql.org; Wed, 08 Jan 2020 22:46:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ipK6J-0004Zx-DS for pgsql-general@arkaria.postgresql.org; Wed, 08 Jan 2020 22:46:55 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ipK6J-0004Zp-3e for pgsql-general@lists.postgresql.org; Wed, 08 Jan 2020 22:46:55 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ipK6E-0001uq-P3 for pgsql-general@lists.postgresql.org; Wed, 08 Jan 2020 22:46:53 +0000 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 1956721C0F; Wed, 8 Jan 2020 17:46:49 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute7.internal (MEProxy); Wed, 08 Jan 2020 17:46:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=CFa3MsnzlCXqg8n0MJ87TtK994HtFFk5ZrprZGA0F E4=; b=mHxYaAj7E2Wgz6HkEpF51DhsD1e9ZXKcnkxxGj/Ykw7OfL8txx/K2QxX5 vEVPF382Y2URZOodAaFOJNOl38pNQbpEpd3zWo/tbYVt5LTX1bTOBjbq4x7fHV3R cL1hA+wmvYjHmEkvl4Z3oDRS0i3RlX/cV4LDOYte/A0yuWmLGeZ6yy7sMnafjscQ eRfbxBBGhvhZT/9K3n47sKS12vdJaZMYq52dAPkJ9rHqlTzT9gV3+fovm185rHwD 82vgVksCMs7D1BM88Mc19/B2jN4N1EI7veR9RUUg/yKY3NKV1yq1icjcNybD/Vs+ 0jWo2wwJRDlf7b/h+Ul60OoqI2wQg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrvdehledgtdduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepuffvfhfhohfkffgfgggjtgfgsehtjeertddtfeejnecuhfhrohhmpefrvght vghrucfgihhsvghnthhrrghuthcuoehpvghtvghrrdgvihhsvghnthhrrghuthesvdhnug hquhgrughrrghnthdrtghomheqnecuffhomhgrihhnpedvnhguqhhurggurhgrnhhtrdgt ohhmpdhpohhsthhgrhgvshhqlhdrohhrghenucfkphepleefrddvgeefrddukeejrdduge egnecurfgrrhgrmhepmhgrihhlfhhrohhmpehpvghtvghrrdgvihhsvghnthhrrghuthes vdhnughquhgrughrrghnthdrtghomhenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: Received: from april.pezone.net (p5df3bb90.dip0.t-ipconnect.de [93.243.187.144]) by mail.messagingengine.com (Postfix) with ESMTPA id EFA1E80063; Wed, 8 Jan 2020 17:46:47 -0500 (EST) Subject: Re: Is it safe to transfer logical replication publication/subscription? To: Mike Lissner , pgsql-general@lists.postgresql.org References: From: Peter Eisentraut Organization: 2ndQuadrant Message-ID: <70822442-b8dc-1394-382b-ed8a024c89d8@2ndquadrant.com> Date: Wed, 8 Jan 2020 23:46:46 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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-SUBSCRIPTION-SLOT for details. -- Peter Eisentraut http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services