List:Commits« Previous MessageNext Message »
From:Frazer Clement Date:October 23 2009 2:57pm
Subject:bzr commit into mysql-5.1-telco-7.0 branch (frazer:3156)
View as plain text  
#At file:///home/frazer/bzr/mysql-5.1-telco-7.0/

 3156 Frazer Clement	2009-10-23 [merge]
      Merge 6.3->7.0
      modified:
        mysql-test/include/have_multi_ndb.inc
        mysql-test/include/have_ndb.inc
        mysql-test/include/have_one_ndb.inc
        mysql-test/include/ndb_master-slave_2ch.inc
        mysql-test/suite/ndb/my.cnf
        mysql-test/suite/ndb/t/ndb_discover_db.test
        mysql-test/suite/ndb_binlog/my.cnf
        mysql-test/suite/ndb_binlog/t/ndb_binlog_variants.cnf
        mysql-test/suite/ndb_team/my.cnf
        mysql-test/suite/rpl_ndb/my.cnf
        sql/ha_ndbcluster.cc
        sql/ha_ndbcluster_binlog.cc
        sql/mysql_priv.h
        sql/mysqld.cc
        sql/slave.cc

=== modified file 'mysql-test/include/have_multi_ndb.inc'
--- a/mysql-test/include/have_multi_ndb.inc	2009-02-11 10:27:14 +0000
+++ b/mysql-test/include/have_multi_ndb.inc	2009-10-23 14:56:46 +0000
@@ -23,7 +23,6 @@ if (`SELECT 1 FROM dual WHERE '$engines_
 {
 --require r/true.require
 SELECT (support = 'YES' or support = 'DEFAULT' or support = 'ENABLED') as `TRUE` FROM information_schema.engines WHERE engine = 'ndbcluster';
---source include/ndb_not_readonly.inc
 }
 enable_query_log;
 
@@ -37,7 +36,6 @@ if (`SELECT 1 FROM dual WHERE '$engines_
 {
 --require r/true.require
 SELECT (support = 'YES' or support = 'DEFAULT' or support = 'ENABLED') as `TRUE` FROM information_schema.engines WHERE engine = 'ndbcluster';
---source include/ndb_not_readonly.inc
 }
 enable_query_log;
 }

=== modified file 'mysql-test/include/have_ndb.inc'
--- a/mysql-test/include/have_ndb.inc	2009-02-11 10:27:14 +0000
+++ b/mysql-test/include/have_ndb.inc	2009-10-23 14:56:46 +0000
@@ -22,11 +22,6 @@ if (!`select @have_ndb`){
 }
 
 #
-# Wait until mysqld has connected properly to cluster
-#
-source include/ndb_not_readonly.inc;
-
-#
 # cleanup
 #
 

=== modified file 'mysql-test/include/have_one_ndb.inc'
--- a/mysql-test/include/have_one_ndb.inc	2009-02-03 13:35:56 +0000
+++ b/mysql-test/include/have_one_ndb.inc	2009-10-23 14:31:33 +0000
@@ -2,7 +2,6 @@
 disable_query_log;
 --require r/true.require
 select (support = 'YES' or support = 'DEFAULT') as `TRUE` from information_schema.engines where engine = 'ndbcluster';
---source include/ndb_not_readonly.inc
 enable_query_log;
 
 #cleanup

=== modified file 'mysql-test/include/ndb_master-slave_2ch.inc'
--- a/mysql-test/include/ndb_master-slave_2ch.inc	2008-04-24 20:41:04 +0000
+++ b/mysql-test/include/ndb_master-slave_2ch.inc	2009-10-23 14:02:54 +0000
@@ -26,28 +26,24 @@ connect (slave1,127.0.0.1,root,,test,$SL
 --disable_query_log
 --require r/true.require
 SELECT (support = 'YES' or support = 'DEFAULT') AS `TRUE` FROM information_schema.engines WHERE engine = 'ndbcluster';
---source include/ndb_not_readonly.inc
 --enable_query_log
 
 --connection master1
 --disable_query_log
 --require r/true.require
 SELECT (support = 'YES' or support = 'DEFAULT') AS `TRUE` FROM information_schema.engines WHERE engine = 'ndbcluster';
---source include/ndb_not_readonly.inc
 --enable_query_log
 
 --connection slave
 --disable_query_log
 --require r/true.require
 SELECT (support = 'YES' or support = 'DEFAULT') AS `TRUE` FROM information_schema.engines WHERE engine = 'ndbcluster';
---source include/ndb_not_readonly.inc
 --enable_query_log
 
 --connection slave1
 --disable_query_log
 --require r/true.require
 SELECT (support = 'YES' or support = 'DEFAULT') AS `TRUE` FROM information_schema.engines WHERE engine = 'ndbcluster';
---source include/ndb_not_readonly.inc
 --enable_query_log
 
 # Stop slaves

=== modified file 'mysql-test/suite/ndb/my.cnf'
--- a/mysql-test/suite/ndb/my.cnf	2009-10-22 11:33:55 +0000
+++ b/mysql-test/suite/ndb/my.cnf	2009-10-23 14:56:46 +0000
@@ -38,6 +38,7 @@ NodeId=255
 # Make all mysqlds use cluster
 ndbcluster
 ndb-wait-connected=20
+ndb-wait-setup=60
 ndb-cluster-connection-pool=3
 ndb-extra-logging=99
 

=== modified file 'mysql-test/suite/ndb/t/ndb_discover_db.test'
--- a/mysql-test/suite/ndb/t/ndb_discover_db.test	2009-02-01 21:05:19 +0000
+++ b/mysql-test/suite/ndb/t/ndb_discover_db.test	2009-10-23 14:02:54 +0000
@@ -58,9 +58,6 @@ EOF
 # Turn off reconnect again.
 --disable_reconnect
 #
---disable_query_log
---source include/ndb_not_readonly.inc
---enable_query_log
 
 #
 # Now check that databases have been discovered

=== modified file 'mysql-test/suite/ndb_binlog/my.cnf'
--- a/mysql-test/suite/ndb_binlog/my.cnf	2009-10-22 11:09:33 +0000
+++ b/mysql-test/suite/ndb_binlog/my.cnf	2009-10-23 14:31:33 +0000
@@ -12,6 +12,7 @@ ndbapi=,,,,,,,,,,,
 # Make all mysqlds use cluster
 ndbcluster
 ndb-wait-connected=20
+ndb-wait-setup=60
 ndb-cluster-connection-pool=3
 ndb-extra-logging=99
 

=== modified file 'mysql-test/suite/ndb_binlog/t/ndb_binlog_variants.cnf'
--- a/mysql-test/suite/ndb_binlog/t/ndb_binlog_variants.cnf	2009-09-29 14:25:03 +0000
+++ b/mysql-test/suite/ndb_binlog/t/ndb_binlog_variants.cnf	2009-10-23 14:02:54 +0000
@@ -15,6 +15,7 @@ ndbapi=,,,,,,,,,,,
 # Make all mysqlds use cluster
 ndbcluster
 ndb-wait-connected=20
+ndb-wait-setup=60
 ndb-cluster-connection-pool=1
 binlog-format=row
 

=== modified file 'mysql-test/suite/ndb_team/my.cnf'
--- a/mysql-test/suite/ndb_team/my.cnf	2009-10-22 11:09:33 +0000
+++ b/mysql-test/suite/ndb_team/my.cnf	2009-10-23 14:31:33 +0000
@@ -19,6 +19,7 @@ ndbapi=,,,,
 # Make all mysqlds use cluster
 ndbcluster
 ndb-wait-connected=20
+ndb-wait-setup=60
 ndb-cluster-connection-pool=3
 loose-slave-allow-batching
 loose-ndb-log-orig

=== modified file 'mysql-test/suite/rpl_ndb/my.cnf'
--- a/mysql-test/suite/rpl_ndb/my.cnf	2009-10-22 11:09:33 +0000
+++ b/mysql-test/suite/rpl_ndb/my.cnf	2009-10-23 14:31:33 +0000
@@ -19,6 +19,7 @@ ndbapi=,,,,
 # Make all mysqlds use cluster
 ndbcluster
 ndb-wait-connected=20
+ndb-wait-setup=60
 ndb-cluster-connection-pool=3
 slave-allow-batching
 ndb-log-orig

=== modified file 'sql/ha_ndbcluster.cc'
--- a/sql/ha_ndbcluster.cc	2009-10-21 16:49:01 +0000
+++ b/sql/ha_ndbcluster.cc	2009-10-23 14:56:46 +0000
@@ -154,6 +154,14 @@ static void set_ndb_err(THD *thd, const 
 static int ndbcluster_inited= 0;
 int ndbcluster_terminating= 0;
 
+/* 
+   Indicator and CONDVAR used to delay client and slave
+   connections until Ndb has Binlog setup
+   (bug#46955)
+*/
+int ndb_setup_complete= 0;
+pthread_cond_t COND_ndb_setup_complete; // Signal with ndbcluster_mutex
+
 extern Ndb* g_ndb;
 
 uchar g_node_id_map[max_ndb_nodes];
@@ -9364,9 +9372,55 @@ static int connect_callback()
   return 0;
 }
 
+static int ndb_wait_setup_func_impl(ulong max_wait)
+{
+  DBUG_ENTER("ndb_wait_setup_func_impl");
+
+#ifdef HAVE_NDB_BINLOG
+  pthread_mutex_lock(&ndbcluster_mutex);
+
+  struct timespec abstime;
+  set_timespec(abstime, 1);
+  
+  while (!ndb_setup_complete && max_wait)
+  {
+    int rc= pthread_cond_timedwait(&COND_ndb_setup_complete, 
+                                   &ndbcluster_mutex,
+                                   &abstime);
+    if (rc)
+    {
+      if (rc == ETIMEDOUT)
+      {
+        DBUG_PRINT("info", ("1s elapsed waiting"));
+        max_wait--;
+        set_timespec(abstime, 1); /* 1 second from now*/
+      }
+      else
+      {
+        DBUG_PRINT("info", ("Bad pthread_cond_timedwait rc : %u",
+                            rc));
+        assert(false);
+        break;
+      }
+    }
+  }
+
+  pthread_mutex_unlock(&ndbcluster_mutex);
+
+  DBUG_RETURN((ndb_setup_complete == 1)? 0 : 1);
+#else
+  ndb_setup_complete = 1;
+  DBUG_RETURN(0);
+#endif
+}
+
 extern int ndb_dictionary_is_mysqld;
 extern pthread_mutex_t LOCK_plugin;
 
+#ifdef HAVE_NDB_BINLOG
+extern wait_cond_timed_func ndb_wait_setup_func;
+#endif
+
 static int ndbcluster_init(void *p)
 {
   DBUG_ENTER("ndbcluster_init");
@@ -9385,9 +9439,11 @@ static int ndbcluster_init(void *p)
   pthread_mutex_init(&LOCK_ndb_util_thread, MY_MUTEX_INIT_FAST);
   pthread_cond_init(&COND_ndb_util_thread, NULL);
   pthread_cond_init(&COND_ndb_util_ready, NULL);
+  pthread_cond_init(&COND_ndb_setup_complete, NULL);
   ndb_util_thread_running= -1;
   ndbcluster_terminating= 0;
   ndb_dictionary_is_mysqld= 1;
+  ndb_setup_complete= 0;
   ndbcluster_hton= (handlerton *)p;
   ndbcluster_global_schema_lock_init();
 
@@ -9444,6 +9500,7 @@ static int ndbcluster_init(void *p)
     pthread_mutex_destroy(&LOCK_ndb_util_thread);
     pthread_cond_destroy(&COND_ndb_util_thread);
     pthread_cond_destroy(&COND_ndb_util_ready);
+    pthread_cond_destroy(&COND_ndb_setup_complete);
     ndbcluster_global_schema_lock_deinit();
     goto ndbcluster_init_error;
   }
@@ -9462,10 +9519,15 @@ static int ndbcluster_init(void *p)
     pthread_mutex_destroy(&LOCK_ndb_util_thread);
     pthread_cond_destroy(&COND_ndb_util_thread);
     pthread_cond_destroy(&COND_ndb_util_ready);
+    pthread_cond_destroy(&COND_ndb_setup_complete);
     ndbcluster_global_schema_lock_deinit();
     goto ndbcluster_init_error;
   }
 
+#ifdef HAVE_NDB_BINLOG
+  ndb_wait_setup_func= ndb_wait_setup_func_impl;
+#endif
+
   pthread_mutex_lock(&LOCK_plugin);
 
   ndbcluster_inited= 1;
@@ -9519,6 +9581,7 @@ static int ndbcluster_end(handlerton *ht
   pthread_mutex_destroy(&LOCK_ndb_util_thread);
   pthread_cond_destroy(&COND_ndb_util_thread);
   pthread_cond_destroy(&COND_ndb_util_ready);
+  pthread_cond_destroy(&COND_ndb_setup_complete);
   ndbcluster_global_schema_lock_deinit();
   DBUG_RETURN(0);
 }

=== modified file 'sql/ha_ndbcluster_binlog.cc'
--- a/sql/ha_ndbcluster_binlog.cc	2009-10-01 07:16:52 +0000
+++ b/sql/ha_ndbcluster_binlog.cc	2009-10-23 14:56:46 +0000
@@ -1198,6 +1198,27 @@ private:
   uint32 m_save_val;
 };
 
+#ifdef HAVE_NDB_BINLOG
+extern int ndb_setup_complete;
+extern pthread_cond_t COND_ndb_setup_complete;
+#endif
+
+/*
+   ndb_notify_tables_writable
+   
+   Called to notify any waiting threads that Ndb tables are
+   now writable
+*/ 
+static void ndb_notify_tables_writable()
+{
+#ifdef HAVE_NDB_BINLOG
+  pthread_mutex_lock(&ndbcluster_mutex);
+  ndb_setup_complete= 1;
+  pthread_cond_broadcast(&COND_ndb_setup_complete);
+  pthread_mutex_unlock(&ndbcluster_mutex);
+#endif
+}
+
 /*
   Ndb has no representation of the database schema objects.
   The mysql.ndb_schema table contains the latest schema operations
@@ -1406,6 +1427,12 @@ int ndbcluster_setup_binlog_table_shares
       if (ndb_extra_logging)
         sql_print_information("NDB Binlog: ndb tables writable");
       close_cached_tables(NULL, NULL, TRUE, FALSE, FALSE);
+      
+      /* 
+         Signal any waiting thread that ndb table setup is
+         now complete
+      */
+      ndb_notify_tables_writable();
     }
     pthread_mutex_unlock(&LOCK_open);
     /* Signal injector thread that all is setup */
@@ -5751,6 +5778,12 @@ restart_cluster_failure:
     sql_print_information("NDB Binlog: ndb tables writable");
   close_cached_tables((THD*) 0, (TABLE_LIST*) 0, FALSE, FALSE, FALSE);
 
+  /* 
+     Signal any waiting thread that ndb table setup is
+     now complete
+  */
+  ndb_notify_tables_writable();
+
   {
     static char db[]= "";
     thd->db= db;

=== modified file 'sql/mysql_priv.h'
--- a/sql/mysql_priv.h	2009-10-01 07:16:52 +0000
+++ b/sql/mysql_priv.h	2009-10-23 14:56:46 +0000
@@ -2490,6 +2490,18 @@ inline bool is_user_table(TABLE * table)
   return strncmp(name, tmp_file_prefix, tmp_file_prefix_length);
 }
 
+#ifdef HAVE_NDB_BINLOG
+/*
+   function type for timed wait on some condition
+   max_seconds
+     0 == no wait
+   returns
+     0  condition true within timeout
+     >0 timeout occurred
+*/ 
+typedef int (*wait_cond_timed_func)(ulong max_seconds);
+#endif
+
 /*
   Some functions that are different in the embedded library and the normal
   server

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2009-10-01 07:16:52 +0000
+++ b/sql/mysqld.cc	2009-10-23 14:56:46 +0000
@@ -469,6 +469,10 @@ my_bool opt_ndb_log_updated_only= FALSE;
 my_bool opt_ndb_log_orig= FALSE;
 my_bool opt_ndb_log_bin= FALSE;
 my_bool opt_ndb_log_empty_epochs= FALSE;
+#ifdef HAVE_NDB_BINLOG
+ulong opt_ndb_wait_setup;
+wait_cond_timed_func ndb_wait_setup_func= 0;
+#endif
 
 extern "C" char opt_ndb_constrbuf[1024];
 extern "C" my_bool opt_ndb_shm;
@@ -4501,11 +4505,6 @@ we force server id to 2, but this MySQL 
   create_shutdown_thread();
   start_handle_manager();
 
-  sql_print_information(ER(ER_STARTUP),my_progname,server_version,
-                        ((!my_socket_valid(unix_sock)) ? (char*) ""
-                                                       : mysqld_unix_port),
-                         mysqld_port,
-                         MYSQL_COMPILATION_COMMENT);
 #if defined(_WIN32) && !defined(EMBEDDED_LIBRARY)
   Service.SetRunning();
 #endif
@@ -4517,6 +4516,28 @@ we force server id to 2, but this MySQL 
   pthread_cond_signal(&COND_server_started);
   pthread_mutex_unlock(&LOCK_server_started);
 
+#ifdef HAVE_NDB_BINLOG
+  /* 
+     Give ndb opportunity to initialise more things after
+     mysqld_server_started is true
+  */
+  if (ndb_wait_setup_func)
+  {
+    if (ndb_wait_setup_func(opt_ndb_wait_setup))
+    {
+      sql_print_warning("NDB : Tables not available after %lu seconds."
+                        "  Consider increasing --ndb-wait-setup value",
+                        opt_ndb_wait_setup);
+    }
+  }
+#endif
+
+  sql_print_information(ER(ER_STARTUP),my_progname,server_version,
+                        ((!my_socket_valid(unix_sock)) ? (char*) ""
+                                                       : mysqld_unix_port),
+                         mysqld_port,
+                         MYSQL_COMPILATION_COMMENT);
+  
 #if defined(__NT__) || defined(HAVE_SMEM)
   handle_connections_methods();
 #else
@@ -5579,6 +5600,7 @@ enum options_mysqld
   OPT_NDB_TABLE_TEMPORARY,
   OPT_NDB_WAIT_CONNECTED,
   OPT_NDB_CLUSTER_CONNECTION_POOL,
+  OPT_NDB_WAIT_SETUP,
   OPT_NDB_MGMD, OPT_NDB_NODEID,
   OPT_NDB_DISTRIBUTION,
   OPT_NDB_INDEX_STAT_ENABLE,
@@ -6200,6 +6222,10 @@ master-ssl",
    "ndb_binlog_index table.",
    (uchar**) &ndb_log_binlog_index, (uchar**) &ndb_log_binlog_index,
    0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0},
+  { "ndb-wait-setup", OPT_NDB_WAIT_SETUP,
+    "Time (in seconds) for mysqld to wait for Ndb engine setup to complete",
+    (uchar**) &opt_ndb_wait_setup, (uchar**) &opt_ndb_wait_setup,
+    0, GET_ULONG, REQUIRED_ARG, 15, 0, LONG_TIMEOUT, 0, 0, 0},
   {"ndb-log-empty-epochs", OPT_NDB_LOG_EMPTY_EPOCHS,
    "",
    (uchar**) &opt_ndb_log_empty_epochs,

=== modified file 'sql/slave.cc'
--- a/sql/slave.cc	2009-10-01 07:17:30 +0000
+++ b/sql/slave.cc	2009-10-23 14:31:33 +0000
@@ -2904,6 +2904,11 @@ int check_temp_dir(char* tmp_file)
   DBUG_RETURN(0);
 }
 
+#ifdef HAVE_NDB_BINLOG
+extern wait_cond_timed_func ndb_wait_setup_func;
+extern ulong opt_ndb_wait_setup;
+#endif
+
 /**
   Slave SQL thread entry point.
 
@@ -3027,6 +3032,22 @@ pthread_handler_t handle_slave_sql(void 
 #endif
   DBUG_ASSERT(rli->sql_thd == thd);
 
+#ifdef HAVE_NDB_BINLOG
+  /* 
+     Give ndb opportunity to initialise more things before the slave
+     SQL thread starts trying to write into Ndb
+  */
+  if (ndb_wait_setup_func)
+  {
+    if (ndb_wait_setup_func(opt_ndb_wait_setup))
+    {
+      sql_print_warning("Slave SQL thread : NDB : Tables not available after %lu"
+                        " seconds.  Consider increasing --ndb-wait-setup value",
+                        opt_ndb_wait_setup);
+    }
+  }
+#endif
+
   DBUG_PRINT("master_info",("log_file_name: %s  position: %s",
                             rli->group_master_log_name,
                             llstr(rli->group_master_log_pos,llbuff)));

Thread
bzr commit into mysql-5.1-telco-7.0 branch (frazer:3156)Frazer Clement23 Oct