diff options
| author | Monty <monty@mariadb.org> | 2016-02-01 12:45:39 +0200 |
|---|---|---|
| committer | Monty <monty@mariadb.org> | 2016-02-07 10:34:03 +0200 |
| commit | 3d4a7390c1a94ef6e07b04b52ea94a95878cda1b (patch) | |
| tree | a53179de37b318e27e48546ed3bc8a723148104a /mysql-test | |
| parent | 076aa182c2d2ee67c233d0e79c900dfba6f593c1 (diff) | |
| download | mariadb-git-3d4a7390c1a94ef6e07b04b52ea94a95878cda1b.tar.gz | |
MDEV-6150 Speed up connection speed by moving creation of THD to new thread
Creating a CONNECT object on client connect and pass this to the working thread which creates the THD.
Split LOCK_thread_count to different mutexes
Added LOCK_thread_start to syncronize threads
Moved most usage of LOCK_thread_count to dedicated functions
Use next_thread_id() instead of thread_id++
Other things:
- Thread id now starts from 1 instead of 2
- Added cast for thread_id as thread id is now of type my_thread_id
- Made THD->host const (To ensure it's not changed)
- Removed some DBUG_PRINT() about entering/exiting mutex as these was already logged by mutex code
- Fixed that aborted_connects and connection_errors_internal are counted in all cases
- Don't take locks for current_linfo when we set it (not needed as it was 0 before)
Diffstat (limited to 'mysql-test')
| -rw-r--r-- | mysql-test/r/connect2.result | 45 | ||||
| -rw-r--r-- | mysql-test/r/log_tables.result | 6 | ||||
| -rw-r--r-- | mysql-test/r/mdev375.result | 3 | ||||
| -rw-r--r-- | mysql-test/r/mysqlbinlog_row_minimal.result | 22 | ||||
| -rw-r--r-- | mysql-test/suite/binlog/r/binlog_reset_master.result | 1 | ||||
| -rw-r--r-- | mysql-test/suite/binlog/t/binlog_reset_master.test | 26 | ||||
| -rw-r--r-- | mysql-test/t/connect2.cnf | 9 | ||||
| -rw-r--r-- | mysql-test/t/connect2.test | 81 | ||||
| -rw-r--r-- | mysql-test/t/mdev375.test | 1 |
9 files changed, 153 insertions, 41 deletions
diff --git a/mysql-test/r/connect2.result b/mysql-test/r/connect2.result new file mode 100644 index 00000000000..5e529db9376 --- /dev/null +++ b/mysql-test/r/connect2.result @@ -0,0 +1,45 @@ +SET @old_debug= @@session.debug; +set @old_thread_cache_size=@@global.thread_cache_size; +select 1; +1 +1 +set global debug_dbug='+d,simulate_failed_connection_1'; +connect(localhost,root,,test,MASTER_PORT,MASTER_SOCKET); +ERROR HY000: Lost connection to MySQL server at 'reading initial communication packet', system error: 95 "Operation not supported" +set global debug_dbug=@old_debug; +set global debug_dbug='+d,simulate_failed_connection_2'; +connect(localhost,root,,test,MASTER_PORT,MASTER_SOCKET); +ERROR HY000: Lost connection to MySQL server at 'reading initial communication packet', system error: 95 "Operation not supported" +set global debug_dbug=@old_debug; +select 1; +1 +1 +select 1; +1 +1 +set global debug_dbug='+d,simulate_failed_connection_1'; +connect(localhost,root,,test,MASTER_PORT,MASTER_SOCKET); +ERROR HY000: Lost connection to MySQL server at 'reading initial communication packet', system error: 95 "Operation not supported" +set global debug_dbug=@old_debug; +set global debug_dbug='+d,simulate_failed_connection_2'; +connect(localhost,root,,test,MASTER_PORT,MASTER_SOCKET); +ERROR HY000: Lost connection to MySQL server at 'reading initial communication packet', system error: 95 "Operation not supported" +set global debug_dbug=@old_debug; +select 1; +1 +1 +set @@global.thread_cache_size=2; +select 1; +1 +1 +select 1; +1 +1 +set global debug_dbug='+d,simulate_failed_connection_2'; +connect(localhost,root,,test,MASTER_PORT,MASTER_SOCKET); +ERROR HY000: Lost connection to MySQL server at 'reading initial communication packet', system error: 95 "Operation not supported" +show status like "Threads_connected"; +Variable_name Value +Threads_connected 1 +set global debug_dbug=@old_debug; +set global thread_cache_size=@old_thread_cache_size; diff --git a/mysql-test/r/log_tables.result b/mysql-test/r/log_tables.result index ff5055e1ae4..b37ea359953 100644 --- a/mysql-test/r/log_tables.result +++ b/mysql-test/r/log_tables.result @@ -436,9 +436,9 @@ My own slow query sleep(2) My own slow query 0 SELECT * FROM mysql.slow_log WHERE seq >= 2 LIMIT 3; start_time user_host query_time lock_time rows_sent rows_examined db last_insert_id insert_id server_id sql_text thread_id rows_affected seq -START_TIME USER_HOST QUERY_TIME 00:00:00.000000 1 0 test 0 0 1 SELECT "My own slow query", sleep(2) 3 0 2 -START_TIME USER_HOST QUERY_TIME 00:00:00.000000 1 0 test 0 0 1 SELECT "My own slow query", sleep(2) 3 0 3 -START_TIME USER_HOST QUERY_TIME 00:00:00.000000 1 0 test 0 0 1 SELECT "My own slow query", sleep(2) 3 0 4 +START_TIME USER_HOST QUERY_TIME 00:00:00.000000 1 0 test 0 0 1 SELECT "My own slow query", sleep(2) 2 0 2 +START_TIME USER_HOST QUERY_TIME 00:00:00.000000 1 0 test 0 0 1 SELECT "My own slow query", sleep(2) 2 0 3 +START_TIME USER_HOST QUERY_TIME 00:00:00.000000 1 0 test 0 0 1 SELECT "My own slow query", sleep(2) 2 0 4 SET GLOBAL slow_query_log = 0; SET SESSION long_query_time =@saved_long_query_time; FLUSH LOGS; diff --git a/mysql-test/r/mdev375.result b/mysql-test/r/mdev375.result index 32580804686..426336e5939 100644 --- a/mysql-test/r/mdev375.result +++ b/mysql-test/r/mdev375.result @@ -10,5 +10,8 @@ ERROR HY000: Too many connections SELECT 0; 0 0 +show status like "Threads_connected"; +Variable_name Value +Threads_connected 3 SET GLOBAL log_warnings=default; SET GLOBAL max_connections=default; diff --git a/mysql-test/r/mysqlbinlog_row_minimal.result b/mysql-test/r/mysqlbinlog_row_minimal.result index 6ffaeeafc53..69b5a151d41 100644 --- a/mysql-test/r/mysqlbinlog_row_minimal.result +++ b/mysql-test/r/mysqlbinlog_row_minimal.result @@ -27,10 +27,10 @@ ROLLBACK/*!*/; /*!100001 SET @@session.server_id=1*//*!*/; /*!100001 SET @@session.gtid_seq_no=1*//*!*/; # at 352 -#<date> server id 1 end_log_pos 532 Query thread_id=4 exec_time=x error_code=0 +#<date> server id 1 end_log_pos 532 Query thread_id=3 exec_time=x error_code=0 use `test`/*!*/; SET TIMESTAMP=X/*!*/; -SET @@session.pseudo_thread_id=4/*!*/; +SET @@session.pseudo_thread_id=3/*!*/; SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=1342177280/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; @@ -44,7 +44,7 @@ CREATE TABLE t1 (pk INT PRIMARY KEY, f1 INT, f2 INT, f3 TINYINT, f4 MEDIUMINT, f #<date> server id 1 end_log_pos 570 GTID 0-1-2 ddl /*!100001 SET @@session.gtid_seq_no=2*//*!*/; # at 570 -#<date> server id 1 end_log_pos 743 Query thread_id=4 exec_time=x error_code=0 +#<date> server id 1 end_log_pos 743 Query thread_id=3 exec_time=x error_code=0 SET TIMESTAMP=X/*!*/; CREATE TABLE t2 (pk INT PRIMARY KEY, f1 INT, f2 INT, f3 INT, f4 INT, f5 MEDIUMINT, f6 INT, f7 INT, f8 char(1)) /*!*/; @@ -69,7 +69,7 @@ BEGIN ### @8=7 /* INT meta=0 nullable=1 is_null=0 */ ### @9='' /* STRING(1) meta=65025 nullable=1 is_null=0 */ # at 898 -#<date> server id 1 end_log_pos 967 Query thread_id=4 exec_time=x error_code=0 +#<date> server id 1 end_log_pos 967 Query thread_id=3 exec_time=x error_code=0 SET TIMESTAMP=X/*!*/; COMMIT /*!*/; @@ -94,7 +94,7 @@ BEGIN ### @8=7 /* INT meta=0 nullable=1 is_null=0 */ ### @9=NULL /* STRING(1) meta=65025 nullable=1 is_null=1 */ # at 1121 -#<date> server id 1 end_log_pos 1190 Query thread_id=4 exec_time=x error_code=0 +#<date> server id 1 end_log_pos 1190 Query thread_id=3 exec_time=x error_code=0 SET TIMESTAMP=X/*!*/; COMMIT /*!*/; @@ -119,7 +119,7 @@ BEGIN ### @8=7 /* INT meta=0 nullable=1 is_null=0 */ ### @9='A' /* STRING(1) meta=65025 nullable=1 is_null=0 */ # at 1343 -#<date> server id 1 end_log_pos 1412 Query thread_id=4 exec_time=x error_code=0 +#<date> server id 1 end_log_pos 1412 Query thread_id=3 exec_time=x error_code=0 SET TIMESTAMP=X/*!*/; COMMIT /*!*/; @@ -144,7 +144,7 @@ BEGIN ### @8=7 /* INT meta=0 nullable=1 is_null=0 */ ### @9='A' /* STRING(1) meta=65025 nullable=1 is_null=0 */ # at 1568 -#<date> server id 1 end_log_pos 1637 Query thread_id=4 exec_time=x error_code=0 +#<date> server id 1 end_log_pos 1637 Query thread_id=3 exec_time=x error_code=0 SET TIMESTAMP=X/*!*/; COMMIT /*!*/; @@ -202,7 +202,7 @@ BEGIN ### @8=7 /* INT meta=0 nullable=1 is_null=0 */ ### @9='A' /* STRING(1) meta=65025 nullable=1 is_null=0 */ # at 1890 -#<date> server id 1 end_log_pos 1959 Query thread_id=4 exec_time=x error_code=0 +#<date> server id 1 end_log_pos 1959 Query thread_id=3 exec_time=x error_code=0 SET TIMESTAMP=X/*!*/; COMMIT /*!*/; @@ -234,7 +234,7 @@ BEGIN ### SET ### @5=5 /* INT meta=0 nullable=1 is_null=0 */ # at 2119 -#<date> server id 1 end_log_pos 2188 Query thread_id=4 exec_time=x error_code=0 +#<date> server id 1 end_log_pos 2188 Query thread_id=3 exec_time=x error_code=0 SET TIMESTAMP=X/*!*/; COMMIT /*!*/; @@ -260,7 +260,7 @@ BEGIN ### WHERE ### @1=13 /* INT meta=0 nullable=0 is_null=0 */ # at 2328 -#<date> server id 1 end_log_pos 2397 Query thread_id=4 exec_time=x error_code=0 +#<date> server id 1 end_log_pos 2397 Query thread_id=3 exec_time=x error_code=0 SET TIMESTAMP=X/*!*/; COMMIT /*!*/; @@ -286,7 +286,7 @@ BEGIN ### WHERE ### @1=13 /* INT meta=0 nullable=0 is_null=0 */ # at 2537 -#<date> server id 1 end_log_pos 2606 Query thread_id=4 exec_time=x error_code=0 +#<date> server id 1 end_log_pos 2606 Query thread_id=3 exec_time=x error_code=0 SET TIMESTAMP=X/*!*/; COMMIT /*!*/; diff --git a/mysql-test/suite/binlog/r/binlog_reset_master.result b/mysql-test/suite/binlog/r/binlog_reset_master.result deleted file mode 100644 index b3d605560ff..00000000000 --- a/mysql-test/suite/binlog/r/binlog_reset_master.result +++ /dev/null @@ -1 +0,0 @@ -RESET MASTER; diff --git a/mysql-test/suite/binlog/t/binlog_reset_master.test b/mysql-test/suite/binlog/t/binlog_reset_master.test deleted file mode 100644 index 33b549ad357..00000000000 --- a/mysql-test/suite/binlog/t/binlog_reset_master.test +++ /dev/null @@ -1,26 +0,0 @@ -# ==== Purpose ==== -# -# Test bugs in RESET MASTER. - ---source include/have_debug.inc ---source include/have_log_bin.inc - -####################################################################### -# BUG#12574820: binlog.binlog_tmp_table timing out in daily and weekly trunk run -# Problem: MYSQL_BIN_LOG::reset_logs acquired LOCK_thread_count and -# LOCK_log in the wrong order. This could cause a deadlock when -# RESET MASTER was run concurrently with a disconnecting thread. -####################################################################### - -# We use sleep, not debug_sync, because the sync point needs to be in -# the thread shut down code after the debug sync facility has been -# shut down. ---let $write_var= SET debug_dbug="+d,sleep_after_lock_thread_count_before_delete_thd"; CREATE TEMPORARY TABLE test.t1 (a INT); ---let $write_to_file= GENERATE ---disable_query_log ---source include/write_var_to_file.inc ---enable_query_log - ---exec $MYSQL < $write_to_file -RESET MASTER; ---remove_file $write_to_file diff --git a/mysql-test/t/connect2.cnf b/mysql-test/t/connect2.cnf new file mode 100644 index 00000000000..0acd221b871 --- /dev/null +++ b/mysql-test/t/connect2.cnf @@ -0,0 +1,9 @@ +!include include/default_my.cnf + +[mysqld.1] +extra-port= @ENV.MASTER_EXTRA_PORT +extra-max-connections=2 +thread_handling=pool-of-threads + +[ENV] +MASTER_EXTRA_PORT= @OPT.port diff --git a/mysql-test/t/connect2.test b/mysql-test/t/connect2.test new file mode 100644 index 00000000000..7427afaeffd --- /dev/null +++ b/mysql-test/t/connect2.test @@ -0,0 +1,81 @@ +# This test is to check various cases of connections, some which require +# DBUG + +# This test makes no sense with the embedded server +--source include/not_embedded.inc +--source include/have_debug.inc + +SET @old_debug= @@session.debug; +set @old_thread_cache_size=@@global.thread_cache_size; + +# Test connections to the + +connect(con1,localhost,root,,test,,); +select 1; +disconnect con1; +connection default; +set global debug_dbug='+d,simulate_failed_connection_1'; +--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT +--error 2013 +connect(con1,localhost,root,,test,,); +connection default; +set global debug_dbug=@old_debug; +set global debug_dbug='+d,simulate_failed_connection_2'; +--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT +--error 2013 +connect(con1,localhost,root,,test,,); +connection default; +set global debug_dbug=@old_debug; +connect(con1,localhost,root,,test,,); +select 1; +disconnect con1; + +# Test connections to the extra port. + +connect(con1,localhost,root,,test,$MASTER_EXTRA_PORT,); +select 1; +disconnect con1; +connection default; +set global debug_dbug='+d,simulate_failed_connection_1'; +--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_EXTRA_PORT MASTER_PORT +--error 2013 +connect(con1,localhost,root,,test,$MASTER_EXTRA_PORT,); +connection default; +set global debug_dbug=@old_debug; +set global debug_dbug='+d,simulate_failed_connection_2'; +--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_EXTRA_PORT MASTER_PORT +--error 2013 +connect(con1,localhost,root,,test,$MASTER_EXTRA_PORT,); +connection default; +set global debug_dbug=@old_debug; +connect(con1,localhost,root,,test,$MASTER_EXTRA_PORT,); +select 1; +disconnect con1; +connection default; + +# +# Test thread cache +# +set @@global.thread_cache_size=2; +connect(con1,localhost,root,,test,$MASTER_EXTRA_PORT,); +select 1; +connect(con2,localhost,root,,test,$MASTER_EXTRA_PORT,); +select 1; +disconnect con1; +disconnect con2; +connection default; +set global debug_dbug='+d,simulate_failed_connection_2'; +--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_EXTRA_PORT MASTER_PORT +--error 2013 +connect(con1,localhost,root,,test,$MASTER_EXTRA_PORT,); +connection default; + +# Check that threads_connected didn't count aborted connections +show status like "Threads_connected"; + +# +# Cleanup +# + +set global debug_dbug=@old_debug; +set global thread_cache_size=@old_thread_cache_size; diff --git a/mysql-test/t/mdev375.test b/mysql-test/t/mdev375.test index fe259b37808..92e403b6513 100644 --- a/mysql-test/t/mdev375.test +++ b/mysql-test/t/mdev375.test @@ -17,6 +17,7 @@ SELECT 2; --connection default SELECT 0; +show status like "Threads_connected"; SET GLOBAL log_warnings=default; SET GLOBAL max_connections=default; |
