List:Commits« Previous MessageNext Message »
From:tomas Date:February 6 2007 5:45am
Subject:bk commit into 5.1 tree (tomas:1.2423)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of tomas. When tomas does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.2423 07/02/06 12:45:42 tomas@stripped +3 -0
  Merge poseidon.mysql.com:/home/tomas/mysql-5.1-telco-cga
  into  poseidon.mysql.com:/home/tomas/mysql-5.1-new-ndb

  sql/ha_ndbcluster.cc
    1.402 07/02/06 12:45:34 tomas@stripped +3 -3
    manual merge

  storage/ndb/src/ndbapi/TransporterFacade.cpp
    1.59 07/02/06 12:42:08 tomas@stripped +0 -0
    Auto merged

  sql/ha_ndbcluster_binlog.cc
    1.101 07/02/06 12:42:08 tomas@stripped +0 -0
    Auto merged

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	tomas
# Host:	poseidon.mysql.com
# Root:	/home/tomas/mysql-5.1-new-ndb/RESYNC

--- 1.58/storage/ndb/src/ndbapi/TransporterFacade.cpp	2007-01-29 06:47:32 +07:00
+++ 1.59/storage/ndb/src/ndbapi/TransporterFacade.cpp	2007-02-06 12:42:08 +07:00
@@ -1403,7 +1403,7 @@
     }
     if (wait_time == -1)
     {
-#ifdef VM_TRACE
+#ifdef NOT_USED
       ndbout << "Waited WAITFOR_RESPONSE_TIMEOUT, continuing wait" << endl;
 #endif
       continue;

--- 1.401/sql/ha_ndbcluster.cc	2007-02-05 13:22:21 +07:00
+++ 1.402/sql/ha_ndbcluster.cc	2007-02-06 12:45:34 +07:00
@@ -5004,11 +5004,17 @@
       get a new share
     */
 
+    /* ndb_share reference create */
     if (!(share= get_share(name, form, TRUE, TRUE)))
     {
       sql_print_error("NDB: allocating table share for %s failed", name);
       /* my_errno is set */
     }
+    else
+    {
+      DBUG_PRINT("NDB_SHARE", ("%s binlog create  use_count: %u",
+                               share->key, share->use_count));
+    }
     pthread_mutex_unlock(&ndbcluster_mutex);
 
     while (!IS_TMP_PREFIX(m_tabname))
@@ -5032,7 +5038,7 @@
         if (ndb_extra_logging)
           sql_print_information("NDB Binlog: CREATE TABLE Event: %s",
                                 event_name.c_ptr());
-        if (share && do_event_op &&
+        if (share && 
             ndbcluster_create_event_ops(share, m_table, event_name.c_ptr()))
         {
           sql_print_error("NDB Binlog: FAILED CREATE TABLE event operations."
@@ -5122,6 +5128,9 @@
   }
   
   set_ndb_share_state(m_share, NSS_INITIAL);
+  /* ndb_share reference schema(?) free */
+  DBUG_PRINT("NDB_SHARE", ("%s binlog schema(?) free  use_count: %u",
+                           m_share->key, m_share->use_count));
   free_share(&m_share); // Decrease ref_count
 
   DBUG_RETURN(error);
@@ -5248,7 +5257,10 @@
 */ 
 void ha_ndbcluster::prepare_for_alter()
 {
+  /* ndb_share reference schema */
   ndbcluster_get_share(m_share); // Increase ref_count
+  DBUG_PRINT("NDB_SHARE", ("%s binlog schema  use_count: %u",
+                           m_share->key, m_share->use_count));
   set_ndb_share_state(m_share, NSS_ALTERED);
 }
 
@@ -5282,6 +5294,9 @@
   if (error)
   {
     set_ndb_share_state(m_share, NSS_INITIAL);
+    /* ndb_share reference schema free */
+    DBUG_PRINT("NDB_SHARE", ("%s binlog schema free  use_count: %u",
+                             m_share->key, m_share->use_count));
     free_share(&m_share); // Decrease ref_count
   }
   DBUG_RETURN(error);  
@@ -5326,6 +5341,9 @@
   if((error= drop_indexes(ndb, table_arg)))
   {
     m_share->state= NSS_INITIAL;
+    /* ndb_share reference schema free */
+    DBUG_PRINT("NDB_SHARE", ("%s binlog schema free  use_count: %u",
+                             m_share->key, m_share->use_count));
     free_share(&m_share); // Decrease ref_count
   }
   DBUG_RETURN(error);
@@ -5367,9 +5385,12 @@
   int ndb_table_id= orig_tab->getObjectId();
   int ndb_table_version= orig_tab->getObjectVersion();
 
+  /* ndb_share reference temporary */
   NDB_SHARE *share= get_share(from, 0, FALSE);
   if (share)
   {
+    DBUG_PRINT("NDB_SHARE", ("%s temporary  use_count: %u",
+                             share->key, share->use_count));
     int r= rename_share(share, to);
     DBUG_ASSERT(r == 0);
   }
@@ -5393,6 +5414,9 @@
     {
       int r= rename_share(share, from);
       DBUG_ASSERT(r == 0);
+      /* ndb_share reference temporary free */
+      DBUG_PRINT("NDB_SHARE", ("%s temporary free  use_count: %u",
+                               share->key, share->use_count));
       free_share(&share);
     }
 #endif
@@ -5405,7 +5429,12 @@
     // ToDo in 4.1 should rollback alter table...
 #ifdef HAVE_NDB_BINLOG
     if (share)
+    {
+      /* ndb_share reference temporary free */
+      DBUG_PRINT("NDB_SHARE", ("%s temporary  use_count: %u",
+                               share->key, share->use_count));
       free_share(&share);
+    }
 #endif
     DBUG_RETURN(result);
   }
@@ -5439,7 +5468,7 @@
       if (ndb_extra_logging)
         sql_print_information("NDB Binlog: RENAME Event: %s",
                               event_name.c_ptr());
-      if (share && ndb_binlog_running &&
+      if (share &&
           ndbcluster_create_event_ops(share, ndbtab, event_name.c_ptr()))
       {
         sql_print_error("NDB Binlog: FAILED create event operations "
@@ -5486,7 +5515,12 @@
     }
   }
   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);
+  }
 #endif
 
   DBUG_RETURN(result);
@@ -5521,7 +5555,13 @@
     DBUG_PRINT("info", ("Schema distribution table not setup"));
     DBUG_RETURN(HA_ERR_NO_CONNECTION);
   }
+  /* ndb_share reference temporary */
   NDB_SHARE *share= get_share(path, 0, FALSE);
+  if (share)
+  {
+    DBUG_PRINT("NDB_SHARE", ("%s temporary  use_count: %u",
+                             share->key, share->use_count));
+  }
 #endif
 
   /* Drop the table from NDB */
@@ -5601,9 +5641,14 @@
           The share kept by the server has not been freed, free it
         */
         share->state= NSS_DROPPED;
+        /* ndb_share reference create free */
+        DBUG_PRINT("NDB_SHARE", ("%s create free  use_count: %u",
+                                 share->key, share->use_count));
         free_share(&share, TRUE);
       }
-      /* free the share taken above */
+      /* ndb_share reference temporary free */
+      DBUG_PRINT("NDB_SHARE", ("%s temporary free  use_count: %u",
+                               share->key, share->use_count));
       free_share(&share, TRUE);
       pthread_mutex_unlock(&ndbcluster_mutex);
     }
@@ -5653,9 +5698,14 @@
         The share kept by the server has not been freed, free it
       */
       share->state= NSS_DROPPED;
+      /* ndb_share reference create free */
+      DBUG_PRINT("NDB_SHARE", ("%s create free  use_count: %u",
+                               share->key, share->use_count));
       free_share(&share, TRUE);
     }
-    /* free the share taken above */
+    /* ndb_share reference temporary free */
+    DBUG_PRINT("NDB_SHARE", ("%s temporary free  use_count: %u",
+                             share->key, share->use_count));
     free_share(&share, TRUE);
     pthread_mutex_unlock(&ndbcluster_mutex);
   }
@@ -5831,6 +5881,9 @@
 
   if (m_share)
   {
+    /* ndb_share reference handler free */
+    DBUG_PRINT("NDB_SHARE", ("%s handler free  use_count: %u",
+                             m_share->key, m_share->use_count));
     free_share(&m_share);
   }
   release_metadata(thd, ndb);
@@ -5893,14 +5946,21 @@
   DBUG_PRINT("info", ("ref_length: %d", ref_length));
 
   // Init table lock structure 
+  /* ndb_share reference handler */
   if (!(m_share=get_share(name, table)))
     DBUG_RETURN(1);
+  DBUG_PRINT("NDB_SHARE", ("%s handler  use_count: %u",
+                           m_share->key, m_share->use_count));
   thr_lock_data_init(&m_share->lock,&m_lock,(void*) 0);
   
   set_dbname(name);
   set_tabname(name);
   
-  if (check_ndb_connection()) {
+  if (check_ndb_connection())
+  {
+    /* ndb_share reference handler free */
+    DBUG_PRINT("NDB_SHARE", ("%s handler free  use_count: %u",
+                             m_share->key, m_share->use_count));
     free_share(&m_share);
     m_share= 0;
     DBUG_RETURN(HA_ERR_NO_CONNECTION);
@@ -5961,6 +6021,9 @@
   DBUG_ENTER("close");
   THD *thd= current_thd;
   Ndb *ndb= thd ? check_ndb_in_thd(thd) : g_ndb;
+  /* ndb_share reference handler free */
+  DBUG_PRINT("NDB_SHARE", ("%s handler free  use_count: %u",
+                           m_share->key, m_share->use_count));
   free_share(&m_share);
   m_share= 0;
   release_metadata(thd, ndb);
@@ -6067,7 +6130,13 @@
   ndb->setDatabaseName(db);
   NDBDICT* dict= ndb->getDictionary();
   build_table_filename(key, sizeof(key), db, name, "", 0);
+  /* ndb_share reference temporary */
   NDB_SHARE *share= get_share(key, 0, FALSE);
+  if (share)
+  {
+    DBUG_PRINT("NDB_SHARE", ("%s temporary  use_count: %u",
+                             share->key, share->use_count));
+  }
   if (share && get_ndb_share_state(share) == NSS_ALTERED)
   {
     // Frm has been altered on disk, but not yet written to ndb
@@ -6113,12 +6182,22 @@
   *frmblob= data;
   
   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);
+  }
 
   DBUG_RETURN(0);
 err:
   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);
+  }
   if (ndb_error.code)
   {
     ERR_RETURN(ndb_error);
@@ -6356,7 +6435,13 @@
       }
       else if (cmp_frm(ndbtab, pack_data, pack_length))
       {
+        /* ndb_share reference temporary */
         NDB_SHARE *share= get_share(key, 0, FALSE);
+        if (share)
+        {
+          DBUG_PRINT("NDB_SHARE", ("%s temporary  use_count: %u",
+                                   share->key, share->use_count));
+        }
         if (!share || get_ndb_share_state(share) != NSS_ALTERED)
         {
           discover= 1;
@@ -6364,7 +6449,12 @@
                                 elmt.database, elmt.name);
         }
         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);
+        }
       }
       my_free((char*) data, MYF(MY_ALLOW_ZERO_PTR));
       my_free((char*) pack_data, MYF(MY_ALLOW_ZERO_PTR));
@@ -7169,7 +7259,10 @@
     DBUG_PRINT("info", ("Table %s not found in ndbcluster_open_tables", name));
     DBUG_RETURN(1);
   }
+  /* ndb_share reference temporary, free below */
   share->use_count++;
+  DBUG_PRINT("NDB_SHARE", ("%s temporary  use_count: %u",
+                           share->key, share->use_count));
   pthread_mutex_unlock(&ndbcluster_mutex);
 
   pthread_mutex_lock(&share->mutex);
@@ -7182,6 +7275,9 @@
       DBUG_PRINT("info", ("Getting commit_count: %s from share",
                           llstr(share->commit_count, buff)));
       pthread_mutex_unlock(&share->mutex);
+      /* ndb_share reference temporary free */
+      DBUG_PRINT("NDB_SHARE", ("%s temporary free  use_count: %u",
+                               share->key, share->use_count));
       free_share(&share);
       DBUG_RETURN(0);
     }
@@ -7200,6 +7296,9 @@
     if (ndbtab_g.get_table() == 0
         || ndb_get_table_statistics(NULL, FALSE, ndb, ndbtab_g.get_table(), &stat))
     {
+      /* ndb_share reference temporary free */
+      DBUG_PRINT("NDB_SHARE", ("%s temporary free  use_count: %u",
+                               share->key, share->use_count));
       free_share(&share);
       DBUG_RETURN(1);
     }
@@ -7220,6 +7319,9 @@
     *commit_count= 0;
   }
   pthread_mutex_unlock(&share->mutex);
+  /* ndb_share reference temporary free */
+  DBUG_PRINT("NDB_SHARE", ("%s temporary free  use_count: %u",
+                           share->key, share->use_count));
   free_share(&share);
   DBUG_RETURN(0);
 }
@@ -7436,7 +7538,10 @@
   static ulong trailing_share_id= 0;
   DBUG_ENTER("handle_trailing_share");
 
+  /* ndb_share reference temporary, free below */
   ++share->use_count;
+  DBUG_PRINT("NDB_SHARE", ("%s temporary  use_count: %u",
+                           share->key, share->use_count));
   pthread_mutex_unlock(&ndbcluster_mutex);
 
   TABLE_LIST table_list;
@@ -7447,10 +7552,14 @@
   close_cached_tables(thd, 0, &table_list, TRUE);
 
   pthread_mutex_lock(&ndbcluster_mutex);
+  /* ndb_share reference temporary free */
+  DBUG_PRINT("NDB_SHARE", ("%s temporary free  use_count: %u",
+                           share->key, share->use_count));
   if (!--share->use_count)
   {
     if (ndb_extra_logging)
-      sql_print_information("NDB_SHARE: trailing share %s(connect_count: %u) "
+      sql_print_information("NDB_SHARE: trailing share "
+                            "%s(connect_count: %u) "
                             "released by close_cached_tables at "
                             "connect_count: %u",
                             share->key,
@@ -7464,20 +7573,28 @@
     share still exists, if share has not been dropped by server
     release that share
   */
-  if (share->state != NSS_DROPPED && !--share->use_count)
+  if (share->state != NSS_DROPPED)
   {
-    if (ndb_extra_logging)
-      sql_print_information("NDB_SHARE: trailing share %s(connect_count: %u) "
-                            "released after NSS_DROPPED check "
-                            "at connect_count: %u",
-                            share->key,
-                            share->connect_count,
-                            g_ndb_cluster_connection->get_connect_count());
-    ndbcluster_real_free_share(&share);
-    DBUG_RETURN(0);
+    share->state= NSS_DROPPED;
+    /* ndb_share reference create free */
+    DBUG_PRINT("NDB_SHARE", ("%s create free  use_count: %u",
+                             share->key, share->use_count));
+    --share->use_count;
+
+    if (share->use_count == 0)
+    {
+      if (ndb_extra_logging)
+        sql_print_information("NDB_SHARE: trailing share "
+                              "%s(connect_count: %u) "
+                              "released after NSS_DROPPED check "
+                              "at connect_count: %u",
+                              share->key,
+                              share->connect_count,
+                              g_ndb_cluster_connection->get_connect_count());
+      ndbcluster_real_free_share(&share);
+      DBUG_RETURN(0);
+    }
   }
-  DBUG_PRINT("error", ("NDB_SHARE: %s already exists  use_count=%d.",
-                       share->key, share->use_count));
 
   sql_print_error("NDB_SHARE: %s already exists  use_count=%d."
                   " Moving away for safety, but possible memleak.",
@@ -8530,7 +8647,10 @@
         continue; // injector thread is the only user, skip statistics
       share->util_lock= current_thd; // Mark that util thread has lock
 #endif /* HAVE_NDB_BINLOG */
+      /* ndb_share reference temporary, free below */
       share->use_count++; /* Make sure the table can't be closed */
+      DBUG_PRINT("NDB_SHARE", ("%s temporary  use_count: %u",
+                               share->key, share->use_count));
       DBUG_PRINT("ndb_util_thread",
                  ("Found open table[%d]: %s, use_count: %d",
                   i, share->table_name, share->use_count));
@@ -8551,6 +8671,9 @@
         /*
           Util thread and injector thread is the only user, skip statistics
 	*/
+        /* ndb_share reference temporary free */
+        DBUG_PRINT("NDB_SHARE", ("%s temporary free  use_count: %u",
+                                 share->key, share->use_count));
         free_share(&share);
         continue;
       }
@@ -8594,7 +8717,9 @@
         share->commit_count= stat.commit_count;
       pthread_mutex_unlock(&share->mutex);
 
-      /* Decrease the use count and possibly free share */
+      /* ndb_share reference temporary free */
+      DBUG_PRINT("NDB_SHARE", ("%s temporary free  use_count: %u",
+                               share->key, share->use_count));
       free_share(&share);
     }
 

--- 1.100/sql/ha_ndbcluster_binlog.cc	2007-02-06 00:10:45 +07:00
+++ 1.101/sql/ha_ndbcluster_binlog.cc	2007-02-06 12:42:08 +07:00
@@ -371,6 +371,10 @@
       strcmp(share->db, NDB_REP_DB) == 0 &&
       strcmp(share->table_name, NDB_SCHEMA_TABLE) == 0)
     do_event_op= 1;
+  else if (!ndb_apply_status_share &&
+           strcmp(share->db, NDB_REP_DB) == 0 &&
+           strcmp(share->table_name, NDB_APPLY_TABLE) == 0)
+    do_event_op= 1;
 
   {
     int i, no_nodes= g_ndb_cluster_connection->no_db_nodes();
@@ -606,7 +610,14 @@
         DBUG_PRINT("share",
                    ("table->s->db.table_name: %s.%s",
                     share->table->s->db.str, share->table->s->table_name.str));
-      if (share->state != NSS_DROPPED && !--share->use_count)
+      /* ndb_share reference create free */
+      if (share->state != NSS_DROPPED)
+      {
+        DBUG_PRINT("NDB_SHARE", ("%s create free  use_count: %u",
+                                 share->key, share->use_count));
+        --share->use_count;
+      }
+      if (share->use_count == 0)
         ndbcluster_real_free_share(&share);
       else
       {
@@ -1716,15 +1727,25 @@
   (void) pthread_cond_signal(&injector_cond);
 
   pthread_mutex_lock(&ndbcluster_mutex);
+  /* ndb_share reference binlog free */
+  DBUG_PRINT("NDB_SHARE", ("%s binlog free  use_count: %u",
+                           share->key, share->use_count));
   free_share(&share, TRUE);
   if (is_remote_change && share && share->state != NSS_DROPPED)
   {
     DBUG_PRINT("info", ("remote change"));
     share->state= NSS_DROPPED;
     if (share->use_count != 1)
+    {
+      /* open handler holding reference */
+      /* wait with freeing create ndb_share to below */
       do_close_cached_tables= TRUE;
+    }
     else
     {
+      /* ndb_share reference create free */
+      DBUG_PRINT("NDB_SHARE", ("%s create free  use_count: %u",
+                               share->key, share->use_count));
       free_share(&share, TRUE);
       share= 0;
     }
@@ -1747,6 +1768,9 @@
     table_list.db= (char *)dbname;
     table_list.alias= table_list.table_name= (char *)tabname;
     close_cached_tables(thd, 0, &table_list);
+    /* ndb_share reference create free */
+    DBUG_PRINT("NDB_SHARE", ("%s create free  use_count: %u",
+                             share->key, share->use_count));
     free_share(&share);
   }
   DBUG_RETURN(0);
@@ -1814,7 +1838,13 @@
           char key[FN_REFLEN];
           build_table_filename(key, sizeof(key),
                                schema->db, schema->name, "", 0);
+          /* ndb_share reference temporary, free below */
           NDB_SHARE *share= get_share(key, 0, FALSE, FALSE);
+          if (share)
+          {
+            DBUG_PRINT("NDB_SHARE", ("%s temporary  use_count: %u",
+                                     share->key, share->use_count));
+          }
           // invalidation already handled by binlog thread
           if (!share || !share->op)
           {
@@ -1830,8 +1860,13 @@
             table_list.alias= table_list.table_name= schema->name;
             close_cached_tables(thd, 0, &table_list, FALSE);
           }
+          /* ndb_share reference temporary free */
           if (share)
+          {
+            DBUG_PRINT("NDB_SHARE", ("%s temporary free  use_count: %u",
+                                     share->key, share->use_count));
             free_share(&share);
+          }
         }
         // fall through
         case SOT_CREATE_TABLE:
@@ -1940,6 +1975,10 @@
 
       /* begin protect ndb_schema_share */
       pthread_mutex_lock(&ndb_schema_share_mutex);
+      /* ndb_share reference binlog extra free */
+      DBUG_PRINT("NDB_SHARE", ("%s binlog extra free  use_count: %u",
+                               ndb_schema_share->key,
+                               ndb_schema_share->use_count));
       free_share(&ndb_schema_share);
       ndb_schema_share= 0;
       pthread_mutex_unlock(&ndb_schema_share_mutex);
@@ -2066,7 +2105,13 @@
         pthread_mutex_unlock(&ndbcluster_mutex);
         continue;
       }
+      /* ndb_share reference temporary, free below */
       NDB_SHARE *share= get_share(key, 0, FALSE, FALSE);
+      if (share)
+      {
+        DBUG_PRINT("NDB_SHARE", ("%s temporary  use_count: %u",
+                                 share->key, share->use_count));
+      }
       switch (schema_type)
       {
       case SOT_DROP_DB:
@@ -2111,6 +2156,9 @@
           */
           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;
           }
@@ -2143,6 +2191,9 @@
       }
       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;
       }
@@ -2445,10 +2496,8 @@
       pthread_mutex_unlock(&ndbcluster_mutex);
       DBUG_RETURN(1);
     }
-#ifdef NOT_YET
-    if (share->connect_count != 
+    if (!share_may_exist || share->connect_count != 
         g_ndb_cluster_connection->get_connect_count())
-#endif
     {
       handle_trailing_share(share);
       share= NULL;
@@ -2456,23 +2505,33 @@
   }
 
   /* Create share which is needed to hold replication information */
-#ifdef NOT_YET
   if (share)
   {
+    /* ndb_share reference create */
     ++share->use_count;
+    DBUG_PRINT("NDB_SHARE", ("%s create  use_count: %u",
+                             share->key, share->use_count));
   }
-  else
-#endif
-  if (!(share= get_share(key, 0, TRUE, TRUE)))
+  /* ndb_share reference create */
+  else if (!(share= get_share(key, 0, TRUE, TRUE)))
   {
     sql_print_error("NDB Binlog: "
                     "allocating table share for %s failed", key);
   }
+  else
+  {
+    DBUG_PRINT("NDB_SHARE", ("%s create  use_count: %u",
+                             share->key, share->use_count));
+  }
 
   if (!ndb_schema_share &&
       strcmp(share->db, NDB_REP_DB) == 0 &&
       strcmp(share->table_name, NDB_SCHEMA_TABLE) == 0)
     do_event_op= 1;
+  else if (!ndb_apply_status_share &&
+           strcmp(share->db, NDB_REP_DB) == 0 &&
+           strcmp(share->table_name, NDB_APPLY_TABLE) == 0)
+    do_event_op= 1;
 
   if (!do_event_op)
   {
@@ -2744,7 +2803,7 @@
   else if (!ndb_apply_status_share && strcmp(share->db, NDB_REP_DB) == 0 &&
            strcmp(share->table_name, NDB_APPLY_TABLE) == 0)
     do_ndb_apply_status_share= 1;
-  else if (!binlog_filter->db_ok(share->db))
+  else if (!binlog_filter->db_ok(share->db) || !ndb_binlog_running)
   {
     share->flags|= NSF_NO_BINLOG;
     DBUG_RETURN(0);
@@ -2756,6 +2815,9 @@
 
     DBUG_ASSERT(share->use_count > 1);
     sql_print_error("NDB Binlog: discover reusing old ev op");
+    /* ndb_share reference ToDo free */
+    DBUG_PRINT("NDB_SHARE", ("%s ToDo free  use_count: %u",
+                             share->key, share->use_count));
     free_share(&share); // old event op already has reference
     DBUG_RETURN(0);
   }
@@ -2898,15 +2960,24 @@
     break;
   }
 
+  /* ndb_share reference binlog */
   get_share(share);
+  DBUG_PRINT("NDB_SHARE", ("%s binlog  use_count: %u",
+                           share->key, share->use_count));
   if (do_ndb_apply_status_share)
   {
+    /* ndb_share reference binlog extra */
     ndb_apply_status_share= get_share(share);
+    DBUG_PRINT("NDB_SHARE", ("%s binlog extra  use_count: %u",
+                             share->key, share->use_count));
     (void) pthread_cond_signal(&injector_cond);
   }
   else if (do_ndb_schema_share)
   {
+    /* ndb_share reference binlog extra */
     ndb_schema_share= get_share(share);
+    DBUG_PRINT("NDB_SHARE", ("%s binlog extra  use_count: %u",
+                             share->key, share->use_count));
     (void) pthread_cond_signal(&injector_cond);
   }
 
@@ -3093,6 +3164,9 @@
           ndb_binlog_tables_inited && ndb_binlog_running)
         sql_print_information("NDB Binlog: ndb tables initially "
                               "read only on reconnect.");
+      /* ndb_share reference binlog extra free */
+      DBUG_PRINT("NDB_SHARE", ("%s binlog extra free  use_count: %u",
+                               share->key, share->use_count));
       free_share(&ndb_apply_status_share);
       ndb_apply_status_share= 0;
     }
@@ -3109,6 +3183,9 @@
           ndb_binlog_tables_inited && ndb_binlog_running)
         sql_print_information("NDB Binlog: ndb tables initially "
                               "read only on reconnect.");
+      /* ndb_share reference binlog extra free */
+      DBUG_PRINT("NDB_SHARE", ("%s binlog extra free  use_count: %u",
+                               share->key, share->use_count));
       free_share(&ndb_apply_status_share);
       ndb_apply_status_share= 0;
     }
@@ -4009,6 +4086,10 @@
 
   if (ndb_apply_status_share)
   {
+    /* ndb_share reference binlog extra free */
+    DBUG_PRINT("NDB_SHARE", ("%s binlog extra free  use_count: %u",
+                             ndb_apply_status_share->key,
+                             ndb_apply_status_share->use_count));
     free_share(&ndb_apply_status_share);
     ndb_apply_status_share= 0;
   }
@@ -4016,6 +4097,10 @@
   {
     /* begin protect ndb_schema_share */
     pthread_mutex_lock(&ndb_schema_share_mutex);
+    /* ndb_share reference binlog extra free */
+    DBUG_PRINT("NDB_SHARE", ("%s binlog extra free  use_count: %u",
+                             ndb_schema_share->key,
+                             ndb_schema_share->use_count));
     free_share(&ndb_schema_share);
     ndb_schema_share= 0;
     pthread_mutex_unlock(&ndb_schema_share_mutex);
@@ -4037,6 +4122,9 @@
       DBUG_ASSERT(share->op == op ||
                   share->op_old == op);
       share->op= share->op_old= 0;
+      /* ndb_share reference binlog free */
+      DBUG_PRINT("NDB_SHARE", ("%s binlog free  use_count: %u",
+                               share->key, share->use_count));
       free_share(&share);
       s_ndb->dropEventOperation(op);
     }
@@ -4057,6 +4145,9 @@
       DBUG_ASSERT(share->op == op ||
                   share->op_old == op);
       share->op= share->op_old= 0;
+      /* ndb_share reference binlog free */
+      DBUG_PRINT("NDB_SHARE", ("%s binlog free  use_count: %u",
+                               share->key, share->use_count));
       free_share(&share);
       i_ndb->dropEventOperation(op);
     }
Thread
bk commit into 5.1 tree (tomas:1.2423)tomas6 Feb