Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eFIvl-00058l-LJ for pgsql-hackers@arkaria.postgresql.org; Thu, 16 Nov 2017 12:06:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eFIvl-0001mq-7f for pgsql-hackers@arkaria.postgresql.org; Thu, 16 Nov 2017 12:06:05 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eFIvk-0001mP-SS; Thu, 16 Nov 2017 12:06:05 +0000 Received: from mail.postgrespro.ru ([93.174.131.138]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1eFIvh-0001YP-Me; Thu, 16 Nov 2017 12:06:04 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id E227521C1690; Thu, 16 Nov 2017 15:06:00 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at postgrespro.ru Received: from mail.postgrespro.ru (unknown [192.168.27.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mail.postgrespro.ru (Postfix) with ESMTPSA id 3CF8E21C1664; Thu, 16 Nov 2017 15:06:00 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1510833960; bh=5mtA/SiNqUtNPsfNp917t6KAhyO+qwye6MkynBy+cxo=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=JXhkMc7YTSMsZimr93OOaIuBA/9CzifQh9orrH7w31Xeh2UxiRO7Uaa0FVaS75WuX JyuwHKst0f2swRJr+a+KDaJ8e5tbtfaUX0uw8O03xa+1oiaCZMi1GiNeqYHgiHeSf8 I3BZRB9fzZBqyshL3d1koZQkgGZ7bKMULj755zsQ= MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=_b7eb9c10db995b53aecf71d59d7ae55d" Date: Thu, 16 Nov 2017 15:05:59 +0300 From: a.akenteva@postgrespro.ru To: Tom Lane Cc: pgsql-hackers@postgresql.org, pgsql-hackers-owner@postgresql.org Subject: Re: [HACKERS] A weird bit in pg_upgrade/exec.c In-Reply-To: <21596.1510244246@sss.pgh.pa.us> References: <21596.1510244246@sss.pgh.pa.us> Message-ID: X-Sender: a.akenteva@postgrespro.ru User-Agent: Roundcube Webmail/1.2.4 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --=_b7eb9c10db995b53aecf71d59d7ae55d Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed Tom Lane writes: > Yeah, the way it is now seems outright broken. It will try to do > get_bin_version on the new cluster before having done validate_exec > there, violating its own comment. > > I think we should change this as a bug fix, independently of whatever > else you had in mind to do here. I see this bug is now fixed in pg_upgrade/exec.c => check_bin_dir(). There's another bit exactly like that in check_data_dir() though. We use global variables instead of using the argument passed to the function, which makes the function not reusable. Sorry if I mentioned it too vaguely in the previous letter. I attached a patch with the change that would fix it. In pg_upgrade/exec.c => check_data_dir() I substituted these two lines old_cluster.major_version = get_major_server_version(&old_cluster); new_cluster.major_version = get_major_server_version(&new_cluster); with this line: cluster->major_version = get_major_server_version(cluster); and changed the comment accordingly. --=_b7eb9c10db995b53aecf71d59d7ae55d Content-Transfer-Encoding: base64 Content-Type: text/x-diff; name=Fixed-exec-c.patch Content-Disposition: attachment; filename=Fixed-exec-c.patch; size=1047 RnJvbSA5YjYzYTdmYzVkMWRjZTZkMjU0YWVjMGFiZTQxMmYyYzFjZDVmODg5IE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBBa2VudGV2YSBBbm5hIDxhLmFrZW50ZXZhQHBvc3RncmVzcHJv LnJ1PgpEYXRlOiBUaHUsIDE2IE5vdiAyMDE3I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