List:Commits« Previous MessageNext Message »
From:magnus.blaudd Date:November 9 2011 7:38am
Subject:bzr push into mysql-5.5-cluster branch (magnus.blaudd:3645 to 3648)
View as plain text  
 3648 magnus.blaudd@stripped	2011-11-09
      ndb schema dist
       - remove unnecessary setting of NO_NO_LOCK_SCHEMA_OP(i.e no global schema lock) before calling
        ndb_create_table_from_engine

    modified:
      sql/ha_ndbcluster_binlog.cc
 3647 magnus.blaudd@stripped	2011-11-09
      ndb schema dist
       - only call 'handle_clear_slock' after epoch

    modified:
      sql/ha_ndbcluster_binlog.cc
 3646 magnus.blaudd@stripped	2011-11-09
      ndb schema dist
       - add more DBUG_PRINT and DBUG_ENTER
       - move a few variables in the "drop path" to the scope where they are used

    modified:
      sql/ha_ndbcluster.cc
      sql/ha_ndbcluster_binlog.cc
 3645 magnus.blaudd@stripped	2011-11-09
      ndb schema dist
       - first step towards determing in one place if NDB_SHARE should subscribe
         to events
       - move as much as possible for initializing share into 'NDB_SHARE::create'
       - share pointer is required both in 'ndbcluster_create_event' and 'ndbcluster_create_event_ops'

    modified:
      sql/ha_ndbcluster.cc
      sql/ha_ndbcluster_binlog.cc
      sql/ndb_share.cc
      sql/ndb_share.h
=== modified file 'sql/ha_ndbcluster.cc'
--- a/sql/ha_ndbcluster.cc	2011-11-09 06:31:45 +0000
+++ b/sql/ha_ndbcluster.cc	2011-11-09 07:31:37 +0000
@@ -11020,6 +11020,7 @@ static
 void
 delete_table_drop_share(NDB_SHARE* share, const char * path)
 {
+  DBUG_ENTER("delete_table_drop_share");
   if (share)
   {
     pthread_mutex_lock(&ndbcluster_mutex);
@@ -11051,6 +11052,7 @@ do_drop:
     }
     pthread_mutex_unlock(&ndbcluster_mutex);
   }
+  DBUG_VOID_RETURN;
 }
 
 /* static version which does not need a handler */
@@ -11061,7 +11063,7 @@ ha_ndbcluster::drop_table_impl(THD *thd,
                                const char *db,
                                const char *table_name)
 {
-  DBUG_ENTER("ha_ndbcluster::ndbcluster_delete_table");
+  DBUG_ENTER("ha_ndbcluster::drop_table_impl");
   NDBDICT *dict= ndb->getDictionary();
   int ndb_table_id= 0;
   int ndb_table_version= 0;
@@ -11198,8 +11200,7 @@ int ha_ndbcluster::delete_table(const ch
 {
   THD *thd= current_thd;
   Thd_ndb *thd_ndb= get_thd_ndb(thd);
-  Ndb *ndb;
-  int error= 0;
+
   DBUG_ENTER("ha_ndbcluster::delete_table");
   DBUG_PRINT("enter", ("name: %s", name));
 
@@ -11211,6 +11212,7 @@ int ha_ndbcluster::delete_table(const ch
       dropped inside ndb.
       Just drop local files.
     */
+    DBUG_PRINT("info", ("Table is already dropped in NDB"));
     delete_table_drop_share(0, name);
     DBUG_RETURN(handler::delete_table(name));
   }
@@ -11226,16 +11228,12 @@ int ha_ndbcluster::delete_table(const ch
 
   if (check_ndb_connection(thd))
   {
-    error= HA_ERR_NO_CONNECTION;
-    goto err;
+    DBUG_RETURN(HA_ERR_NO_CONNECTION);
   }
 
-  ndb= thd_ndb->ndb;
-
   if (!thd_ndb->has_required_global_schema_lock("ha_ndbcluster::delete_table"))
   {
-    error= HA_ERR_NO_CONNECTION;
-    goto err;
+    DBUG_RETURN(HA_ERR_NO_CONNECTION);
   }
 
   /*
@@ -11243,6 +11241,8 @@ int ha_ndbcluster::delete_table(const ch
     If it was already gone it might have been dropped
     remotely, give a warning and then drop .ndb file.
    */
+  int error;
+  Ndb* ndb= thd_ndb->ndb;
   if (!(error= drop_table_impl(thd, this, ndb, name,
                                m_dbname, m_tabname)) ||
       error == HA_ERR_NO_SUCH_TABLE)
@@ -11253,7 +11253,6 @@ int ha_ndbcluster::delete_table(const ch
       error= error1;
   }
 
-err:
   DBUG_RETURN(error);
 }
 

=== modified file 'sql/ha_ndbcluster_binlog.cc'
--- a/sql/ha_ndbcluster_binlog.cc	2011-11-09 06:31:45 +0000
+++ b/sql/ha_ndbcluster_binlog.cc	2011-11-09 07:37:30 +0000
@@ -1969,19 +1969,21 @@ ndb_handle_schema_change(THD *thd, Ndb *
                          const Ndb_event_data *event_data)
 {
   DBUG_ENTER("ndb_handle_schema_change");
-  NDB_SHARE *share= event_data->share;
-  TABLE *shadow_table= event_data->shadow_table;
-  const char *tabname= shadow_table->s->table_name.str;
-  const char *dbname= shadow_table->s->db.str;
-  bool do_close_cached_tables= FALSE;
-  bool is_remote_change= !ndb_has_node_id(pOp->getReqNodeId());
 
   if (pOp->getEventType() == NDBEVENT::TE_ALTER)
   {
+    DBUG_PRINT("exit", ("Event type is TE_ALTER"));
     DBUG_RETURN(0);
   }
+
+  DBUG_ASSERT(event_data);
   DBUG_ASSERT(pOp->getEventType() == NDBEVENT::TE_DROP ||
               pOp->getEventType() == NDBEVENT::TE_CLUSTER_FAILURE);
+
+  NDB_SHARE *share= event_data->share;
+  TABLE *shadow_table= event_data->shadow_table;
+  const char *tabname= shadow_table->s->table_name.str;
+  const char *dbname= shadow_table->s->db.str;
   {
     Thd_ndb *thd_ndb= get_thd_ndb(thd);
     Ndb *ndb= thd_ndb->ndb;
@@ -2007,10 +2009,10 @@ ndb_handle_schema_change(THD *thd, Ndb *
   {
     share->op= 0;
   }
-  // either just us or drop table handling as well
-      
-  /* Signal ha_ndbcluster::delete/rename_table that drop is done */
   pthread_mutex_unlock(&share->mutex);
+
+  /* Signal ha_ndbcluster::delete/rename_table that drop is done */
+  DBUG_PRINT("info", ("signal that drop is done"));
   (void) pthread_cond_signal(&injector_cond);
 
   pthread_mutex_lock(&ndbcluster_mutex);
@@ -2018,6 +2020,9 @@ ndb_handle_schema_change(THD *thd, Ndb *
   DBUG_PRINT("NDB_SHARE", ("%s binlog free  use_count: %u",
                            share->key, share->use_count));
   free_share(&share, TRUE);
+
+  bool do_close_cached_tables= FALSE;
+  bool is_remote_change= !ndb_has_node_id(pOp->getReqNodeId());
   if (is_remote_change && share && share->state != NSS_DROPPED)
   {
     DBUG_PRINT("info", ("remote change"));
@@ -2041,15 +2046,13 @@ ndb_handle_schema_change(THD *thd, Ndb *
     share= 0;
   pthread_mutex_unlock(&ndbcluster_mutex);
 
-  if (event_data)
-  {
-    delete event_data;
-    pOp->setCustomData(NULL);
-  }
+  DBUG_PRINT("info", ("Deleting event_data"));
+  delete event_data;
+  pOp->setCustomData(NULL);
 
+  DBUG_PRINT("info", ("Dropping event operation"));
   pthread_mutex_lock(&injector_mutex);
   is_ndb->dropEventOperation(pOp);
-  pOp= 0;
   pthread_mutex_unlock(&injector_mutex);
 
   if (do_close_cached_tables)
@@ -2517,18 +2520,21 @@ class Ndb_schema_event_handler {
   void
   ndbapi_invalidate_table(const char* db_name, const char* table_name) const
   {
+    DBUG_ENTER("ndbapi_invalidate_table");
     Thd_ndb *thd_ndb= get_thd_ndb(m_thd);
     Ndb *ndb= thd_ndb->ndb;
 
     ndb->setDatabaseName(db_name);
     Ndb_table_guard ndbtab_g(ndb->getDictionary(), table_name);
     ndbtab_g.invalidate();
+    DBUG_VOID_RETURN;
   }
 
 
   void
   mysqld_close_cached_table(const char* db_name, const char* table_name) const
   {
+    DBUG_ENTER("mysqld_close_cached_table");
      // Just mark table as "need reopen"
     const bool wait_for_refresh = false;
     // Not waiting -> no timeout needed
@@ -2541,6 +2547,7 @@ class Ndb_schema_event_handler {
 
     close_cached_tables(m_thd, &table_list,
                         wait_for_refresh, timeout);
+    DBUG_VOID_RETURN;
   }
 
 
@@ -2548,6 +2555,7 @@ class Ndb_schema_event_handler {
   mysqld_write_frm_from_ndb(const char* db_name,
                             const char* table_name) const
   {
+    DBUG_ENTER("mysqld_write_frm_from_ndb");
     Thd_ndb *thd_ndb= get_thd_ndb(m_thd);
     Ndb *ndb= thd_ndb->ndb;
     Ndb_table_guard ndbtab_g(ndb->getDictionary(), table_name);
@@ -2583,11 +2591,13 @@ class Ndb_schema_event_handler {
     }
     my_free(data);
     my_free(pack_data);
+    DBUG_VOID_RETURN;
   }
 
 
   NDB_SHARE* get_share(Ndb_schema_op* schema) const
   {
+    DBUG_ENTER("get_share(Ndb_schema_op*)");
     char key[FN_REFLEN + 1];
     build_table_filename(key, sizeof(key) - 1,
                          schema->db, schema->name, "", 0);
@@ -2597,7 +2607,7 @@ class Ndb_schema_event_handler {
       DBUG_PRINT("NDB_SHARE", ("%s temporary  use_count: %u",
                                share->key, share->use_count));
     }
-    return share;
+    DBUG_RETURN(share);
   }
 
 
@@ -2638,16 +2648,9 @@ class Ndb_schema_event_handler {
 
   void handle_clear_slock(Ndb_schema_op* schema)
   {
-    if (!is_post_epoch())
-    {
-      /*
-        handle slock after epoch is completed to ensure that
-        schema events get inserted in the binlog after any data
-        events
-      */
-      log_after_epoch(schema);
-      return;
-    }
+    DBUG_ENTER("handle_clear_slock");
+
+    assert(is_post_epoch());
 
     char key[FN_REFLEN + 1];
     build_table_filename(key, sizeof(key) - 1, schema->db, schema->name, "", 0);
@@ -2660,7 +2663,7 @@ class Ndb_schema_event_handler {
       if (opt_ndb_extra_logging > 19)
         sql_print_information("NDB: Discarding event...no obj: %s (%u/%u)",
                               key, schema->id, schema->version);
-      return;
+      DBUG_VOID_RETURN;
     }
 
     if (ndb_schema_object->table_id != schema->id ||
@@ -2676,7 +2679,7 @@ class Ndb_schema_event_handler {
                               schema->id,
                               schema->version);
       ndb_free_schema_object(&ndb_schema_object);
-      return;
+      DBUG_VOID_RETURN;
     }
 
     /*
@@ -2705,7 +2708,8 @@ class Ndb_schema_event_handler {
 
     /* Wake up the waiter */
     pthread_cond_signal(&injector_cond);
-    return;
+
+    DBUG_VOID_RETURN;
   }
 
 
@@ -2913,7 +2917,12 @@ class Ndb_schema_event_handler {
       switch (schema_type)
       {
       case SOT_CLEAR_SLOCK:
-        handle_clear_slock(schema);
+        /*
+          handle slock after epoch is completed to ensure that
+          schema events get inserted in the binlog after any data
+          events
+        */
+        log_after_epoch(schema);
         DBUG_RETURN(0);
 
       case SOT_ALTER_TABLE_COMMIT:
@@ -2993,7 +3002,6 @@ class Ndb_schema_event_handler {
           if (share)
             free_share(&share);
 
-          thd_ndb_options.set(TNO_NO_LOCK_SCHEMA_OP);
           if (is_local_table(schema->db, schema->name))
           {
             sql_print_error("NDB Binlog: Skipping locally defined table "
@@ -3011,7 +3019,6 @@ class Ndb_schema_event_handler {
         }
 
         case SOT_CREATE_TABLE:
-          thd_ndb_options.set(TNO_NO_LOCK_SCHEMA_OP);
           if (is_local_table(schema->db, schema->name))
           {
             DBUG_PRINT("info", ("NDB Binlog: Skipping locally defined table '%s.%s'",

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-5.5-cluster branch (magnus.blaudd:3645 to 3648) magnus.blaudd11 Nov