List:Commits« Previous MessageNext Message »
From:Michael Widenius Date:October 21 2008 11:29pm
Subject:bzr push into mysql-6.0 branch (monty:2744 to 2746) Bug#39395
View as plain text  
 2746 Michael Widenius	2008-10-22
      Fix for bug#39395 Maria: ma_extra.c:286: maria_extra: Assertion `share->reopen == 1' failed
added:
  mysql-test/suite/maria/r/maria-lock.result
  mysql-test/suite/maria/t/maria-lock.test
modified:
  sql/sql_base.cc
  storage/maria/ma_extra.c

 2745 Michael Widenius	2008-10-22
      Fixes associated with last 5.1-maria -> 6.0-maria merge
modified:
  mysql-test/lib/mtr_cases.pl
  mysql-test/r/lock.result
  mysql-test/suite/maria/r/maria.result
  mysql-test/suite/maria/t/maria.test
  mysql-test/t/lock.test
  sql/key.cc

 2744 Sergei Golubchik	2008-10-21 [merge]
      merged from mysql-maria
removed:
  mysql-test/include/wait_condition.inc.moved
modified:
  include/my_global.h
  include/waiting_threads.h
  mysys/my_wincond.c
  mysys/thr_rwlock.c
  mysys/waiting_threads.c

=== modified file 'mysql-test/lib/mtr_cases.pl'
--- a/mysql-test/lib/mtr_cases.pl	2008-10-20 19:13:22 +0000
+++ b/mysql-test/lib/mtr_cases.pl	2008-10-21 23:12:53 +0000
@@ -60,13 +60,14 @@ sub collect_test_cases ($) {
 
   my $suites= shift; # Semicolon separated list of test suites
   my $cases = [];    # Array of hash
+  my %found_suites;
 
   foreach my $suite (split(",", $suites))
   {
+    $found_suites{$suite}= 1;
     push(@$cases, collect_one_suite($suite));
   }
 
-
   if ( @::opt_cases )
   {
     # Check that the tests specified was found
@@ -75,6 +76,12 @@ sub collect_test_cases ($) {
     {
       my $found= 0;
       my ($sname, $tname, $extension)= split_testname($test_name_spec);
+      if (defined($sname) && !defined($found_suites{$sname}))
+      {
+	$found_suites{$sname}= 1;
+	push(@$cases, collect_one_suite($sname));
+      }
+
       foreach my $test ( @$cases )
       {
 	# test->{name} is always in suite.name format

=== modified file 'mysql-test/r/lock.result'
--- a/mysql-test/r/lock.result	2008-10-09 10:58:51 +0000
+++ b/mysql-test/r/lock.result	2008-10-21 23:12:53 +0000
@@ -1,4 +1,4 @@
-drop table if exists t1,t2;
+drop table if exists t1,t2,t3;
 CREATE TABLE t1 (  `id` int(11) NOT NULL default '0', `id2` int(11) NOT NULL default '0', `id3` int(11) NOT NULL default '0', `dummy1` char(30) default NULL, PRIMARY KEY  (`id`,`id2`), KEY `index_id3` (`id3`)) ENGINE=MyISAM;
 insert into t1 (id,id2) values (1,1),(1,2),(1,3);
 LOCK TABLE t1 WRITE;

=== added file 'mysql-test/suite/maria/r/maria-lock.result'
--- a/mysql-test/suite/maria/r/maria-lock.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/maria/r/maria-lock.result	2008-10-21 23:23:23 +0000
@@ -0,0 +1,35 @@
+drop table if exists t1,t2,t3;
+create table t1 (c1 int) engine=maria;
+create table t2 (c1 int) engine=maria;
+create table t3 (c1 int) engine=maria;
+lock tables t1 write, t2 write, t3 write, t1 as t4 read;
+alter table t2 add column c2 int;
+drop table t1, t2, t3;
+create table t1 (a int) engine=maria;
+create table t2 (a int) engine=maria;
+lock table t1 write, t2 write, t1 as t1_2 write, t2 as t2_2 write;
+insert t1 select * from t2;
+drop table t2;
+"table dropped";
+ERROR 42S02: Table 'test.t2' doesn't exist
+drop table t1;
+create table t1 (a int, b int) engine=maria;
+create table t2 (c int, d int) engine=maria;
+insert into t1 values(1,1);
+insert into t1 values(2,2);
+insert into t2 values(1,2);
+lock table t1 read;
+update t1,t2 set c=a where b=d;
+select c from t2;
+c
+2
+unlock tables;
+drop table t1;
+drop table t2;
+create table t1 (a int) engine=maria;
+create table t2 (a int) engine=maria;
+lock table t1 write, t2 write, t1 as t1_2 write, t2 as t2_2 write;
+insert t1 select * from t2;
+drop table t2;
+ERROR 42S02: Table 'test.t2' doesn't exist
+drop table t1;

=== modified file 'mysql-test/suite/maria/r/maria.result'
--- a/mysql-test/suite/maria/r/maria.result	2008-10-20 13:03:34 +0000
+++ b/mysql-test/suite/maria/r/maria.result	2008-10-21 23:12:53 +0000
@@ -2551,6 +2551,8 @@ insert into t1 values (1);
 lock table t1 write concurrent;
 delete from t1;
 ERROR 42000: The storage engine for the table doesn't support DELETE in WRITE CONCURRENT
+drop table t1;
+ERROR HY000: Table 't1' was locked with a READ lock and can't be updated
 unlock tables;
 drop table t1;
 create table t1 (p int primary key, i int, a char(10), key k1(i), key k2(a))
@@ -2599,6 +2601,11 @@ ALTER TABLE t1 CHANGE c d varchar(10);
 affected rows: 0
 info: Records: 0  Duplicates: 0  Warnings: 0
 drop table t1;
+create table t1 (s1 int);
+insert into t1 values (1);
+alter table t1 partition by list (s1) (partition p1 values in (2));
+ERROR HY000: Table has no partition for value 1
+drop table t1;
 create table t1 (c1 int);
 create table t2 (c1 int);
 lock table t1 read, t2 read;

=== added file 'mysql-test/suite/maria/t/maria-lock.test'
--- a/mysql-test/suite/maria/t/maria-lock.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/maria/t/maria-lock.test	2008-10-21 23:23:23 +0000
@@ -0,0 +1,98 @@
+#
+# Different cases involving locking that has failed with Maria
+#
+# Can't test with embedded server
+-- source include/not_embedded.inc
+
+--disable_warnings
+drop table if exists t1,t2,t3;
+--enable_warnings
+
+# Check that a lock merge works.
+create table t1 (c1 int) engine=maria;
+create table t2 (c1 int) engine=maria;
+create table t3 (c1 int) engine=maria;
+lock tables t1 write, t2 write, t3 write, t1 as t4 read;
+alter table t2 add column c2 int;
+drop table t1, t2, t3;
+
+#
+# Bug #39395 maria_extra: Assertion `share->reopen == 1' failed
+#
+# Test problem when using locks on many tables and droping a table that
+# is to-be-locked by another thread. Dropped table locked twice
+#
+
+connect (locker,localhost,root,,);
+connect (reader,localhost,root,,);
+connect (writer,localhost,root,,);
+
+connection locker;
+create table t1 (a int) engine=maria;
+create table t2 (a int) engine=maria;
+lock table t1 write, t2 write, t1 as t1_2 write, t2 as t2_2 write;
+connection reader;
+send insert t1 select * from t2;
+connection locker;
+let $wait_condition=
+  select count(*) = 1 from information_schema.processlist
+  where state = "Table lock" and info = "insert t1 select * from t2";
+--source include/wait_condition.inc
+drop table t2;
+--echo "table dropped";
+connection reader;
+--error 1146
+reap;
+connection locker;
+drop table t1;
+connection default;
+
+#
+# We need to disconnect and reconnect for the bug to appear. This is still
+# part of Bug#39395
+#
+
+disconnect locker;
+disconnect reader;
+disconnect writer;
+connect (locker,localhost,root,,);
+connect (reader,localhost,root,,);
+connect (writer,localhost,root,,);
+
+connection locker;
+create table t1 (a int, b int) engine=maria;
+create table t2 (c int, d int) engine=maria;
+insert into t1 values(1,1);
+insert into t1 values(2,2);
+insert into t2 values(1,2);
+lock table t1 read;
+connection writer;
+update t1,t2 set c=a where b=d;
+connection reader;
+select c from t2;
+connection locker;
+unlock tables;
+drop table t1;
+drop table t2;
+
+connection locker;
+create table t1 (a int) engine=maria;
+create table t2 (a int) engine=maria;
+lock table t1 write, t2 write, t1 as t1_2 write, t2 as t2_2 write;
+connection reader;
+send insert t1 select * from t2;
+connection locker;
+let $wait_condition=
+  select count(*) = 1 from information_schema.processlist
+  where state = "Table lock" and info = "insert t1 select * from t2";
+--source include/wait_condition.inc
+drop table t2;
+connection reader;
+--error 1146
+reap;
+connection locker;
+drop table t1;
+connection default;
+disconnect locker;
+disconnect reader;
+disconnect writer;

=== modified file 'mysql-test/suite/maria/t/maria.test'
--- a/mysql-test/suite/maria/t/maria.test	2008-10-20 13:03:34 +0000
+++ b/mysql-test/suite/maria/t/maria.test	2008-10-21 23:12:53 +0000
@@ -1832,6 +1832,8 @@ lock table t1 write concurrent;
 # should be fixed with fully implemented versioning
 --error ER_CHECK_NOT_IMPLEMENTED
 delete from t1;
+--error 1099
+drop table t1;
 unlock tables;
 drop table t1;
 
@@ -1880,7 +1882,18 @@ ALTER TABLE t1 CHANGE c d varchar(10);
 drop table t1;
 
 #
+# Bug #39227 Maria: crash with ALTER TABLE PARTITION
+#
+
+create table t1 (s1 int);
+insert into t1 values (1);
+--error ER_NO_PARTITION_FOR_GIVEN_VALUE
+alter table t1 partition by list (s1) (partition p1 values in (2));
+drop table t1;
+
+#
 # Bug #39226 Maria: crash with FLUSH TABLES WITH READ LOCK after LOCK TABLES
+#
 
 create table t1 (c1 int);
 create table t2 (c1 int);
@@ -1891,7 +1904,9 @@ flush tables with read lock;
 unlock tables;
 drop table t1, t2;
 
+#
 # Set defaults back
+#
 --disable_result_log
 --disable_query_log
 eval set global storage_engine=$default_engine, maria_page_checksum=$default_checksum;

=== modified file 'mysql-test/t/lock.test'
--- a/mysql-test/t/lock.test	2008-06-25 12:44:00 +0000
+++ b/mysql-test/t/lock.test	2008-10-21 23:12:53 +0000
@@ -3,7 +3,7 @@
 #
 
 --disable_warnings
-drop table if exists t1,t2;
+drop table if exists t1,t2,t3;
 --enable_warnings
 CREATE TABLE t1 (  `id` int(11) NOT NULL default '0', `id2` int(11) NOT NULL default '0', `id3` int(11) NOT NULL default '0', `dummy1` char(30) default NULL, PRIMARY KEY  (`id`,`id2`), KEY `index_id3` (`id3`)) ENGINE=MyISAM;
 insert into t1 (id,id2) values (1,1),(1,2),(1,3);

=== modified file 'sql/key.cc'
--- a/sql/key.cc	2008-09-08 14:54:16 +0000
+++ b/sql/key.cc	2008-10-21 23:12:53 +0000
@@ -368,7 +368,7 @@ void key_unpack(String *to,TABLE *table,
     {
       CHARSET_INFO *cs= field->charset();
       field->val_str(&tmp);
-      if (cs->mbmaxlen > 1 && tmp.length() > 0 &&
+      if (cs->mbmaxlen > 1 &&
           table->field[key_part->fieldnr - 1]->field_length !=
           key_part->length)
       {
@@ -382,7 +382,7 @@ void key_unpack(String *to,TABLE *table,
         uint charpos, char_length= key_part->length / cs->mbmaxlen;
         if ((charpos= my_charpos(cs, tmp.ptr(),
                                  tmp.ptr() + tmp.length(),
-                                 char_length)) < key_part->length)
+                                 char_length)) < tmp.length())
           tmp.length(charpos);
       }
       

=== modified file 'sql/sql_base.cc'
--- a/sql/sql_base.cc	2008-10-20 19:13:22 +0000
+++ b/sql/sql_base.cc	2008-10-21 23:23:23 +0000
@@ -2031,12 +2031,16 @@ bool wait_while_table_is_used(THD *thd, 
                               enum ha_extra_function function)
 {
   enum thr_lock_type old_lock_type;
-
   DBUG_ENTER("wait_while_table_is_used");
   DBUG_PRINT("enter", ("table: '%s'  share: %p  db_stat: %u  version: %lu",
                        table->s->table_name.str, table->s,
                        table->db_stat, table->s->version));
 
+  /* Ensure no one can reopen table before it's removed */
+  pthread_mutex_lock(&LOCK_open);
+  table->s->version= 0;
+  pthread_mutex_unlock(&LOCK_open);
+
   old_lock_type= table->reginfo.lock_type;
   mysql_lock_abort(thd, table, TRUE);	/* end threads waiting on lock */
 

=== modified file 'storage/maria/ma_extra.c'
--- a/storage/maria/ma_extra.c	2008-10-20 09:16:47 +0000
+++ b/storage/maria/ma_extra.c	2008-10-21 23:23:23 +0000
@@ -279,11 +279,12 @@ int maria_extra(MARIA_HA *info, enum ha_
   case HA_EXTRA_FORCE_REOPEN:
     /*
       MySQL uses this case after it has closed all other instances
-      of this table.
-      We however do a flush here for additional safety.
+      of this table;  Note that MySQL may have several copies of the table
+      in the same thread!
+
+      We owever do a flush of data and index here for additional safety.
     */
     /** @todo consider porting these flush-es to MyISAM */
-    DBUG_ASSERT(share->reopen == 1);
     error= _ma_flush_table_files(info, MARIA_FLUSH_DATA | MARIA_FLUSH_INDEX,
                                  FLUSH_FORCE_WRITE, FLUSH_FORCE_WRITE);
     if (!error && share->changed)

Thread
bzr push into mysql-6.0 branch (monty:2744 to 2746) Bug#39395Michael Widenius22 Oct