mirror of
				https://github.com/MariaDB/server.git
				synced 2025-11-03 14:33:32 +03:00 
			
		
		
		
	The problem was a race condition in a test case. The fix eliminates the race condition by explicit wait on UNIX socket to start accepting connections. The patch affects only test suite (i.e. does not touch server codebase). mysql-test/mysql-test-run.pl: Expose necessary environment variables. mysql-test/r/im_daemon_life_cycle.result: Update result file. mysql-test/t/im_daemon_life_cycle.imtest: Wait for Instance Manager to start accepting connections after restart. mysql-test/t/wait_for_socket.sh: Helper script: waits for UNIX socket to start accepting connections.
		
			
				
	
	
		
			63 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			63 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
#!/bin/sh
 | 
						|
 | 
						|
###########################################################################
 | 
						|
 | 
						|
if [ $# -ne 6 ]; then
 | 
						|
  echo "Usage: wait_for_socket.sh <executable path> <socket path> <username> <password> <db> <timeout>"
 | 
						|
  exit 0
 | 
						|
fi
 | 
						|
 | 
						|
client_exe="$1"
 | 
						|
socket_path="$2"
 | 
						|
username="$3"
 | 
						|
password="$4"
 | 
						|
db="$5"
 | 
						|
total_timeout="$6"
 | 
						|
 | 
						|
###########################################################################
 | 
						|
 | 
						|
if [ -z "$client_exe" ]; then
 | 
						|
  echo "Error: invalid path to client executable ($client_exe)."
 | 
						|
  exit 0;
 | 
						|
fi
 | 
						|
 | 
						|
if [ ! -x "$client_exe" ]; then
 | 
						|
  echo "Error: client by path '$client_exe' is not available."
 | 
						|
  exit 0;
 | 
						|
fi
 | 
						|
 | 
						|
if [ -z "$socket_path" ]; then
 | 
						|
  echo "Error: invalid socket patch."
 | 
						|
  exit 0
 | 
						|
fi
 | 
						|
 | 
						|
###########################################################################
 | 
						|
 | 
						|
client_args="--silent --socket=$socket_path "
 | 
						|
 | 
						|
[ -n "$username" ] && client_args="$client_args --user=$username "
 | 
						|
[ -n "$password" ] && client_args="$client_args --password=$password "
 | 
						|
[ -n "$db" ] && client_args="$client_args $db"
 | 
						|
 | 
						|
###########################################################################
 | 
						|
 | 
						|
cur_attempt=1
 | 
						|
 | 
						|
while true; do
 | 
						|
 | 
						|
  if ( echo 'quit' | "$client_exe" $client_args >/dev/null 2>&1 ); then
 | 
						|
    echo "Success: server is ready to accept connection on socket."
 | 
						|
    exit 0
 | 
						|
  fi
 | 
						|
 | 
						|
  [ $cur_attempt -ge $total_timeout ] && break
 | 
						|
 | 
						|
  sleep 1
 | 
						|
 | 
						|
  cur_attempt=`expr $cur_attempt + 1`
 | 
						|
 | 
						|
done
 | 
						|
 | 
						|
echo "Error: server does not accept connections after $total_timeout seconds."
 | 
						|
exit 0
 |