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 1rp4ca-004vBo-NX for pgsql-hackers@arkaria.postgresql.org; Tue, 26 Mar 2024 11:05:37 +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 1rp4cZ-00Df3g-6g for pgsql-hackers@arkaria.postgresql.org; Tue, 26 Mar 2024 11:05:35 +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 1rp4cY-00Df3Y-Tg for pgsql-hackers@lists.postgresql.org; Tue, 26 Mar 2024 11:05:35 +0000 Received: from mail-lf1-x131.google.com ([2a00:1450:4864:20::131]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rp4cV-006ZVs-0o for pgsql-hackers@lists.postgresql.org; Tue, 26 Mar 2024 11:05:34 +0000 Received: by mail-lf1-x131.google.com with SMTP id 2adb3069b0e04-513dd2d2415so5683372e87.3 for ; Tue, 26 Mar 2024 04:05:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711451130; x=1712055930; 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=9TxgguRcS8t4lUB+pFQ4KWSVpBtElwVO2Bl6/991OdU=; b=BB1ry0iJRZgT1lzA+A5m1Qpf8M44cd55AH5OAIaKD6svoj0rilw2t8WT1F2rAbCUGe P0vAeAE3pP7Kan7f942I6cx4pEGAkjPwkQajwxFKwRP+C+AVV67NkiZDfpd3iQwl5blm HVTOxsj9aNAZEoBqU0HQgZsI0y8rNMM/a/3QKPvX5ShGj0yPZAIuMaNCE4ys7eBsMBZZ Gz9Fx9G6rgNzwTNTUKawBS9rCCnN/whEq1gPf36BvHmggrw7DNNOFyKjq2mq65A4BYnU UscEHibVjNrpWkNp6Spp+rfaEb97SgCcOCw2K8eURMgPlErkZvba2AV3inKWKKCx1nIG P/1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711451130; x=1712055930; 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=9TxgguRcS8t4lUB+pFQ4KWSVpBtElwVO2Bl6/991OdU=; b=Lo9tqm+jTO9F7l2PZyBt6vhr2lwbg7GFskXBDGRpa01jtOPVBiiY8eMdt7JyBSvrbH H0h5IJGK1hIqS/b/EznJEG/rcIu5Ia44ED72EkLtBc8FX72ECF3sC4myoWCI0kQJzz1M LXVD5bhXXktDOSHhu5l5pdjlkakvhxmLhJSLyyYZGMdjfDjaTZmb9/Rwu+QHsesUJ2YR BFt20PJmIQFTlgqje4n2o1BKyNDvXpSNvBA4LeTrneFy+9FuvJ/ooU44UEzo/XqxomSD H4X005Doq/UIgLyu0DoATNJR9W4GKXlQ8mHtCIlw9zebnjb0D81hYGFh6FxEY+OFl28A 54gg== X-Forwarded-Encrypted: i=1; AJvYcCXuuGbzTlJ9jzzTPQVZOU2ljvgQ97KIpErC0y/TmUh8tVQIxrbB9gMXymEr1P8JU56Ocodp3fcQBm+UY4l5r2RlhXgIrtyiTEjY+HZch365Pf6B X-Gm-Message-State: AOJu0Yy/dg875Ic6vSUODi1U6jcLft528FnBOGm0lPOUuVmQRMSmn+z0 buKvPWW2ug2eXow7mZZQHOKT7aSm+1Z2YcgIqXt9whb1XRFiSgtAxBCoMgh/gs/4f9gKZ/GFIxK Z/3axpg2KBchKIbP41pWwmUn1B2OEgfi8TH4= X-Google-Smtp-Source: AGHT+IHRtO1q4/5+dDawVAZelyJ/UQpvOUIOCf00fYT/gq0BwMWb5wZbakj/U0/gJfTSrtHEkjybjJxk63N4Vb0p/Go= X-Received: by 2002:a2e:a712:0:b0:2d6:d470:9d35 with SMTP id s18-20020a2ea712000000b002d6d4709d35mr3150987lje.24.1711451129948; Tue, 26 Mar 2024 04:05:29 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Bharath Rupireddy Date: Tue, 26 Mar 2024 16:35:16 +0530 Message-ID: Subject: Re: Introduce XID age and inactive timeout based replication slot invalidation To: shveta malik Cc: Bertrand Drouvot , Amit Kapila , Nathan Bossart , PostgreSQL Hackers 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:18=E2=80=AFPM shveta malik wrote: > > > What about another approach?: inactive_since gives data synced from pri= mary for > > synced slots and another dedicated field (could be added later...) coul= d > > 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? We don't expose slot creation time, no? 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? --=20 Bharath Rupireddy PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com