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 1rsJ2X-006EQL-9o for pgsql-hackers@arkaria.postgresql.org; Thu, 04 Apr 2024 09:05:45 +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 1rsJ2W-000sNw-EF for pgsql-hackers@arkaria.postgresql.org; Thu, 04 Apr 2024 09:05:44 +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 1rsJ2W-000sNn-2l for pgsql-hackers@lists.postgresql.org; Thu, 04 Apr 2024 09:05:44 +0000 Received: from mail-lj1-x22d.google.com ([2a00:1450:4864:20::22d]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rsJ2T-000VJs-6I for pgsql-hackers@lists.postgresql.org; Thu, 04 Apr 2024 09:05:42 +0000 Received: by mail-lj1-x22d.google.com with SMTP id 38308e7fff4ca-2d6f9ce80a9so1285321fa.1 for ; Thu, 04 Apr 2024 02:05:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712221539; x=1712826339; 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=d9qXUMIKytsD57T3eXJBgjiG3fafFVAFe08Jop9CtVE=; b=CE3hI8neIN2XZzrbhMLkxw2SJvxcUV7Kgq8aExPlacLvW8MuZCYemf2It5WbYFPwxe n+bAlqbm1DmIDWFwudCYsVyFTv2jq8BQWCI2jTIz0gZcxG39g5Tpmre2puCkXo5Uy3Qw qsi24206StYwZaWOYrDGA9Cn7BQn0IggWb3U/yXr5vTPulawupMt3Qze2KJF1QVjk1a+ QkRAeEtETxgOEF7WLCWx2lFZ/vuTF4SXU7fDafGbR+2A2FK/db7s4Z6aMkdv/Tmhp/4d WM375lE8w7O3jxW5rLghX/7EF1I6YdtmHZlj7KwoUezqHfoX3M+4UH+UlV0p4xVuEMLb etLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712221539; x=1712826339; 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=d9qXUMIKytsD57T3eXJBgjiG3fafFVAFe08Jop9CtVE=; b=Uq279zBthQfqJGkOOIi2LUqA8eYBF8YCvn1uX2tMkilXwg72wU/4/nFmnNwrRaEKo2 gEhCl+5zVcSSbJbliVyZvVbZsbe5r0fpop+9GO5YwTK9n4pvAwNI3oqVEjfWk6hsdRwU KOxRHQ+oILBKNP0mUiFPe99ZhcpY9XTb1tf4PPpBeH75WFn1se4PKXo9PCkyJrSTY9C+ ZmhNidltLzSghHJHNrdACZWhbhvSoSALgln10TLmIGigx+TB89erYg0WH4gvp4ujoxPr 8Rq2PqX1aFPCuTsjwBbxYn2T0zbYvxG1VjmpmbQdW+vGf3GWxBgzUEfmpE48oD3JTA7o MQRw== X-Forwarded-Encrypted: i=1; AJvYcCWXe81flEQsSD6i70JXq+DEMeZuXaI+LXbMxdoSfkzmj5buAyvxzwYvQNB/i+pEvrwfljMOJIP7yAf7RY/6dMBHitbXUDnhgUXwFaJbFNQVQynB X-Gm-Message-State: AOJu0Yz8ceX33fUmo0FGINanQ2xaOiFQkMEekXxE2aMaLfBmcyER+CG9 AJpYy3rm4lnFfOG/VRhGH9SY6oASZkghEjWPhu96yhGUul+b1DI8AKNu012T50THClGGXRCwgNG 6JQUA4o4nww20K/6+X7iDMLY3HmQ= X-Google-Smtp-Source: AGHT+IEtaq03bcU/bfRZSZ0j6pN8mwNZV7VkS7UIASuhdXA925LsjYkbbiamWcMdhmtS4HPShEL3nRkUxvYxDakIoEw= X-Received: by 2002:a2e:8684:0:b0:2d8:c62:5e20 with SMTP id l4-20020a2e8684000000b002d80c625e20mr1180423lji.3.1712221539320; Thu, 04 Apr 2024 02:05:39 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Masahiko Sawada Date: Thu, 4 Apr 2024 18:05:02 +0900 Message-ID: Subject: Re: Introduce XID age and inactive timeout based replication slot invalidation To: Amit Kapila Cc: Bharath Rupireddy , Bertrand Drouvot , shveta malik , 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 Thu, Apr 4, 2024 at 5:36=E2=80=AFPM Amit Kapila wrote: > > On Thu, Apr 4, 2024 at 1:32=E2=80=AFPM Masahiko Sawada wrote: > > > > On Thu, Apr 4, 2024 at 1:34=E2=80=AFPM Bharath Rupireddy > > wrote: > > > > > > On Thu, Apr 4, 2024 at 9:42=E2=80=AFAM Masahiko Sawada wrote: > > > > > > > > @@ -1368,6 +1416,7 @@ ShutDownSlotSync(void) > > > > if (SlotSyncCtx->pid =3D=3D InvalidPid) > > > > { > > > > SpinLockRelease(&SlotSyncCtx->mutex); > > > > + update_synced_slots_inactive_since(); > > > > return; > > > > } > > > > SpinLockRelease(&SlotSyncCtx->mutex); > > > > @@ -1400,6 +1449,8 @@ ShutDownSlotSync(void) > > > > } > > > > > > > > SpinLockRelease(&SlotSyncCtx->mutex); > > > > + > > > > + update_synced_slots_inactive_since(); > > > > } > > > > > > > > Why do we want to update all synced slots' inactive_since values at > > > > shutdown in spite of updating the value every time when releasing t= he > > > > slot? It seems to contradict the fact that inactive_since is update= d > > > > when releasing or restoring the slot. > > > > > > It is to get the inactive_since right for the cases where the standby > > > is promoted without a restart similar to when a standby is promoted > > > with restart in which case the inactive_since is set to current time > > > in RestoreSlotFromDisk. > > > > > > Imagine the slot is synced last time at time t1 and then a few hours > > > passed, the standby is promoted without a restart. If we don't set > > > inactive_since to current time in this case in ShutDownSlotSync, the > > > inactive timeout invalidation mechanism can kick in immediately. > > > > > > > Thank you for the explanation! I understood the needs. > > > > Do you want to review the v34_0001* further or shall I proceed with > the commit of the same? Thanks for asking. The v34-0001 patch looks good to me. Regards, --=20 Masahiko Sawada Amazon Web Services: https://aws.amazon.com