MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Jon Olav Hauglid Date:August 31 2009 12:48pm
Subject:bzr commit into mysql-5.4 branch (jon.hauglid:2804) Bug#42074
View as plain text  
#At file:///export/home/z/mysql-next-bugfixing-bug42074/ based on revid:alik@stripped

 2804 Jon Olav Hauglid	2009-08-31
      Bug #42074 concurrent optimize table and 
                 alter table = Assertion failed: thd->is_error()
      
      This bug could occur if OPTIMIZE TABLE was started on a InnoDB table
      and the table was altered to different storage engine after OPTIMIZE
      had started. This allowed OPTIMIZE to pass the initial checks for 
      storage engine support, but fail once it reached "recreate+analyze"
      if this operation was not supported by the new storage engine.
      
      If the call to ha_analyze() returned HA_ADMIN_NOT_IMPLEMENTED,
      this would trigger a code path which included an assert checking
      for diagnostics area contents. Since this area had not been filled,
      the assert was triggered.
      
      This patch removes the assertion. The diagnostics area is in this case
      only used to provide more detailed information about why optimize failed.
      The triggered code path sends this information to the client and clears 
      the diagnostic area.
      
      Test case added to innodb_mysql.test.

    modified:
      mysql-test/r/innodb_mysql.result
      mysql-test/t/innodb_mysql.test
      sql/sql_table.cc
=== modified file 'mysql-test/r/innodb_mysql.result'
--- a/mysql-test/r/innodb_mysql.result	2009-07-31 19:46:24 +0000
+++ b/mysql-test/r/innodb_mysql.result	2009-08-31 12:48:42 +0000
@@ -2253,4 +2253,28 @@ b
 1
 set join_cache_level=default;
 DROP TABLE t1,t2;
+#
+# Bug #42074: concurrent optimize table and 
+#             alter table = Assertion failed: thd->is_error()
+#
+DROP TABLE IF EXISTS t1;
+# Create InnoDB table
+CREATE TABLE t1 (id INT) engine=innodb;
+connect(localhost,root,,test,13000,/export/home/z/mysql-next-bugfixing-bug42074/mysql-test/var/tmp/mysqld.1.sock);
+# Connection 1
+# Start optimizing table
+SET DEBUG_SYNC='ha_admin_try_alter SIGNAL optimize_started WAIT_FOR table_altered';
+OPTIMIZE TABLE t1;
+# Connection 2
+# Change table to engine=memory
+SET DEBUG_SYNC='now WAIT_FOR optimize_started';
+ALTER TABLE t1 engine=memory;
+SET DEBUG_SYNC='now SIGNAL table_altered';
+# Connection 1
+# Complete optimization
+Table	Op	Msg_type	Msg_text
+test.t1	optimize	note	Table does not support optimize, doing recreate + analyze instead
+test.t1	optimize	status	Operation failed
+DROP TABLE t1;
+SET DEBUG_SYNC='RESET';
 End of 6.0 tests

=== modified file 'mysql-test/t/innodb_mysql.test'
--- a/mysql-test/t/innodb_mysql.test	2009-07-28 12:56:22 +0000
+++ b/mysql-test/t/innodb_mysql.test	2009-08-31 12:48:42 +0000
@@ -13,6 +13,7 @@ let $test_foreign_keys= 1;
 set global innodb_support_xa=default;
 set session innodb_support_xa=default;
 --source include/mix1.inc
+--source include/have_debug_sync.inc
 
 --disable_warnings
 drop table if exists t1, t2, t3;
@@ -503,4 +504,39 @@ set join_cache_level=default;
 
 DROP TABLE t1,t2;
 
+--echo #
+--echo # Bug #42074: concurrent optimize table and 
+--echo #             alter table = Assertion failed: thd->is_error()
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--echo # Create InnoDB table
+CREATE TABLE t1 (id INT) engine=innodb;
+connect (con2, localhost, root);
+
+--echo # Connection 1
+--echo # Start optimizing table
+connection default;
+SET DEBUG_SYNC='ha_admin_try_alter SIGNAL optimize_started WAIT_FOR table_altered';
+--send OPTIMIZE TABLE t1
+
+--echo # Connection 2
+--echo # Change table to engine=memory
+connection con2;
+SET DEBUG_SYNC='now WAIT_FOR optimize_started';
+ALTER TABLE t1 engine=memory;
+SET DEBUG_SYNC='now SIGNAL table_altered';
+
+--echo # Connection 1
+--echo # Complete optimization
+connection default;
+--reap
+
+disconnect con2;
+DROP TABLE t1;
+SET DEBUG_SYNC='RESET';
+
 --echo End of 6.0 tests

=== modified file 'sql/sql_table.cc'
--- a/sql/sql_table.cc	2009-08-25 07:22:47 +0000
+++ b/sql/sql_table.cc	2009-08-31 12:48:42 +0000
@@ -4807,6 +4807,7 @@ send_result_message:
       close_thread_tables(thd);
       if (!thd->locked_tables_mode)
         thd->mdl_context.release_all_locks();
+      DEBUG_SYNC(thd, "ha_admin_try_alter");
       protocol->store(STRING_WITH_LEN("note"), system_charset_info);
       protocol->store(STRING_WITH_LEN(
           "Table does not support optimize, doing recreate + analyze instead"),
@@ -4847,7 +4848,6 @@ send_result_message:
       protocol->store(operator_name, system_charset_info);
       if (result_code) // either mysql_recreate_table or analyze failed
       {
-        DBUG_ASSERT(thd->is_error());
         if (thd->is_error())
         {
           const char *err_msg= thd->stmt_da->message();


Attachment: [text/bzr-bundle] bzr/jon.hauglid@sun.com-20090831124842-dj9dwz8x31icaaqw.bundle
Thread
bzr commit into mysql-5.4 branch (jon.hauglid:2804) Bug#42074Jon Olav Hauglid31 Aug
  • Re: bzr commit into mysql-5.4 branch (jon.hauglid:2804) Bug#42074Konstantin Osipov15 Sep