Skip to content

Commit 4492ab5

Browse files
committed
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.
1 parent 19e4694 commit 4492ab5

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

doc/src/sgml/ref/pg_ctl-ref.sgml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,9 @@ PostgreSQL documentation
361361
<listitem>
362362
<para>
363363
The maximum number of seconds to wait when waiting for startup or
364-
shutdown to complete. The default is 60 seconds.
364+
shutdown to complete. Defaults to the value of the
365+
<envar>PGCTLTIMEOUT</> environment variable or, if not set, to 60
366+
seconds.
365367
</para>
366368
</listitem>
367369
</varlistentry>
@@ -469,6 +471,17 @@ PostgreSQL documentation
469471
<title>Environment</title>
470472

471473
<variablelist>
474+
<varlistentry>
475+
<term><envar>PGCTLTIMEOUT</envar></term>
476+
477+
<listitem>
478+
<para>
479+
Default limit on the number of seconds to wait when waiting for startup
480+
or shutdown to complete. If not set, the default is 60 seconds.
481+
</para>
482+
</listitem>
483+
</varlistentry>
484+
472485
<varlistentry>
473486
<term><envar>PGDATA</envar></term>
474487

src/bin/pg_ctl/pg_ctl.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ typedef enum
7979
static bool do_wait = false;
8080
static bool wait_set = false;
8181
static int wait_seconds = DEFAULT_WAIT;
82+
static bool wait_seconds_arg = false;
8283
static bool silent_mode = false;
8384
static ShutdownMode shutdown_mode = SMART_MODE;
8485
static int sig = SIGTERM; /* default */
@@ -1456,7 +1457,8 @@ pgwin32_CommandLine(bool registration)
14561457
if (registration && do_wait)
14571458
appendPQExpBuffer(cmdLine, " -w");
14581459

1459-
if (registration && wait_seconds != DEFAULT_WAIT)
1460+
/* Don't propagate a value from an environment variable. */
1461+
if (registration && wait_seconds_arg && wait_seconds != DEFAULT_WAIT)
14601462
appendPQExpBuffer(cmdLine, " -t %d", wait_seconds);
14611463

14621464
if (registration && silent_mode)
@@ -2291,6 +2293,7 @@ main(int argc, char **argv)
22912293
{NULL, 0, NULL, 0}
22922294
};
22932295

2296+
char *env_wait;
22942297
int option_index;
22952298
int c;
22962299
pgpid_t killproc = 0;
@@ -2341,6 +2344,10 @@ main(int argc, char **argv)
23412344
}
23422345
#endif
23432346

2347+
env_wait = getenv("PGCTLTIMEOUT");
2348+
if (env_wait != NULL)
2349+
wait_seconds = atoi(env_wait);
2350+
23442351
/*
23452352
* 'Action' can be before or after args so loop over both. Some
23462353
* getopt_long() implementations will reorder argv[] to place all flags
@@ -2406,6 +2413,7 @@ main(int argc, char **argv)
24062413
break;
24072414
case 't':
24082415
wait_seconds = atoi(optarg);
2416+
wait_seconds_arg = true;
24092417
break;
24102418
case 'U':
24112419
if (strchr(optarg, '\\'))

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy