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 1rryBv-003ukS-HB for pgsql-hackers@arkaria.postgresql.org; Wed, 03 Apr 2024 10:50:04 +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 1rryBt-000STi-Pb for pgsql-hackers@arkaria.postgresql.org; Wed, 03 Apr 2024 10:50:01 +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 1rryBt-000STZ-GC for pgsql-hackers@lists.postgresql.org; Wed, 03 Apr 2024 10:50:01 +0000 Received: from mail-ot1-x32b.google.com ([2607:f8b0:4864:20::32b]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rryBq-000LNA-SL for pgsql-hackers@lists.postgresql.org; Wed, 03 Apr 2024 10:50:00 +0000 Received: by mail-ot1-x32b.google.com with SMTP id 46e09a7af769-6e673ffbd79so3924118a34.2 for ; Wed, 03 Apr 2024 03:49:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712141398; x=1712746198; 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=BB9WFZlvAHRXYSzXI2P2qN+VAp/E0iz1m8Hpmk4jFVU=; b=NbJ+KB+Tr3kFYApYbs8vGRd5sLJWQqIfgVt9HvgVnVs1APeIgJUb6fuuRzvSH+IEjP 7C2kcRofm1SY8Ml9xJOP6MzFbAwZDE+88PZwd03go9fSNSKIBHJcioEwKO/2XrvDbuRg Dp3zXCH02PySqEMnqBW25fhpK7dBJlcD3GbwOAg4bsHZBC2NbmqsxeoSEwB+grwWBVqN x2aC6ksYk8+urTdDrL24MsqQKwfiJZiIRLZjLgzpGdMiwlLHM4UEBSp9pJYZBpj6U+67 j7Y1eqQ2mVG8noFViagrPpvVyKghbe+XpeR0d9e3B81tW8iQnz06t587HNbp1DVAJl01 bCPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712141398; x=1712746198; 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=BB9WFZlvAHRXYSzXI2P2qN+VAp/E0iz1m8Hpmk4jFVU=; b=cGy4RfRgWP17XlbJruzoa45UxuAEKjAUBiLU7GcWxmFUMkutRV/UC8c2eQmnm4fYKY gcjVG9IwYaUucjaEsFfNIQ0qP8vSkFDxyj2lorKhVn5JoxQ1Qqhr6XohC8Uq5K7ftXwm TAGhI8pwp0pfj25bCkWxQ3mIYzvDG+iXCQzaD3dHVX0qw9D5trZ1P3xE/as/mv1yRWci 32GapecO9kTv/TAgpLc6d08u6t16O0E0LYDH2ch/GNNQFJybl6drbmgtqPzI9kKr654g 5SZdPCAlEeqFJ5fh1ns/jDMtLVmgqKrzgWSSrsphzfM8CslKVpdJ1p5XOqGmIPYl/IvS Kc/Q== X-Forwarded-Encrypted: i=1; AJvYcCV43O1JgKmbgY2u+TpLLkTGPPuf3ND0M6V2nHokql4K/xpeLlBqtAvsY77AJmXEuGAjWJ5DPnHJRPIg4aJcSwnUESRifXLDcSSc14U9df76Dxmg X-Gm-Message-State: AOJu0YxNHr4zhfsM3U9DwyLqgWOhUs/YwhPI9sDJZogeVgVjO8i8ZGbn n0x86WvTpkJhxbWxtsbTMGCzd6HdELqeeHmYJkHR/ao/jGx2+0UE4R7f7cv8ZfEG+DCvoY5hHw3 0DYnlBboOaG1ErOmvSKc5fXhRfPw= X-Google-Smtp-Source: AGHT+IEyyvPhFCps9ElMeE4Uh/u6G1ndHyXMQwfkef2XuqbeLH8HIxc+nvZjoDXz0AU6VUhXRXbJ5Ly/k/IKF6pzSQQ= X-Received: by 2002:a05:6870:2314:b0:229:87f6:ee8a with SMTP id w20-20020a056870231400b0022987f6ee8amr15800636oao.30.1712141397707; Wed, 03 Apr 2024 03:49:57 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Amit Kapila Date: Wed, 3 Apr 2024 16:19:46 +0530 Message-ID: Subject: Re: Introduce XID age and inactive timeout based replication slot invalidation To: shveta malik Cc: Bharath Rupireddy , Bertrand Drouvot , Masahiko Sawada , 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 Wed, Apr 3, 2024 at 2:58=E2=80=AFPM shveta malik wrote: > > On Wed, Apr 3, 2024 at 11:17=E2=80=AFAM Bharath Rupireddy > wrote: > > > > On Wed, Apr 3, 2024 at 8:38=E2=80=AFAM shveta malik wrote: > > > > > > > > Or a simple solution is that the slotsync worker updates > > > > > inactive_since as it does for non-synced slots, and disables > > > > > timeout-based slot invalidation for synced slots. > > > > > > I like this idea better, it takes care of such a case too when the > > > user is relying on sync-function rather than worker and does not want > > > to get the slots invalidated in between 2 sync function calls. > > > > Please find the attached v31 patches implementing the above idea: > > > > Thanks for the patches, please find few comments: > > v31-001: > > 1) > system-views.sgml: > value will get updated after every synchronization from the > corresponding remote slot on the primary. > > --This is confusing. It will be good to rephrase it. > > 2) > update_synced_slots_inactive_since() > > --May be, we should mention in the header that this function is called > only during promotion. > > 3) 040_standby_failover_slots_sync.pl: > We capture inactive_since_on_primary when we do this for the first time a= t #175 > ALTER SUBSCRIPTION regress_mysub1 DISABLE" > > But we again recreate the sub and disable it at line #280. > Do you think we shall get inactive_since_on_primary again here, to be > compared with inactive_since_on_new_primary later? > I think so. Few additional comments on tests: 1. +is( $standby1->safe_psql( + 'postgres', + "SELECT '$inactive_since_on_primary'::timestamptz < '$inactive_since_on_standby'::timestamptz AND + '$inactive_since_on_standby'::timestamptz < '$slot_sync_time'::timestampt= z;" Shall we do <=3D check as we are doing in the main function get_slot_inactive_since_value as the time duration is less so it can be the same as well? Similarly, please check other tests. 2. +=3Ditem $node->get_slot_inactive_since_value(self, slot_name, reference_ti= me) + +Get inactive_since column value for a given replication slot validating it +against optional reference time. + +=3Dcut + +sub get_slot_inactive_since_value I see that all callers validate against reference time. It is better to name it validate_slot_inactive_since rather than using get_* as the main purpose is to validate the passed value. --=20 With Regards, Amit Kapila.