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 1xBTDq-00000003DSI-2P0f for pgsql-hackers@arkaria.postgresql.org; Tue, 29 Sep 2026 08:29:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xBTDo-0000000Dla5-2lzq for pgsql-hackers@arkaria.postgresql.org; Tue, 29 Sep 2026 08:29:56 +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.98.2) (envelope-from ) id 1xBTDo-0000000DlZx-0uBf for pgsql-hackers@lists.postgresql.org; Tue, 29 Sep 2026 08:29:56 +0000 Received: from mail-wm2-x10.google.com ([2a00:1450:4864:31::10]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1xBTDm-00000001pxe-1eNz for pgsql-hackers@lists.postgresql.org; Tue, 29 Sep 2026 08:29:55 +0000 Received: by mail-wm2-x10.google.com with SMTP id 5b1f17b1804b1-49ff9621c5dso20002405e9.0 for ; Tue, 29 Sep 2026 01:29:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790670592; x=1791275392; darn=lists.postgresql.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=xXTqabuoE7ohIaEgfCvU+GVS23Sh/1hrSDPxLacin3M=; b=grxwBuPy1ecuiPxfy4fs2vClk1sAPdSJQmqGpKlMcxzRgVtLOZaMJiVJEG9ye7PUBP VVKuXHQ/pHEIS05kaFVrILwKc8LkK33tP4XV9nSIQx9BXt3pC/6DOaNMk8Kvg8gcIfB5 PZvh/9yeOnURhHcZvQqTRA3a5NQ19bXwzaepJCpUOa13hIQWZlpKZ1KQg+tdWke+Kpov 4dKetLrH1YJnUIN0CWDOjO/a/JQvx5N84dt4GqaQhU3mvNtP0GjvOOiAvqteDvD6iXF/ 6dlD2fgV8U1ZaQKVouw8gIVX1cEfZVWuYUEnsqWXTc8MYHLE+v+EhgizUc72ZjSygGMf zN5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790670592; x=1791275392; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=xXTqabuoE7ohIaEgfCvU+GVS23Sh/1hrSDPxLacin3M=; b=KetgWnGg5+LqKWoT9Rg9PKj93bs1jsWxLxuTUT8zjht3h5qXarSWkXPOGL4E9stuXi 3DXHSFhPGmAeltxq8dWNF0GkaXL2Gk9et5xZIX+Et16GF7VkmZsmZZxZZKy4UNiMPbDh XsSdxIvgBouKJBJLaFczgh6Kc9EkahMGwR0rMGaGmuJI/5C8NogJzFA40sgPmEW1TPYu ErkPSfIhUZoQRCyOQ8o97pppovH35wvaxVUsikD3qUGHtCm7sr06J15UjEnKnZIw+JJm fZaNCZyEVQxrqmEm3aRrhpTIELPF9t93aGg6ii0eiul1TgBkFFiNURZMz6Tu+b/H8gvx E8+A== X-Forwarded-Encrypted: i=1; AKwUvBxe4UAJ8/1JOolK+YutPhUC2ETHp+lZQtEoQ0SJMhgloARFT7SuYh3nCDr1kqxWtiBLeUeoQFNA3cmvGzQk@lists.postgresql.org X-Gm-Message-State: AFuF++mgwd03THV28vsZjMEV9lVjuNoT5/3HVgv4pclVAqSbl2mu40P2 yAIB41jNgkCyFo33/u2/zCAfck3IQea/ajx1VpZC6Zv9pj3jzgCWiLOI X-Gm-Gg: AYBFou2asBgXPacqiKxuahtPnAkiOE5uhepFT3VpHcvtFLhc1jNyvUhOH2QPCVzRviA fzwIkNAT1HQaonJZ/WyEGkvttn+vgDAdHW/k1kOMpJweoNr50MS02Y718aMoQYdTzUbWZfa4Wv9 6oT31gNk5WQbgk7qrqmjO8hyqce4fA50xKmgx6TDqBSAq+/CUjPgFYvtpcMtVVV5d0KTj422X+I 3PmZF97dDSIDU61AVhX8xVXmL9GTcfjPBBdctn5c/5oPznnRPW8W091nCVxfaW/jcK6jmFnv/Bx Qakil26SQ48j5YlyvXRkVr54CrFpUMje6uD0ccspDjiNdqAS2MoS70htnBjSQcUPp/wRPRAuR2B tLbq4TM/jimaijW++hiH+BTzNB+jZycKCbfMuSKOamI9nCeHWUo2M7YWPM6xP1CCKyUgWADHuAx ZCXOww0ZDMu4RIzoKZj1iM/vCdVjZLHTEnX/bmq5kJhUDT2L4Y34og2Z7dv/Jg4FM5j/jxt5+0r fqsQUvmqdsU0OFcvKmizRX/E29CyZxb45LTWEjaBahyiwna3wKUOslgTQ== X-Received: by 2002:a05:600c:540e:b0:49f:cbf1:e77b with SMTP id 5b1f17b1804b1-49fe66ca828mr289088395e9.10.1790670591385; Tue, 29 Sep 2026 01:29:51 -0700 (PDT) Received: from bdtpg (ec2-15-237-197-144.eu-west-3.compute.amazonaws.com. [15.237.197.144]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a00cfafa23sm56717525e9.14.2026.09.29.01.29.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Sep 2026 01:29:51 -0700 (PDT) Date: Tue, 29 Sep 2026 08:29:49 +0000 From: Bertrand Drouvot To: shveta malik Cc: JoongHyuk Shin , Amit Kapila , Rui Zhao , pgsql-hackers@lists.postgresql.org Subject: Re: Persist slot invalidations before publishing them Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On Tue, Sep 29, 2026 at 11:07:34AM +0530, shveta malik wrote: > > > Bertrand, I will come to this Assert soon. First I would like to > think/discuss if we can get rid of passing the 'update_inactive_since' > boolean altogether. Currently, we need it mainly for two reasons: > > a) ReplicationSlotRelease() does not know when it should update > inactive_since and when it should skip it. > b) The slot-skip and other invalidation flows currently behave differently. > > We could eliminate the second difference by making the logic same for > both the flows. I don't think there is any harm in skipping the > 'inactive_since' update for the slot-sync's > slot-invalidation-persist's error case as well. We never use > 'inactive_since' to invalidate idle synced slots (see > CanInvalidateIdleSlot()). And 'inactive_since' only matters for > synced slots after standby promotion, when it is reset for all synced > slots by update_synced_slots_inactive_since() from ShutDownSlotSync() > (promotion's flow). So I don't think we need to maintain separate > logic for this rare error case. If really needed in the future, we > could still preserve the current behavior IsSyncingReplicationSlots() > check in ReplicationSlotRelease(), but I don't think it is worth the > extra complexity. Yeah, that makes sense. This is a rare error path, so I agree that it is not worth the extra complexity. > That leaves us with just handling the failed-invalidation case where > ReplicationSlotRelease() need to avoid update of inactive_since. How > about using a static flag for this? We can set it in the CATCH block > of ReplicationSlotPersistInvalidation() before calling > ReplicationSlotRelease(). > > With this approach, both flows can use ReplicationSlotRelease() in the > same way and we don't need to split the logic into > ReplicationSlotReleaseInternal() either. I have attached a sample > patch. Please let me know your thoughts. The static flag looks safe, but I wonder if it wouldn't be clearer to keep ReplicationSlotReleaseInternal() and call it with false from the error path? That would still allow us to remove update_inactive_since from ReplicationSlotPersistInvalidation() and its callers, while keeping the exceptional release behavior explicit. Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com