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 1qczza-001pQX-Kw for pgsql-hackers@arkaria.postgresql.org; Mon, 04 Sep 2023 03:11:10 +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 1qczzZ-007ppQ-Ax for pgsql-hackers@arkaria.postgresql.org; Mon, 04 Sep 2023 03:11:09 +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 1qczzY-007pp0-W7 for pgsql-hackers@lists.postgresql.org; Mon, 04 Sep 2023 03:11:08 +0000 Received: from mail-oa1-x29.google.com ([2001:4860:4864:20::29]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qczzV-002bfU-KT for pgsql-hackers@lists.postgresql.org; Mon, 04 Sep 2023 03:11:07 +0000 Received: by mail-oa1-x29.google.com with SMTP id 586e51a60fabf-1c4cd0f6cb2so542674fac.0 for ; Sun, 03 Sep 2023 20:11:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693797064; x=1694401864; 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=iqQiWAe9Ot0EEQ+huxewrfK8a3pDAFXg8+kGEcMJsuY=; b=HOONYOmNUaZxxPDZUsC6sqqFwPNsHTTh34RaedmdGrY6pK0XrlcxxH1ivvI9eoqRWk gSCdrf6DlJhhDQ0VN8a5TLUFHoeSSbg9IKO5vm1rmRcGXMOLZDEs5XxXBXRyLeaXu/3n HIxbJvlJaIuW7Yb7NVWU0U/T8rDVdm0VD+VHSe0j1NvBmBG0uT/oStda2yFq93eTPsMG jI/LD7YTVA1g4GF1Q19bj8K4Eou65Xjk9kI877GJbKaT5elRdtK8usdNBtipzqe0aZLm KXVpywwdVWXru+OhxM3bdUKb8TzZ9FA3o/sVyCzxSAZA9/ddSiHlCPjdUJBDGzv6eAnP RUjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693797064; x=1694401864; 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=iqQiWAe9Ot0EEQ+huxewrfK8a3pDAFXg8+kGEcMJsuY=; b=S+hEVNE/DjObaetIbJtR8grcDRUxHKXzo07XVGDGQfml8HCmPZg2gv7jhe1cvn5wRP V9/E7Ent9OQbjWqBcag4BZDom3etSX9wX54fWXOtLuIMqhaUlrV6YdclVuJ7Zl4w0yNx JwFQ/UnE2CMZk9A6vSM9B5hwlgnv0V0VqdqXxTNC5U0TvZ78pt5YVI2hInUgjKnumsu2 smWr3CwcplRZoQHiWIGo0vi1DHTBhz1VEcMfu3wb//j4KddJMTGbCmzQKNqIFQ4EpszA dDqWH6PweLGIFBHPPe4w7pCl68f3sfbN8HEC8W6IiW+FCArOJ00CrQpqhTDUyq+Swryu RinA== X-Gm-Message-State: AOJu0YzQA41hl3ysP7hbgBtip7zalKQvuWSlc9L7RFnCylVSPFfKAj8H OHaSw9e7p4c5jxdXMRUFw09+SaK2oZ55lD6L77E= X-Google-Smtp-Source: AGHT+IE3DM8G9Vfsm39X1J1keS1J4GykP7lOFnoCReLMLhlP9hp8CtmggVse6s74WESAcGpS9R7TMY5K0KZyH27ETPU= X-Received: by 2002:a05:6870:a408:b0:1be:cb40:eea0 with SMTP id m8-20020a056870a40800b001becb40eea0mr5199938oal.12.1693797064593; Sun, 03 Sep 2023 20:11:04 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Amit Kapila Date: Mon, 4 Sep 2023 08:40:53 +0530 Message-ID: Subject: Re: Impact of checkpointer during pg_upgrade To: Dilip Kumar Cc: PostgreSQL Hackers , Sawada Masahiko , "Hayato Kuroda (Fujitsu)" , vignesh C , =?UTF-8?B?SG91LCBaaGlqaWUv5L6vIOW/l+adsA==?= , 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 Sat, Sep 2, 2023 at 6:12=E2=80=AFPM Dilip Kumar = wrote: > > On Sat, Sep 2, 2023 at 10:09=E2=80=AFAM Amit Kapila wrote: > > > The other possibilities apart from not allowing an upgrade in such a > > case could be (a) Before starting the old cluster, we fetch the slots > > directly from the disk using some tool like [2] and make the decisions > > based on that state; > > Okay, so IIUC along with dumping the slot data we also need to dump > the latest checkpoint LSN because during upgrade we do check that the > confirmed flush lsn for all the slots should be the same as the latest > checkpoint. Yeah but I think we could work this out. > We already have the latest checkpoint LSN information from pg_controldata. I think we can use that as the patch proposed in the thread [1] is doing now. Do you have something else in mind? > (b) During the upgrade, we don't allow WAL to be > > removed if it can invalidate slots; (c) Copy/Migrate the invalid slots > > as well but for that, we need to expose an API to invalidate the > > slots; > > (d) somehow distinguish the slots that are invalidated during > > an upgrade and then simply copy such slots because anyway we ensure > > that all the WAL required by slot is sent before shutdown. > > Yeah this could also be an option, although we need to think the > mechanism of distinguishing those slots looks clean and fit well with > other architecture. > If we want to do this we probably need to maintain a flag in the slot indicating that it was invalidated during an upgrade and then use the same flag in the upgrade to check the validity of slots. I think such a flag needs to be maintained at the same level as ReplicationSlotInvalidationCause to avoid any inconsistency among those. > Alternatively can't we just ignore all the invalidated slots and do > not migrate them at all. Because such scenarios are very rare that > some of the segments are getting dropped just during the upgrade time > and that too from the old cluster so in such cases not migrating the > slots which are invalidated should be fine no? > I also think that such a scenario would be very rare but are you suggesting to ignore all invalidated slots or just the slots that got invalidated during an upgrade? BTW, if we simply ignore invalidated slots then users won't be able to drop corresponding subscriptions after an upgrade. They need to first use the Alter Subscription command to disassociate the slot (by using the command ALTER SUBSCRIPTION ... SET (slot_name =3D NONE)) and then drop the subscription similar to what we suggest in other cases as described in the Replication Slot Management section in docs [2]. Also, if users really want to continue that subscription by syncing corresponding tables then they can recreate the slots manually and then continue with replication. So, if we want to do this then we will just rely on the current state (at the time we query for them in the old cluster) of slots, and even if they later got invalidated during the upgrade, we will just ignore such invalidations as anyway the required WAL is already copied. [1] - https://www.postgresql.org/message-id/TYAPR01MB58664C81887B3AF2EB6B16= E3F5939%40TYAPR01MB5866.jpnprd01.prod.outlook.com [2] - https://www.postgresql.org/docs/devel/logical-replication-subscriptio= n.html --=20 With Regards, Amit Kapila.