diff options
author | kroki@mysql.com <> | 2006-04-12 17:37:57 +0400 |
---|---|---|
committer | kroki@mysql.com <> | 2006-04-12 17:37:57 +0400 |
commit | 4a81c0dfb91cc7f768b15a47ab0b1f9dfdf1a4a1 (patch) | |
tree | d5151e758a0c76b0bf8f9faf81fcce929dca3c75 /mysql-test/t/status.test | |
parent | 6222ca41a5066d8dd56d4f4b7aa47d742fd8095e (diff) | |
download | mariadb-git-4a81c0dfb91cc7f768b15a47ab0b1f9dfdf1a4a1.tar.gz |
In test for bug#15933 we have to wait for all disconnects to finish to avoid
a race between updating and checking Max_used_connections. This is done in
a loop until either disconnect finished or timeout expired. In a latter case
the test will fail.
Diffstat (limited to 'mysql-test/t/status.test')
-rw-r--r-- | mysql-test/t/status.test | 65 |
1 files changed, 51 insertions, 14 deletions
diff --git a/mysql-test/t/status.test b/mysql-test/t/status.test index 79a46a38550..1a71425d2a7 100644 --- a/mysql-test/t/status.test +++ b/mysql-test/t/status.test @@ -36,6 +36,10 @@ reap; show status like 'Table_lock%'; drop table t1; +disconnect con2; +disconnect con1; +connection default; + # End of 4.1 tests # @@ -60,48 +64,81 @@ show status like 'last_query_cost'; # taking a thread from the cache as well as when creating new threads # -# Previous test uses con1, con2. If we disconnect them, there will be -# a race on when exactly this will happen, so we better leave them as -# is. -connection default; +# Wait for at most $disconnect_timeout seconds for disconnects to finish. +let $disconnect_timeout = 10; -# Reset max_used_connections from previous tests. +# Wait for any previous disconnects to finish. FLUSH STATUS; +--disable_query_log +--disable_result_log +eval SET @wait_left = $disconnect_timeout; +let $max_used_connections = `SHOW STATUS LIKE 'max_used_connections'`; +eval SET @max_used_connections = SUBSTRING('$max_used_connections', 21)+0; +let $wait_more = `SELECT @max_used_connections != 1 && @wait_left > 0`; +while ($wait_more) +{ + sleep 1; + FLUSH STATUS; + SET @wait_left = @wait_left - 1; + let $max_used_connections = `SHOW STATUS LIKE 'max_used_connections'`; + eval SET @max_used_connections = SUBSTRING('$max_used_connections', 21)+0; + let $wait_more = `SELECT @max_used_connections != 1 && @wait_left > 0`; +} +--enable_query_log +--enable_result_log + +# Prerequisite. SHOW STATUS LIKE 'max_used_connections'; # Save original setting. SET @save_thread_cache_size=@@thread_cache_size; SET GLOBAL thread_cache_size=3; -connect (con3,localhost,root,,); -connect (con4,localhost,root,,); +connect (con1,localhost,root,,); +connect (con2,localhost,root,,); -connection con3; -disconnect con4; +connection con1; +disconnect con2; # Check that max_used_connections still reflects maximum value. SHOW STATUS LIKE 'max_used_connections'; # Check that after flush max_used_connections equals to current number -# of connections. +# of connections. First wait for previous disconnect to finish. FLUSH STATUS; +--disable_query_log +--disable_result_log +eval SET @wait_left = $disconnect_timeout; +let $max_used_connections = `SHOW STATUS LIKE 'max_used_connections'`; +eval SET @max_used_connections = SUBSTRING('$max_used_connections', 21)+0; +let $wait_more = `SELECT @max_used_connections != 2 && @wait_left > 0`; +while ($wait_more) +{ + sleep 1; + FLUSH STATUS; + SET @wait_left = @wait_left - 1; + let $max_used_connections = `SHOW STATUS LIKE 'max_used_connections'`; + eval SET @max_used_connections = SUBSTRING('$max_used_connections', 21)+0; + let $wait_more = `SELECT @max_used_connections != 2 && @wait_left > 0`; +} +--enable_query_log +--enable_result_log +# Check that we don't count disconnected thread any longer. SHOW STATUS LIKE 'max_used_connections'; # Check that max_used_connections is updated when cached thread is # reused... -connect (con4,localhost,root,,); +connect (con2,localhost,root,,); SHOW STATUS LIKE 'max_used_connections'; # ...and when new thread is created. -connect (con5,localhost,root,,); +connect (con3,localhost,root,,); SHOW STATUS LIKE 'max_used_connections'; # Restore original setting. connection default; SET GLOBAL thread_cache_size=@save_thread_cache_size; -disconnect con5; -disconnect con4; disconnect con3; disconnect con2; disconnect con1; |