Skip to content

Commit 725f0ce

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 b10635b commit 725f0ce

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
@@ -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

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 = FAST_MODE;
8485
static int sig = SIGINT; /* 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)
@@ -2312,6 +2314,7 @@ main(int argc, char **argv)
23122314
{NULL, 0, NULL, 0}
23132315
};
23142316

2317+
char *env_wait;
23152318
int option_index;
23162319
int c;
23172320
pgpid_t killproc = 0;
@@ -2362,6 +2365,10 @@ main(int argc, char **argv)
23622365
}
23632366
#endif
23642367

2368+
env_wait = getenv("PGCTLTIMEOUT");
2369+
if (env_wait != NULL)
2370+
wait_seconds = atoi(env_wait);
2371+
23652372
/*
23662373
* 'Action' can be before or after args so loop over both. Some
23672374
* getopt_long() implementations will reorder argv[] to place all flags
@@ -2439,6 +2446,7 @@ main(int argc, char **argv)
24392446
break;
24402447
case 't':
24412448
wait_seconds = atoi(optarg);
2449+
wait_seconds_arg = true;
24422450
break;
24432451
case 'U':
24442452
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