List:Commits« Previous MessageNext Message »
From:Praveenkumar Hulakund Date:December 26 2011 10:13am
Subject:bzr push into mysql-trunk branch (praveenkumar.hulakund:3686 to 3687)
Bug#11764724
View as plain text  
 3687 Praveenkumar Hulakund	2011-12-26
      BUG#11764724 - 57586: UNKNOWN TABLE WHEN TRYING TO DROP A TABLE AND NO AVAILABLE UNDO 
      SLOTS LEFT
      
      Description:
      If you attempt to drop an existing InnoDB table, but you do not have any 
      available undo slots open, then you will receive an "unknown table" error. 
      
      mysql> DROP TABLE test.innodb_table_monitor; 
      ERROR 1051 (42S02): Unknown table 'innodb_table_monitor' 
      
      How To Repeat: 
      <first> make sure max_connections > 1024 </first> 
      
      use test; 
      create table t (id int) engine=innodb; 
      create table innodb_table_monitor (id int) engine=innodb; 
      
      Run following script: 
      
      <? 
      $db_arr=array(); 
      for ($i = 1; $i <= 1024; $i++) { 
      $db=$db_arr[$i]=mysql_connect("localhost:3307","root","pass",1); 
              mysql_select_db("test",$db); 
              mysql_query("BEGIN",$db) or die(mysql_error()); 
              mysql_query("INSERT INTO t VALUES ($i)",$db) or die(mysql_error()); 
      } 
      $db=$db_arr[$i]=mysql_connect("localhost:3307","root","pass",1); 
      mysql_select_db("test",$db); 
      mysql_query("DROP TABLE test.innodb_table_monitor",$db) or die(mysql_error()); 
      
      sleep(60); 
      ?> 
      
      
      After the above script, it will throw the following error: 
      
      Unknown table 'innodb_table_monitor' 
      
      Analysis:
      Here, max number of concurrent transactions/connections are started and then the
      next transaction to drop a table is initiated. Since, system has already max number
      of transactions running, next transaction to "drop table" was not started and innodb
      returned error "DB_TOO_MANY_CONCURRENT_TRXS". But this error was not handled properly 
      in sql layer because of which "drop table" operation was throwing wrong error message. 
      
      Fix:
      As a fix, I have added check in sql (in function "mysql_rm_table_part2") to handle error 
      code "HA_ERR_TOO_MANY_CONCURRENT_TRXS" and throw proper error message.
      
      Ouput of drop command after fix (with max number of concurrent transaction running)
      
      mysql> drop table test;
      ERROR 177 (HY000): Too many active concurrent transactions
      
      To reproduce this issue, max_connections should be set to value greater than 1024 and
      1024 connections/transactions need to be started. Since, this process consumes lot of
      time and resource, I havent added test case in mysql_test. But I will update but list
      with request of QA assistance to verify fix.

    modified:
      sql/sql_table.cc
 3686 Nirbhay Choubey	2011-12-24 [merge]
      Merge of post-fix for bug#12809202 from mysql-5.5

    modified:
      client/mysqldump.c
      mysql-test/r/mysqldump.result
      mysql-test/t/mysqldump.test
=== modified file 'sql/sql_table.cc'
--- a/sql/sql_table.cc	revid:nirbhay.choubey@stripped
+++ b/sql/sql_table.cc	revid:praveenkumar.hulakund@stripped
@@ -2421,6 +2421,9 @@ int mysql_rm_table_no_locks(THD *thd, TA
       error= ha_delete_table(thd, table_type, path, db, table->table_name,
                              !dont_log_query);
 
+      if (error == HA_ERR_TOO_MANY_CONCURRENT_TRXS)
+        goto err;
+
       /* No error if non existent table and 'IF EXIST' clause or view */
       if ((error == ENOENT || error == HA_ERR_NO_SUCH_TABLE) && 
 	  (if_exists || table_type == NULL))
@@ -2470,7 +2473,12 @@ int mysql_rm_table_no_locks(THD *thd, TA
                                non_trans_tmp_table_deleted);
   error= 0;
 err:
-  if (wrong_tables.length())
+  if (error == HA_ERR_TOO_MANY_CONCURRENT_TRXS)
+  {
+    my_error(HA_ERR_TOO_MANY_CONCURRENT_TRXS, MYF(0));
+    error= 1;
+  }
+  else if (wrong_tables.length())
   {
     if (!foreign_key_error)
       my_printf_error(ER_BAD_TABLE_ERROR, ER(ER_BAD_TABLE_ERROR), MYF(0),

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk branch (praveenkumar.hulakund:3686 to 3687)Bug#11764724Praveenkumar Hulakund29 Dec