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 1rp5xV-00525z-Ha for pgsql-hackers@arkaria.postgresql.org; Tue, 26 Mar 2024 12:31:18 +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 1rp5xS-00EFnm-Kz for pgsql-hackers@arkaria.postgresql.org; Tue, 26 Mar 2024 12:31:14 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rp5xS-00EFne-9T for pgsql-hackers@lists.postgresql.org; Tue, 26 Mar 2024 12:31:14 +0000 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rp5xP-006a7P-1U for pgsql-hackers@lists.postgresql.org; Tue, 26 Mar 2024 12:31:13 +0000 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-33ed4dd8659so4013151f8f.0 for ; Tue, 26 Mar 2024 05:31:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711456270; x=1712061070; darn=lists.postgresql.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=YKos54hfo5P05+WRGUsetVBFVpMsUCYihb6LtlGxif8=; b=O/KCkQtyE3morYVm0+uWGCvtcnRKncPpmJv0aKuBi2uhleTbBfG4XlI5ll3LyEDVUo boN2SSrR+nAwBaZDh37PRhAXEtf/argyafMFRySl7rZr6jEtsZ/ck3zppb3LSUfKApKM HamlY69waLYMWb5du0Qh0HK1t7gCh0FUcHB9tqvAfv31Bq8BCEs7+s+nu6TubPepnCU+ KhiI5neEL2skyEOCG9hAQLCs4iJUtNg4+BFoS8YvbPcPIpdcJldIfdbGuw6KUdkjb9p5 5PVr4UAH5BS7bzFXcKg3VUAohuSgmEfkH7MIa2Y4cTRt/qQMnBtzBuX1lW4sHq0Ddf+x bttg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711456270; x=1712061070; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=YKos54hfo5P05+WRGUsetVBFVpMsUCYihb6LtlGxif8=; b=mrnkbqU2sUXg8U+HMpfcYMsSSSIURXhNRkQ2ZProbbh3jlSPv56QJV7duy+eg7keP8 LPlWf/e0OvHnJi4g+Zfn8Gb1CefhmTvYUONVghCMi11f6Uj+WksscJkhrqSfnitE3UvD uMMBg87DS1Jpi1MzaqWduan9gOs0fTKa7jsnA0obOXK2zRVHC3ShVE0VWU9nIm9O4M89 GNaD0KNvOZcYrEWESAU9cSqURhHVQzLsQf6zC3GwyUBRvsg/Up2iTb5lHEvyBJRKcBel jOUuo0w47u5B+e/yV6YOyYmrjnvqKyy2T2SwACh0lGFFj1KC/Q+MLo3EXB+wf5Ngs/gV dXJA== X-Forwarded-Encrypted: i=1; AJvYcCUu15rvCTwasscoYNtuhgaqZ1JpHG2trqBvg8lNMakHZIe13vScHLf5P1kRqm+i2WEULv+3UmRw2nfZIHJDNPkpoVHuoX0OVa0S7XjP0WZ590gq X-Gm-Message-State: AOJu0Yz2Oe7gkpIMEd/n99Si2492FD3Cw/9QmpW4tQ1lLRMxvQseusNp OCNsEr1Dx5Zeyn1kZ/PAZUMmlgRy9qwJz5iBBzHmias/dB5WyJLv X-Google-Smtp-Source: AGHT+IHqjcNVNyiQDL87vgi/n+iAvUUHqsMkEST9KT3CELEYtxH5of4aT0EI1DkcChOPnEANakq02g== X-Received: by 2002:adf:e587:0:b0:33e:c0f0:c159 with SMTP id l7-20020adfe587000000b0033ec0f0c159mr1192894wrm.10.1711456269725; Tue, 26 Mar 2024 05:31:09 -0700 (PDT) Received: from ip-10-97-1-34.eu-west-3.compute.internal (ec2-15-236-134-5.eu-west-3.compute.amazonaws.com. [15.236.134.5]) by smtp.gmail.com with ESMTPSA id df10-20020a5d5b8a000000b0033e756ed840sm12040235wrb.47.2024.03.26.05.31.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 05:31:09 -0700 (PDT) Date: Tue, 26 Mar 2024 12:31:08 +0000 From: Bertrand Drouvot To: shveta malik Cc: Bharath Rupireddy , Amit Kapila , Nathan Bossart , PostgreSQL Hackers Subject: Re: Introduce XID age and inactive timeout based replication slot invalidation 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 Tue, Mar 26, 2024 at 04:49:18PM +0530, shveta malik wrote: > On Tue, Mar 26, 2024 at 4:35 PM Bharath Rupireddy > wrote: > > > > On Tue, Mar 26, 2024 at 4:18 PM shveta malik wrote: > > > > > > > What about another approach?: inactive_since gives data synced from primary for > > > > synced slots and another dedicated field (could be added later...) could > > > > 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 = xmin_horizon; > > slot->data.catalog_xmin = xmin_horizon; > > + slot->inactive_since = 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? In case the primary goes down, then one could use the value on the standby to get the value coming from the primary. I think that could be useful info to have. Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com