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 1rp3PU-004oUN-2N for pgsql-hackers@arkaria.postgresql.org; Tue, 26 Mar 2024 09:48:00 +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 1rp3PR-00DCN3-OV for pgsql-hackers@arkaria.postgresql.org; Tue, 26 Mar 2024 09:47:58 +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 1rp3PR-00DCMl-AY for pgsql-hackers@lists.postgresql.org; Tue, 26 Mar 2024 09:47:57 +0000 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rp3PJ-006VdB-KD for pgsql-hackers@lists.postgresql.org; Tue, 26 Mar 2024 09:47:56 +0000 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-33ec7e38b84so3777995f8f.1 for ; Tue, 26 Mar 2024 02:47:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711446469; x=1712051269; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=3adLjgwbxtoerl/tM1rTXOIG1coXYdVkLcA/jRGZ2w8=; b=HtedlkDNG6GZtIrTdaEnfhZAvxlqKlPWPC6w0kEQLiNPpV+Cg2I8RZ6fEHQMV3NKuI ZUKzXX4252R74+ETYLvu6TVkUyRzwUe09M5GaYQVP7coTY5zLHHDHab6WSXLct4I2Pj7 tWA3HLnWy+bHuDAPWrz0ladyomYNAyrolZxRUkS4ZgPnqk+PBI6l0D++0xj6HBMmlvDw UztND9w0T92nA7YKhS+avKVRSOnl74sFMrGALlFYUL1OGeFvIdzhP4nGLvlsmAwuymVd wlSL5IZuHadD6P2jbAKQusEGqRetLvHZuy/1gYHpPOzl+RwXriIC37DKvjXtL/M03IW0 R2vQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711446469; x=1712051269; h=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=3adLjgwbxtoerl/tM1rTXOIG1coXYdVkLcA/jRGZ2w8=; b=wMBiuAA9mGWNsVqVKlN8Z8dmVqiKegRaayAMtSmTcXosgg95fXraqNd5Fck0uF4gsg +YhklSUXEJip+J07X0VTVAiXyvjQJvyvKFGEVCuNIVduSOtxjRPtETsa/iHaTLMkZFvU gfiAMjJX7yLkpqLwaTLGBFbULknOIARVAfNh0a97qmhdT6luPjn6+uGjWN/ELH1LBnmp PsBJnrAQ9IJgg3h5XNFb2ZyGf0N54yesRMfmlEq1aQHbSJGzL7CUspXad71TzYPB/bnG dt6SsQ5nQImMCmKX/egOBd8V0RVYfuJCm6YpxrrMWz3JF7Ux76oli3NQR3xDOpJd+QUn nHSw== X-Forwarded-Encrypted: i=1; AJvYcCWSurNkxfmvZL2AOjsn3U/ubONHHerLI6l6RbPaIFp1vdNbFoV9e4R8ob5zGojWeHhDCE/7zKOs/G5oNHEb33bF1vX94nFpTbtjhdpzDtpwUa8B X-Gm-Message-State: AOJu0Yz9fbl+Ezj55e7De0H21jeVnTp1/D1c6V1KNNYsds70rdLfEz5H hhUQo9fGGFfpqsN74oNV+rV2aOYA187wRq/kd+WmdhLV5Y/oa0OZwSK7wuV86nIKNJ0qe6ntRbF uIKsxFOjSVEJYqpNiSRTf4yHza+E= X-Google-Smtp-Source: AGHT+IH+dg1nN+B50mIVKg3e8ZkjMfifCRvc+8W9RGvjEUKz/NqQiRovizk//aVHZKtd8OlnbBjUeqz/BluvjJ57t7w= X-Received: by 2002:adf:fc0f:0:b0:33e:afec:e7d8 with SMTP id i15-20020adffc0f000000b0033eafece7d8mr524918wrr.42.1711446468577; Tue, 26 Mar 2024 02:47:48 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: shveta malik Date: Tue, 26 Mar 2024 15:17:36 +0530 Message-ID: Subject: Re: Introduce XID age and inactive timeout based replication slot invalidation To: Bertrand Drouvot Cc: Amit Kapila , Bharath Rupireddy , Nathan Bossart , PostgreSQL Hackers , shveta malik Content-Type: multipart/mixed; boundary="000000000000cfebc606148d2ead" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000cfebc606148d2ead Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Mar 26, 2024 at 1:54=E2=80=AFPM Bertrand Drouvot wrote: > > Hi, > > On Tue, Mar 26, 2024 at 01:37:21PM +0530, Amit Kapila wrote: > > On Tue, Mar 26, 2024 at 1:15=E2=80=AFPM Bertrand Drouvot > > wrote: > > > > > > 2 =3D=3D=3D > > > > > > It looks like inactive_since is set to the current timestamp on the s= tandby > > > each time the sync worker does a cycle: > > > > > > primary: > > > > > > postgres=3D# select slot_name,inactive_since from pg_replication_slot= s where failover =3D 't'; > > > slot_name | inactive_since > > > -------------+------------------------------- > > > lsub27_slot | 2024-03-26 07:39:19.745517+00 > > > lsub28_slot | 2024-03-26 07:40:24.953826+00 > > > > > > standby: > > > > > > postgres=3D# select slot_name,inactive_since from pg_replication_slot= s where failover =3D 't'; > > > slot_name | inactive_since > > > -------------+------------------------------- > > > lsub27_slot | 2024-03-26 07:43:56.387324+00 > > > lsub28_slot | 2024-03-26 07:43:56.387338+00 > > > > > > I don't think that should be the case. > > > > > > > But why? This is exactly what we discussed in another thread where we > > agreed to update inactive_since even for sync slots. > > Hum, I thought we agreed to "sync" it and to "update it to current time" > only at promotion time. I think there may have been some misunderstanding here. But now if I rethink this, I am fine with 'inactive_since' getting synced from primary to standby. But if we do that, we need to add docs stating "inactive_since" represents primary's inactivity and not standby's slots inactivity for synced slots. The reason for this clarification is that the synced slot might be generated much later, yet 'inactive_since' is synced from the primary, potentially indicating a time considerably earlier than when the synced slot was actually created. Another approach could be that "inactive_since" for synced slot actually gives its own inactivity data rather than giving primary's slot data. We update inactive_since on standby only at 3 occasions: 1) at the time of creation of the synced slot. 2) during standby restart. 3) during promotion of standby. I have attached a sample patch for this idea as.txt file. I am fine with any of these approaches. One gives data synced from primary for synced slots, while another gives actual inactivity data of synced slots. thanks Shveta --000000000000cfebc606148d2ead Content-Type: text/plain; charset="US-ASCII"; name="v1-0001-inactive_since-for-synced-slots.patch.txt" Content-Disposition: attachment; filename="v1-0001-inactive_since-for-synced-slots.patch.txt" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_lu86xh8q0 RnJvbSA3ZGNkMGU5NTI5OTI2MzE4N2ViMWYwMzgxMmY4MzIxYjI2MTJlZTVjIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBTaHZldGEgTWFsaWsgPHNodmV0YS5tYWxpa0BnbWFpbC5jb20+ CkRhdGU6IFR1ZSwgMjYgTWFyIDIwMjQgMTQ6NDI6MjUgKzA1MzAKU3ViamVjdDogW1BBVENIIHYx XSBpbmFjdGl2ZV9zaW5jZSBmb3Igc3luY2VkIHNsb3RzLgoKaW5hY3RpdmVfc2luY2UgaXMgdXBk YXRlZCBmb3Igc3luY2VkIHNsb3RzOgoxKSBhdCB0aGUgdGltZSBvZiBjcmVhdGlvbiBvZiBzbG90 LgoyKSBkdXJpbmcgc2VydmVyIHJlc3RhcnQuCjMpIGR1cmluZyBwcm9tb3Rpb24uCi0tLQogc3Jj L2JhY2tlbmQvcmVwbGljYXRpb24vbG9naWNhbC9zbG90c3luYy5jIHwgIDEgKwogc3JjL2JhY2tl bmQvcmVwbG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