#At file:///data0/magnus/mysql/7.0-bug11894966/ based on revid:magnus.blaudd@strippedyznse
4251 Magnus Blåudd 2011-03-22
Bug#11894966 - second mysqld does not have table after non distributed table
alter to ndb
- move the ndb_create_table_from_engine call and related code out of
"if (ndb_binlog_running)", ndb schema distribution should run
also when mysqld is not configured to binlog
modified:
mysql-test/suite/ndb/r/ndb_multi.result
mysql-test/suite/ndb/t/ndb_multi.test
sql/ha_ndbcluster_binlog.cc
=== modified file 'mysql-test/suite/ndb/r/ndb_multi.result'
--- a/mysql-test/suite/ndb/r/ndb_multi.result 2009-11-10 14:07:30 +0000
+++ b/mysql-test/suite/ndb/r/ndb_multi.result 2011-03-22 08:32:32 +0000
@@ -189,3 +189,10 @@ b
c
drop table t1;
drop table t1;
+Bug 11894966 - second mysqld does not have table after non
+distributed table alter to ndb
+create table t1(a int) engine myisam;
+insert into t1 values(37);
+alter table t1 engine ndb;
+truncate t1;
+drop table t1;
=== modified file 'mysql-test/suite/ndb/t/ndb_multi.test'
--- a/mysql-test/suite/ndb/t/ndb_multi.test 2009-12-17 15:43:35 +0000
+++ b/mysql-test/suite/ndb/t/ndb_multi.test 2011-03-22 08:32:32 +0000
@@ -210,4 +210,39 @@ select * from t1 order by s;
connection server1;
drop table t1;
connection server2;
-drop table t1;
\ No newline at end of file
+drop table t1;
+
+#
+--echo Bug 11894966 - second mysqld does not have table after non
+--echo distributed table alter to ndb
+#
+# - only queries with "autodiscover" see the new table
+# on second mysqld since schema distribution does not
+# create the table on second mysqld(at least when !ndb_binlog_running)
+#
+connection server1;
+
+# Create table t1 in myisam
+create table t1(a int) engine myisam;
+insert into t1 values(37);
+
+# Alter t1 into ndb
+alter table t1 engine ndb;
+
+# Switch to other mysqld
+connection server2;
+
+# Check that .frm and .ndb file has been created
+# on second mysqld
+let $datadir2 = `select @@datadir`;
+#echo datadir2: $datadir2;
+--file_exists $datadir2/test/t1.frm
+--file_exists $datadir2/test/t1.ndb
+
+# Check that truncate works on second mysqld
+# (didn't work before fix)
+truncate t1;
+
+# Cleanup
+drop table t1;
+connection server1;
=== modified file 'sql/ha_ndbcluster_binlog.cc'
--- a/sql/ha_ndbcluster_binlog.cc 2011-02-18 13:55:27 +0000
+++ b/sql/ha_ndbcluster_binlog.cc 2011-03-22 08:32:32 +0000
@@ -3197,38 +3197,35 @@ ndb_binlog_thread_handle_schema_event_po
}
free_share(&share);
}
- if (ndb_binlog_running)
+
+ if (share)
{
/*
- we need to free any share here as command below
- may need to call handle_trailing_share
+ Free the share pointer early, ndb_create_table_from_engine()
+ may delete what share is pointing to as a sideeffect
*/
- if (share)
- {
- /* ndb_share reference temporary free */
- DBUG_PRINT("NDB_SHARE", ("%s temporary free use_count: %u",
- share->key, share->use_count));
- free_share(&share);
- share= 0;
- }
- thd_ndb_options.set(TNO_NO_LOCK_SCHEMA_OP);
- mysql_mutex_lock(&LOCK_open);
- if (ndbcluster_check_if_local_table(schema->db, schema->name))
- {
- DBUG_PRINT("info", ("NDB Binlog: Skipping locally defined table '%s.%s'",
- schema->db, schema->name));
- sql_print_error("NDB Binlog: Skipping locally defined table '%s.%s' from "
- "binlog schema event '%s' from node %d. ",
- schema->db, schema->name, schema->query,
- schema->node_id);
- }
- else if (ndb_create_table_from_engine(thd, schema->db, schema->name))
- {
- print_could_not_discover_error(thd, schema);
- }
- mysql_mutex_unlock(&LOCK_open);
+ DBUG_PRINT("NDB_SHARE", ("%s early free, use_count: %u",
+ share->key, share->use_count));
+ free_share(&share);
+ share= 0;
}
+
+ thd_ndb_options.set(TNO_NO_LOCK_SCHEMA_OP);
+ mysql_mutex_lock(&LOCK_open);
+ if (ndbcluster_check_if_local_table(schema->db, schema->name))
+ {
+ sql_print_error("NDB Binlog: Skipping locally defined table '%s.%s' "
+ "from binlog schema event '%s' from node %d.",
+ schema->db, schema->name, schema->query,
+ schema->node_id);
+ }
+ else if (ndb_create_table_from_engine(thd, schema->db, schema->name))
+ {
+ print_could_not_discover_error(thd, schema);
+ }
+ mysql_mutex_unlock(&LOCK_open);
break;
+
case SOT_ONLINE_ALTER_TABLE_PREPARE:
{
if (opt_ndb_extra_logging > 9)
Attachment: [text/bzr-bundle] bzr/magnus.blaudd@oracle.com-20110322083232-ev1pi0ag7bju7pkg.bundle
| Thread |
|---|
| • bzr commit into mysql-5.1-telco-7.0 branch (magnus.blaudd:4251) Bug#11894966 | Magnus Blåudd | 22 Mar |