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 1gm0Ex-0006gy-Gp for pgsql-general@arkaria.postgresql.org; Tue, 22 Jan 2019 17:53:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gm0Ew-0006U3-C0 for pgsql-general@arkaria.postgresql.org; Tue, 22 Jan 2019 17:53:34 +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 1gm0Eu-0006RR-DR for pgsql-general@lists.postgresql.org; Tue, 22 Jan 2019 17:53:34 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gm0Eq-0003lq-Vm for pgsql-general@postgresql.org; Tue, 22 Jan 2019 17:53:31 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 45BFC22086; Tue, 22 Jan 2019 12:53:28 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Tue, 22 Jan 2019 12:53:28 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm2; bh=N YmpVZt+cDdNPcgcpA3ckRzNCaNLu9lYgs4+MXZFePw=; b=gLZ9EW/PmUm//YRoK 4RWJBqPgxCaz7HJPhOdxoIFRrfWy76Vee7yXZi1A47pDaVySFiFpwi3FoYz9PSjk Ln+ZPx69fzow7lSCbO9+mNQwv5IJNKlTkt7/bLEp2XFpGVrD5YiVngURttRFTp8v 1i4dwgf0s7EBKiyaL6zMqzLF62RZRJ/JLPzNJ/u/qNqk6nvT3X6BQkJ2NPG6Om21 qTRKxPWZbE9DgbC63tT7Vo0m1VDnWJmAGXawWwIdv971fbED5sFM1JNAbzpQoT5t UTwV3btjk2nQDsIl5/fah4LsUZxrAv6jJbHhLA8+crW+tEPPJ836+HAjMoQqWEDg PvEhw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc: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=NYmpVZt+cDdNPcgcpA3ckRzNCaNLu9lYgs4+MXZFe Pw=; b=eONKw94C96RePMweY1HFSWK/HnfX1Hwly769XeVUNqmcAFdun+MR0dvaZ pWyqzdk9nSKZcqB89Ul22oY6/ZgfSekpzhnAww1LPUtq1wcfVaSK17xKpl99vFwn 0pOHgglmtLFmaJqLJZDTLDtpbz4T9MuOJ0dpOf673/o319RdRmnkfkgyX8pplZpG kDh8d9iXy0y5PZEU7TAAr7tXC9cxsPavrywC7QoqETOuh1xRslKY/OcttbsQOjsF AhQ463qbTRY08bNMNFI6amcdnSw6jJ1k6BTAyTw6e39wmAhoApfbGea/tcgYRP8p HdEAfu15FqehhcfSvPxO3dBsL1Tig== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtledrheekgddutdehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfquhhtnecuuegrihhlohhuthemucef tddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefuvfhfhffkff gfgggjtgfgsehtkeertddtfeejnecuhfhrohhmpeetughrihgrnhcumfhlrghvvghruceo rggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomheqnecukfhppeejgedrle egrdejfedrvddvvdenucfrrghrrghmpehmrghilhhfrhhomheprggurhhirghnrdhklhgr vhgvrhesrghklhgrvhgvrhdrtghomhenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: Received: from ranger.suse (unknown [74.94.73.222]) by mail.messagingengine.com (Postfix) with ESMTPA id 32E5A10310; Tue, 22 Jan 2019 12:53:27 -0500 (EST) Subject: Re: PostgreSQL logical replication depends on WAL segments? To: Jeremy Finzel , Josef Machytka Cc: Postgres General References: <507c69ad-e87b-2180-c2ec-08e1aee20352@aklaver.com> From: Adrian Klaver Message-ID: <47f78c16-1b15-8f2d-1cb0-613aaa973d5c@aklaver.com> Date: Tue, 22 Jan 2019 09:53:26 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 1/22/19 9:10 AM, Jeremy Finzel wrote: > Thanks, I see... So if I understand it correctly - since I have > quite big partitions like ~30 GB each in one parent table and from > ~1GB to ~5 GB in several others I presume I had to set > wal_keep_segments to some really high number and stop our security > cronjob cleaning old WAL segments (because we already had some > problems with almost full disk due to old WAL segments) until the > whole transfer of snapshot is done. Because only after the whole > snapshot is transferred logical replication workers start to > transfer WAL logs reflecting changes done from the moment snapshot > was taken... > > jm > > > Understand there are other downsides to just keeping around a huge > amount of WAL segments apart from only taking up disk space.  None of > the data held in those WAL segments can be vacuumed away while they are > left around, which can lead to significant bloat and performance issues > over time. That is news to me. Can you provide a citation for this? > > I'm not exactly clear on your use case, but if you need to just > resychronize data for a single table, there is a built-in way to do that > (actually would be nice if the docs spelled this out). > > On publisher: > > ALTER PUBLICATION mypub DROP TABLE old_data_table; > > On subscriber: > > ALTER SUBSCRIPTION mysub REFRESH PUBLICATION WITH ( COPY_DATA = true); > > On publisher: > > ALTER PUBLICATION mypub ADD TABLE old_data_table; > > On subscriber: > > ALTER SUBSCRIPTION mysub REFRESH PUBLICATION WITH ( COPY_DATA = true); > > The last command will resync the table from the current table data, > regardless of the WAL file situation.  This is the "normal" way you > would go about resynchronizing data between clusters when a long time > has passed, rather than trying to keep all that WAL around! > > So far as I can tell from testing, above pattern is the easiest way to > do this, and it will not resynchronize any of the other tables in your > subscription. > > P.S. do heed the advice of the others and get more familiar with the > docs around WAL archiving. > > Thanks, > Jeremy -- Adrian Klaver adrian.klaver@aklaver.com