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 1tH0FH-002RVd-0H for pgsql-hackers@arkaria.postgresql.org; Fri, 29 Nov 2024 12:37:15 +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 1tH0FE-007O5V-FQ for pgsql-hackers@arkaria.postgresql.org; Fri, 29 Nov 2024 12:37:13 +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 1tH0FE-007O5D-5v for pgsql-hackers@lists.postgresql.org; Fri, 29 Nov 2024 12:37:13 +0000 Received: from mail-lf1-x131.google.com ([2a00:1450:4864:20::131]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1tH0FC-000AG0-Re for pgsql-hackers@lists.postgresql.org; Fri, 29 Nov 2024 12:37:12 +0000 Received: by mail-lf1-x131.google.com with SMTP id 2adb3069b0e04-53de8ecafeeso2084304e87.1 for ; Fri, 29 Nov 2024 04:37:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732883829; x=1733488629; 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=2pPE4YY3xTw6e9m4Cijz5KtdYVLdDPO1U8ALrGwTRaQ=; b=edOg81eE5D/IQ+UH4phL9ysKsIg9AAQXzhmiI4eKh9fXHHXEf/kSiCUrU4ZlLtmsBC ZAwkI0MpJx+h+t6gsvLYJNVB+lV1RN5rtGx2m8BhdDwjadgdaD88ECM0Cr+EmV41tyo5 2ffaK2WGkBnVkvP1OI8XNr/0m50cHMh5VWQny4wyCuoIcn5eLpkxgrY1kNw+vT/Tx7I2 oUw8hnvPoRVUaHNkZM1ppoi2mxoWlNcFNLd/e15NEy5l3jYgCZ/iAyuOGEm2aQRsTtaD 03ewu+YWHFGuRv6XcDUgIyrhiQQ10xuXvszbCfeyQ2sHAGSrO/TOwMje06L4MHgq8Sbp dzXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732883829; x=1733488629; 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=2pPE4YY3xTw6e9m4Cijz5KtdYVLdDPO1U8ALrGwTRaQ=; b=Dp+qMfJajovU03sgb8iBvcHOSbUwX/n6czX9gQRq81WmAxjKinrPhdZUmRxGMdUpOx SQ5Gowr95OsQGH6+utuwjCiHRJsxtnkKjg8zsTLTmVLacXWKloVDNfNWNE/Y86w8ozzV P1JZ9g/yCgZirLHpiO5aqC149zzvabPQCwIjMFEp5clb4VmnWQv2lpgaTJu1dQU++zc5 01yXEfS8Rv2+ve6R4S/q1W8MJBP0HbScVs36yAgMl5wK0cQN8KDOwiOD6JRnSdDpHvn9 D3XodSOnvChj4e1ZxlRZ9aHqjVeE+G4gcy8mDXIK2G6KzjSaKQ2+crGZb4Q/wFPpvp+n xN5Q== X-Forwarded-Encrypted: i=1; AJvYcCX18lIIVEMLlJ9nu7LeuyLIEutGYZ2XSy1dJfz/3D/lNfiTTAxxdvQitHdY1OrQDEuY8dqRfdoV/CglLFf2@lists.postgresql.org X-Gm-Message-State: AOJu0YxQCZ8F/r2qgkw9SD952IIGOJ9N/DWJ8KZkVMYgPQMPQLORqrrG wZVQL0EjfYZgqiBcFebE8+1NQwJLQZpxqu3PPDGW+3Hx1U0x3D2EWz0Jz/0Qp7WNkghM2uPeDcG hBaIL3TVmkgQYbtj5AZAfKLNwOw== X-Gm-Gg: ASbGncuTL1G9Bl8/REG7XBF6bROhlHALNwpI4tsZXe/YULfH/7sn8HcLujt56GG8Ye7 OLGT+S1ej27pdEAasOUOAS0ZWkkQWsbCG X-Google-Smtp-Source: AGHT+IETfb61m7fvMnkZx1w0+VbAAEKtndvgmQuywcAk7m/UMKZ+VGqNbFmP3gzJPKxifLf9puD6/w9s7EQQsWpJjPw= X-Received: by 2002:a05:6512:1155:b0:53d:e5f0:32d1 with SMTP id 2adb3069b0e04-53df010eabemr7387919e87.54.1732883828448; Fri, 29 Nov 2024 04:37:08 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Nisha Moond Date: Fri, 29 Nov 2024 18:06:56 +0530 Message-ID: Subject: Re: Introduce XID age and inactive timeout based replication slot invalidation To: "Hayato Kuroda (Fujitsu)" Cc: vignesh C , shveta malik , Bharath Rupireddy , Amit Kapila , Ajin Cherian , Bertrand Drouvot , Masahiko Sawada , Nathan Bossart , PostgreSQL Hackers , Peter Smith 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, Nov 28, 2024 at 1:29=E2=80=AFPM Hayato Kuroda (Fujitsu) wrote: > > Dear Nisha, > > > > > Attached v51 patch-set addressing all comments in [1] and [2]. > > > > Thanks for working on the feature! I've stated to review the patch. > Here are my comments - sorry if there are something which have already be= en discussed. > The thread is too long to follow correctly. > > Comments for 0001 > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > 01. binary_upgrade_logical_slot_has_caught_up > > ISTM that error_if_invalid is set to true when the slot can be moved forw= ard, otherwise > it is set to false. Regarding the binary_upgrade_logical_slot_has_caught_= up, however, > only valid slots will be passed to the funciton (see pg_upgrade/info.c) s= o I feel > it is OK to set to true. Thought? > Right, corrected the call with error_if_invalid as true. > Comments for 0002 > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > 03. check_replication_slot_inactive_timeout > > Can we overwrite replication_slot_inactive_timeout to zero when pg_uprade= (and also > pg_createsubscriber?) starts a server process? Several parameters have al= ready been > specified via -c option at that time. This can avoid an error while the u= pgrading. > Note that this part is still needed even if you accept the comment. Users= can > manually boot with upgrade mode. > Done. > 06. found bug > > While testing the patch, I found that slots can be invalidated too early = when when > the GUC is quite large. I think because an overflow is caused in Invalida= tePossiblyObsoleteSlot(). > > - Reproducer > > I set the replication_slot_inactive_timeout to INT_MAX and executed below= commands, > and found that the slot is invalidated. > > ``` > postgres=3D# SHOW replication_slot_inactive_timeout; > replication_slot_inactive_timeout > ----------------------------------- > 2147483647s > (1 row) > postgres=3D# SELECT * FROM pg_create_logical_replication_slot('test', 'te= st_decoding'); > slot_name | lsn > -----------+----------- > test | 0/18B7F38 > (1 row) > postgres=3D# CHECKPOINT ; > CHECKPOINT > postgres=3D# SELECT slot_name, inactive_since, invalidation_reason FROM p= g_replication_slots ; > slot_name | inactive_since | invalidation_reason > -----------+-------------------------------+--------------------- > test | 2024-11-28 07:50:25.927594+00 | inactive_timeout > (1 row) > ``` > > - analysis > > In InvalidatePossiblyObsoleteSlot(), replication_slot_inactive_timeout_se= c * 1000 > is passed to the third argument of TimestampDifferenceExceeds(), which is= also the > integer datatype. This causes an overflow and parameter is handled as the= small > value. > > - solution > > I think there are two possible solutions. You can choose one of them: > > a. Make the maximum INT_MAX/1000, or > b. Change the unit to millisecond. > Fixed. It is reasonable to align with other timeout parameters by using milliseconds as the unit. -- Thanks, Nisha