Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jj4zC-0001dt-8D for pgsql-hackers@arkaria.postgresql.org; Wed, 10 Jun 2020 17:58:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jj4yf-00075q-Jx for pgsql-hackers@arkaria.postgresql.org; Wed, 10 Jun 2020 17:57:29 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jj4yf-0006xn-5f for pgsql-hackers@lists.postgresql.org; Wed, 10 Jun 2020 17:57:29 +0000 Received: from mail.postgrespro.ru ([93.174.131.139]) by magus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jj4yV-000189-LF for pgsql-hackers@postgresql.org; Wed, 10 Jun 2020 17:57:27 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id D746121C6CFF; Wed, 10 Jun 2020 20:57:17 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at postgrespro.ru X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=x tagged_above=-99 required=4 WHITELISTED tests=[] autolearn=unavailable Received: from mail.postgrespro.ru (unknown [93.174.131.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail.postgrespro.ru (Postfix) with ESMTPSA id A405521C6CFE; Wed, 10 Jun 2020 20:57:17 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1591811837; bh=dR4pMa3RBGUq+TheUbh/30UcrUdd20EpK4oktJH69H4=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=G8TXpMyPYfDHl4l7TS1wYWsq+qvJE6TTGiwrs0BFClgSjpdQgA4vca5vxShppt1zc pyCNejcetIWVD/JGY8sWUNK3h98AlflU+9Jgk8r9vs46oBwuU/ttgeklYNBo7QwpBU bhHd7dszbTRogzYid1MzwAWU3YUyFUjOHfKXcfqg= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 10 Jun 2020 20:57:17 +0300 From: Alexey Kondratov To: Kyotaro Horiguchi Cc: michael@paquier.xyz, andres@anarazel.de, dim@tapoueh.org, pgsql-hackers@postgresql.org, simon@2ndquadrant.com Subject: Re: Physical replication slot advance is not persistent In-Reply-To: <20200610.173844.78906193765823414.horikyota.ntt@gmail.com> References: <20200609171904.kpltxxvjzislidks@alap3.anarazel.de> <82163ef4a380c5255e5004659d02559e@postgrespro.ru> <20200610065353.GA358163@paquier.xyz> <20200610.173844.78906193765823414.horikyota.ntt@gmail.com> User-Agent: Roundcube Webmail/1.4.0 Message-ID: <876a782d320a52b0c54d6d48372de17d@postgrespro.ru> X-Sender: a.kondratov@postgrespro.ru List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2020-06-10 11:38, Kyotaro Horiguchi wrote: > At Wed, 10 Jun 2020 15:53:53 +0900, Michael Paquier > wrote in >> > > I find it really depressing how much obviously untested stuff gets >> > > added in this area. >> > >> > Prior to this patch pg_replication_slot_advance was not being tested >> > at all. >> > Unfortunately, added tests appeared to be not enough to cover all >> > cases. It >> > seems that the whole machinery of WAL holding and trimming is worth >> > to be >> > tested more thoroughly. >> >> I think that it would be interesting if we had a SQL representation of >> the contents of XLogCtlData (wanted that a couple of times). Now we >> are actually limited to use a checkpoint and check that past segments >> are getting recycled by looking at the contents of pg_wal. Doing that >> here does not cause the existing tests to be much more expensive as we >> only need one extra call to pg_switch_wal(), mostly. Please see the >> attached. > > The test in the patch looks fine to me and worked well for me. > > Using smaller wal_segment_size (1(MB) worked for me) reduces the cost > of the check, but I'm not sure it's worth doing. > New test reproduces this issue well. Left it running for a couple of hours in repeat and it seems to be stable. Just noted that we do not need to keep $phys_restart_lsn_pre: my $phys_restart_lsn_pre = $node_master->safe_psql('postgres', "SELECT restart_lsn from pg_replication_slots WHERE slot_name = '$phys_slot';" ); chomp($phys_restart_lsn_pre); we can safely use $current_lsn used for pg_replication_slot_advance(), since reatart_lsn is set as is there. It may make the test a bit simpler as well. -- Alexey Kondratov Postgres Professional https://www.postgrespro.com Russian Postgres Company