Skip to content

Commit 0b8e0bf

Browse files
committed
Honor PGCTLTIMEOUT environment variable for pg_regress' startup wait.
In commit 2ffa869 we made pg_ctl recognize an environment variable PGCTLTIMEOUT to set the default timeout for starting and stopping the postmaster. However, pg_regress uses pg_ctl only for the "stop" end of that; it has bespoke code for starting the postmaster, and that code has historically had a hard-wired 60-second timeout. Further buildfarm experience says it'd be a good idea if that timeout were also controlled by PGCTLTIMEOUT, so let's make it so. Like the previous patch, back-patch to all active branches. Discussion: <13969.1461191936@sss.pgh.pa.us>
1 parent be27544 commit 0b8e0bf

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

src/test/regress/pg_regress.c

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2185,6 +2185,8 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc
21852185
if (temp_instance)
21862186
{
21872187
FILE *pg_conf;
2188+
const char *env_wait;
2189+
int wait_seconds;
21882190

21892191
/*
21902192
* Prepare the temp instance
@@ -2334,11 +2336,23 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc
23342336
}
23352337

23362338
/*
2337-
* Wait till postmaster is able to accept connections (normally only a
2338-
* second or so, but Cygwin is reportedly *much* slower). Don't wait
2339-
* forever, however.
2339+
* Wait till postmaster is able to accept connections; normally this
2340+
* is only a second or so, but Cygwin is reportedly *much* slower, and
2341+
* test builds using Valgrind or similar tools might be too. Hence,
2342+
* allow the default timeout of 60 seconds to be overridden from the
2343+
* PGCTLTIMEOUT environment variable.
23402344
*/
2341-
for (i = 0; i < 60; i++)
2345+
env_wait = getenv("PGCTLTIMEOUT");
2346+
if (env_wait != NULL)
2347+
{
2348+
wait_seconds = atoi(env_wait);
2349+
if (wait_seconds <= 0)
2350+
wait_seconds = 60;
2351+
}
2352+
else
2353+
wait_seconds = 60;
2354+
2355+
for (i = 0; i < wait_seconds; i++)
23422356
{
23432357
/* Done if psql succeeds */
23442358
if (system(buf2) == 0)
@@ -2359,9 +2373,10 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc
23592373

23602374
pg_usleep(1000000L);
23612375
}
2362-
if (i >= 60)
2376+
if (i >= wait_seconds)
23632377
{
2364-
fprintf(stderr, _("\n%s: postmaster did not respond within 60 seconds\nExamine %s/log/postmaster.log for the reason\n"), progname, outputdir);
2378+
fprintf(stderr, _("\n%s: postmaster did not respond within %d seconds\nExamine %s/log/postmaster.log for the reason\n"),
2379+
progname, wait_seconds, outputdir);
23652380

23662381
/*
23672382
* If we get here, the postmaster is probably wedged somewhere in

0 commit comments

Comments
 (0)