List:Commits« Previous MessageNext Message »
From:Magnus Blåudd Date:January 19 2011 3:05pm
Subject:bzr commit into mysql-5.5-telco-7.0 branch (magnus.blaudd:3139)
View as plain text  
#At file:///home/msvensson/mysql/5.5-telco-7.0/ based on revid:magnus.blaudd@stripped48is1

 3139 Magnus Blåudd	2011-01-19
      ndb
       - Remove all uses of LOCK_open except the one place around the
         call to 'assign_new_table_id' which is necessary to protect the
         global counter variable.
      - Inspired by Kostjas patches to ha_ndbcluster in 5.5

    modified:
      sql/ha_ndbcluster.cc
      sql/ha_ndbcluster_binlog.cc
      sql/ha_ndbcluster_binlog.h
=== modified file 'sql/ha_ndbcluster.cc'
--- a/sql/ha_ndbcluster.cc	2011-01-14 15:25:27 +0000
+++ b/sql/ha_ndbcluster.cc	2011-01-19 15:05:02 +0000
@@ -8198,7 +8198,7 @@ cleanup_failed:
                                m_table->getObjectVersion(),
                                (is_truncate) ?
 			       SOT_TRUNCATE_TABLE : SOT_CREATE_TABLE, 
-			       0, 0, 1);
+			       NULL, NULL);
       break;
     }
   }
@@ -8518,7 +8518,7 @@ int ha_ndbcluster::rename_table(const ch
                              old_dbname, m_tabname,
                              ndb_table_id, ndb_table_version,
                              SOT_RENAME_TABLE_PREPARE,
-                             m_dbname, new_tabname, 1);
+                             m_dbname, new_tabname);
   }
   if (share)
   {
@@ -8606,7 +8606,7 @@ int ha_ndbcluster::rename_table(const ch
                                old_dbname, m_tabname,
                                ndb_table_id, ndb_table_version,
                                SOT_RENAME_TABLE,
-                               m_dbname, new_tabname, 1);
+                               m_dbname, new_tabname);
     }
     else
     {
@@ -8615,7 +8615,7 @@ int ha_ndbcluster::rename_table(const ch
                                m_dbname, new_tabname,
                                ndb_table_id, ndb_table_version,
                                SOT_ALTER_TABLE_COMMIT,
-                               0, 0, 1);
+                               NULL, NULL);
 
     }
   }
@@ -8819,7 +8819,7 @@ retry_temporary_error1:
                              thd->query(), thd->query_length(),
                              share->db, share->table_name,
                              ndb_table_id, ndb_table_version,
-                             SOT_DROP_TABLE, 0, 0, 1);
+                             SOT_DROP_TABLE, NULL, NULL);
   }
 
   if (share)
@@ -9772,7 +9772,6 @@ int ndbcluster_drop_database_impl(THD *t
   while ((tabname=it++))
   {
     tablename_to_filename(tabname, tmp, FN_REFLEN - (tmp - full_path)-1);
-    mysql_mutex_lock(&LOCK_open);
     if (ha_ndbcluster::delete_table(thd, 0, ndb, full_path, dbname, tabname))
     {
       const NdbError err= dict->getNdbError();
@@ -9782,7 +9781,6 @@ int ndbcluster_drop_database_impl(THD *t
         ret= ndb_to_mysql_error(&err);
       }
     }
-    mysql_mutex_unlock(&LOCK_open);
   }
 
   dict->invalidateDbGlobal(dbname);
@@ -9818,7 +9816,7 @@ static void ndbcluster_drop_database(han
   ndbcluster_log_schema_op(thd,
                            thd->query(), thd->query_length(),
                            db, "", table_id, table_version,
-                           SOT_DROP_DB, 0, 0, 0);
+                           SOT_DROP_DB, NULL, NULL);
   DBUG_VOID_RETURN;
 }
 
@@ -9943,7 +9941,6 @@ int ndbcluster_find_all_files(THD *thd)
       my_free((char*) data, MYF(MY_ALLOW_ZERO_PTR));
       my_free((char*) pack_data, MYF(MY_ALLOW_ZERO_PTR));
 
-      mysql_mutex_lock(&LOCK_open);
       if (discover)
       {
         /* ToDo 4.1 database needs to be created if missing */
@@ -9959,7 +9956,6 @@ int ndbcluster_find_all_files(THD *thd)
                                        elmt.database, elmt.name,
                                        TRUE);
       }
-      mysql_mutex_unlock(&LOCK_open);
     }
   }
   while (unhandled && retries);
@@ -10058,19 +10054,16 @@ int ndbcluster_find_files(handlerton *ht
                            file_name->str, reg_ext, 0);
       if (my_access(name, F_OK))
       {
-        mysql_mutex_lock(&LOCK_open);
         DBUG_PRINT("info", ("Table %s listed and need discovery",
                             file_name->str));
         if (ndb_create_table_from_engine(thd, db, file_name->str))
         {
-          mysql_mutex_unlock(&LOCK_open);
           push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
                               ER_TABLE_EXISTS_ERROR,
                               "Discover of table %s.%s failed",
                               db, file_name->str);
           continue;
         }
-        mysql_mutex_unlock(&LOCK_open);
       }
       DBUG_PRINT("info", ("%s existed in NDB _and_ on disk ", file_name->str));
       file_on_disk= TRUE;
@@ -10127,10 +10120,8 @@ int ndbcluster_find_files(handlerton *ht
       file_name_str= (char*)my_hash_element(&ok_tables, i);
       end= end1 +
         tablename_to_filename(file_name_str, end1, sizeof(name) - (end1 - name));
-      mysql_mutex_lock(&LOCK_open);
       ndbcluster_create_binlog_setup(thd, ndb, name, end-name,
                                      db, file_name_str, TRUE);
-      mysql_mutex_unlock(&LOCK_open);
     }
   }
 
@@ -10183,7 +10174,6 @@ int ndbcluster_find_files(handlerton *ht
     }
   }
 
-  mysql_mutex_lock(&LOCK_open);
   // Create new files
   List_iterator_fast<char> it2(create_list);
   while ((file_name_str=it2++))
@@ -10198,8 +10188,6 @@ int ndbcluster_find_files(handlerton *ht
     }
   }
 
-  mysql_mutex_unlock(&LOCK_open);
-
   my_hash_free(&ok_tables);
   my_hash_free(&ndb_tables);
 
@@ -11099,7 +11087,7 @@ static void print_ndbcluster_open_tables
   
   Must be called with previous pthread_mutex_lock(&ndbcluster_mutex)
 */
-int handle_trailing_share(THD *thd, NDB_SHARE *share, int have_lock_open)
+int handle_trailing_share(THD *thd, NDB_SHARE *share)
 {
   static ulong trailing_share_id= 0;
   DBUG_ENTER("handle_trailing_share");
@@ -11116,13 +11104,7 @@ int handle_trailing_share(THD *thd, NDB_
   bzero((char*) &table_list,sizeof(table_list));
   table_list.db= share->db;
   table_list.alias= table_list.table_name= share->table_name;
-  if (have_lock_open)
-    mysql_mutex_assert_owner(&LOCK_open);
-  else
-    mysql_mutex_lock(&LOCK_open);
   close_cached_tables(thd, &table_list, TRUE, FALSE, FALSE);
-  if (!have_lock_open)
-    mysql_mutex_unlock(&LOCK_open);
 
   pthread_mutex_lock(&ndbcluster_mutex);
   /* ndb_share reference temporary free */
@@ -11245,7 +11227,7 @@ int ndbcluster_undo_rename_share(THD *th
   return 0;
 }
 
-int ndbcluster_rename_share(THD *thd, NDB_SHARE *share, int have_lock_open)
+int ndbcluster_rename_share(THD *thd, NDB_SHARE *share)
 {
   NDB_SHARE *tmp;
   pthread_mutex_lock(&ndbcluster_mutex);
@@ -11255,7 +11237,7 @@ int ndbcluster_rename_share(THD *thd, ND
   if ((tmp= (NDB_SHARE*) my_hash_search(&ndbcluster_open_tables,
                                         (const uchar*) share->new_key,
                                         new_length)))
-    handle_trailing_share(thd, tmp, have_lock_open);
+    handle_trailing_share(thd, tmp);
 
   /* remove the share from hash */
   my_hash_delete(&ndbcluster_open_tables, (uchar*) share);
@@ -13881,7 +13863,7 @@ int ha_ndbcluster::alter_table_phase3(TH
                            db, name,
                            table_id, table_version,
                            SOT_ONLINE_ALTER_TABLE_PREPARE,
-                           0, 0, 0);
+                           NULL, NULL);
 
   /*
     Get table id/version for new table
@@ -13913,7 +13895,7 @@ int ha_ndbcluster::alter_table_phase3(TH
                            db, name,
                            table_id, table_version,
                            SOT_ONLINE_ALTER_TABLE_COMMIT,
-                           0, 0, 0);
+                           NULL, NULL);
 
   delete alter_data;
   alter_info->data= 0;
@@ -14261,13 +14243,13 @@ int ndbcluster_alter_tablespace(handlert
                              thd->query(), thd->query_length(),
                              "", alter_info->tablespace_name,
                              table_id, table_version,
-                             SOT_TABLESPACE, 0, 0, 0);
+                             SOT_TABLESPACE, NULL, NULL);
   else
     ndbcluster_log_schema_op(thd,
                              thd->query(), thd->query_length(),
                              "", alter_info->logfile_group_name,
                              table_id, table_version,
-                             SOT_LOGFILE_GROUP, 0, 0, 0);
+                             SOT_LOGFILE_GROUP, NULL, NULL);
   DBUG_RETURN(FALSE);
 
 ndberror:

=== modified file 'sql/ha_ndbcluster_binlog.cc'
--- a/sql/ha_ndbcluster_binlog.cc	2011-01-14 15:25:27 +0000
+++ b/sql/ha_ndbcluster_binlog.cc	2011-01-19 15:05:02 +0000
@@ -409,7 +409,6 @@ ndbcluster_binlog_open_table(THD *thd, N
   TABLE *table= event_data->table= 
     (TABLE*)alloc_root(&event_data->mem_root, sizeof(TABLE));
 
-  mysql_mutex_assert_owner(&LOCK_open);
   init_tmp_table_share(thd, table_share, share->db, 0, share->table_name, 
                        share->key);
   if ((error= open_table_def(thd, table_share, 0)) ||
@@ -427,7 +426,9 @@ ndbcluster_binlog_open_table(THD *thd, N
     *root_ptr= old_root;
     DBUG_RETURN(error);
   }
+  mysql_mutex_lock(&LOCK_open);
   assign_new_table_id(table_share);
+  mysql_mutex_unlock(&LOCK_open);
 
   table->in_use= injector_thd;
   
@@ -774,7 +775,7 @@ ndbcluster_binlog_log_query(handlerton *
   {
     ndbcluster_log_schema_op(thd, query, query_length,
                              db, table_name, table_id, table_version, type,
-                             0, 0, 0);
+                             NULL, NULL);
   }
   DBUG_VOID_RETURN;
 }
@@ -1562,9 +1563,7 @@ int ndbcluster_setup_binlog_table_shares
   if (!ndb_schema_share &&
       ndbcluster_check_ndb_schema_share() == 0)
   {
-    mysql_mutex_lock(&LOCK_open);
     ndb_create_table_from_engine(thd, NDB_REP_DB, NDB_SCHEMA_TABLE);
-    mysql_mutex_unlock(&LOCK_open);
     if (!ndb_schema_share)
     {
       ndbcluster_create_schema_table(thd);
@@ -1576,9 +1575,7 @@ int ndbcluster_setup_binlog_table_shares
   if (!ndb_apply_status_share &&
       ndbcluster_check_ndb_apply_status_share() == 0)
   {
-    mysql_mutex_lock(&LOCK_open);
     ndb_create_table_from_engine(thd, NDB_REP_DB, NDB_APPLY_TABLE);
-    mysql_mutex_unlock(&LOCK_open);
     if (!ndb_apply_status_share)
     {
       ndbcluster_create_ndb_apply_status_table(thd);
@@ -1594,7 +1591,6 @@ int ndbcluster_setup_binlog_table_shares
 
   if (!ndbcluster_find_all_files(thd))
   {
-    mysql_mutex_lock(&LOCK_open);
     ndb_binlog_tables_inited= TRUE;
     if (ndb_binlog_tables_inited &&
         ndb_binlog_running && ndb_binlog_is_ready)
@@ -1609,7 +1605,6 @@ int ndbcluster_setup_binlog_table_shares
       */
       ndb_notify_tables_writable();
     }
-    mysql_mutex_unlock(&LOCK_open);
     /* Signal injector thread that all is setup */
     pthread_cond_signal(&injector_cond);
   }
@@ -2017,8 +2012,7 @@ int ndbcluster_log_schema_op(THD *thd,
                              uint32 ndb_table_id,
                              uint32 ndb_table_version,
                              enum SCHEMA_OP_TYPE type,
-                             const char *new_db, const char *new_table_name,
-                             int have_lock_open)
+                             const char *new_db, const char *new_table_name)
 {
   DBUG_ENTER("ndbcluster_log_schema_op");
   Thd_ndb *thd_ndb= get_thd_ndb(thd);
@@ -2351,11 +2345,6 @@ end:
   {
     int max_timeout= DEFAULT_SYNC_TIMEOUT;
     pthread_mutex_lock(&ndb_schema_object->mutex);
-    if (have_lock_open)
-    {
-      mysql_mutex_assert_owner(&LOCK_open);
-      mysql_mutex_unlock(&LOCK_open);
-    }
     while (1)
     {
       struct timespec abstime;
@@ -2413,10 +2402,6 @@ end:
                              &ndb_schema_object->slock_bitmap);
       }
     }
-    if (have_lock_open)
-    {
-      mysql_mutex_lock(&LOCK_open);
-    }
     pthread_mutex_unlock(&ndb_schema_object->mutex);
   }
   else if (ndb_error)
@@ -2791,7 +2776,6 @@ ndb_binlog_thread_handle_schema_event(TH
         // fall through
         case SOT_CREATE_TABLE:
           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'",
@@ -2810,7 +2794,6 @@ ndb_binlog_thread_handle_schema_event(TH
                             schema->node_id, my_errno);
             print_warning_list("NDB Binlog", thd_warn_list(thd));
           }
-          mysql_mutex_unlock(&LOCK_open);
           log_query= 1;
           break;
         case SOT_DROP_DB:
@@ -3106,9 +3089,7 @@ ndb_binlog_thread_handle_schema_event_po
         log_query= 1;
         if (share)
         {
-          mysql_mutex_lock(&LOCK_open);
           ndbcluster_rename_share(thd, share);
-          mysql_mutex_unlock(&LOCK_open);
         }
         break;
       case SOT_RENAME_TABLE_PREPARE:
@@ -3169,7 +3150,6 @@ ndb_binlog_thread_handle_schema_event_po
             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'",
@@ -3187,7 +3167,6 @@ ndb_binlog_thread_handle_schema_event_po
                             schema->node_id, my_errno);
             print_warning_list("NDB Binlog", thd_warn_list(thd));
           }
-          mysql_mutex_unlock(&LOCK_open);
         }
         break;
       case SOT_ONLINE_ALTER_TABLE_PREPARE:
@@ -3207,7 +3186,6 @@ ndb_binlog_thread_handle_schema_event_po
           Refresh local frm file and dictionary cache if
           remote on-line alter table
         */
-        mysql_mutex_lock(&LOCK_open);
         TABLE_LIST table_list;
         bzero((char*) &table_list,sizeof(table_list));
         table_list.db= (char *)schema->db;
@@ -3249,9 +3227,7 @@ ndb_binlog_thread_handle_schema_event_po
           my_free((char*)data, MYF(MY_ALLOW_ZERO_PTR));
           my_free((char*)pack_data, MYF(MY_ALLOW_ZERO_PTR));
         }
-        if (!share)
-          mysql_mutex_unlock(&LOCK_open);
-        else
+        if (share)
         {
           if (opt_ndb_extra_logging > 9)
             sql_print_information("NDB Binlog: handeling online alter/rename");
@@ -3262,7 +3238,6 @@ ndb_binlog_thread_handle_schema_event_po
           if ((error= ndbcluster_binlog_open_table(thd, share)))
             sql_print_error("NDB Binlog: Failed to re-open table %s.%s",
                             schema->db, schema->name);
-          mysql_mutex_unlock(&LOCK_open);
           if (error)
             pthread_mutex_unlock(&share->mutex);
         }
@@ -3348,7 +3323,6 @@ ndb_binlog_thread_handle_schema_event_po
             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'",
@@ -3366,7 +3340,6 @@ ndb_binlog_thread_handle_schema_event_po
                             schema->node_id, my_errno);
             print_warning_list("NDB Binlog", thd_warn_list(thd));
           }
-          mysql_mutex_unlock(&LOCK_open);
         }
         break;
       default:
@@ -5086,8 +5059,6 @@ ndbcluster_handle_drop_table(THD *thd, N
 #ifdef SYNC_DROP_
   thd->proc_info= "Syncing ndb table schema operation and binlog";
   pthread_mutex_lock(&share->mutex);
-  mysql_mutex_assert_owner(&LOCK_open);
-  mysql_mutex_unlock(&LOCK_open);
   int max_timeout= DEFAULT_SYNC_TIMEOUT;
   while (share->op)
   {
@@ -5114,7 +5085,6 @@ ndbcluster_handle_drop_table(THD *thd, N
                            type_str, share->key, 0);
     }
   }
-  mysql_mutex_lock(&LOCK_open);
   pthread_mutex_unlock(&share->mutex);
 #else
   pthread_mutex_lock(&share->mutex);

=== modified file 'sql/ha_ndbcluster_binlog.h'
--- a/sql/ha_ndbcluster_binlog.h	2010-11-10 10:37:58 +0000
+++ b/sql/ha_ndbcluster_binlog.h	2011-01-19 15:05:02 +0000
@@ -225,8 +225,7 @@ int ndbcluster_log_schema_op(THD *thd,
                              uint32 ndb_table_version,
                              enum SCHEMA_OP_TYPE type,
                              const char *new_db,
-                             const char *new_table_name,
-                             int have_lock_open);
+                             const char *new_table_name);
 int ndbcluster_drop_event(THD *thd, Ndb *ndb, NDB_SHARE *share,
                           const char *type_str,
                           const char * dbname, const char * tabname);
@@ -285,9 +284,9 @@ NDB_SHARE *ndbcluster_get_share(const ch
 NDB_SHARE *ndbcluster_get_share(NDB_SHARE *share);
 void ndbcluster_free_share(NDB_SHARE **share, bool have_lock);
 void ndbcluster_real_free_share(NDB_SHARE **share);
-int handle_trailing_share(THD *thd, NDB_SHARE *share, int have_lock_open= 1);
+int handle_trailing_share(THD *thd, NDB_SHARE *share);
 int ndbcluster_prepare_rename_share(NDB_SHARE *share, const char *new_key);
-int ndbcluster_rename_share(THD *thd, NDB_SHARE *share, int have_lock_open= 1);
+int ndbcluster_rename_share(THD *thd, NDB_SHARE *share);
 int ndbcluster_undo_rename_share(THD *thd, NDB_SHARE *share);
 inline NDB_SHARE *get_share(const char *key,
                             TABLE *table,

Attachment: [text/bzr-bundle] bzr/magnus.blaudd@oracle.com-20110119150502-ev5yvhgvg09zxqdj.bundle
Thread
bzr commit into mysql-5.5-telco-7.0 branch (magnus.blaudd:3139) Magnus Blåudd19 Jan