List:Commits« Previous MessageNext Message »
From:<gshchepa Date:May 29 2007 3:23pm
Subject:bk commit into 5.0 tree (gshchepa:1.2504) BUG#28598
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of uchum. When uchum 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-05-29 20:22:56+05:00, gshchepa@stripped +3 -0
  Fixed bug #28598.
  mysqld was crashing when a long-running explain query was killed from
  another connection.
   
  The greedy_search() function ignored thd->killed status after
  a call to the best_extension_by_limited_search() function.
  choose_plan(), greedy_search() best_extension_by_limited_search()
  functions has been changed to return TRUE in case of fatal error.

  mysql-test/r/kill.result@stripped, 2007-05-29 20:22:45+05:00, gshchepa@stripped +14 -0
    Updated test case for bug #28598.

  mysql-test/t/kill.test@stripped, 2007-05-29 20:22:44+05:00, gshchepa@stripped +116 -0
    Updated test case for bug #28598.

  sql/sql_select.cc@stripped, 2007-05-29 20:22:39+05:00, gshchepa@stripped +36 -31
    Fixed bug #28598.
    The greedy_search() function ignored thd->killed status after
    a call to the best_extension_by_limited_search() function.
    choose_plan(), greedy_search() best_extension_by_limited_search()
    functions has been changed to return TRUE in case of fatal error.

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	gshchepa
# Host:	gleb.loc
# Root:	/home/uchum/work/bk/mysql-5.0-opt-28598

--- 1.526/sql/sql_select.cc	2007-05-27 01:19:34 +05:00
+++ 1.527/sql/sql_select.cc	2007-05-29 20:22:39 +05:00
@@ -49,15 +49,15 @@ static int sort_keyuse(KEYUSE *a,KEYUSE 
 static void set_position(JOIN *join,uint index,JOIN_TAB *table,KEYUSE *key);
 static bool create_ref_for_key(JOIN *join, JOIN_TAB *j, KEYUSE *org_keyuse,
 			       table_map used_tables);
-static void choose_plan(JOIN *join,table_map join_tables);
+static bool choose_plan(JOIN *join,table_map join_tables);
 
 static void best_access_path(JOIN *join, JOIN_TAB *s, THD *thd,
                              table_map remaining_tables, uint idx,
                              double record_count, double read_time);
 static void optimize_straight_join(JOIN *join, table_map join_tables);
-static void greedy_search(JOIN *join, table_map remaining_tables,
+static bool greedy_search(JOIN *join, table_map remaining_tables,
                              uint depth, uint prune_level);
-static void best_extension_by_limited_search(JOIN *join,
+static bool best_extension_by_limited_search(JOIN *join,
                                              table_map remaining_tables,
                                              uint idx, double record_count,
                                              double read_time, uint depth,
@@ -2717,7 +2717,8 @@ make_join_statistics(JOIN *join, TABLE_L
   if (join->const_tables != join->tables)
   {
     optimize_keyuse(join, keyuse_array);
-    choose_plan(join, all_table_map & ~join->const_table_map);
+    if (choose_plan(join, all_table_map & ~join->const_table_map))
+      DBUG_RETURN(TRUE);
   }
   else
   {
@@ -4307,11 +4308,12 @@ best_access_path(JOIN      *join,
     the array 'join->best_positions', and the cost of the plan in
     'join->best_read'.
 
-  RETURN
-    None
+  RETURN VALUES
+    0	ok
+    1	Fatal error
 */
 
-static void
+static bool
 choose_plan(JOIN *join, table_map join_tables)
 {
   uint search_depth= join->thd->variables.optimizer_search_depth;
@@ -4351,7 +4353,8 @@ choose_plan(JOIN *join, table_map join_t
       if (search_depth == 0)
         /* Automatically determine a reasonable value for 'search_depth' */
         search_depth= determine_search_depth(join);
-      greedy_search(join, join_tables, search_depth, prune_level);
+      if (greedy_search(join, join_tables, search_depth, prune_level))
+        DBUG_RETURN(TRUE);
     }
   }
 
@@ -4361,7 +4364,7 @@ choose_plan(JOIN *join, table_map join_t
   */
   if (join->thd->lex->orig_sql_command != SQLCOM_SHOW_STATUS)
     join->thd->status_var.last_query_cost= join->best_read;
-  DBUG_VOID_RETURN;
+  DBUG_RETURN(FALSE);
 }
 
 
@@ -4589,11 +4592,12 @@ optimize_straight_join(JOIN *join, table
     In the future, 'greedy_search' might be extended to support other
     implementations of 'best_extension', e.g. some simpler quadratic procedure.
 
-  RETURN
-    None
+  RETURN VALUES
+    0	ok
+    1	Fatal error
 */
 
-static void
+static bool
 greedy_search(JOIN      *join,
               table_map remaining_tables,
               uint      search_depth,
@@ -4615,8 +4619,9 @@ greedy_search(JOIN      *join,
   do {
     /* Find the extension of the current QEP with the lowest cost */
     join->best_read= DBL_MAX;
-    best_extension_by_limited_search(join, remaining_tables, idx, record_count,
-                                     read_time, search_depth, prune_level);
+    if (best_extension_by_limited_search(join, remaining_tables, idx, record_count,
+                                         read_time, search_depth, prune_level))
+      DBUG_RETURN(TRUE);
 
     if (size_remain <= search_depth)
     {
@@ -4627,7 +4632,7 @@ greedy_search(JOIN      *join,
       DBUG_EXECUTE("opt", print_plan(join, join->tables,
                                      record_count, read_time, read_time,
                                      "optimal"););
-      DBUG_VOID_RETURN;
+      DBUG_RETURN(FALSE);
     }
 
     /* select the first table in the optimal extension as most promising */
@@ -4772,11 +4777,12 @@ greedy_search(JOIN      *join,
     The parameter 'search_depth' provides control over the recursion
     depth, and thus the size of the resulting optimal plan.
 
-  RETURN
-    None
+  RETURN VALUES
+    0	ok
+    1	Fatal error
 */
 
-static void
+static bool
 best_extension_by_limited_search(JOIN      *join,
                                  table_map remaining_tables,
                                  uint      idx,
@@ -4785,11 +4791,11 @@ best_extension_by_limited_search(JOIN   
                                  uint      search_depth,
                                  uint      prune_level)
 {
+  DBUG_ENTER("best_extension_by_limited_search");
+
   THD *thd= join->thd;
   if (thd->killed)  // Abort
-    return;
-
-  DBUG_ENTER("best_extension_by_limited_search");
+    DBUG_RETURN(TRUE);
 
   /* 
      'join' is a partial plan with lower cost than the best plan so far,
@@ -4869,15 +4875,14 @@ best_extension_by_limited_search(JOIN   
       if ( (search_depth > 1) && (remaining_tables & ~real_table_bit) )
       { /* Recursively expand the current partial plan */
         swap_variables(JOIN_TAB*, join->best_ref[idx], *pos);
-        best_extension_by_limited_search(join,
-                                         remaining_tables & ~real_table_bit,
-                                         idx + 1,
-                                         current_record_count,
-                                         current_read_time,
-                                         search_depth - 1,
-                                         prune_level);
-        if (thd->killed)
-          DBUG_VOID_RETURN;
+        if (best_extension_by_limited_search(join,
+                                             remaining_tables & ~real_table_bit,
+                                             idx + 1,
+                                             current_record_count,
+                                             current_read_time,
+                                             search_depth - 1,
+                                             prune_level))
+          DBUG_RETURN(TRUE);
         swap_variables(JOIN_TAB*, join->best_ref[idx], *pos);
       }
       else
@@ -4906,7 +4911,7 @@ best_extension_by_limited_search(JOIN   
       restore_prev_nj_state(s);
     }
   }
-  DBUG_VOID_RETURN;
+  DBUG_RETURN(FALSE);
 }
 
 

--- 1.17/mysql-test/r/kill.result	2007-05-24 00:23:33 +05:00
+++ 1.18/mysql-test/r/kill.result	2007-05-29 20:22:45 +05:00
@@ -123,3 +123,17 @@ release_lock("lock27563")
 drop table t1, t2;
 drop function bug27563;
 drop procedure proc27563;
+explain select * from 
+t01, t02, t03, t04, t05, t06, t07, t08, t09, 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
+a01=a02 and a02=a03 and a03=a04 and a05=a06 and a06=a07 and a08=a09 and a09=a10
+and
+a11=a12 and a12=a13 and a13=a14 and a15=a16 and a16=a17 and a18=a19 and a19=a20
+and
+a21=a22 and a22=a23 and a23=a24 and a25=a26 and a26=a27 and a28=a29 and a29=a30
+and
+a31=a32 and a32=a33 and a33=a34 and a35=a36 and a36=a37 and a38=a39 and a39=a40;
+kill query 4;

--- 1.25/mysql-test/t/kill.test	2007-05-24 00:23:43 +05:00
+++ 1.26/mysql-test/t/kill.test	2007-05-29 20:22:44 +05:00
@@ -249,3 +249,119 @@ select release_lock("lock27563");
 drop table t1, t2;
 drop function bug27563;
 drop procedure proc27563;
+
+#
+# Bug#28598: mysqld crash when killing a long-running explain query.
+#
+connection con1;
+let $ID= `select connection_id()`;
+
+--disable_query_log
+create table t01(a01 int,key(a01))engine=myisam;
+create table t02(a02 int,key(a02))engine=myisam;
+create table t03(a03 int,key(a03))engine=myisam;
+create table t04(a04 int,key(a04))engine=myisam;
+create table t05(a05 int,key(a05))engine=myisam;
+create table t06(a06 int,key(a06))engine=myisam;
+create table t07(a07 int,key(a07))engine=myisam;
+create table t08(a08 int,key(a08))engine=myisam;
+create table t09(a09 int,key(a09))engine=myisam;
+create table t10(a10 int,key(a10))engine=myisam;
+create table t11(a11 int,key(a11))engine=myisam;
+create table t12(a12 int,key(a12))engine=myisam;
+create table t13(a13 int,key(a13))engine=myisam;
+create table t14(a14 int,key(a14))engine=myisam;
+create table t15(a15 int,key(a15))engine=myisam;
+create table t16(a16 int,key(a16))engine=myisam;
+create table t17(a17 int,key(a17))engine=myisam;
+create table t18(a18 int,key(a18))engine=myisam;
+create table t19(a19 int,key(a19))engine=myisam;
+create table t20(a20 int,key(a20))engine=myisam;
+create table t21(a21 int,key(a21))engine=myisam;
+create table t22(a22 int,key(a22))engine=myisam;
+create table t23(a23 int,key(a23))engine=myisam;
+create table t24(a24 int,key(a24))engine=myisam;
+create table t25(a25 int,key(a25))engine=myisam;
+create table t26(a26 int,key(a26))engine=myisam;
+create table t27(a27 int,key(a27))engine=myisam;
+create table t28(a28 int,key(a28))engine=myisam;
+create table t29(a29 int,key(a29))engine=myisam;
+create table t30(a30 int,key(a30))engine=myisam;
+create table t31(a31 int,key(a31))engine=myisam;
+create table t32(a32 int,key(a32))engine=myisam;
+create table t33(a33 int,key(a33))engine=myisam;
+create table t34(a34 int,key(a34))engine=myisam;
+create table t35(a35 int,key(a35))engine=myisam;
+create table t36(a36 int,key(a36))engine=myisam;
+create table t37(a37 int,key(a37))engine=myisam;
+create table t38(a38 int,key(a38))engine=myisam;
+create table t39(a39 int,key(a39))engine=myisam;
+create table t40(a40 int,key(a40))engine=myisam;
+
+insert into t01 values (1),(2),(3),(4),(5),(6),(7);
+insert into t02 values (1),(2),(3),(4),(5),(6),(7);
+insert into t03 values (1),(2),(3),(4),(5),(6),(7);
+insert into t04 values (1),(2),(3),(4),(5),(6),(7);
+insert into t05 values (1),(2),(3),(4),(5),(6),(7);
+insert into t06 values (1),(2),(3),(4),(5),(6),(7);
+insert into t07 values (1),(2),(3),(4),(5),(6),(7);
+insert into t08 values (1),(2),(3),(4),(5),(6),(7);
+insert into t09 values (1),(2),(3),(4),(5),(6),(7);
+insert into t10 values (1),(2),(3),(4),(5),(6),(7);
+insert into t11 values (1),(2),(3),(4),(5),(6),(7);
+insert into t12 values (1),(2),(3),(4),(5),(6),(7);
+insert into t13 values (1),(2),(3),(4),(5),(6),(7);
+insert into t14 values (1),(2),(3),(4),(5),(6),(7);
+insert into t15 values (1),(2),(3),(4),(5),(6),(7);
+insert into t16 values (1),(2),(3),(4),(5),(6),(7);
+insert into t17 values (1),(2),(3),(4),(5),(6),(7);
+insert into t18 values (1),(2),(3),(4),(5),(6),(7);
+insert into t19 values (1),(2),(3),(4),(5),(6),(7);
+insert into t20 values (1),(2),(3),(4),(5),(6),(7);
+insert into t21 values (1),(2),(3),(4),(5),(6),(7);
+insert into t22 values (1),(2),(3),(4),(5),(6),(7);
+insert into t23 values (1),(2),(3),(4),(5),(6),(7);
+insert into t24 values (1),(2),(3),(4),(5),(6),(7);
+insert into t25 values (1),(2),(3),(4),(5),(6),(7);
+insert into t26 values (1),(2),(3),(4),(5),(6),(7);
+insert into t27 values (1),(2),(3),(4),(5),(6),(7);
+insert into t28 values (1),(2),(3),(4),(5),(6),(7);
+insert into t29 values (1),(2),(3),(4),(5),(6),(7);
+insert into t30 values (1),(2),(3),(4),(5),(6),(7);
+insert into t31 values (1),(2),(3),(4),(5),(6),(7);
+insert into t32 values (1),(2),(3),(4),(5),(6),(7);
+insert into t33 values (1),(2),(3),(4),(5),(6),(7);
+insert into t34 values (1),(2),(3),(4),(5),(6),(7);
+insert into t35 values (1),(2),(3),(4),(5),(6),(7);
+insert into t36 values (1),(2),(3),(4),(5),(6),(7);
+insert into t37 values (1),(2),(3),(4),(5),(6),(7);
+insert into t38 values (1),(2),(3),(4),(5),(6),(7);
+insert into t39 values (1),(2),(3),(4),(5),(6),(7);
+insert into t40 values (1),(2),(3),(4),(5),(6),(7);
+
+set session optimizer_search_depth=0;
+--enable_query_log
+
+send explain select * from 
+  t01, t02, t03, t04, t05, t06, t07, t08, t09, 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
+a01=a02 and a02=a03 and a03=a04 and a05=a06 and a06=a07 and a08=a09 and a09=a10
+and
+a11=a12 and a12=a13 and a13=a14 and a15=a16 and a16=a17 and a18=a19 and a19=a20
+and
+a21=a22 and a22=a23 and a23=a24 and a25=a26 and a26=a27 and a28=a29 and a29=a30
+and
+a31=a32 and a32=a33 and a33=a34 and a35=a36 and a36=a37 and a38=a39 and a39=a40;
+
+connection con2;
+real_sleep 2;
+eval kill query $ID;
+--disable_query_log
+drop table t01, t02, t03, t04, t05, t06, t07, t08, t09, 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;
+--enable_query_log
Thread
bk commit into 5.0 tree (gshchepa:1.2504) BUG#28598gshchepa29 May