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 1glyk4-0001SN-OL for pgsql-general@arkaria.postgresql.org; Tue, 22 Jan 2019 16:17: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 1glyk2-0004SF-SX for pgsql-general@arkaria.postgresql.org; Tue, 22 Jan 2019 16:17: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 1glyk2-0004S6-GJ for pgsql-general@lists.postgresql.org; Tue, 22 Jan 2019 16:17:34 +0000 Received: from hermes.gatewaynet.com ([193.92.121.98]) by makus.postgresql.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1glyjx-0001WT-Fv for pgsql-general@lists.postgresql.org; Tue, 22 Jan 2019 16:17:33 +0000 Received: from smadev.internal.net (pc131.internal.net [10.9.200.131]) by hermes.gatewaynet.com (8.14.3/8.14.3/Debian-9.4) with ESMTP id x0MGHJck019240 for ; Tue, 22 Jan 2019 18:17:24 +0200 Received: from smadev.internal.net (smadev [10.9.200.131]) by smadev.internal.net (8.15.2/8.15.2) with ESMTP id x0MGHI5f040148 for ; Tue, 22 Jan 2019 18:17:19 +0200 (EET) (envelope-from achill@matrix.gatewaynet.com) Subject: Re: PostgreSQL logical replication depends on WAL segments? To: pgsql-general@lists.postgresql.org References: <507c69ad-e87b-2180-c2ec-08e1aee20352@aklaver.com> From: Achilleas Mantzios Message-ID: <67714b88-9c9a-8b37-0009-e8643e586388@matrix.gatewaynet.com> Date: Tue, 22 Jan 2019 18:17:18 +0200 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:60.0) Gecko/20100101 Thunderbird/60.3.2 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------4A41A009D895B56E51EA2734" Content-Language: en-US X-Virus-Scanned: clamav-milter 0.98.7 at hermes X-Virus-Status: Clean X-Spam-Status: No, score=-24.9 required=5.0 tests=ALL_TRUSTED,DYN_HAM_COORD, DYN_HAM_IT,DYN_HAM_NAUTICAL,DYN_SPAM_SUBJ,HTML_MESSAGE,TW_PG autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on hermes.gatewaynet.com List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------4A41A009D895B56E51EA2734 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 22/1/19 6:01 μ.μ., Josef Machytka wrote: > > https://www.postgresql.org/docs/11/logical-replication-architecture.html > > > 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) I asked you if you had any cron jobs messing around with your WALs. The WALs in pg_wal dir is PostgreSQL's business to manage, not your scripts. Dont do that. Defining wal_keep_segments to a very large value or using replication slots (as with logical repl) won't help if your crons are deleting the WALs. Now what you have to do : - read up about the basic concepts of pgsql administration : https://www.postgresql.org/docs/11/admin.html - understand how postgresql replication slots work (logical repl is based on those) - understand how WAL archiving works - understand how streaming replication works - understand how logical replication works - understand how the various runtime configuration params act on the number of WALs kept > 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 -- Achilleas Mantzios IT DEV Lead IT DEPT Dynacom Tankers Mgmt --------------4A41A009D895B56E51EA2734 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit
On 22/1/19 6:01 μ.μ., Josef Machytka 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)

I asked you if you had any cron jobs messing around with your WALs. The WALs in pg_wal dir is PostgreSQL's business to manage, not your scripts. Dont do that. Defining wal_keep_segments to a very large value or using replication slots (as with logical repl) won't help if your crons are deleting the WALs.
Now what you have to do :
- read up about the basic concepts of pgsql administration : https://www.postgresql.org/docs/11/admin.html
- understand how postgresql replication slots work (logical repl is based on those)
- understand how WAL archiving works
- understand how streaming replication works
- understand how logical replication works
- understand how the various runtime configuration params act on the number of WALs kept

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


-- 
Achilleas Mantzios
IT DEV Lead
IT DEPT
Dynacom Tankers Mgmt
--------------4A41A009D895B56E51EA2734--