MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Alexander Nozdrin Date:November 15 2007 12:35pm
Subject:bk commit into 5.1 tree (anozdrin:1.2613) BUG#19723
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of alik. When alik does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2007-11-15 15:35:35+03:00, anozdrin@station. +3 -0
  A patch for BUG#19723: kill of active connection yields
  different error code depending on platform.
  
  On Mac OS X, KILL statement issued to kill the current
  connection would return a different error code and message than on
  other platforms ('MySQL server has gone away' instead of 'Shutdown
  in progress').
  
  The reason for this difference was that on Mac OS X we have macro
  SIGNAL_WITH_VIO_CLOSE defined. This macro forces KILL
  implementation to close the communication socket of the thread
  that is being killed. SIGNAL_WITH_VIO_CLOSE macro is defined on
  platforms where just sending a signal is not a reliable mechanism
  to interrupt the thread from sleeping on a blocking system call.
  In a nutshell, closing the socket is a hack to work around an
  operating system bug and awake the blocked thread no matter what.
  
  However, if the thread that is being killed is the same
  thread that issued KILL statement, closing the socket leads to a
  prematurely lost connection. At the same time it is not necessary
  to close the socket in this case, since the thread in question
  is not inside a blocking system call.
  
  The fix, therefore, is to not close the socket if the thread that
  is being killed is the same that issued KILL statement, even with
  defined SIGNAL_WITH_VIO_CLOSE.

  mysql-test/r/kill.result@stripped, 2007-11-15 15:35:32+03:00, anozdrin@station. +9 -0
    Update result file.

  mysql-test/t/kill.test@stripped, 2007-11-15 15:35:32+03:00, anozdrin@station. +16 -0
    Added a test case for BUG#19723: kill of active connection yields
    different error code depending on platform.

  sql/sql_class.cc@stripped, 2007-11-15 15:35:32+03:00, anozdrin@station. +14 -1
    Call close_active_vio() only if we're killing another thread.

diff -Nrup a/mysql-test/r/kill.result b/mysql-test/r/kill.result
--- a/mysql-test/r/kill.result	2007-06-22 06:08:10 +04:00
+++ b/mysql-test/r/kill.result	2007-11-15 15:35:32 +03:00
@@ -125,3 +125,12 @@ drop function bug27563;
 drop procedure proc27563;
 PREPARE stmt FROM 'EXPLAIN SELECT * FROM t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30,t31,t32,t33,t34,t35,t36,t37,t38,t39,t40 WHERE a1=a2 AND a2=a3 AND a3=a4 AND a4=a5 AND a5=a6 AND a6=a7 AND a7=a8 AND a8=a9 AND a9=a10 AND a10=a11 AND a11=a12 AND a12=a13 AND a13=a14 AND a14=a15 AND a15=a16 AND a16=a17 AND a17=a18 AND a18=a19 AND a19=a20 AND a20=a21 AND a21=a22 AND a22=a23 AND a23=a24 AND a24=a25 AND a25=a26 AND a26=a27 AND a27=a28 AND a28=a29 AND a29=a30 AND a30=a31 AND a31=a32 AND a32=a33 AND a33=a34 AND a34=a35 AND a35=a36 AND a36=a37 AND a37=a38 AND a38=a39 AND a39=a40  ';
 EXECUTE stmt;
+#
+# Bug#19723: kill of active connection yields different error code
+# depending on platform.
+#
+
+# Connection: con2.
+KILL CONNECTION_ID();
+SELECT 1;
+ERROR HY000: Lost connection to MySQL server during query
diff -Nrup a/mysql-test/t/kill.test b/mysql-test/t/kill.test
--- a/mysql-test/t/kill.test	2007-06-22 06:08:10 +04:00
+++ b/mysql-test/t/kill.test	2007-11-15 15:35:32 +03:00
@@ -304,3 +304,19 @@ while ($i)
   dec $i ;
 }
 --enable_query_log
+
+###########################################################################
+
+--echo #
+--echo # Bug#19723: kill of active connection yields different error code
+--echo # depending on platform.
+--echo #
+
+--echo
+--echo # Connection: con2.
+--connection con2
+
+KILL CONNECTION_ID();
+
+--error 2013
+SELECT 1;
diff -Nrup a/sql/sql_class.cc b/sql/sql_class.cc
--- a/sql/sql_class.cc	2007-10-31 18:33:06 +03:00
+++ b/sql/sql_class.cc	2007-11-15 15:35:32 +03:00
@@ -818,7 +818,20 @@ void THD::awake(THD::killed_state state_
     if (!slave_thread)
       thread_scheduler.post_kill_notification(this);
 #ifdef SIGNAL_WITH_VIO_CLOSE
-    close_active_vio();
+    if (this != current_thd)
+    {
+      /*
+        In addition to a signal, let's close the socket of the thread that
+        is being killed. This is to make sure it does not block if the
+        signal is lost. This needs to be done only on platforms where
+        signals are not a reliable interruption mechanism.
+
+        If we're killing ourselves, we know that we're not blocked, so this
+        hack is not used.
+      */
+
+      close_active_vio();
+    }
 #endif    
   }
   if (mysys_var)
Thread
bk commit into 5.1 tree (anozdrin:1.2613) BUG#19723Alexander Nozdrin15 Nov