=== added file 'mysql-test/t/kill_bug.test' --- mysql-test/t/kill_bug.test 1970-01-01 00:00:00 +0000 +++ mysql-test/t/kill_bug.test 2010-11-11 14:15:40 +0000 @@ -0,0 +1,31 @@ +--source include/not_embedded.inc +--source include/have_debug.inc +--source include/have_debug_sync.inc + +connect (new_conn, localhost, root,,); +let $kill_id = `SELECT CONNECTION_ID()`; +SET DEBUG_SYNC='before_close_connection SIGNAL disconnect WAIT_FOR kill_cmd EXECUTE 3'; +set session debug="+d,sleep_in_vio_close,info"; + +--connection default +eval SET @kill_id = $kill_id; +SET DEBUG_SYNC='before_kill WAIT_FOR disconnect EXECUTE 3'; +SET DEBUG_SYNC='before_kill_and_after_lock SIGNAL kill_cmd EXECUTE 3'; +set session debug="+d,sleep_in_vio_close,info"; + +--connection default +--send KILL @kill_id + +--disconnect new_conn; + +--connection default +--reap + +let $wait_condition= SELECT COUNT(*) = 0 +FROM information_schema.processlist +WHERE id = $kill_id; +--source include/wait_condition.inc +if (!$success) +{ + --die #abort +} === modified file 'sql/sql_class.cc' --- sql/sql_class.cc 2010-09-06 13:40:55 +0000 +++ sql/sql_class.cc 2010-11-11 14:15:40 +0000 @@ -1203,7 +1203,7 @@ If we're killing ourselves, we know that we're not blocked, so this hack is not used. */ - + DEBUG_SYNC(this, "before_close_active_vio"); close_active_vio(); } #endif === modified file 'sql/sql_connect.cc' --- sql/sql_connect.cc 2010-08-16 12:50:27 +0000 +++ sql/sql_connect.cc 2010-11-11 14:15:40 +0000 @@ -36,6 +36,7 @@ // reset_host_errors #include "sql_acl.h" // acl_getroot, NO_ACCESS, SUPER_ACL #include "sql_callback.h" +#include "debug_sync.h" #if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY) /* @@ -1193,7 +1194,8 @@ break; } end_connection(thd); - + DEBUG_SYNC(thd, "before_close_connection"); + end_thread: close_connection(thd, 0, 1); if (MYSQL_CALLBACK_ELSE(thread_scheduler, end_thread, (thd, 1), 0)) === modified file 'sql/sql_parse.cc' --- sql/sql_parse.cc 2010-08-25 10:22:34 +0000 +++ sql/sql_parse.cc 2010-11-11 14:15:40 +0000 @@ -6399,6 +6399,8 @@ uint error=ER_NO_SUCH_THREAD; DBUG_ENTER("kill_one_thread"); DBUG_PRINT("enter", ("id=%lu only_kill=%d", id, only_kill_query)); + + DEBUG_SYNC(thd, "before_kill"); mysql_mutex_lock(&LOCK_thread_count); // For unlink from list I_List_iterator it(threads); while ((tmp=it++)) @@ -6412,6 +6414,7 @@ } } mysql_mutex_unlock(&LOCK_thread_count); + DEBUG_SYNC(thd, "before_kill_and_after_lock"); if (tmp) { === modified file 'vio/viosocket.c' --- vio/viosocket.c 2010-08-16 12:50:27 +0000 +++ vio/viosocket.c 2010-11-11 14:15:40 +0000 @@ -277,6 +277,7 @@ if (vio->type != VIO_CLOSED) { + DBUG_EXECUTE_IF("sleep_in_vio_close", my_sleep(2000000);); DBUG_ASSERT(vio->type == VIO_TYPE_TCPIP || vio->type == VIO_TYPE_SOCKET || vio->type == VIO_TYPE_SSL);