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 1rpK1N-0069Gh-AG for pgsql-hackers@arkaria.postgresql.org; Wed, 27 Mar 2024 03:32:13 +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 1rpK1M-009BqU-2C for pgsql-hackers@arkaria.postgresql.org; Wed, 27 Mar 2024 03:32:12 +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 1rpK1L-009BqM-Ov for pgsql-hackers@lists.postgresql.org; Wed, 27 Mar 2024 03:32:11 +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 1rpK1E-006gsC-SL for pgsql-hackers@lists.postgresql.org; Wed, 27 Mar 2024 03:32:10 +0000 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-33ed4d8e9edso4601393f8f.2 for ; Tue, 26 Mar 2024 20:32:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711510323; x=1712115123; 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=mxgvUtUdOnoj9MSBdlGWGb6dY1c3esTdJOMjWNl/PH8=; b=IgqoVDms82V3NGzZ7/UKAxec0Nl7jCquWGIROVSauUvvXiO4NIoXWnkqk2JiG+yp48 HdRY5UyrVJpuE8Tx4fWspzNAfjuqVV6A9nM9wfUkJkG5jxb8tSc1LTiYDF41k3PWQjdF FI2d14Qo41N+MC8hUOUuJ3wZAfDT7lO/CuVvOFv9VUn/hIjjeWu27HbWonPUIV5Ud9wJ Y8p3iK2ZW2V9Ey4futGPe6Kl3wXoLY6puzghb6kGUBVd+o7AO6PVrUpKZJLVID8wURgM Rc5uZZ2S1eIVpzDfN7fJxIVGaOCXgHQ908/8B7IkC+LdSaRAtmQfEntu9r469BwVgirx SJ9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711510323; x=1712115123; 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=mxgvUtUdOnoj9MSBdlGWGb6dY1c3esTdJOMjWNl/PH8=; b=lNSMtrTKqpDML4LBOCRfki9BswV9NmvgIL/qFY2CFvt7VfGBStmQYTGsCfD/SAyyC5 6QeeJD9R14ne08gyk0XMbLYdlKWVo8sA5aNsXcBgKFWTqRUOvZ6kBaLNbrAq7TrOfw/L VqyP+F/cVNbpJHdYEzQGyYZjl2mMxXvDMD4WRY3dZ3OmC9kJTiY9TYoVjF3e7FSBgT2Z dXZ8jiC4eYpBEskwttiLQfYy1iqt7hl+FAqdym6TC2axPLCkLBmd/16HzVxOYEnOYukI gPyze+G1jc9DWzk+Wnu7WKEJOWOeVrhWMwJ4ejsJ1p6yKjJFcwroY+mVCxnaUcFDs1Be blcg== X-Forwarded-Encrypted: i=1; AJvYcCW2V46vgY9vSIPzGWWN+yt4ROn012VWxPP0Ajb5GpdIqkiJQy/NGNE9FrnL1utWzOjJogvYG6uOhwZ9EZaa6+qc2qrQZZhUQ8dRSlp3xsC8w+kp X-Gm-Message-State: AOJu0Yw7n2rg2puK/wPUEtTG+njwcQQSCQZZmLoPL8Oy4QXHOXNpXR0K 80guPNkoszQFYU5eVDINZHQnrpoAJXESasPppkwTEX4CrbqUO1Yjx0lmqO2TDzCc005Dae2L5y4 u9uzRYBCnvLirGYLd4KvXmOY62gs= X-Google-Smtp-Source: AGHT+IF0JcWo8GnLSYnsc/9kRxM80e5TAU8E/qggnIGMaVLQ1Jv+UqsySMeXa/xZrRrRQncjPnMgkuntkU47j1aN1/4= X-Received: by 2002:a5d:4b52:0:b0:33e:7621:e15f with SMTP id w18-20020a5d4b52000000b0033e7621e15fmr3113842wrs.39.1711510322835; Tue, 26 Mar 2024 20:32:02 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: shveta malik Date: Wed, 27 Mar 2024 09:01:50 +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 9:59=E2=80=AFPM Bharath Rupireddy wrote: > > On Tue, Mar 26, 2024 at 4:35=E2=80=AFPM Bharath Rupireddy > wrote: > > > > 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. > > I'm attaching v24 patches. It implements the above idea proposed > upthread for synced slots. I've now separated > s/last_inactive_time/inactive_since and synced slots behaviour. Please > have a look. Thanks for the patches. Few trivial comments for v24-002: 1) slot.c: + * data from the remote slot. We use InRecovery flag instead of + * RecoveryInProgress() as it always returns true even for normal + * server startup. a) Not clear what 'it' refers to. Better to use 'the latter' b) Is it better to mention the primary here: 'as the latter always returns true even on the primary server during start= up'. 2) update_local_synced_slot(): - strcmp(remote_slot->plugin, NameStr(slot->data.plugin)) =3D=3D 0) + strcmp(remote_slot->plugin, NameStr(slot->data.plugin)) =3D=3D 0 && + remote_slot->inactive_since =3D=3D slot->inactive_since) When this code was written initially, the intent was to do strcmp at the end (only if absolutely needed). It will be good if we maintain the same and add new checks before strcmp. 3) update_synced_slots_inactive_time(): This assert is removed, is it intentional? Assert(s->active_pid =3D=3D 0); 4) 040_standby_failover_slots_sync.pl: +# Capture the inactive_since of the slot from the standby the logical fail= over +# slots are synced/created on the standby. The comment is unclear, something seems missing. thanks Shveta