diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 18:00:34 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 18:00:34 +0000 |
commit | 3f619478f796eddbba6e39502fe941b285dd97b1 (patch) | |
tree | e2c7b5777f728320e5b5542b6213fd3591ba51e2 /mysql-test/suite/perfschema/t/thread_cache.test | |
parent | Initial commit. (diff) | |
download | mariadb-upstream.tar.xz mariadb-upstream.zip |
Adding upstream version 1:10.11.6.upstream/1%10.11.6upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'mysql-test/suite/perfschema/t/thread_cache.test')
-rw-r--r-- | mysql-test/suite/perfschema/t/thread_cache.test | 173 |
1 files changed, 173 insertions, 0 deletions
diff --git a/mysql-test/suite/perfschema/t/thread_cache.test b/mysql-test/suite/perfschema/t/thread_cache.test new file mode 100644 index 00000000..92309bb9 --- /dev/null +++ b/mysql-test/suite/perfschema/t/thread_cache.test @@ -0,0 +1,173 @@ +# Tests for PERFORMANCE_SCHEMA + +--source include/not_embedded.inc +--source include/have_perfschema.inc + +# +# Important note: +# this test is extremely sensitive to how threads are running inside the server, +# so it has it's own -master.opt file, to enforce it runs alone in mysqld +# + +# Setup + +flush status; + +SET @saved_thread_cache_size = @@global.thread_cache_size; + +set global thread_cache_size = 0; + +show global variables like "thread_cache_size"; + +connect (con1, localhost, root, , ); + +let $con1_ID=`select connection_id()`; + +let $con1_THREAD_ID=`select thread_id from performance_schema.threads + where PROCESSLIST_ID = connection_id()`; + +connect (con2, localhost, root, , ); + +let $con2_ID=`select connection_id()`; + +let $con2_THREAD_ID=`select thread_id from performance_schema.threads + where PROCESSLIST_ID = connection_id()`; + +--connection default + +--disable_query_log +eval select ($con2_ID - $con1_ID) into @id_increment; +eval select ($con2_THREAD_ID - $con1_THREAD_ID) into @thread_id_increment; +--enable_query_log + +# Expect 1, connection_id() is incremented for each new connection +select @id_increment; +# Expect 1, THREAD_ID is incremented for each new connection +select @thread_id_increment; + +--disconnect con2 + +--connection default + +# Debug +# select * from performance_schema.threads +# where name like "thread/sql/one_connection"; + +# Wait for the disconnect con2 to complete +let $wait_condition= + select count(*) = 2 from performance_schema.threads + where name like "thread/sql/one_connection"; +--source include/wait_condition.inc + +connect (con3, localhost, root, , ); + +let $con3_ID=`select connection_id()`; + +let $con3_THREAD_ID=`select thread_id from performance_schema.threads + where PROCESSLIST_ID = connection_id()`; + +--disconnect con3 +--disconnect con1 + +--connection default + +# Debug +# select * from performance_schema.threads +# where name like "thread/sql/one_connection"; + +# Wait for the disconnect con1 and con3 to complete +let $wait_condition= + select count(*) = 1 from performance_schema.threads + where name like "thread/sql/one_connection"; +--source include/wait_condition.inc + +--disable_query_log +eval select ($con3_ID - $con2_ID) into @id_increment; +eval select ($con3_THREAD_ID - $con2_THREAD_ID) into @thread_id_increment; +--enable_query_log + +select @id_increment; +select @thread_id_increment; + +set global thread_cache_size = 100; + +show global variables like "thread_cache_size"; + +connect (con1, localhost, root, , ); + +let $con1_ID=`select connection_id()`; + +let $con1_THREAD_ID=`select thread_id from performance_schema.threads + where PROCESSLIST_ID = connection_id()`; + +connect (con2, localhost, root, , ); + +let $con2_ID=`select connection_id()`; + +let $con2_THREAD_ID=`select thread_id from performance_schema.threads + where PROCESSLIST_ID = connection_id()`; + +--connection default + +--disable_query_log +eval select ($con2_ID - $con1_ID) into @id_increment; +eval select ($con2_THREAD_ID - $con1_THREAD_ID) into @thread_id_increment; +--enable_query_log + +select @id_increment; +select @thread_id_increment; + +--disconnect con2 + +--connection default + +# Debug +# select * from performance_schema.threads +# where name like "thread/sql/one_connection"; + +# Wait for the disconnect con2 to complete +let $wait_condition= + select count(*) = 2 from performance_schema.threads + where name like "thread/sql/one_connection"; +--source include/wait_condition.inc + +connect (con3, localhost, root, , ); + +let $con3_ID=`select connection_id()`; + +let $con3_THREAD_ID=`select thread_id from performance_schema.threads + where PROCESSLIST_ID = connection_id()`; + +--disconnect con3 +--disconnect con1 + +--connection default + +# Debug +# select * from performance_schema.threads +# where name like "thread/sql/one_connection"; + +# Wait for the disconnect con1 and con3 to complete +let $wait_condition= + select count(*) = 1 from performance_schema.threads + where name like "thread/sql/one_connection"; +--source include/wait_condition.inc + +--disable_query_log +eval select ($con3_ID - $con2_ID) into @id_increment; +eval select ($con3_THREAD_ID - $con2_THREAD_ID) into @thread_id_increment; +--enable_query_log + +# When caching threads, the pthread that executed con2 was parked in the +# cache on disconnect, and then picked up con3. + +# Still expect a new connection_id() +select @id_increment; + +# And expect a new instrumentation: the THREAD_ID of old connections should not be reused. +select @thread_id_increment; + +set global thread_cache_size = @saved_thread_cache_size; + +show global status like "performance_schema_thread%"; + |