From 4d3a78a26b44e5faa5a02c42398e2884dee80524 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 23 May 2006 10:20:57 +0200 Subject: [PATCH 1/6] Bug#19938 Valgrind error (race) in handle_slave_sql() - Unlock the mutex after looking at rli->events_till_abort - Already fixed in 5.1 so it will be null merged. sql/slave.cc: Unlock the mutex after looking at rli->events_till_abort --- sql/slave.cc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/sql/slave.cc b/sql/slave.cc index fa7ccc4427d..399a36ed077 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -3950,11 +3950,20 @@ the slave SQL thread with \"SLAVE START\". We stopped at log \ pthread_mutex_unlock(&LOCK_thread_count); pthread_cond_broadcast(&rli->stop_cond); // tell the world we are done - pthread_mutex_unlock(&rli->run_lock); + #ifndef DBUG_OFF // TODO: reconsider the code below if (abort_slave_event_count && !rli->events_till_abort) + { + /* + Bug #19938 Valgrind error (race) in handle_slave_sql() + Read the value of rli->event_till_abort before releasing the mutex + */ + pthread_mutex_unlock(&rli->run_lock); goto slave_begin; -#endif + } +#endif + pthread_mutex_unlock(&rli->run_lock); + my_thread_end(); pthread_exit(0); DBUG_RETURN(0); // Can't return anything here From 90b8e601032341a6e63fc931d9c3cd2ebe64e7ff Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 23 May 2006 10:33:53 +0200 Subject: [PATCH 2/6] Add comment for 'kill_server' function --- sql/mysqld.cc | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 9c1089dbdb2..fc3ca5085cf 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -863,7 +863,20 @@ void kill_mysql(void) DBUG_VOID_RETURN; } - /* Force server down. kill all connections and threads and exit */ +/* + Force server down. Kill all connections and threads and exit + + SYNOPSIS + kill_server + + sig_ptr Signal number that caused kill_server to be called. + + NOTE! + A signal number of 0 mean that the function was not called + from a signal handler and there is thus no signal to block + or stop, we just want to kill the server. + +*/ #if defined(OS2) || defined(__NETWARE__) extern "C" void kill_server(int sig_ptr) From 022e12d4adf26b18c6ab98f27011308f07e833aa Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 23 May 2006 10:52:53 +0200 Subject: [PATCH 3/6] Move the requirement for "not running as root" to information_schema_chmod --- mysql-test/t/information_schema.test | 3 --- mysql-test/t/information_schema_chmod.test | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test index e96f1ef4bbd..0f6ae2bf4e0 100644 --- a/mysql-test/t/information_schema.test +++ b/mysql-test/t/information_schema.test @@ -1,9 +1,6 @@ # This test uses grants, which can't get tested for embedded server -- source include/not_embedded.inc -# This test uses chmod, can't be run with root permissions --- source include/not_as_root.inc - # Test for information_schema.schemata & # show databases diff --git a/mysql-test/t/information_schema_chmod.test b/mysql-test/t/information_schema_chmod.test index fb850b8e38d..c7ea2b03890 100644 --- a/mysql-test/t/information_schema_chmod.test +++ b/mysql-test/t/information_schema_chmod.test @@ -8,6 +8,9 @@ # --source include/not_windows.inc +# This test uses chmod, can't be run with root permissions +-- source include/not_as_root.inc + # # Bug #15851 Unlistable directories yield no info from information_schema From 54526d177f0bbba841e8588700b6cc0fc9da427c Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 23 May 2006 15:45:16 +0200 Subject: [PATCH 4/6] Make wait_timeout test not timing dependent mysql-test/t/wait_timeout.test: Remove sleeps from wait_timeout in order to make it timing independent. Instead get the status variable "aborted_clients" in a seconds connection. --- mysql-test/t/wait_timeout.test | 68 ++++++++++++++++++++++++++++++++-- 1 file changed, 64 insertions(+), 4 deletions(-) diff --git a/mysql-test/t/wait_timeout.test b/mysql-test/t/wait_timeout.test index 1fef3deea3c..9310c3502b9 100644 --- a/mysql-test/t/wait_timeout.test +++ b/mysql-test/t/wait_timeout.test @@ -4,10 +4,41 @@ # # Bug #8731: wait_timeout does not work on Mac OS X # + + +# Connect with another connection and reset counters +--disable_query_log +connect (wait_con,localhost,root,,test,,); +flush status; # Reset counters +connection wait_con; +let $retries=300; +let $aborted_clients = `SHOW STATUS LIKE 'aborted_clients'`; +set @aborted_clients= 0; +--enable_query_log + +# Disable reconnect and do the query +connection default; --disable_reconnect select 1; -# wait_timeout is 1, so we should get disconnected now ---sleep 2 + +# Switch to wait_con and wait until server has aborted the connection +--disable_query_log +connection wait_con; +while (!`select @aborted_clients`) +{ + sleep 0.1; + 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 + +connection default; # When the connection is closed in this way, the error code should # be consistent see bug#2845 for an explanation --error 2006 @@ -15,12 +46,41 @@ select 2; --enable_reconnect select 3; +# # Do the same test as above on a TCP connection +# (which we get by specifying a ip adress) + +# Connect with another connection and reset counters +--disable_query_log +connection wait_con; +flush status; # Reset counters +let $retries=300; +let $aborted_clients = `SHOW STATUS LIKE 'aborted_clients'`; +set @aborted_clients= 0; +--enable_query_log + connect (con1,127.0.0.1,root,,test,$MASTER_MYPORT,); --disable_reconnect select 1; -# wait_timeout is 1, so we should get disconnected now ---sleep 2 + +# Switch to wait_con and wait until server has aborted the connection +--disable_query_log +connection wait_con; +while (!`select @aborted_clients`) +{ + sleep 0.1; + 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 + +connection con1; # When the connection is closed in this way, the error code should # be consistent see bug#2845 for an explanation --error 2006 From a2fb5dc56a458a043cdc5e3b71e2b24731ecc06c Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 23 May 2006 16:14:48 +0200 Subject: [PATCH 5/6] Cset exclude: msvensson@neptunus.(none)|ChangeSet|20060523082057|49143 sql/slave.cc: Exclude --- sql/slave.cc | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/sql/slave.cc b/sql/slave.cc index 399a36ed077..fa7ccc4427d 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -3950,20 +3950,11 @@ the slave SQL thread with \"SLAVE START\". We stopped at log \ pthread_mutex_unlock(&LOCK_thread_count); pthread_cond_broadcast(&rli->stop_cond); // tell the world we are done - + pthread_mutex_unlock(&rli->run_lock); #ifndef DBUG_OFF // TODO: reconsider the code below if (abort_slave_event_count && !rli->events_till_abort) - { - /* - Bug #19938 Valgrind error (race) in handle_slave_sql() - Read the value of rli->event_till_abort before releasing the mutex - */ - pthread_mutex_unlock(&rli->run_lock); goto slave_begin; - } -#endif - pthread_mutex_unlock(&rli->run_lock); - +#endif my_thread_end(); pthread_exit(0); DBUG_RETURN(0); // Can't return anything here From a6cc2de9f6dad07da112697f192828546bc706bd Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 23 May 2006 16:20:03 +0200 Subject: [PATCH 6/6] Bug #19938 Valgrind error (race) in handle_slave_sql() sql/slave.cc: Read rli->events_till_abort to a temporary variable before unlocking the mutex --- sql/slave.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sql/slave.cc b/sql/slave.cc index fa7ccc4427d..379d881f579 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -3949,10 +3949,17 @@ the slave SQL thread with \"SLAVE START\". We stopped at log \ delete thd; pthread_mutex_unlock(&LOCK_thread_count); pthread_cond_broadcast(&rli->stop_cond); + + /* + Bug #19938 Valgrind error (race) in handle_slave_sql() + Read the value of rli->event_till_abort before releasing the mutex + */ + const int eta= rli->events_till_abort; + // tell the world we are done pthread_mutex_unlock(&rli->run_lock); #ifndef DBUG_OFF // TODO: reconsider the code below - if (abort_slave_event_count && !rli->events_till_abort) + if (abort_slave_event_count && !eta) goto slave_begin; #endif my_thread_end();