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 1hlrmA-00065x-B2 for pgsql-hackers@arkaria.postgresql.org; Fri, 12 Jul 2019 09:23:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hlrm8-0002oy-8Y for pgsql-hackers@arkaria.postgresql.org; Fri, 12 Jul 2019 09:23:32 +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 1hlrm7-0002kP-SC for pgsql-hackers@lists.postgresql.org; Fri, 12 Jul 2019 09:23:32 +0000 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hlrm4-0003Sx-On for pgsql-hackers@postgresql.org; Fri, 12 Jul 2019 09:23:30 +0000 Received: by mail-pf1-x442.google.com with SMTP id q10so4041467pff.9 for ; Fri, 12 Jul 2019 02:23:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language; bh=BYsBiP897zzZNGqu0fsQriiK6mlQdrOha+kJABuWyjo=; b=aHHxOuOF+0VJBL/Osc740M4W64Iy+3cKB+c3Xy1bbq8vKCZdI0atE8lBm/WEe2Zhrh d+uem0rlxJgxR0stw5cwC7Jh54Bu1KeaSsTIkuDVfy5+34H0i506w3ZqRS9EUOq3PrrT BZkAHRPhmkIDwHBgys16NTwRkFiEcBN2nCi1qJG9/DTfs2gkUQFoLZerSuE8Lln2fTGi 6G+EVvONSOyF4JvUn7OQHaZ2Scc62WUUR+8FAImtP5uaDdOjGPHX6zIpe9HMddVKOW2p mnq+WJd1a49e0uDNH8hyeh2MWxRi2ZY5w1Vomlkid9X6Z/cLa5Y9iEbyaEFIxkn4wWd7 dQFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=BYsBiP897zzZNGqu0fsQriiK6mlQdrOha+kJABuWyjo=; b=LCARkP18rU2/8LyyLfGcq5oWmK2dODKfkZJCp800ahfJ4k9OjuFjGKoiH5FeaL4Rs7 Meh/dF5aKvct7RpUXjycOELMPXf0wCpJsPREWmNY/md0mWfKTBM1VmYjCP+IO908j6wj qA+1kLXl6w7EFxtHVS76/lK3FrIQLGOxQtq9qtYxrHLyaqfpXMNU2gcv8LRutmt+Xt4O Jihy13f3jFFlilfbnxxFj2o5N6r+0Q0ainM7rcDOVmgF2adJcL2eTVPp5/o5hIApzWZJ xQo7Z79t234eOwjh0Cb6lk+2XstMcG95uJ7D28HOHVCy93nY3hZlnsUFCkVNOAFExgK1 6c1g== X-Gm-Message-State: APjAAAVNmNg1gVE97MfWFdcsh5gK1v5VCKYkxMKDY+nquvLXRT92tZ95 z+eKSCuJkaJ5D5wu9ssBydEL3Zw0f2QvmbliWUeDeKUhxFzX9O7J+sGvF5tA5jq++GKn1Omgxp6 UhZNNe8MEDWcBh7XorH2Yx/YRx/peXSoEm5roQGXdhCkaVuoHvhGs8vliZkW1xQ7SNk50CbAIPc PuHG+An4XQ0A== X-Google-Smtp-Source: APXvYqwutbydxsXgo6/MJmQUxrS31MYp+Qfu7viGrD+Sy8FWAFpu0FQRnfAqnXSMpG09aCjt/vm7wg== X-Received: by 2002:a63:f4e:: with SMTP id 14mr9652258pgp.58.1562923407332; Fri, 12 Jul 2019 02:23:27 -0700 (PDT) Received: from localhost.localdomain ([114.143.109.178]) by smtp.gmail.com with ESMTPSA id 2sm3131880pgm.39.2019.07.12.02.23.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jul 2019 02:23:26 -0700 (PDT) Subject: Re: Minimal logical decoding on standbys To: Amit Khandekar , Andres Freund Cc: Robert Haas , Petr Jelinek , Craig Ringer , Petr Jelinek , pgsql-hackers References: <20190604155853.6oiirwpbvcpubr5s@alap3.anarazel.de> <20190619190138.rufzsld5xgcgshmh@alap3.anarazel.de> <20190710031424.dfhzlqj2tpvznibe@alap3.anarazel.de> From: tushar Message-ID: <5a80cbcb-185c-fb81-02f2-7f26a8ea8efc@enterprisedb.com> Date: Fri, 12 Jul 2019 14:53:21 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------6DADFC08A420C5A8528F421A" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------6DADFC08A420C5A8528F421A Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 07/10/2019 05:12 PM, Amit Khandekar wrote: > All right. Will do that in the next patch set. For now, I have quickly > done the below changes in a single patch again (attached), in order to > get early comments if any. Thanks Amit for your patch. i am able to see 1 issues  on Standby server - (where  logical replication slot created ) , a)size of  pg_wal folder  is NOT decreasing even after firing get_changes function b)pg_wal files are not recycling  and every time it is creating new files after firing get_changes function Here are the detailed steps - create a directory with the name 'archive_dir' under /tmp (mkdir /tmp/archive_dir) *SR setup -* *Master* .)Perform initdb  (./initdb -D master --wal-segsize=2) .)Open postgresql.conf file and add these below parameters  at the end of  file wal_level='logical' min_wal_size=4MB max_wal_size=4MB hot_standby_feedback = on archive_mode=on archive_command='cp %p /tmp/archive_dir/%f' .)Start the server ( /pg_ctl -D master/ start -l logsM -c ) .)Connect to psql , create physical  slot     ->SELECT * FROM pg_create_physical_replication_slot('decoding_standby'); *Standby - * .)Perform pg_basebackup ( ./pg_basebackup -D standby/ --slot=decoding_standby -R -v) .)Open postgresql.conf file of standby and add these 2 parameters - at the end of file   port=5555 primary_slot_name = 'decoding_standby' .)Start the Standby server  ( ./pg_ctl -D standby/ start -l logsS -c ) .)Connect to psql terminal and create logical replication slot   ->SELECT * from   pg_create_logical_replication_slot('standby', 'test_decoding'); *MISC steps**- *.)Connect to master and create table/insert rows ( create table t(n int); insert into t (values (1);) .)Connect to standby and fire get_changes function ( select * from pg_logical_slot_get_changes('standby',null,null); ) .)Run pgbench ( ./pgbench -i -s 10 postgres) .)Check the pg_wal directory size of  STANDBY [centos@mail-arts bin]$ du -sch standby/pg_wal/ 127M    standby/pg_wal/ 127M    total [centos@mail-arts bin]$ .)Connect to standby and fire get_changes function ( select * from pg_logical_slot_get_changes('standby',null,null); ) .)Check the pg_wal directory size of STANDBY [centos@mail-arts bin]$ du -sch standby/pg_wal/ 127M    standby/pg_wal/ 127M    total [centos@mail-arts bin]$ .)Restart both master and standby ( ./pg_ctl -D master restart -l logsM -c) and (./pg_ctl -D standby restart -l logsS -c ) .)Check the pg_wal directory size of STANDBY [centos@mail-arts bin]$ du -sch standby/pg_wal/ 127M    standby/pg_wal/ 127M    total [centos@mail-arts bin]$ and if we see the pg_wal files ,it is growing rampant and not reusing. -- regards,tushar EnterpriseDB https://www.enterprisedb.com/ The Enterprise PostgreSQL Company --------------6DADFC08A420C5A8528F421A Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit
On 07/10/2019 05:12 PM, Amit Khandekar wrote:
All right. Will do that in the next patch set. For now, I have quickly
done the below changes in a single patch again (attached), in order to
get early comments if any.
Thanks Amit for your patch. i am able to see 1 issues  on Standby server - (where  logical replication slot created ) , 
a)size of  pg_wal folder  is NOT decreasing even after firing get_changes function
b)pg_wal files are not recycling  and every time it is creating new files after firing get_changes function

Here are the detailed steps -
create a directory with the name 'archive_dir' under /tmp (mkdir /tmp/archive_dir)
SR setup -
Master
.)Perform initdb  (./initdb -D master --wal-segsize=2)
.)Open postgresql.conf file and add these below parameters  at the end of  file
wal_level='logical'
min_wal_size=4MB
max_wal_size=4MB
hot_standby_feedback = on
archive_mode=on
archive_command='cp %p /tmp/archive_dir/%f'
.)Start the server ( /pg_ctl -D master/ start -l logsM -c )
.)Connect to psql , create physical  slot
    ->SELECT * FROM pg_create_physical_replication_slot('decoding_standby');
Standby -
.)Perform pg_basebackup ( ./pg_basebackup -D standby/ --slot=decoding_standby -R -v)
.)Open postgresql.conf file of standby and add these 2 parameters - at the end of file
  port=5555
primary_slot_name = 'decoding_standby'
.)Start the Standby server  ( ./pg_ctl -D standby/ start -l logsS -c )
.)Connect to psql terminal and create logical replication slot
  ->SELECT * from   pg_create_logical_replication_slot('standby', 'test_decoding');

MISC steps-
.)Connect to master and create table/insert rows ( create table t(n int); insert into t (values (1);)
.)Connect to standby and fire get_changes function ( select * from pg_logical_slot_get_changes('standby',null,null); )
.)Run pgbench ( ./pgbench -i -s 10 postgres)
.)Check the pg_wal directory size of  STANDBY
[centos@mail-arts bin]$ du -sch standby/pg_wal/
127M    standby/pg_wal/
127M    total
[centos@mail-arts bin]$
 
.)Connect to standby and fire get_changes function ( select * from pg_logical_slot_get_changes('standby',null,null); )
.)Check the pg_wal directory size of STANDBY
[centos@mail-arts bin]$ du -sch standby/pg_wal/
127M    standby/pg_wal/
127M    total
[centos@mail-arts bin]$


.)Restart both master and standby ( ./pg_ctl -D master restart -l logsM -c) and (./pg_ctl -D standby restart -l logsS -c )

.)Check the pg_wal directory size of STANDBY
[centos@mail-arts bin]$ du -sch standby/pg_wal/
127M    standby/pg_wal/
127M    total
[centos@mail-arts bin]$

and if we see the pg_wal files ,it is growing rampant and not reusing.
-- 
regards,tushar
EnterpriseDB  https://www.enterprisedb.com/
The Enterprise PostgreSQL Company
--------------6DADFC08A420C5A8528F421A--