diff --git a/mysql-test/t/ndb_dd_basic.test b/mysql-test/t/ndb_dd_basic.test index 7f74fe7d050..81286d3121f 100644 --- a/mysql-test/t/ndb_dd_basic.test +++ b/mysql-test/t/ndb_dd_basic.test @@ -25,7 +25,6 @@ INITIAL_SIZE 16M UNDO_BUFFER_SIZE = 1M ENGINE=MYISAM; ---error ER_UNKNOWN_STORAGE_ENGINE ALTER LOGFILE GROUP lg1 ADD UNDOFILE 'undofile02.dat' INITIAL_SIZE = 4M diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index a2ca0c8047d..10f484b7f6d 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -6851,6 +6851,7 @@ static int connect_callback() } extern int ndb_dictionary_is_mysqld; +extern pthread_mutex_t LOCK_plugin; static int ndbcluster_init(void *p) { @@ -6860,6 +6861,13 @@ static int ndbcluster_init(void *p) if (ndbcluster_inited) DBUG_RETURN(FALSE); + /* + Below we create new THD's. They'll need LOCK_plugin, but it's taken now by + plugin initialization code. Release it to avoid deadlocks. It's safe, as + there're no threads that may concurrently access plugin control structures. + */ + pthread_mutex_unlock(&LOCK_plugin); + pthread_mutex_init(&ndbcluster_mutex,MY_MUTEX_INIT_FAST); pthread_mutex_init(&LOCK_ndb_util_thread, MY_MUTEX_INIT_FAST); pthread_cond_init(&COND_ndb_util_thread, NULL); @@ -6998,6 +7006,8 @@ static int ndbcluster_init(void *p) goto ndbcluster_init_error; } + pthread_mutex_lock(&LOCK_plugin); + ndbcluster_inited= 1; DBUG_RETURN(FALSE); @@ -7010,6 +7020,8 @@ ndbcluster_init_error: g_ndb_cluster_connection= NULL; ndbcluster_hton->state= SHOW_OPTION_DISABLED; // If we couldn't use handler + pthread_mutex_lock(&LOCK_plugin); + DBUG_RETURN(TRUE); } diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 2f62b39d51c..83d71af227e 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -99,7 +99,7 @@ static bool initialized= 0; following variables/structures. We are always manipulating ref count, so a rwlock here is unneccessary. */ -static pthread_mutex_t LOCK_plugin; +pthread_mutex_t LOCK_plugin; static DYNAMIC_ARRAY plugin_dl_array; static DYNAMIC_ARRAY plugin_array; static HASH plugin_hash[MYSQL_MAX_PLUGIN_TYPE_NUM];