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 1rp4qD-004wOo-Qz for pgsql-hackers@arkaria.postgresql.org; Tue, 26 Mar 2024 11:19:42 +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 1rp4qB-00Dk4w-Cn for pgsql-hackers@arkaria.postgresql.org; Tue, 26 Mar 2024 11:19:39 +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 1rp4qB-00Dk4k-0X for pgsql-hackers@lists.postgresql.org; Tue, 26 Mar 2024 11:19:39 +0000 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rp4q3-006WFs-MI for pgsql-hackers@lists.postgresql.org; Tue, 26 Mar 2024 11:19:38 +0000 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-4148c681e3bso6584005e9.0 for ; Tue, 26 Mar 2024 04:19:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711451970; x=1712056770; 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=59StxDDxsMZDGfdGIOJJJzhIsz3wEhFA5fEpiXuJLyQ=; b=iJduJv1Te3XdP7IzTHmC+ix40Xk3mWoFoAshyaVZioAvqPyrUzLDBPyGDop+CHLydw 37J/TCSRL2a3iLgEvhAvVkOxAg+d9mAnmCPls7o+ZFIbm8gz36Eu+VrrqmatjJjRdWlA kwEekJzlpjBGSQ/mhquVo9hxfiF3NKGwg1hZP+dNzdENzOiP7/j12W5ko2mI2j2Si0+K yHBsulhm115UDJOGk/SlMXLCouUGE1F2qrM1KZPY+nqppeOjpTRrYtHLFg6geVl8XVDQ noWJtBHQetXYipvzum5gvEl77xxXbRsOfl+b+a59SyGwJRk8WLB0Bt4eftEIGt/81tSJ xxLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711451970; x=1712056770; 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=59StxDDxsMZDGfdGIOJJJzhIsz3wEhFA5fEpiXuJLyQ=; b=mSiA3hIahaaNHj1uDOykhI5bAZaOSEH8gJeJ9GI+r1wQJoYmmopY+LM5SRbkbd9G/L sCubHd8TPL1dmOl54RMzuZwt8tME6z9tqvMkIQURnP4/ZB+5b6zp/jRA8AbK42pSEBGX cgG3wpiKjqCOxxTzYpZiGIHIOErjfy2RDZyIXVZQvSUiQ/7gCITCemPqJTNvlF/7K6mu 8ecQIzYI8tcsD6MOpi3vBjV3zWY+NaZcq1qTB6EFH0Kdacd2MpMbsInsLGp9t6JDE/5b zj2BJKjcckVwBmACYUPP7QIFOM9/u3NT0eVzVK4NKhqOPVxvDCK/KPldPoT1xbIq/t5F qXeg== X-Forwarded-Encrypted: i=1; AJvYcCUU4AJ8/fjQfV/Ka2d+gvGKAmdKqVbHNlBIpKW+I0+JP7efCbwR1iUNXsAsWdSbP58JObWxHrrj5YolZRE8NRRqbDVFBkx40HSkVg3HXQsvg30+ X-Gm-Message-State: AOJu0Yw7YzdoYZ+bre4ODCN43irqkVqhyhl2vy45xQiBa3T5eGU4+ou3 4/iaGmfeuyhBcBzddOgrccHShueCsbEDoPDs18LElb6Nv9gL4tYMYeVHHUuj9s/Cj8XgpC1zItb n26Y1qb9AF4ZI1FkOeMa9c5SrwZI= X-Google-Smtp-Source: AGHT+IGUfpPZ/myRBDX9UY0H7oX53ovcwcWsfrHVJJSZkjjGMDLf5rM8OMZAg/XkL0a0JlpEOcPnHY0GiVEMK/QBh+I= X-Received: by 2002:a05:600c:1396:b0:414:12ef:83a9 with SMTP id u22-20020a05600c139600b0041412ef83a9mr975090wmf.20.1711451970328; Tue, 26 Mar 2024 04:19:30 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: shveta malik Date: Tue, 26 Mar 2024 16:49:18 +0530 Message-ID: Subject: Re: Introduce XID age and inactive timeout based replication slot invalidation To: Bharath Rupireddy Cc: Bertrand Drouvot , Amit Kapila , 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 Tue, Mar 26, 2024 at 4:35=E2=80=AFPM Bharath Rupireddy wrote: > > On Tue, Mar 26, 2024 at 4:18=E2=80=AFPM shveta malik wrote: > > > > > What about another approach?: inactive_since gives data synced from p= rimary for > > > synced slots and another dedicated field (could be added later...) co= uld > > > represent what you suggest as the other option. > > > > Yes, okay with me. I think there is some confusion here as well. In my > > second approach above, I have not suggested anything related to > > sync-worker. We can think on that later if we really need another > > field which give us sync time. In my second approach, I have tried to > > avoid updating inactive_since for synced slots during sync process. We > > update that field during creation of synced slot so that > > inactive_since reflects correct info even for synced slots (rather > > than copying from primary). Please have a look at my patch and let me > > know your thoughts. I am fine with copying it from primary as well and > > documenting this behaviour. > > I took a look at your patch. > > --- a/src/backend/replication/logical/slotsync.c > +++ b/src/backend/replication/logical/slotsync.c > @@ -628,6 +628,7 @@ synchronize_one_slot(RemoteSlot *remote_slot, Oid > remote_dbid) > SpinLockAcquire(&slot->mutex); > slot->effective_catalog_xmin =3D xmin_horizon; > slot->data.catalog_xmin =3D xmin_horizon; > + slot->inactive_since =3D GetCurrentTimestamp(); > SpinLockRelease(&slot->mutex); > > If we just sync inactive_since value for synced slots while in > recovery from the primary, so be it. Why do we need to update it to > the current time when the slot is being created? If we update inactive_since at synced slot's creation or during restart (skipping setting it during sync), then this time reflects actual 'inactive_since' for that particular synced slot. Isn't that a clear info for the user and in alignment of what the name 'inactive_since' actually suggests? > We don't expose slot > creation time, no? No, we don't. But for synced slot, that is the time since that slot is inactive (unless promoted), so we are exposing inactive_since and not creation time. >Aren't we fine if we just sync the value from > primary and document that fact? After the promotion, we can reset it > to the current time so that it gets its own time. Do you see any > issues with it? Yes, we can do that. But curious to know, do we see any additional benefit of reflecting primary's inactive_since at standby which I might be missing? thanks Shveta