From: Stephen Frost <sfrost@snowman.net>
To: Ashutosh Bapat <ashutosh.bapat@enterprisedb.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Subject: Re: pg_restore accepts -j -1
Date: Wed, 11 Jan 2017 11:48:25 -0500
Message-ID: <20170111164825.GL18360@tamriel.snowman.net> (raw)
In-Reply-To: <20170111143643.GK18360@tamriel.snowman.net>
References: <20170110044815.GC18360@tamriel.snowman.net>
<CAFjFpRdSP_N8ZL=sXGvmZR1hF=PuieLyK3Xsvh=jr1v2Kf-70w@mail.gmail.com>
<20170111143643.GK18360@tamriel.snowman.net>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>
Ashutosh,
* Stephen Frost (sfrost@snowman.net) wrote:
> Attached patch adds the same check to pg_restore that's in pg_dump
> already. Looks like it should back-patch to 9.3 pretty cleanly and I'll
> add a similar check for 9.2.
After playing with this, it seems entirely wrong to wait until after we
try to open the archive before we finish checking the validity of the
options, so I moved these checks up to a more sensible location.
> Any thoughts about adding the Windows-specific MAXIMUM_WAIT_OBJECTS
> check to 9.2 pg_restore..? It certainly looks entirely straight-forward
> to do, and though I don't recall hearing anyone complaining about trying
> to run pg_restore on Windows with lots of jobs and having it fall over,
> it might avoid a bit of frustration for anyone who does try.
The more I think about it, the more it seems like this is something we
should have back-patched when we added that check, so I'll go ahead and
add that check to 9.2 also.
Updated patch attached.
I'll plan to push these changes later on this afternoon.
Thanks!
Stephen
Attachments:
[text/x-diff] check_numworkers_pg_restore_master_v2.patch (1.2K, ../20170111164825.GL18360@tamriel.snowman.net/2-check_numworkers_pg_restore_master_v2.patch)
download | inline diff:diff --git a/src/bin/pg_dump/pg_restore.c b/src/bin/pg_dump/pg_restore.cnew file mode 100644index b21fd26..239b0d8
*** a/src/bin/pg_dump/pg_restore.c
--- b/src/bin/pg_dump/pg_restore.c
*************** main(int argc, char **argv)
*** 330,335 ****
--- 330,351 ----
exit_nicely(1);
}
+ if (numWorkers <= 0)+ {+ fprintf(stderr, _("%s: invalid number of parallel jobs\n"), progname);+ exit(1);+ }+ + /* See comments in pg_dump.c */+ #ifdef WIN32+ if (numWorkers > MAXIMUM_WAIT_OBJECTS)+ {+ fprintf(stderr, _("%s: maximum number of parallel jobs is %d\n"),+ progname, MAXIMUM_WAIT_OBJECTS);+ exit(1);+ }+ #endif+
/* Can't do single-txn mode with multiple connections */
if (opts->single_txn && numWorkers > 1)
{
*************** main(int argc, char **argv)
*** 402,417 ****
if (opts->tocFile)
SortTocFromFile(AH);
- /* See comments in pg_dump.c */- #ifdef WIN32- if (numWorkers > MAXIMUM_WAIT_OBJECTS)- {- fprintf(stderr, _("%s: maximum number of parallel jobs is %d\n"),- progname, MAXIMUM_WAIT_OBJECTS);- exit(1);- }- #endif-
AH->numWorkers = numWorkers;
if (opts->tocSummary)
--- 418,423 ----
[application/pgp-signature] signature.asc (818B, ../20170111164825.GL18360@tamriel.snowman.net/3-signature.asc)
download
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: sfrost@snowman.net, ashutosh.bapat@enterprisedb.com
Subject: Re: pg_restore accepts -j -1
In-Reply-To: <20170111164825.GL18360@tamriel.snowman.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox