diff options
author | Noah Misch <noah@leadboat.com> | 2016-02-10 20:34:02 -0500 |
---|---|---|
committer | Noah Misch <noah@leadboat.com> | 2016-02-10 20:34:35 -0500 |
commit | 198242ede432f78561eb043c412a19fc88ddbed9 (patch) | |
tree | 668200851932b17ad767ed291b70687c897a8d03 /src | |
parent | 24ce5754ae676b5b01a8451fbcc9f516ef6111fc (diff) |
Accept pg_ctl timeout from the PGCTLTIMEOUT environment variable.
Many automated test suites call pg_ctl. Buildfarm members axolotl,
hornet, mandrill, shearwater, sungazer and tern have failed when server
shutdown took longer than the pg_ctl default 60s timeout. This addition
permits slow hosts to easily raise the timeout without us editing a
--timeout argument into every test suite pg_ctl call. Back-patch to 9.1
(all supported versions) for the sake of automated testing.
Reviewed by Tom Lane.
Diffstat (limited to 'src')
-rw-r--r-- | src/bin/pg_ctl/pg_ctl.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index a8a8564599d..4889e3a1a3f 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -79,6 +79,7 @@ typedef enum static bool do_wait = false; static bool wait_set = false; static int wait_seconds = DEFAULT_WAIT; +static bool wait_seconds_arg = false; static bool silent_mode = false; static ShutdownMode shutdown_mode = SMART_MODE; static int sig = SIGTERM; /* default */ @@ -1379,7 +1380,8 @@ pgwin32_CommandLine(bool registration) if (registration && do_wait) appendPQExpBuffer(cmdLine, " -w"); - if (registration && wait_seconds != DEFAULT_WAIT) + /* Don't propagate a value from an environment variable. */ + if (registration && wait_seconds_arg && wait_seconds != DEFAULT_WAIT) appendPQExpBuffer(cmdLine, " -t %d", wait_seconds); if (registration && silent_mode) @@ -2214,6 +2216,7 @@ main(int argc, char **argv) {NULL, 0, NULL, 0} }; + char *env_wait; int option_index; int c; pgpid_t killproc = 0; @@ -2265,6 +2268,10 @@ main(int argc, char **argv) } #endif + env_wait = getenv("PGCTLTIMEOUT"); + if (env_wait != NULL) + wait_seconds = atoi(env_wait); + /* * 'Action' can be before or after args so loop over both. Some * getopt_long() implementations will reorder argv[] to place all flags @@ -2334,6 +2341,7 @@ main(int argc, char **argv) break; case 't': wait_seconds = atoi(optarg); + wait_seconds_arg = true; break; case 'U': if (strchr(optarg, '\\')) |