From: Ole John Aske Date: March 23 2011 12:55pm Subject: bzr commit into mysql-5.1-telco-7.0-spj-scan-vs-scan branch (ole.john.aske:3451) List-Archive: http://lists.mysql.com/commits/133631 Message-Id: <20110323125530.37D17218@fimafeng09.norway.sun.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit #At file:///net/fimafeng09/export/home/tmp/oleja/mysql/mysql-5.1-telco-7.0-spj-scan-scan/ based on revid:ole.john.aske@stripped 3451 Ole John Aske 2011-03-23 [merge] SPJ merge from telco mainline > SPJ branch removed: mysql-test/suite/rpl_ndb/have_one_ndb.inc modified: mysql-test/suite/ndb/r/ndb_multi.result mysql-test/suite/ndb/t/ndb_multi.test mysql-test/suite/rpl_ndb/ndb_master-slave.inc sql/ha_ndbcluster_binlog.cc storage/ndb/src/common/portlib/NdbCondition.c === 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; === removed file 'mysql-test/suite/rpl_ndb/have_one_ndb.inc' --- a/mysql-test/suite/rpl_ndb/have_one_ndb.inc 2010-10-22 15:16:26 +0000 +++ b/mysql-test/suite/rpl_ndb/have_one_ndb.inc 1970-01-01 00:00:00 +0000 @@ -1,15 +0,0 @@ -# Check that server is compiled and started with support for NDB -disable_query_log; ---require r/true.require -select (support = 'YES' or support = 'DEFAULT') as `TRUE` from information_schema.engines where engine = 'ndbcluster'; -enable_query_log; - -#cleanup -disable_query_log; -disable_warnings; ---error 0,1051 -drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9,t10; -flush tables; -flush status; -enable_warnings; -enable_query_log; === modified file 'mysql-test/suite/rpl_ndb/ndb_master-slave.inc' --- a/mysql-test/suite/rpl_ndb/ndb_master-slave.inc 2011-03-16 10:52:36 +0000 +++ b/mysql-test/suite/rpl_ndb/ndb_master-slave.inc 2011-03-18 07:04:45 +0000 @@ -1,16 +1 @@ -# Replication tests need binlog -source include/have_log_bin.inc; - -connect (master,127.0.0.1,root,,test,$MASTER_MYPORT,); -connect (master1,127.0.0.1,root,,test,$MASTER_MYPORT,); - -connect (slave,127.0.0.1,root,,test,$SLAVE_MYPORT,); --- connection slave --- source suite/rpl_ndb/have_one_ndb.inc - -connect (slave1,127.0.0.1,root,,test,$SLAVE_MYPORT,); - --- source include/master-slave-reset.inc - -# Set the default connection to 'master' -connection master; +--source include/master-slave.inc === 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) === modified file 'storage/ndb/src/common/portlib/NdbCondition.c' --- a/storage/ndb/src/common/portlib/NdbCondition.c 2011-03-15 15:55:03 +0000 +++ b/storage/ndb/src/common/portlib/NdbCondition.c 2011-03-18 14:14:08 +0000 @@ -33,17 +33,19 @@ NdbCondition_initialize(int need_monoton #if defined HAVE_CLOCK_GETTIME && defined HAVE_PTHREAD_CONDATTR_SETCLOCK && \ defined CLOCK_MONOTONIC - int res; + int res, condattr_init = 0; pthread_cond_t tmp; pthread_condattr_t attr; + init = 1; + if (!need_monotonic) return; if ((res = pthread_condattr_init(&attr)) != 0) goto nogo; - init = 1; + condattr_init = 1; if ((res = pthread_condattr_setclock(&attr, CLOCK_MONOTONIC)) != 0) goto nogo; @@ -59,7 +61,7 @@ NdbCondition_initialize(int need_monoton return; nogo: - if (init) + if (condattr_init) { pthread_condattr_destroy(&attr); } No bundle (reason: revision is a merge).