Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 2ffa869

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 51e78ab commit 2ffa869

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

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

+14-1
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,9 @@ PostgreSQL documentation
362362
<listitem>
363363
<para>
364364
The maximum number of seconds to wait when waiting for startup or
365-
shutdown to complete. The default is 60 seconds.
365+
shutdown to complete. Defaults to the value of the
366+
<envar>PGCTLTIMEOUT</> environment variable or, if not set, to 60
367+
seconds.
366368
</para>
367369
</listitem>
368370
</varlistentry>
@@ -486,6 +488,17 @@ PostgreSQL documentation
486488
<title>Environment</title>
487489

488490
<variablelist>
491+
<varlistentry>
492+
<term><envar>PGCTLTIMEOUT</envar></term>
493+
494+
<listitem>
495+
<para>
496+
Default limit on the number of seconds to wait when waiting for startup
497+
or shutdown to complete. If not set, the default is 60 seconds.
498+
</para>
499+
</listitem>
500+
</varlistentry>
501+
489502
<varlistentry>
490503
<term><envar>PGDATA</envar></term>
491504

src/bin/pg_ctl/pg_ctl.c

+9-1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ typedef enum
7272
static bool do_wait = false;
7373
static bool wait_set = false;
7474
static int wait_seconds = DEFAULT_WAIT;
75+
static bool wait_seconds_arg = false;
7576
static bool silent_mode = false;
7677
static ShutdownMode shutdown_mode = FAST_MODE;
7778
static int sig = SIGINT; /* default */
@@ -1431,7 +1432,8 @@ pgwin32_CommandLine(bool registration)
14311432
if (registration && do_wait)
14321433
appendPQExpBuffer(cmdLine, " -w");
14331434

1434-
if (registration && wait_seconds != DEFAULT_WAIT)
1435+
/* Don't propagate a value from an environment variable. */
1436+
if (registration && wait_seconds_arg && wait_seconds != DEFAULT_WAIT)
14351437
appendPQExpBuffer(cmdLine, " -t %d", wait_seconds);
14361438

14371439
if (registration && silent_mode)
@@ -2128,6 +2130,7 @@ main(int argc, char **argv)
21282130
{NULL, 0, NULL, 0}
21292131
};
21302132

2133+
char *env_wait;
21312134
int option_index;
21322135
int c;
21332136
pgpid_t killproc = 0;
@@ -2178,6 +2181,10 @@ main(int argc, char **argv)
21782181
}
21792182
#endif
21802183

2184+
env_wait = getenv("PGCTLTIMEOUT");
2185+
if (env_wait != NULL)
2186+
wait_seconds = atoi(env_wait);
2187+
21812188
/*
21822189
* 'Action' can be before or after args so loop over both. Some
21832190
* getopt_long() implementations will reorder argv[] to place all flags
@@ -2255,6 +2262,7 @@ main(int argc, char **argv)
22552262
break;
22562263
case 't':
22572264
wait_seconds = atoi(optarg);
2265+
wait_seconds_arg = true;
22582266
break;
22592267
case 'U':
22602268
if (strchr(optarg, '\\'))

0 commit comments

Comments
 (0)