Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1n2GxK-0003SE-S7 for pgsql-bugs@arkaria.postgresql.org; Tue, 28 Dec 2021 18:12:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1n2GxJ-0002VE-G3 for pgsql-bugs@arkaria.postgresql.org; Tue, 28 Dec 2021 18:12:13 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1n2GxJ-0002V4-6D for pgsql-bugs@lists.postgresql.org; Tue, 28 Dec 2021 18:12:13 +0000 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1n2GxG-0000LV-1T for pgsql-bugs@lists.postgresql.org; Tue, 28 Dec 2021 18:12:11 +0000 Received: by mail-wr1-x42a.google.com with SMTP id r17so39824045wrc.3 for ; Tue, 28 Dec 2021 10:12:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=D3PA14ppPxWv3JQLK5Z9eaSkgFKwfRKJkl5Unyy0pPg=; b=h/RKi25EPEM317H+M0y1b4V11QSHiPC/lo7rHsWoq316ZrefhFkeihKUQmvu4OIAjA ro6W8CYJO0FhsHWnAdxbiLoFLhBTnaXfb6bm1j7soximELb2lEem93TxN5AzdE0M8iSb J2bY3RyIKmk6xg31q3GEfAlOl1kfU4Ewlr7Q2ascDZmhUUMZLEBnqiBqt882f/z0F+8b zDdz7brhOoQ5lRJvCXVt+jREehVrX3WYTTbhNHbdt1eyyWGZTCISWAWHudOOuTPMl5h7 C5eYrYkfTHapB15izIwHGitP548lO4qoL8qhdLljS2d2eMRLvlI48ttAz0hU2bLA/Eas 8o5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=D3PA14ppPxWv3JQLK5Z9eaSkgFKwfRKJkl5Unyy0pPg=; b=EjZOwweBM65iAFE7AAOT1ALe6bgtiuhpPjfxNQc4+uoQLXRIvsiMvYHCcdIokXiyfP 6HC3r52Z/kZcRPp21ENd6dW394PXClf7/APhrP8tUTjoBAj4oraX+eGzBxUnrik3mnyG zz48EOJvhuHXQadE2VRVkSmc4OKgKojgmsMEd7LczngbxaZIa3UlcaUER5RraILTJ9xq DBMLDWiCtnf5LvosI/9sOdJqBTW9bRxrcZ+j3QRcU5M5UhUhIwK+PnhR6//b5zrGSRBT tQSFdNxXvm1cyKsjn1ja9Sv2DR3opxUO4Q6vNygPclv9zU3yzohlU3JPiBiQCTYetYT6 mMCg== X-Gm-Message-State: AOAM531a35g6dHXLIZnR9bgaS28St91AZ8F2NMcLkVpiY6k2FUWrwWdm F87yJEeRf7i6iW64s59LibqKwbWGEQo= X-Google-Smtp-Source: ABdhPJz3PBTt/s26npS203AO+Dz3tVA8WZ+Y4KC3JQp6WWp5gtqoZiISGybYM+0rkrPfsjiMuBUdDA== X-Received: by 2002:a5d:64e7:: with SMTP id g7mr16971000wri.203.1640715128496; Tue, 28 Dec 2021 10:12:08 -0800 (PST) Received: from ?IPv6:2a02:8388:e002:8cf0:d51a:d0ef:f60c:aa3a? (2a02-8388-e002-8cf0-d51a-d0ef-f60c-aa3a.cable.dynamic.v6.surfer.at. [2a02:8388:e002:8cf0:d51a:d0ef:f60c:aa3a]) by smtp.googlemail.com with ESMTPSA id q1sm19160266wra.82.2021.12.28.10.12.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 28 Dec 2021 10:12:07 -0800 (PST) Subject: Re: BUG #17347: pg_upgrade: analyze_new_cluster script analyzes wrong cluster To: Tom Lane Cc: pgsql-bugs@lists.postgresql.org References: <17347-27b988f51d9dee1a@postgresql.org> <1760674.1640707235@sss.pgh.pa.us> From: Mathias Kunter Message-ID: <10f71bb9-2ca6-24c4-0feb-f64138a0e4b3@gmail.com> Date: Tue, 28 Dec 2021 19:12:06 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: <1760674.1640707235@sss.pgh.pa.us> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: de-AT Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > The assumption you're making is that --new-port will be the new > cluster's port number after it's started for real. I'd argue that this assumption is mostly correct in such situations where the user explicitly specifies the --new-port argument. In case a nonce configuration is wanted, why would a user explicitly specify the --new-port argument instead of just using pg_upgrade with default settings? Also, the analyze script considers neither the new nor the old port of the upgraded cluster, but apparently just simply always connects to the cluster on the default 5432 port. I followed the steps outlined at https://www.postgresql.org/docs/12/pgupgrade.html to upgrade a cluster running on port 5433 (not port 5432). Thus, I've run pg_upgrade with both --old-port and --new-port set to 5433. In such a scenario, I'd definitely expect the analyze script to connect to the cluster on port 5433. But it will instead analyze the cluster on port 5432, which is completely unrelated to the upgrade. This problem can be hard to detect if a different cluster is running on port 5432 (in my situation this was the case) because obviously you won't get any error message then. I didn't notice the problem until I found out that some queries were painfully slow after the upgrade, which was a result of some indices not being used due to missing statistics. > It's a bit moot now anyway, since pg_upgrade doesn't create > that script anymore in v14 and up. The docs at https://www.postgresql.org/docs/14/pgupgrade.html (step 15 "Statistics") though say the user must "run a command to regenerate that information". Is the documentation up-to-date? Best regards Mathias Kunter Am 28.12.21 um 17:00 schrieb Tom Lane: > PG Bug reporting form writes: >> When upgrading a PostgreSQL cluster with pg_upgrade (tested while upgrading >> from 11.14 to 12.9, but supposedly affects all versions), and the --new-port >> argument is used to specify a new port number for the upgraded cluster, then >> the generated analyze_new_cluster script will connect to and analyze a >> different cluster instead of the upgraded one. >> The vacuumdb command found within the analyze_new_cluster script should >> explicitly specify the port number of the upgraded cluster, so that it will >> actually analyze the correct cluster after the upgrade. > > Hmm. I'm not sure whether changing that would be an improvement. > The assumption you're making is that --new-port will be the new > cluster's port number after it's started for real. But it seems > at least as likely that it's just a nonce specification used for > long enough to finish sucking data out of your old cluster, and > then you'll start the new server in place of your old one (ie > using the old port). > > It's a bit moot now anyway, since pg_upgrade doesn't create > that script anymore in v14 and up. > > regards, tom lane >