mirror of
				https://github.com/MariaDB/server.git
				synced 2025-11-03 14:33:32 +03:00 
			
		
		
		
	The problem was in a test case for Bug33507:
  - when the number of active connections reaches the limit,
    the server accepts only root connections. That's achieved by
    accepting a connection, negotiating with the client and
    checking user credentials. If it is not SUPER, the connection
    is dropped.
  - when the server accepts connection, it increases the counter;
  - when the server drops connection, it decreases the counter;
  - the race was in between of decreasing the counter and accepting
    new connection:
    - max_user_connections = 2;
    - 2 oridinary user connections accepted;
    - extra user connection is establishing;
    - server checked user credentials, and sent 'Too many connections'
      error;
    - the client receives the error and establishes extra SUPER user
      connection;
    - the server however didn't decrease the counter (the extra
      user connection still is "alive" in the server) -- so, the new
      SUPER-user connection, will be dropped, because it exceeds
      (max_user_connections + 1).
The fix is to implement "safe connect", which makes several attempts
to connect and use it in the test script.
		
	
		
			
				
	
	
		
			57 lines
		
	
	
		
			977 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			57 lines
		
	
	
		
			977 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
# include/connect2.inc
 | 
						|
#
 | 
						|
# SUMMARY
 | 
						|
# 
 | 
						|
#   Make several attempts to connect.
 | 
						|
#
 | 
						|
# USAGE
 | 
						|
#
 | 
						|
# EXAMPLE
 | 
						|
# 
 | 
						|
#   connect.test
 | 
						|
#
 | 
						|
 | 
						|
--disable_query_log
 | 
						|
 | 
						|
let $wait_counter= 300;
 | 
						|
if ($wait_timeout)
 | 
						|
{
 | 
						|
  let $wait_counter= `SELECT $wait_timeout * 10`;
 | 
						|
}
 | 
						|
# Reset $wait_timeout so that its value won't be used on subsequent
 | 
						|
# calls, and default will be used instead.
 | 
						|
let $wait_timeout= 0;
 | 
						|
 | 
						|
--echo # -- Establishing connection '$con_name' (user: $con_user_name)...
 | 
						|
 | 
						|
while ($wait_counter)
 | 
						|
{
 | 
						|
    --disable_abort_on_error
 | 
						|
    --disable_result_log
 | 
						|
    --connect ($con_name,localhost,$con_user_name)
 | 
						|
    --enable_result_log
 | 
						|
    --enable_abort_on_error
 | 
						|
 | 
						|
    let $error = $mysql_errno;
 | 
						|
 | 
						|
    if (!$error)
 | 
						|
    {
 | 
						|
        let $wait_counter= 0;
 | 
						|
    }
 | 
						|
    if ($error)
 | 
						|
    {
 | 
						|
        real_sleep 0.1;
 | 
						|
        dec $wait_counter;
 | 
						|
    }
 | 
						|
}
 | 
						|
if ($error)
 | 
						|
{
 | 
						|
  --echo # -- Error: can not establish connection '$con_name'.
 | 
						|
}
 | 
						|
if (!$error)
 | 
						|
{
 | 
						|
  --echo # -- Connection '$con_name' has been established.
 | 
						|
}
 | 
						|
 | 
						|
--enable_query_log
 |