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.98.2) (envelope-from ) id 1xVqEF-00000000JHf-3UaU for pgsql-bugs@arkaria.postgresql.org; Tue, 24 Nov 2026 13:06:36 +0000 Received: from localhost ([127.0.0.1]:39510 helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xVqEF-0000000EawV-1Pce for pgsql-bugs@arkaria.postgresql.org; Tue, 24 Nov 2026 13:06:35 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]:39542) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xVqEF-0000000EawB-0MKi for pgsql-bugs@lists.postgresql.org; Tue, 24 Nov 2026 13:06:35 +0000 Received: from mail.zonezero.se ([46.246.30.157]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xVqED-00000000D3c-2CTL for pgsql-bugs@lists.postgresql.org; Tue, 24 Nov 2026 13:06:35 +0000 Received: from mail.zonezero.se (unknown [10.100.2.1]) by mail.zonezero.se (Postfix) with ESMTPS id C8CFA741; Tue, 24 Nov 2026 14:06:32 +0100 (CET) Received: from webmail.zonezero.se (localhost.localdomain [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.zonezero.se (Postfix) with ESMTPSA id 1B98A1200F9; Tue, 24 Nov 2026 14:06:32 +0100 (CET) Authentication-Results: ORIGINATING; auth=pass smtp.auth=admin@zonezero.se smtp.mailfrom=jesper@stjohn.se MIME-Version: 1.0 Date: Tue, 24 Nov 2026 14:06:31 +0100 From: Jesper St John To: Zsolt Parragi Cc: pgsql-bugs@lists.postgresql.org, Jesper St John , Andrey Borodin , Magnus Hagander , Kirill Reshke Subject: Re: Timing issue in pg_basebackup In-Reply-To: References: <4417791388e8f1df20f64013e944be8e@stjohn.se> <80143a07e6732576c9f815a3058fa31d@stjohn.se> <4E8EC951-B75E-4CB8-97B6-D5C21F88A991@yandex-team.ru> <4F71E8F4-32D9-4B37-9DA9-203564F00692@zonezero.se> <4fdcbef083932d15d6d03c4fd9076e42@stjohn.se> Message-ID: X-Sender: jesper@stjohn.se Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2026-11-23 23:16, Zsolt Parragi wrote: > On Mon, 23 Nov 2026, Jesper St John wrote: >> But it seems that in master today, a previously created slot which >> would >> be specified by --slot and not --create-slot could also be invalidated >> if a tiny idle_replication_slot_timeout is set. > > It seems like a new behavior to me with --create-slot (I agree that it > is preexisting with --slot). Ok, fair. I think the idle_replication_slot_timeout needs some more documentation though. > > Also, --create-slot leaves the slot behind in this case, which is also > new. And this happens in two more cases: when the connection is lost > and when the process is killed with SIGINT/SIGTERM during the > checkpoint. > Yes. > The new hint can also be misleading in some cases: > > PGOPTIONS='-c idle_session_timeout=2s' pg_basebackup -X stream > --checkpoint=spread (no slot invalidated in the server log) > pg_basebackup: warning: replication slot "pg_basebackup_664448" was > invalidated during the base backup checkpoint, recreating it > pg_basebackup: hint: You might need to increase > "max_slot_wal_keep_size". > > I am not sure if this is bad or not, because that is probably the more > common case of why is this happening, and the hint says 'might', so it > might be okay. It can be rephrased. What if we create a temp slot before running base backup and then drop it and create a new slot if needed as it is done today? That way it shouldn't be hit by idle_replication_slot_timeout and any sigint/sigterm would not leave the slot behind. The patch might be smaller... The idle_session_timeout of something smaller than the time it takes to do checkpoint=spread would probably recreate the timing issue with temp slot- so perhaps that could be overriden? Any thoughts before I start exploring? //Jesper