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 1iommI-0001Kz-VO for pgsql-general@arkaria.postgresql.org; Tue, 07 Jan 2020 11:12:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iommH-0007iU-P6 for pgsql-general@arkaria.postgresql.org; Tue, 07 Jan 2020 11:12:01 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iommH-0007ho-6m for pgsql-general@lists.postgresql.org; Tue, 07 Jan 2020 11:12:01 +0000 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1iommE-00080J-OM for pgsql-general@lists.postgresql.org; Tue, 07 Jan 2020 11:12:00 +0000 Received: by mail-wr1-x436.google.com with SMTP id c9so53471094wrw.8 for ; Tue, 07 Jan 2020 03:11:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20150623.gappssmtp.com; s=20150623; h=message-id:subject:from:to:date:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=DBzdl/ZyW+NvGdAwvPUwJqi9EHIrYlQu7Hxmqb5CNtk=; b=UILstKxk245WuIuREfSld9a/TYWgyI6CbV4ZhzIECANhm9WyVPl3UiOlMets5OTaDY GqmHI7uo38C/QLCg/6OiNsTcDL84Ckub4ea+MJc3vSkx4Utze1yICTk0Py3XkpFZGH5o 0xtOk2G9UYEpjoQ3ByBoNHvEp+xCvzuY3Y6WRjtrQHW3W2ffLyFhme1lJ1QYeEOmaNkH 0LLV5wF7Z/8lfThWLk0wOpIkIPZZKEEUK2hOgrH6e9y+iSx5tMb3/JfpXDcB9Dh36EW0 yV9spTADkaziuaBJzUa+eZUz/8d237v+WW0e3QfCPvcbaAPXoVpdVR6kDdnGRXuOE8mv MIAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=DBzdl/ZyW+NvGdAwvPUwJqi9EHIrYlQu7Hxmqb5CNtk=; b=meP/b77swH8L9KP9EF91fdgt9ZXJok/eb6m3nqiGQmHvJmK0rYXLAwXbnGzDaFCP/J xcPQCgP+B43v2v1H7a/lIjQFXKEZE0v1ZgzsJ98lf5773wo5sH8UbHhFtArqqrCZdPw6 knP3w3opv7f4x6PzksVGYH3Z0F0uuHB3rXCV4yMS7MAdIuNJ0j8Z5jGfmJnxXB6EAYDK buUoUY90HS3yII45AtqjFDZDy7RYCWQbYyX+CWN72CCWL9U3X12nldQ/Q/ghpWY+A1dE CaaG7R//K25QS+fxCvQKuwQXFGAsIfG0/v0xmKmf3QB/zolczYe5l41abU7VKREe9Yll M45A== X-Gm-Message-State: APjAAAXG2bcCTyuFuZVuvadiCGXFZRBUuzsQ50Elb2z31QWXpNFV5mzi f7qCvxSW+6zQ0FskYeoQYA0HJA== X-Google-Smtp-Source: APXvYqzZt18bgk/So3rq8Tm1H3nrXYIZi0rPkJC7p2GwGovxPFeWVPXm2AHNKAoS+imTlYH3sgV5eQ== X-Received: by 2002:a5d:4f8e:: with SMTP id d14mr70425925wru.112.1578395516379; Tue, 07 Jan 2020 03:11:56 -0800 (PST) Received: from localhost.localdomain ([212.186.219.234]) by smtp.gmail.com with ESMTPSA id 60sm79542338wrn.86.2020.01.07.03.11.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2020 03:11:55 -0800 (PST) Message-ID: Subject: Re: How to shorten a chain of logically replicated servers From: Laurenz Albe To: Mike Lissner , pgsql-general@lists.postgresql.org Date: Tue, 07 Jan 2020 12:11:54 +0100 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.32.5 (3.32.5-1.fc30) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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