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 1xDFGY-00000000Or2-3BXz for pgsql-hackers@arkaria.postgresql.org; Sun, 04 Oct 2026 06:00:06 +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 1xDFGX-000000048Nt-1TZU for pgsql-hackers@arkaria.postgresql.org; Sun, 04 Oct 2026 06:00:05 +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 1xDFGX-000000048Nj-0Fkg for pgsql-hackers@lists.postgresql.org; Sun, 04 Oct 2026 06:00:05 +0000 Received: from mail-wr2-x0f.google.com ([2a00:1450:4864:30::f]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1xDFGU-00000000GhD-3YsP for pgsql-hackers@lists.postgresql.org; Sun, 04 Oct 2026 06:00:03 +0000 Received: by mail-wr2-x0f.google.com with SMTP id ffacd0b85a97d-48b059eae96so627900f8f.0 for ; Sat, 03 Oct 2026 23:00:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1791093601; x=1791698401; darn=lists.postgresql.org; h=in-reply-to:content-transfer-encoding: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=BqCi+bfPt1eh3zgHJiDt4irytYXg9+YoPQYGFHBE1AM=; b=nssdXK81LQfm7/2s4UXNKv45hyYdbDTt3wWvip9aByCQ9WenX90ZfrcZeG2PlAbMNU ANEJ9/IOpLr9CRTywntKjSUrXoK3riKAzPWNXZaw9uqffjwtZS4L0nnSdO3JFkvY9X9t y3nIuKyxa9pcvX7KJjxBFboZC9kwNHThlBMVGKuBljRvPSb8FeccXAJKw1kGAr2DnxWd jVNtjvNtRL6SM/75g+H6JmUFbYT1PgKL6SOaaGj3MPRirppeB+BIHw9PXjcX7Ofk2gis wHWxvSr9PPEy+yxnsKN1x5rTtE4zGup9xtwbo6rvEmKwbmo1e8brybwFzzE1VAKJvufr sSbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791093601; x=1791698401; h=in-reply-to:content-transfer-encoding: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=BqCi+bfPt1eh3zgHJiDt4irytYXg9+YoPQYGFHBE1AM=; b=ToxnbIHgUjUsm59oZgpenLpn1pS75rqAAmnGMiw5J49LAsM93i1XH1uPBd8SKLvqb4 jUzsE0XG2MzvIvmu6iWGDMNY+nzsNyAo6U0jf5jsjWJtjOMZDpoFP3iPFuMFw+s5tIa8 i9Nkvf6Qd05/HOI6GHAfl7ZazPQwlh0jRAkOHovB8Cl7NrxsNrHr3LTuNrIP9vPoLUnR lZF+p7H8oGp5F/DpIPvQV6X35AkgnTkH4w/sVvt778S4e7A9xc1vjeuBZsCuW3Oy4e70 WCIUqq8/t8csJedPRA7RNChnUzDS1OSpjNDv9Ae4C26OmCfPDfVrj3LqoabUcXauC38M 2E/w== X-Forwarded-Encrypted: i=1; AKwUvBx4smriNXQ3EdgGZ5HDH7OzQGdCCfghVRgz/I1N0OY9cpm1Jsck1tSoRRHsL2MHdCHCXRCgPo+7ydqpo2iT@lists.postgresql.org X-Gm-Message-State: AFq9FYLnjYf1KwZbm/LrpxsmH8szRQknQtn/bJymCJhzFB8cZ82VImu7 x1HqDF/soATz0c31XhE1JyS3DuCAq5JONn3/gwUGiO2h4fkKCk9OFoCq X-Gm-Gg: AYBFou2pUNVn69iAI869pUPl/RmOjb5kFT72xI1NgleZxhDFBMwNsWMGpBZYubAos5s gxFkC9VwNT55/xVlUU9pcZf0QVMvLi/Zh0sCEzZwvcpAdsDTGvktC+iwYB9m6ANYTJ+47Fg27Tj ex6ZtSloNL/MxSHBvCva4RfHaB373T0PHQFudlUrlO7Lxa7CgR2bYF4o+jqFIz/3wf6nnpy0EHm npA8BtK8SHQ/d5/BBuo8EZiIlQ/kpt+3HKOcV71BJur6wx9hskCNGS8lqInuSUTtQflvOpPvdKt 8SlSfrTXpcLXRHHY0XiFheaRLVOGTQCLp2JYXn0kml8kbsE/RB5WD4eBQkNnIRNSHl3TTUMn7bt f4AK8T4vLEwXEKDszefL++8RTgJlMRrhd3KTCq06zqAxuKdzn4pDSiaPbe7cgDCz90ceuhvuDgc 8d93J8bwnq8SL9vNSotsCCmlYUZj2wXZqRqmtRHWzAi8nQb9WqXb7JcpaYi8p45+1dGBUSKSGuZ /BJ91Ax0bvjpaz7b+YRT+hvld1fwbbX61YjFUcjK5brGOPkNOmexi0OGg== X-Received: by 2002:a05:6000:2613:b0:48b:2a2:31dc with SMTP id ffacd0b85a97d-48b127447d3mr12956566f8f.49.1791093601186; Sat, 03 Oct 2026 23:00:01 -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 ffacd0b85a97d-48b382f98ffsm16836171f8f.38.2026.10.03.23.00.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Oct 2026 23:00:00 -0700 (PDT) Date: Sun, 4 Oct 2026 05:59:59 +0000 From: Bertrand Drouvot To: Ashutosh Sharma Cc: shveta malik , 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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On Wed, Sep 30, 2026 at 03:50:30PM +0530, Ashutosh Sharma wrote: > Hi, > > On Mon, Sep 28, 2026 at 9:16 PM Bertrand Drouvot > wrote: > > > > The patch needed a rebase, so at the same time I went ahead with the proposed > > changes above (plus the one in the commit message suggested by Rui in [1]). > > > > Thanks for reporting the problem and providing a patch for it. The > approach looks good to me, but I have a few comments to share: Thanks for looking at it! > > I think it would be good to add a comment above > InvalidatePossiblyObsoleteSlot() explaining the reason for this change > in the usual slot update pattern. What about something like? " Unlike normal replication slot updates, persist the invalidation before publishing it in shared memory. Publishing it first could allow resource horizon computations to remove resources required by the slot before the invalidation reaches disk. If saving then failed, a restart could restore the old valid slot. Keeping the shared slot valid until the invalidated image is durable avoids that state. " > > 2) > > + { > + SaveSlotToPath(slot, path, ERROR, cause, clear_restart_lsn); > + } > > Do we need to pass clear_restart_lsn here? Cause can be used to > determine the restart lsn value later, no? I don't think so. InvalidatePossiblyObsoleteSlot() clears restart_lsn for RS_INVAL_WAL_REMOVED, while slotsync must preserve the local restart_lsn when copying the same invalidation cause. So the cause alone is not enough to determine the desired behavior. > 3) > > The current patch changes the interface for SaveSlotToPath() (), isn't > it possible to keep it unchanged, that would probably also reduce some > amount of complexity. Yeah, that seems worthwhile. I'll change it that way. Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com