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

Commit cbabb70

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 b4e0f18 commit cbabb70

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
@@ -2335,11 +2337,23 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc
23352337
}
23362338

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

23612375
pg_usleep(1000000L);
23622376
}
2363-
if (i >= 60)
2377+
if (i >= wait_seconds)
23642378
{
2365-
fprintf(stderr, _("\n%s: postmaster did not respond within 60 seconds\nExamine %s/log/postmaster.log for the reason\n"), progname, outputdir);
2379+
fprintf(stderr, _("\n%s: postmaster did not respond within %d seconds\nExamine %s/log/postmaster.log for the reason\n"),
2380+
progname, wait_seconds, outputdir);
23662381

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

0 commit comments

Comments
 (0)