# Last modification: # 2009-01-19 H.Hunger Fix Bug#39108 main.wait_timeout fails sporadically # - Increase wait timeout to 2 seconds # - Eliminated the corresponding opt file, # set global wait timeout within the test. # - Replaced sleeps by wait condition # - Minor improvements ############################################################################### # These tests cannot run with the embedded server -- source include/not_embedded.inc -- source include/one_thread_per_connection.inc # ML: 1. Already done: Trailing spaces removed, fix typo's # 2. Already done: CONNECT/DISCONNECT replaced by lowercase words. It's no SQL and # we write mysqltest builtin commands usually lowercase. # 3. Messages printed into the protocol telling when a session is # switched, reconnect is disabled/enabled, we wait etc. would be nice. # # # Bug#8731: wait_timeout does not work on Mac OS X # let $start_value= `SELECT @@global.wait_timeout`; SET @@global.wait_timeout= 2; disconnect default; # Connect with another connection and reset counters # ML: Where is the "reset counters" which is mentioned within the comment? # I think this is no more valid because the FLUSH is removed. --disable_query_log connect (wait_con,localhost,root,,test,,); connection wait_con; SET SESSION wait_timeout=100; # ML: session to uppercase, is keyword let $retries=300; SET @aborted_clients= 0; --enable_query_log # Disable reconnect and do the query connect (default,localhost,root,,test,,); connection default; --disable_reconnect SELECT 1; # Switch to wait_con and wait until server has aborted the connection --disable_query_log connection wait_con; while (!`select @aborted_clients`) { real_sleep 0.1; # ML: Pure "sleep " might be replaced by mysql-test-run.pl startup # option setting it for example to a real world "sleep 5 seconds". # I assume this is not intended here. # Anyway this weakness was already within the original test. let $aborted_clients = `SHOW STATUS LIKE 'aborted_clients'`; eval SET @aborted_clients= SUBSTRING('$aborted_clients', 16)+0; dec $retries; if (!$retries) { Failed to detect that client has been aborted; # ML: It looks like the author wants to get a "parse error" in case # the connection does not get aborted. unusual but ok } } --enable_query_log # The server has disconnected, add small sleep to make sure # the disconnect has reached client let $wait_condition= SELECT COUNT(*)=1 FROM information_schema.processlist; --source include/wait_condition.inc connection default; # When the connection is closed in this way, the error code should # be consistent see Bug#2845 for an explanation # depending on platform/client, either errno 2006 or 2013 can occur below --error 2006,2013 SELECT 2; --enable_reconnect SELECT 3; # Disconnect so that we will not be confused by a future abort from this # connection. disconnect default; # # Do the same test as above on a TCP connection # (which we get by specifying an ip adress) # Connect with another connection and reset counters --disable_query_log connection wait_con; FLUSH STATUS; # Reset counters let $retries=300; SET @aborted_clients= 0; --enable_query_log connect (con1,127.0.0.1,root,,test,$MASTER_MYPORT,); --disable_reconnect SELECT 1; # Switch to wait_con and wait until server has aborted the connection --disable_query_log connection wait_con; while (!`select @aborted_clients`) { real_sleep 0.1; # ML: Pure "sleep " might be replaced by mysql-test-run.pl startup # option setting it for example to a real world "sleep 5 seconds". # I assume this is not intended here. # Anyway this weakness was already within the original test. let $aborted_clients = `SHOW STATUS LIKE 'aborted_clients'`; eval SET @aborted_clients= SUBSTRING('$aborted_clients', 16)+0; dec $retries; if (!$retries) { Failed to detect that client has been aborted; } } --enable_query_log # The server has disconnected, add small sleep to make sure # the disconnect has reached client let $wait_condition= SELECT COUNT(*)=1 FROM information_schema.processlist; --source include/wait_condition.inc connection con1; # When the connection is closed in this way, the error code should # be consistent see Bug#2845 for an explanation # depending on platform/client, either errno 2006 or 2013 can occur below --error 2006,2013 SELECT 2; --enable_reconnect SELECT 3; --replace_result $start_value eval SET @@global.wait_timeout= $start_value; # ML: The start value might be changed in future ... disconnect con1;