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 1gpeGv-0004ny-0V for pgsql-hackers@arkaria.postgresql.org; Fri, 01 Feb 2019 19:14:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gpeGt-0000tD-BO for pgsql-hackers@arkaria.postgresql.org; Fri, 01 Feb 2019 19:14:39 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gpeGt-0000t6-0O for pgsql-hackers@lists.postgresql.org; Fri, 01 Feb 2019 19:14:39 +0000 Received: from mail-qt1-f194.google.com ([209.85.160.194]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gpeGl-00055O-N9 for pgsql-hackers@lists.postgresql.org; Fri, 01 Feb 2019 19:14:37 +0000 Received: by mail-qt1-f194.google.com with SMTP id n32so8796226qte.11 for ; Fri, 01 Feb 2019 11:14:30 -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=OVnSlGVnT7CWMTaJeV85h/wWddjKKpDQuN3qzfe0uqk=; b=o9d3tC+X/4QOyXNf8USjKIgxrQSbf8wBKr+f5lGtlhHlP5abOzeOI96XIWu218L/Hu kf4A6r0rOnZ7x4ioEnZSxuJMlN0YFWJeyuG/CYYcwORuepTtXEvRSNSbyHmGJg8+uIk2 pWM+IkMrroAsvhZsBjLeFMfOOzurIQtB6Sn7u2ed+RgIdhOwkIyex0+3WAif2TKcfYaV WiqRy702fUdRmh0+pU0IoyyYhQgyxAcDQUa+kyGu2FjiBz5lQDE0ccvqnevBQSSiVAfd dl7ZebwKXFShXhicfR21MVpu1QaXARu2pb1YYt9qRY47bc8gqEiOuHCEoDNAj7g1gfve Svkw== X-Gm-Message-State: AJcUukeqhHIPYJa2tSU41KNhN9hLeiD0w3C/vYq6W4IucMjmAYQE3ouT 87BjbTOyTK7VCwLHXGJSS4z2VQ== X-Google-Smtp-Source: ALg8bN5rj28yz3/u0AIu63IoKmLgkau5AUWKjbr1AqRY3KPLU+REeTG8re8V0MPMqp41dReo8b0R0g== X-Received: by 2002:a0c:e610:: with SMTP id z16mr38527601qvm.81.1549048469546; Fri, 01 Feb 2019 11:14:29 -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 u11sm9608651qtc.61.2019.02.01.11.14.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Feb 2019 11:14:28 -0800 (PST) Reply-To: jesper.pedersen@redhat.com Subject: Re: pg_upgrade: Pass -j down to vacuumdb To: Alvaro Herrera , "Jamison, Kirk" Cc: Michael Paquier , Peter Eisentraut , "fabriziomello@gmail.com" , Tom Lane , "pgsql-hackers@lists.postgresql.org" , Bruce Momjian References: <201902010958.cf2cbi3d2ule@alvherre.pgsql> From: Jesper Pedersen Organization: Red Hat Message-ID: Date: Fri, 1 Feb 2019 14:14:27 -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: <201902010958.cf2cbi3d2ule@alvherre.pgsql> Content-Type: multipart/mixed; boundary="------------1625A89444BEE0D4B5C9189B" 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. --------------1625A89444BEE0D4B5C9189B Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Hi, On 2/1/19 4:58 AM, Alvaro Herrera wrote: > On 2019-Feb-01, Jamison, Kirk wrote: > >> I'm not sure if misunderstood the purpose of $VACUUMDB_OPTS. I thought what >> the other developers suggested is to utilize it so that --jobs for vacuumdb >> would be optional and just based from user-specified option $VACUUMDB_OPTS. >> By which it would not utilize the amount of jobs used for pg_upgrade. >> To address your need of needing a parallel, the script would just then >> suggest if the user wants a --jobs option. The if/else for number of jobs is >> not needed in that case, maybe only for ifndef WIN32 else case. > > No Kirk, you got it right -- (some of) those ifdefs are not needed, as > adding the --jobs in the command line is not needed. I do think some > extra whitespace in the format string is needed. > I'm confused by this. The point of the patch is to highlight to the user that even though he/she does "pg_upgrade -j 8" the "-j 8" option isn't passed down to vacuumdb. Default value is 1, so in that case the echo command doesn't highlight that fact, otherwise it is. The user can then cancel the script and use the suggested command line. The script then executes the vaccumdb command with the $VACUUMDB_OPTS argument as noted in the documentation. Sample script attached as well. I added extra space in the --analyze-in-stages part. Kirk, can you provide a delta patch to match what you are thinking ? Best regards, Jesper --------------1625A89444BEE0D4B5C9189B Content-Type: text/x-patch; name="v7_0001-Highlight-that-the-jobs-option-isn-t-passed-down-to-.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="v7_0001-Highlight-that-the-jobs-option-isn-t-passed-down-to-"; filename*1=".patch" From 4b5856725af5d971a26a2ba150c1067ee21bb242 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..570b7c9ae7 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 --------------1625A89444BEE0D4B5C9189B Content-Type: application/x-shellscript; name="analyze_new_cluster.sh" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="analyze_new_cluster.sh" IyEvYmluL3NoCgplY2hvICdUaGlzIHNjcmlwdCB3aWxsIGdlbmVyYXRlIG1pbmltYWwgb3B0 aW1pemVyIHN0YXRpc3RpY3MgcmFwaWRseScKZWNobyAnc28geW91ciBzeXN0ZW0gaXMgdXNh YmxlLCBhbmQgdGhlbiBnYXRoZXIgc3RhdGlzdGljcyB0d2ljZSBtb3JlJwplY2hvICd3aXRo IGluY3JlYXNpbmcgYWNjdXJhY3kuICBXaGVuIGl0IGlzIGRvbmUsIHlvdXIgc3lzdGVtIHdp bGwnCmVjaG8gJ2hhdmUgdGhlIGRlZmF1bHQgbGV2ZWwgb2Ygb3B0aW1pemVyIHN0YXRpc3Rp Y3MuJwplY2hvCgplY2hvICdJZiB5b3UgaGF2ZSB1c2VkIEFMVEVSIFRBQkxFIHRvIG1vZGlm eSB0aGUgc3RhdGlzdGljcyB0YXJnZXQgZm9yJwplY2hvICdhbnkgdGFibGVzLCB5b3UgbWln aHQgd2FudCB0byByZW1vdmUgdGhlbSBhbmQgcmVzdG9yZSB0aGVtIGFmdGVyJwplY2hvICdy dW5uaW5nIHRoaXMgc2NyaXB0IGJlY2F1c2UgdGhleSB3aWxsIGRlbGF5IGZhc3Qgc3RhdGlz dGljcyBnZW5lcmF0aW9uLicKZWNobwoKZWNobyAnSWYgeW91IHdvdWxkIGxpa2UgZGVmYXVs dCBzdGF0aXN0aWNzIGFzIHF1aWNrbHkgYXMgcG9zc2libGUsIGNhbmNlbCcKZWNobyAndGhp cyBzY3JpcHQgYW5kIHJ1bjonCmVjaG8gJyAgICAiL2hvbWUvanBlZGVyc2VuL3Bnc3FsL3Bv c3RncmVzcWwtMTIueC9iaW4vdmFjdXVtZGIiIC0tam9icyA4IC0tYWxsIC0tYW5hbHl6ZS1v bmx5JwplY2hvCgoiL2hvbWUvanBlZGVyc2VuL3Bnc3FsL3Bvc3RncmVzcWwtMTIueC9iaW4v dmFjdXVtZGIiICRWQUNVVU1EQl9PUFRTIC0tYWxsIC0tYW5hbHl6ZS1pbi1zdGFnZXMKZWNo bwoKZWNobyAnRG9uZScK --------------1625A89444BEE0D4B5C9189B--