mirror of
				https://github.com/postgres/postgres.git
				synced 2025-10-31 00:03:57 -04:00 
			
		
		
		
	Honor PGCTLTIMEOUT environment variable for pg_regress' startup wait.
In commit 2ffa86962077c588 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>
This commit is contained in:
		
							parent
							
								
									b4e0f18382
								
							
						
					
					
						commit
						cbabb70f35
					
				| @ -2185,6 +2185,8 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc | |||||||
| 	if (temp_instance) | 	if (temp_instance) | ||||||
| 	{ | 	{ | ||||||
| 		FILE	   *pg_conf; | 		FILE	   *pg_conf; | ||||||
|  | 		const char *env_wait; | ||||||
|  | 		int			wait_seconds; | ||||||
| 
 | 
 | ||||||
| 		/*
 | 		/*
 | ||||||
| 		 * Prepare the temp instance | 		 * Prepare the temp instance | ||||||
| @ -2335,11 +2337,23 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc | |||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		/*
 | 		/*
 | ||||||
| 		 * Wait till postmaster is able to accept connections (normally only a | 		 * Wait till postmaster is able to accept connections; normally this | ||||||
| 		 * second or so, but Cygwin is reportedly *much* slower).  Don't wait | 		 * is only a second or so, but Cygwin is reportedly *much* slower, and | ||||||
| 		 * forever, however. | 		 * test builds using Valgrind or similar tools might be too.  Hence, | ||||||
|  | 		 * allow the default timeout of 60 seconds to be overridden from the | ||||||
|  | 		 * PGCTLTIMEOUT environment variable. | ||||||
| 		 */ | 		 */ | ||||||
| 		for (i = 0; i < 60; i++) | 		env_wait = getenv("PGCTLTIMEOUT"); | ||||||
|  | 		if (env_wait != NULL) | ||||||
|  | 		{ | ||||||
|  | 			wait_seconds = atoi(env_wait); | ||||||
|  | 			if (wait_seconds <= 0) | ||||||
|  | 				wait_seconds = 60; | ||||||
|  | 		} | ||||||
|  | 		else | ||||||
|  | 			wait_seconds = 60; | ||||||
|  | 
 | ||||||
|  | 		for (i = 0; i < wait_seconds; i++) | ||||||
| 		{ | 		{ | ||||||
| 			/* Done if psql succeeds */ | 			/* Done if psql succeeds */ | ||||||
| 			if (system(buf2) == 0) | 			if (system(buf2) == 0) | ||||||
| @ -2360,9 +2374,10 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc | |||||||
| 
 | 
 | ||||||
| 			pg_usleep(1000000L); | 			pg_usleep(1000000L); | ||||||
| 		} | 		} | ||||||
| 		if (i >= 60) | 		if (i >= wait_seconds) | ||||||
| 		{ | 		{ | ||||||
| 			fprintf(stderr, _("\n%s: postmaster did not respond within 60 seconds\nExamine %s/log/postmaster.log for the reason\n"), progname, outputdir); | 			fprintf(stderr, _("\n%s: postmaster did not respond within %d seconds\nExamine %s/log/postmaster.log for the reason\n"), | ||||||
|  | 					progname, wait_seconds, outputdir); | ||||||
| 
 | 
 | ||||||
| 			/*
 | 			/*
 | ||||||
| 			 * If we get here, the postmaster is probably wedged somewhere in | 			 * If we get here, the postmaster is probably wedged somewhere in | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user