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 1rsZxM-007xdO-Vt for pgsql-hackers@arkaria.postgresql.org; Fri, 05 Apr 2024 03:09:33 +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 1rsZxM-00Fyrn-7c for pgsql-hackers@arkaria.postgresql.org; Fri, 05 Apr 2024 03:09:32 +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 1rsZxL-00FyqS-Ub for pgsql-hackers@lists.postgresql.org; Fri, 05 Apr 2024 03:09:31 +0000 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rsZxI-000fei-36 for pgsql-hackers@lists.postgresql.org; Fri, 05 Apr 2024 03:09:30 +0000 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-415584360c0so13080685e9.1 for ; Thu, 04 Apr 2024 20:09:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712286566; x=1712891366; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=bhE7QDg5rUiCNZh1XSovPpw2jtQdzY4VeWiv+jzLjrY=; b=FABzhBsfs9mx+vn8qmeec0d3T/punFKNJlUKmlcNBnTL9sVyugVsiJADKI6N2UG7XR iZ32WG3U5sTJ8rXvKueiuLTEWEFjphj8dY53vCMfyNeGM9RNKC2Y084vXCKm6MJKXWHn ShxACWdsVEb3ZGmhCqFriU62YX029sHtrI2y4qW5XVkRWbzFZ/34tFjFSRWJrX7KZV2Q uYTSEYZFgqtFhCZC83reliSFoDQzm8iMBdeP4LtLNZrPp4OP1y+jKjDRUJu9oyT5eYQn KeDtlRHk6qXJ4XYoIwOrbVjNenFsrn1XCoWgLyFZAVobhqH888jZva71HgxO+q4GA5g4 zGKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712286566; x=1712891366; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bhE7QDg5rUiCNZh1XSovPpw2jtQdzY4VeWiv+jzLjrY=; b=HNRZGMb3Zz3iAK1q+SQRuXv0BhCq+ii7GvUZNAfQm264q81XD5x7ct4thmGn0lTbUm 6Y35eqe4KBJUHnXPfjs4Nn6/f69jNlGcRD5ggoWQWy19EHM1TAOM7siO82AqPRrRVs90 87jM5lAvr9ZqApegASI6r7LqBd8ZQfAhP2IKp5Puk5Q0iXBfr352YmDEvxY5dfvTMRKi gOtuNgSh2Vzlc9f1E7XQxhIlMp+Zf4F/Sstrn1sNB1udIBIJgrR1p/SEtYotMirTg0hn sLkQnOEHwSoI8SVCzSjAw09wOIJLDoye30SlRFB6QQGdsbHR6iEx6AN02koMKrz/UbjS Ehkg== X-Forwarded-Encrypted: i=1; AJvYcCX/Kbe3tI3Lez/CmZb7BTcla3j0CKc7j0qwwCaqIZN39EdYjVrSN9NdYkp/DfgwEYzvBISukpVdzFeajZDWLvXRBms/zkwMZp85+9b8sJ1cSfPE X-Gm-Message-State: AOJu0Yws8P5aJahnGANXFxtl4376po4udLSF0VJpM44yIyScx+6Hnrrj vsv8U120zrd6snchUUwLPT1HUG/zfcoxvyvOQxgjCUmMN5Qmik4mRF8LVb5EvoWoC9Ohw6sFu1M b6g+SqnHq/yx53H3c8esvBGmK8f4= X-Google-Smtp-Source: AGHT+IF29dWF2pdaa8XCDC5LvycO3Q0QzDQsbciZ66NDpg20KWQQTkS02/IT9PxtV6L+Q6WmrkKzkOeNFgFLErJUoUY= X-Received: by 2002:a05:600c:4706:b0:414:1363:53a4 with SMTP id v6-20020a05600c470600b00414136353a4mr157789wmo.15.1712286565424; Thu, 04 Apr 2024 20:09:25 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: shveta malik Date: Fri, 5 Apr 2024 08:39:13 +0530 Message-ID: Subject: Re: Introduce XID age and inactive timeout based replication slot invalidation To: Bharath Rupireddy Cc: Amit Kapila , Bertrand Drouvot , Masahiko Sawada , Nathan Bossart , PostgreSQL Hackers , shveta malik Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, Apr 4, 2024 at 5:53=E2=80=AFPM Bharath Rupireddy wrote: > > On Thu, Apr 4, 2024 at 4:35=E2=80=AFPM Amit Kapila wrote: > > > > > Thanks for the changes. v34-0001 LGTM. > > > > I was doing a final review before pushing 0001 and found that > > 'inactive_since' could be set twice during startup after promotion, > > once while restoring slots and then via ShutDownSlotSync(). The reason > > is that ShutDownSlotSync() will be invoked in normal startup on > > primary though it won't do anything apart from setting inactive_since > > if we have synced slots. I think you need to check 'StandbyMode' in > > update_synced_slots_inactive_since() and return if the same is not > > set. We can't use 'InRecovery' flag as that will be set even during > > crash recovery. > > > > Can you please test this once unless you don't agree with the above the= ory? > > Nice catch. I've verified that update_synced_slots_inactive_since is > called even for normal server startups/crash recovery. I've added a > check to exit if the StandbyMode isn't set. > > Please find the attached v35 patch. Thanks for the patch. Tested it , works well. Few cosmetic changes needed: in 040 test file: 1) # Capture the inactive_since of the slot from the primary. Note that the sl= ot # will be inactive since the corresponding subscription is disabled.. 2 .. at the end. Replace with one. 2) # Synced slot on the standby must get its own inactive_since. . not needed in single line comment (to be consistent with neighbouring comments) 3) update_synced_slots_inactive_since(): if (!StandbyMode) return; It will be good to add comments here. thanks Shveta