8000 Honor PGCTLTIMEOUT environment variable for pg_regress' startup wait. · mayoor/postgres@691073b · GitHub
[go: up one dir, main page]

Skip to content

Commit 691073b

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 6ec1ff8 commit 691073b

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
@@ -2389,6 +2389,8 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc
23892389
{
23902390
FILE *pg_conf;
23912391
_stringlist *sl;
2392+
const char *env_wait;
2393+
int wait_seconds;
23922394

23932395
/*
23942396
* Prepare the temp installation
@@ -2562,11 +2564,23 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc
25622564
}
25632565

25642566
/*
2565-
* Wait till postmaster is able to accept connections (normally only a
2566-
* second or so, but Cygwin is reportedly *much* slower). Don't wait
2567-
* forever, however.
2567+
* Wait till postmaster is able to accept connections; normally this
2568+
* is only a second or so, but Cygwin is reportedly *much* slower, and
2569+
* test builds using Valgrind or similar tools might be too. Hence,
2570+
* allow the default timeout of 60 seconds to be overridden from the
2571+
* PGCTLTIMEOUT environment variable.
25682572
*/
2569-
for (i = 0; i < 60; i++)
2573+
env_wait = getenv("PGCTLTIMEOUT");
2574+
if (env_wait != NULL)
2575+
{
2576+
wait_seconds = atoi(env_wait);
2577+
if (wait_seconds <= 0)
2578+
wait_seconds = 60;
2579+
}
2580+
else
2581+
wait_seconds = 60;
2582+
2583+
for (i = 0; i < wait_seconds; i++)
25702584
{
25712585
/* Done if psql succeeds */
25722586
if (system(buf2) == 0)
@@ -2587,9 +2601,10 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc
25872601

25882602
pg_usleep(1000000L);
25892603
}
2590-
if (i >= 60)
2604+
if (i >= wait_seconds)
25912605
{
2592-
fprintf(stderr, _("\n%s: postmaster did not respond within 60 seconds\nExamine %s/log/postmaster.log for the reason\n"), progname, outputdir);
2606+
fprintf(stderr, _("\n%s: postmaster did not respond within %d seconds\nExamine %s/log/postmaster.log for the reason\n"),
2607+
progname, wait_seconds, outputdir);
25932608

25942609
/*
25952610
* If we get here, the postmaster is probably wedged somewhere in

0 commit comments

Comments
 (0)
0