Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s1PZw-00C7W8-GE for pgsql-hackers@arkaria.postgresql.org; Mon, 29 Apr 2024 11:53:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1s1PZs-00GYQn-7s for pgsql-hackers@arkaria.postgresql.org; Mon, 29 Apr 2024 11:53:49 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s1PZq-00GYQb-Iz for pgsql-hackers@lists.postgresql.org; Mon, 29 Apr 2024 11:53:48 +0000 Received: from fout3-smtp.messagingengine.com ([103.168.172.146]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s1PZn-000bFq-Oo for pgsql-hackers@lists.postgresql.org; Mon, 29 Apr 2024 11:53:46 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailfout.nyi.internal (Postfix) with ESMTP id 1432413819FB; Mon, 29 Apr 2024 07:53:42 -0400 (EDT) Received: from imap49 ([10.202.2.99]) by compute2.internal (MEProxy); Mon, 29 Apr 2024 07:53:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eulerto.com; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm1; t=1714391622; x=1714478022; bh=cwb9mI6DHT t6EDDrqRS/etV8TK/aS6fzvNOTSupWV9o=; b=Jel4mWawyf0s5fq6wQQlNVnqh6 o81EB1gJwFLTP42XxFVGCOEj7zpT9FzB04ljPdIN5KlpvdKe8W7uDaeekwgySxMp 3Gi2Fn8qskK9x+WtMudy0cxmWWAlenY2+N8p7uiPQ8GQ7Jhs3JRvcWD4wADtqGji Js5eu8nqwEL+XiOGO7zcA6FLSkIrP3K8pys9qvbZwFX6d9DWGsQuUVOvvCLRUKNa gPi2TSn5boTYRUYRjlFif3un2MAzg8KnqF0X/Vs6OamoXbHGreYGdfAlVREDyy09 Zx4q7SfHS1zYYYIQakEqaPa8on4fei2WyZkLlXBZKsBOYrciVtoxErIQ5KZA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1714391622; x=1714478022; bh=cwb9mI6DHTt6EDDrqRS/etV8TK/a S6fzvNOTSupWV9o=; b=TkZi2KQwa7JN97/fxrsChkB1ySn6KeacoNoyrbI3CnrS csGUTb+BiIQGA4IsIC1fbslgmSlcKai8exE1AVt5IrGMMlL1GGmK6Vqog37DEbcC VTjIVmq+5/MnY6hKpKmq5SasiTWXLdWgyf2t39KuwlbtnTU1so8xmtxNtAjKFUfj TVwOqkJXTRtf/BkfjKTTTkBA2ovuvjxzN663Jz6uoUo5vFkD2XaPsbs/fncSxeeD S1qAEfLGWcXF1Tw59mGvXlonHOPoj5o293gULFiS8/j7fOYrzmJ9Pyypo15h7eaX an045OWOOw+/yuNVtKXzq8gyCq7geVEEyTMI6F/ZYw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdduuddggeegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvfevufgtsegrtderreerreejnecuhfhrohhmpedfgfhu lhgvrhcuvfgrvhgvihhrrgdfuceovghulhgvrhesvghulhgvrhhtohdrtghomheqnecugg ftrfgrthhtvghrnhepgeeugeelheefheegvefggffhgffgteeuudevvdekhedvvdekgfeh keeitedvgedvnecuffhomhgrihhnpegvnhhtvghrphhrihhsvggusgdrtghomhenucevlh hushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegvuhhlvghrsegv uhhlvghrthhordgtohhm X-ME-Proxy: Feedback-ID: i0c21471d:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 79D7015A0092; Mon, 29 Apr 2024 07:53:40 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.11.0-alpha0-386-g4cb8e397f9-fm-20240415.001-g4cb8e397 MIME-Version: 1.0 Message-Id: <2e86cf53-c806-49d2-9a10-1a1257776d1f@app.fastmail.com> In-Reply-To: References: <9a9c7e65-c47b-4400-a63e-ac6169c0860e@app.fastmail.com> <2f0b73f3-e7c0-4e95-9712-1993442a6b64@app.fastmail.com> <34637e7f-0330-420d-8f45-1d022962d2fe@app.fastmail.com> <7a970912-0b77-4942-84f7-2c9ca0bc05a5@eisentraut.org> <44de4e04-db22-40ed-8ba9-46387dc8bf83@app.fastmail.com> <3fa9ef0f-b277-4c13-850a-8ccc04de1406@eisentraut.org> <65b841a8-0c2f-4953-b9cd-240fce84b90b@eisentraut.org> <47524383-6fd1-4b13-8c4e-fb918b1d35ba@enterprisedb.com> Date: Mon, 29 Apr 2024 08:53:19 -0300 From: "Euler Taveira" To: "Amit Kapila" Cc: "Tomas Vondra" , "kuroda.hayato@fujitsu.com" , "Peter Eisentraut" , "Bharath Rupireddy" , "Shlok Kyal" , "pgsql-hackers@lists.postgresql.org" , "Michael Paquier" , "Andres Freund" , "Ashutosh Bapat" , =?UTF-8?Q?Fabr=C3=ADzio_de_Royes_Mello?= , "vignesh C" Subject: Re: speed up a logical replica setup Content-Type: multipart/alternative; boundary=a5b8760bebfa46ef8dce28cc7a0f5d3f List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --a5b8760bebfa46ef8dce28cc7a0f5d3f Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable On Mon, Apr 29, 2024, at 6:56 AM, Amit Kapila wrote: > On Wed, Mar 27, 2024 at 1:47=E2=80=AFAM Euler Taveira wrote: > > > > On Tue, Mar 26, 2024, at 4:12 PM, Tomas Vondra wrote: > > > > Perhaps I'm missing something, but why is NUM_CONN_ATTEMPTS even nee= ded? > > Why isn't recovery_timeout enough to decide if wait_for_end_recovery= () > > waited long enough? > > > > > > It was an attempt to decoupled a connection failure (that keeps stre= aming the > > WAL) from recovery timeout. The NUM_CONN_ATTEMPTS guarantees that if= the primary > > is gone during the standby recovery process, there is a way to bail = out. > > >=20 > I think we don't need to check primary if the WAL corresponding to > consistent_lsn is already present on the standby. Shouldn't we first > check that? Once we ensure that the required WAL is copied, just > checking server_is_in_recovery() should be sufficient. I feel that > will be a direct way of ensuring what is required rather than > indirectly verifying the same (by checking pg_stat_wal_receiver) as we > are doing currently. How would you check it? WAL file? During recovery, you are not allowed t= o use pg_current_wal_lsn. Tomas suggested to me off-list that we should adopt a simple solution in wait_for_end_recovery: wait for recovery_timeout without additional chec= ks (which means remove the pg_stat_wal_receiver logic). When we have addit= ional information that we can reliably use in this function, we can add it. He= nce, it is also easy to adjust the PG_TEST_TIMEOUT_DEFAULT to have stable tests. -- Euler Taveira EDB https://www.enterprisedb.com/ --a5b8760bebfa46ef8dce28cc7a0f5d3f Content-Type: text/html;charset=utf-8 Content-Transfer-Encoding: quoted-printable
On Mon, Apr 29,= 2024, at 6:56 AM, Amit Kapila wrote:
On Wed, Mar 27, 2024 at 1:47=E2=80=AFAM Euler= Taveira <euler@eulerto.com&= gt; wrote:
>
> On Tue, Mar 26, 2024, a= t 4:12 PM, Tomas Vondra wrote:
>
> Per= haps I'm missing something, but why is NUM_CONN_ATTEMPTS even needed?
> Why isn't recovery_timeout enough to decide if wait_for= _end_recovery()
> waited long enough?
>= ;
>
> It was an attempt to decoupled a= connection failure (that keeps streaming the
> WAL) fr= om recovery timeout. The NUM_CONN_ATTEMPTS guarantees that if the primar= y
> is gone during the standby recovery process, there = is a way to bail out.
>

I = think we don't need to check primary if the WAL corresponding to
consistent_lsn is already present on the standby. Shouldn't we fi= rst
check that? Once we ensure that the required WAL is co= pied, just
checking server_is_in_recovery() should be suff= icient. I feel that
will be a direct way of ensuring what = is required rather than
indirectly verifying the same (by = checking pg_stat_wal_receiver) as we
are doing currently.<= br>

How would you check it? WAL fi= le? During recovery, you are not allowed to use
pg_current= _wal_lsn.

Tomas suggested to me off-list th= at we should adopt a simple solution in
wait_for_end_recov= ery: wait for recovery_timeout without additional checks
(= which means remove the pg_stat_wal_receiver logic).  When we have a= dditional
information that we can reliably use in this fun= ction, we can add it. Hence, it
is also easy to adjust the= PG_TEST_TIMEOUT_DEFAULT to have stable tests.

<= div>
--
Euler Taveira

--a5b8760bebfa46ef8dce28cc7a0f5d3f--