Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1goZr9-00024n-Il for pgsql-hackers@arkaria.postgresql.org; Tue, 29 Jan 2019 20:19:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1goZr8-0008E7-4o for pgsql-hackers@arkaria.postgresql.org; Tue, 29 Jan 2019 20:19:38 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1goZr7-0008Dw-U5 for pgsql-hackers@lists.postgresql.org; Tue, 29 Jan 2019 20:19:37 +0000 Received: from mail-qt1-f178.google.com ([209.85.160.178]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1goZr3-00066f-OV for pgsql-hackers@lists.postgresql.org; Tue, 29 Jan 2019 20:19:37 +0000 Received: by mail-qt1-f178.google.com with SMTP id r14so23849237qtp.1 for ; Tue, 29 Jan 2019 12:19:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:reply-to:subject:to:cc:references:from :organization:message-id:date:user-agent:mime-version:in-reply-to :content-language; bh=E9YBVXCTOstjiN0+6LE4neLFflcyKeLVwh66iNa83dU=; b=pNZtXXKs62zjg17iFv1ErQreBl1SRbJIHiVf3i0b4VcJN/Elo36pqXT1re0ifzbX86 TUGxYXdQ9jogwVmxNIlYjI2v7OyEDPRf1p0r9erukgizl6eSMoGTw+Y4spKBgrqoauhb 7z8DzMb5TsFU/HfBJyioxeguImwqxd8WPMMnAFGBSwj2R0DpNvgFNWtWWkT8AeKpWtRv VtFRHF+xBcoZaftCSC5vaxBbM8+P6B38JNA3Nsr18QrUw+aqFmz+Hf8pvqb3V1ETnN1y CAK6uim/NPMKZallV/g9OajNyW9w+OeuabmkRplJwFaY9l9DilNy6buZu+5XlpDMWyGL lz0A== X-Gm-Message-State: AJcUukd05T/iO8oe81NNUkZJRjoKgxOQK5DQn/DWxjRvxz8W7LdfhlQz XtkcecyRw31s6vQ+rYF+OaVkcg== X-Google-Smtp-Source: ALg8bN5vHOvZu8Ne8YlqX9rwQgIy4rmIowb5tD8VUxoQXADDvHbTOjZ2faHbiWkN1INyrTmSxfOqEQ== X-Received: by 2002:ac8:3437:: with SMTP id u52mr26239303qtb.237.1548793170698; Tue, 29 Jan 2019 12:19:30 -0800 (PST) Received: from localhost.localdomain (c-24-61-8-151.hsd1.ma.comcast.net. [24.61.8.151]) by smtp.gmail.com with ESMTPSA id n67sm63980562qkd.95.2019.01.29.12.19.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Jan 2019 12:19:29 -0800 (PST) Reply-To: jesper.pedersen@redhat.com Subject: Re: pg_upgrade: Pass -j down to vacuumdb To: Michael Paquier , "Jamison, Kirk" Cc: Peter Eisentraut , "fabriziomello@gmail.com" , Tom Lane , Alvaro Herrera , "pgsql-hackers@lists.postgresql.org" , Bruce Momjian References: <5b7d95ba-8920-357d-1ec6-1084ce34a9e6@redhat.com> <388de5bc-858b-4686-d2e5-d0b21981dd72@redhat.com> <4ce565f9-d21f-039f-8f5a-2e16e6aa1ae4@redhat.com> <20190129050830.GE3121@paquier.xyz> From: Jesper Pedersen Organization: Red Hat Message-ID: <37538daf-5f5b-afed-b3f5-a64e154e6433@redhat.com> Date: Tue, 29 Jan 2019 15:19:28 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <20190129050830.GE3121@paquier.xyz> Content-Type: multipart/mixed; boundary="------------C6D2C4D34E9C414DDE6F7784" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------C6D2C4D34E9C414DDE6F7784 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Hi, On 1/29/19 12:08 AM, Michael Paquier wrote: > On Tue, Jan 29, 2019 at 12:35:30AM +0000, Jamison, Kirk wrote: >> I just checked the patch. >> As per advice, you removed the versioning and specified --jobs. >> The patch still applies, builds and passed the tests successfully. > > I would document the optional VACUUM_OPTS on the page of pg_upgrade. > If Peter thinks it is fine to not do so, that's fine for me as well. > I added most of the documentation back, as requested by Kirk. > It seems to me that the latest patch sent is incorrect for multiple > reasons: > 1) You still enforce -j to use the number of jobs that the caller of > pg_upgrade provides, and we agreed that both things are separate > concepts upthread, no? What has been suggested by Alvaro is to add a > comment so as one can use VACUUM_OPTS with -j optionally, instead of > suggesting a full-fledged vacuumdb command which depends on what > pg_upgrade uses. So there is no actual need for the if/else > complication business. I think it is ok for the echo command to highlight to the user that running --analyze-only using the same amount of jobs will give a faster result. > 2) Perhaps we need to worry about the second vacuumdb --all command, > which may want custom options, which are not necessarily the same as > the options of the first command? I don't think we need to care as it > applies only to an upgraded cluster using something older 8.4, just > wondering.. I think that --all --analyze-in-stages is what most people want. And with the $VACUUMDB_OPTS variable people have an option to put in more, such as -j X. Best regards, Jesper --------------C6D2C4D34E9C414DDE6F7784 Content-Type: text/x-patch; name="v6_0001-Highlight-that-the-jobs-option-isn-t-passed-down-to-.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="v6_0001-Highlight-that-the-jobs-option-isn-t-passed-down-to-"; filename*1=".patch" From b02e1f414e309361595ab3fe84fb6f66bcf63265 Mon Sep 17 00:00:00 2001 From: jesperpedersen Date: Fri, 21 Dec 2018 05:05:31 -0500 Subject: [PATCH] Highlight that the --jobs option isn't passed down to vacuumdb by default. Author: Jesper Pedersen --- doc/src/sgml/ref/pgupgrade.sgml | 6 +++++- src/bin/pg_upgrade/check.c | 28 ++++++++++++++++++++++------ 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/doc/src/sgml/ref/pgupgrade.sgml b/doc/src/sgml/ref/pgupgrade.sgml index 7e1afaf0a5..84a7ccb6f1 100644 --- a/doc/src/sgml/ref/pgupgrade.sgml +++ b/doc/src/sgml/ref/pgupgrade.sgml @@ -395,7 +395,11 @@ NET STOP postgresql-&majorversion; in parallel; a good place to start is the maximum of the number of CPU cores and tablespaces. This option can dramatically reduce the time to upgrade a multi-database server running on a multiprocessor - machine. + machine. Note that this option isn't passed to the + vacuumdb application by default. + The system environment variable VACUUMDB_OPTS can be + used to pass extra options to the vacuumdb + application during the script execution. diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c index fc5aa7010f..847e604088 100644 --- a/src/bin/pg_upgrade/check.c +++ b/src/bin/pg_upgrade/check.c @@ -495,15 +495,31 @@ create_script_for_cluster_analyze(char **analyze_script_file_name) ECHO_QUOTE, ECHO_QUOTE); fprintf(script, "echo %sthis script and run:%s\n", ECHO_QUOTE, ECHO_QUOTE); - fprintf(script, "echo %s \"%s/vacuumdb\" %s--all %s%s\n", ECHO_QUOTE, - new_cluster.bindir, user_specification.data, - /* Did we copy the free space files? */ - (GET_MAJOR_VERSION(old_cluster.major_version) >= 804) ? - "--analyze-only" : "--analyze", ECHO_QUOTE); + if (user_opts.jobs <= 1) + { + fprintf(script, "echo %s \"%s/vacuumdb\" %s--all %s%s\n", ECHO_QUOTE, + new_cluster.bindir, user_specification.data, + /* Did we copy the free space files? */ + (GET_MAJOR_VERSION(old_cluster.major_version) >= 804) ? + "--analyze-only" : "--analyze", ECHO_QUOTE); + } + else + { + fprintf(script, "echo %s \"%s/vacuumdb\" %s--jobs %d --all %s%s\n", ECHO_QUOTE, + new_cluster.bindir, user_specification.data, user_opts.jobs, + /* Did we copy the free space files? */ + (GET_MAJOR_VERSION(old_cluster.major_version) >= 804) ? + "--analyze-only" : "--analyze", ECHO_QUOTE); + } fprintf(script, "echo%s\n\n", ECHO_BLANK); - fprintf(script, "\"%s/vacuumdb\" %s--all --analyze-in-stages\n", +#ifndef WIN32 + fprintf(script, "\"%s/vacuumdb\" %s$VACUUMDB_OPTS --all --analyze-in-stages\n", new_cluster.bindir, user_specification.data); +#else + fprintf(script, "\"%s\\vacuumdb.exe\" %s%%VACUUMDB_OPTS%% --all --analyze-in-stages\n", + new_cluster.bindir, user_specification.data); +#endif /* Did we copy the free space files? */ if (GET_MAJOR_VERSION(old_cluster.major_version) < 804) fprintf(script, "\"%s/vacuumdb\" %s--all\n", new_cluster.bindir, -- 2.17.2 --------------C6D2C4D34E9C414DDE6F7784--