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 1sVq4u-00Bty6-Bd for pgsql-hackers@arkaria.postgresql.org; Mon, 22 Jul 2024 10:15:36 +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 1sVq4s-00HJXs-3p for pgsql-hackers@arkaria.postgresql.org; Mon, 22 Jul 2024 10:15:34 +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 1sVq4r-00HJTk-Q1 for pgsql-hackers@lists.postgresql.org; Mon, 22 Jul 2024 10:15:34 +0000 Received: from mail-oi1-x22d.google.com ([2607:f8b0: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 1sVq4p-000qAM-Hn for pgsql-hackers@lists.postgresql.org; Mon, 22 Jul 2024 10:15:32 +0000 Received: by mail-oi1-x22d.google.com with SMTP id 5614622812f47-3dae221e42dso1511141b6e.0 for ; Mon, 22 Jul 2024 03:15:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721643331; x=1722248131; 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=xN1f6GQFQbmSgckFN57EiW1yNekCL34KL1IwN02U2OQ=; b=kamlhTmh9vGiazf1d/VKbM8O6jOzTYZt09J7Getppaus/BiyhZdlRX2EyNziuTWjG3 FOqOAHJRmh+MuxNyHgOhAGzvosiJGOD69XN6u8ethp09h0yfVyYAciNbyYxUGmdwZhGq Ahklfh4k/ixVz+sCaSWFszLagernYu1dBnoNjyHCgSx743070tzVfmdlN2dgCVLlsxQu oX/+2BuSo3j5fGiuYt0FxbKSycTVXF1maMuZ89R2W19N4FLsnNa/rA1ook0TQ8zlPYHx iEZ0g2DOBhS30b0vrtctPKbbu+jFHH2C2r2cWeP/kWWEGLu+enhm3WDWMKrdnNgeSTc5 ak/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721643331; x=1722248131; 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=xN1f6GQFQbmSgckFN57EiW1yNekCL34KL1IwN02U2OQ=; b=rde1PpKI2DiKhCRK8e0/GMfc+49uwVH69RLcFPBOBeneIN01fDxM4JRtnh7lU9N6Im OxhxgMyP9D5Sf5wULp19Bi632jWr4nyESLGDuobgnFVE4KGtWMvIoyA7LyszFd4aKfSL M0QadjkJGvONbk7jRseIehZ69PL/z7NQSaIWVJ/VhR3JMsnXHsrxkBcnylSASpjTanmX 7bxD3VwwqHqcM+DAqlg+K6nHaRQEoXy6VVbHELUueMoyvmXJs5ijVxujBPO+EUwHMxc5 n5QwKP5/H9ekVrMhqTyhB+SfsmpCab3wbSvYI2tmcuI4otam36iHSTSN5Qz/BQIK1ZDw 97OQ== X-Forwarded-Encrypted: i=1; AJvYcCXVYu8/s2EhEl5xkoaB0RjgSlhaKoXkr7tBJmjylRgAiCWdUw0t+zj4ILsVL7Orza8YYyQHGnIiIe2S1APqZu4J1NU6Pt+vWwnGxk4wvscDjuIg X-Gm-Message-State: AOJu0Yy2tGCIQX5fjscKJ9OcW+7rbr4MFpzCdLas6IRdOLV/fZpsJ7+5 4GxS1kepO1mnrSDokRBtiTvtnVsgLuxoXQD3x056CmZ062oYG4gxDU7slQiBoou8V18IKrJbIbW JpST+BdFGqpd+LoChVqalVLAMn7U= X-Google-Smtp-Source: AGHT+IEZYi8YnRhowht+OZOqh9RzDrVitVTLCbeMy7gd5ntTF5WD7wjLMRZSXwFCZOLilNfYzmc8P6HQRbbgXYSgQvE= X-Received: by 2002:a05:6871:5308:b0:25e:1f67:b3bb with SMTP id 586e51a60fabf-261212fd904mr6436117fac.10.1721643330724; Mon, 22 Jul 2024 03:15:30 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Amit Kapila Date: Mon, 22 Jul 2024 15:45:19 +0530 Message-ID: Subject: Re: pg_upgrade and logical replication To: Michael Paquier Cc: Nathan Bossart , vignesh C , "Hayato Kuroda (Fujitsu)" , Justin Pryzby , Masahiko Sawada , Peter Smith , Julien Rouhaud , "pgsql-hackers@lists.postgresql.org" 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 Mon, Jul 22, 2024 at 7:35=E2=80=AFAM Michael Paquier wrote: > > On Sat, Jul 20, 2024 at 09:03:07PM -0500, Nathan Bossart wrote: > >> This is an extremely expensive way to perform that check, and so I'm > >> wondering why we don't just do > >> > >> SELECT count(*) FROM pg_catalog.pg_subscription; > >> > >> once in count_old_cluster_subscriptions(). > > > > Like so... Isn't it better to directly invoke get_subscription_count() in check_new_cluster_subscription_configuration() where it is required rather than in a db-specific general function? > > Ah, good catch. That sounds like a good thing to do because we don't > care about the number of subscriptions for each database in the > current code. > > This is something that qualifies as an open item, IMO, as this code > is new to PG17. > > A comment in get_db_rel_and_slot_infos() becomes incorrect where > get_old_cluster_logical_slot_infos() is called; it is still referring > to the subscription count. > > Actually, on the same grounds, couldn't we do the logical slot info > retrieval in get_old_cluster_logical_slot_infos() in a single pass as > well? pg_replication_slots reports some information about all the > slots, and the current code has a qual on current_database(). It > looks to me that this could be replaced by a single query, ordering > the slots by database names, assigning the slot infos in each > database's DbInfo at the end. > Unlike subscriptions, logical slots are database-specific objects. We have some checks in the code like the one in CreateDecodingContext() for MyDatabaseId which may or may not create a problem for this case as we don't consume changes when checking LogicalReplicationSlotHasPendingWal via binary_upgrade_logical_slot_has_caught_up() but I think this needs more analysis than what Nathan has proposed. So, I suggest taking up this task for PG18 if we want to optimize this code path. --=20 With Regards, Amit Kapila.