List:Internals« Previous MessageNext Message »
From:msvensson Date:November 22 2005 10:34am
Subject:bk commit into 5.0 tree (msvensson:1.1988)
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of msvensson. When msvensson 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.1988 05/11/22 10:34:46 msvensson@neptunus.(none) +2 -0
  Add debug print functions for GlobalDictCache

  ndb/src/ndbapi/DictCache.hpp
    1.10 05/11/22 10:34:33 msvensson@neptunus.(none) +15 -8
    Add debug print functions
    Remove trailing white

  ndb/src/ndbapi/DictCache.cpp
    1.16 05/11/22 10:34:33 msvensson@neptunus.(none) +148 -78
    Add debug print functions
    Remove trailing white

# 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:	msvensson
# Host:	neptunus.(none)
# Root:	/home/msvensson/mysql/bug13228/my50-bug13228

--- 1.15/ndb/src/ndbapi/DictCache.cpp	2005-08-18 14:09:08 +02:00
+++ 1.16/ndb/src/ndbapi/DictCache.cpp	2005-11-22 10:34:33 +01:00
@@ -59,16 +59,16 @@
   m_tableHash.releaseHashTable();
 }
 
-Ndb_local_table_info * 
+Ndb_local_table_info *
 LocalDictCache::get(const char * name){
   const Uint32 len = strlen(name);
   return m_tableHash.getData(name, len);
 }
 
-void 
+void
 LocalDictCache::put(const char * name, Ndb_local_table_info * tab_info){
   const Uint32 id = tab_info->m_table_impl->m_tableId;
-  
+
   m_tableHash.insertKey(name, strlen(name), id, tab_info);
 }
 
@@ -79,6 +79,42 @@
   Ndb_local_table_info::destroy(info);
 }
 
+#ifndef DBUG_OFF
+void
+LocalDictCache::printCache()
+{
+  DBUG_ENTER("LocalDictCache::printCache");
+  DBUG_LOCK_FILE;
+
+  NdbElement_t<Ndb_local_table_info> * curr = m_tableHash.getNext(0);
+  while(curr != 0){
+    fprintf(DBUG_FILE, "* %s len: %d, hash: %d, lk: %d\n",
+            (char*)curr->str, curr->len, curr->hash, curr->localkey1);
+    if (curr->theData){
+      Ndb_local_table_info *info = curr->theData;
+        NdbTableImpl *impl= info->m_table_impl;
+        if(impl != 0)
+          fprintf(DBUG_FILE, "     tabId: %d, name: %s, ver: %d, status: %s\n",
+                  impl->m_tableId, impl->m_internalName.c_str(),
+                  impl->m_version,
+                  impl->m_status ==
+                  NdbDictionary::Object::New ? "New" :
+                  (impl->m_status ==
+                   NdbDictionary::Object::Changed ? "Changed" :
+                   (impl->m_status ==
+                    NdbDictionary::Object::Retrieved ? "Retrieved" :
+                    (impl->m_status ==
+                     NdbDictionary::Object::Invalid ? "Invalid" :
+                     (impl->m_status ==
+                      NdbDictionary::Object::Altered ? "Altered" : "?" )))));
+    }
+    curr = m_tableHash.getNext(curr);
+  }
+  DBUG_UNLOCK_FILE;
+  DBUG_VOID_RETURN;
+}
+#endif
+
 /*****************************************************************
  * Global cache
  */
@@ -91,6 +127,7 @@
 
 GlobalDictCache::~GlobalDictCache(){
   DBUG_ENTER("GlobalDictCache::~GlobalDictCache");
+  DBUG_EXECUTE("global", printCache(););
   NdbElement_t<Vector<TableVersion> > * curr = m_tableHash.getNext(0);
   while(curr != 0){
     Vector<TableVersion> * vers = curr->theData;
@@ -108,41 +145,12 @@
   DBUG_VOID_RETURN;
 }
 
-void GlobalDictCache::printCache()
-{
-  DBUG_ENTER("GlobalDictCache::printCache");
-  NdbElement_t<Vector<TableVersion> > * curr = m_tableHash.getNext(0);
-  while(curr != 0){
-    DBUG_PRINT("curr", ("len: %d, hash: %d, lk: %d, str: %s",
-                        curr->len, curr->hash, curr->localkey1, curr->str));
-    if (curr->theData){
-      Vector<TableVersion> * vers = curr->theData;
-      const unsigned sz = vers->size();
-      for(unsigned i = 0; i<sz ; i++){
-        TableVersion tv= (*vers)[i];
-        DBUG_PRINT("  ", ("vers[%d]: ver: %d, refCount: %d, status: %d",
-                          sz, tv.m_version, tv.m_refCount, tv.m_status));
-        if(tv.m_impl != 0)
-        {
-          DBUG_PRINT("  ", ("m_impl: internalname: %s",
-                            tv.m_impl->m_internalName.c_str()));
-        }
-      }
-    }
-    else
-    {
-      DBUG_PRINT("  ", ("NULL"));
-    }
-    curr = m_tableHash.getNext(curr);
-  }
-  DBUG_VOID_RETURN;
-}
-
 NdbTableImpl *
 GlobalDictCache::get(const char * name)
 {
   DBUG_ENTER("GlobalDictCache::get");
   DBUG_PRINT("enter", ("name: %s", name));
+  DBUG_EXECUTE("global", printCache(););
 
   const Uint32 len = strlen(name);
   Vector<TableVersion> * versions = 0;
@@ -160,6 +168,7 @@
     switch(ver->m_status){
     case OK:
       ver->m_refCount++;
+      DBUG_EXECUTE("global", printCache(););
       DBUG_RETURN(ver->m_impl);
     case DROPPED:
       retreive = true; // Break loop
@@ -169,7 +178,7 @@
       continue;
     }
   }
-  
+
   /**
    * Create new...
    */
@@ -179,6 +188,7 @@
   tmp.m_status = RETREIVING;
   tmp.m_refCount = 1; // The one retreiving it
   versions->push_back(tmp);
+  DBUG_EXECUTE("global", printCache(););
   DBUG_RETURN(0);
 }
 
@@ -192,58 +202,59 @@
   const Uint32 len = strlen(name);
   Vector<TableVersion> * vers = m_tableHash.getData(name, len);
   if(vers == 0){
-    // Should always tried to retreive it first 
+    // Should always tried to retreive it first
     // and thus there should be a record
-    abort(); 
+    abort();
   }
 
   const Uint32 sz = vers->size();
   if(sz == 0){
-    // Should always tried to retreive it first 
+    // Should always tried to retreive it first
     // and thus there should be a record
-    abort(); 
+    abort();
   }
-  
+
   TableVersion & ver = vers->back();
-  if(ver.m_status != RETREIVING || 
-     !(ver.m_impl == 0 || 
-       ver.m_impl == &f_invalid_table || ver.m_impl == &f_altered_table) || 
-     ver.m_version != 0 || 
+  if(ver.m_status != RETREIVING ||
+     !(ver.m_impl == 0 ||
+       ver.m_impl == &f_invalid_table || ver.m_impl == &f_altered_table) ||
+     ver.m_version != 0 ||
      ver.m_refCount == 0){
     abort();
   }
-  
+
   if(tab == 0)
   {
     DBUG_PRINT("info", ("No table found in db"));
     vers->erase(sz - 1);
-  } 
+  }
   else if (ver.m_impl == 0) {
     ver.m_impl = tab;
     ver.m_version = tab->m_version;
     ver.m_status = OK;
-  } 
-  else if (ver.m_impl == &f_invalid_table) 
+  }
+  else if (ver.m_impl == &f_invalid_table)
   {
     ver.m_impl = tab;
     ver.m_version = tab->m_version;
     ver.m_status = DROPPED;
-    ver.m_impl->m_status = NdbDictionary::Object::Invalid;    
+    ver.m_impl->m_status = NdbDictionary::Object::Invalid;
   }
   else if(ver.m_impl == &f_altered_table)
   {
     ver.m_impl = tab;
     ver.m_version = tab->m_version;
     ver.m_status = DROPPED;
-    ver.m_impl->m_status = NdbDictionary::Object::Altered;    
+    ver.m_impl->m_status = NdbDictionary::Object::Altered;
   }
   else
   {
     abort();
   }
+  DBUG_EXECUTE("global", printCache(););
   NdbCondition_Broadcast(m_waitForTableCondition);
   DBUG_RETURN(tab);
-} 
+}
 
 void
 GlobalDictCache::drop(NdbTableImpl * tab)
@@ -253,19 +264,19 @@
 
   unsigned i;
   const Uint32 len = strlen(tab->m_internalName.c_str());
-  Vector<TableVersion> * vers = 
+  Vector<TableVersion> * vers =
     m_tableHash.getData(tab->m_internalName.c_str(), len);
   if(vers == 0){
-    // Should always tried to retreive it first 
+    // Should always tried to retreive it first
     // and thus there should be a record
-    abort(); 
+    abort();
   }
 
   const Uint32 sz = vers->size();
   if(sz == 0){
-    // Should always tried to retreive it first 
+    // Should always tried to retreive it first
     // and thus there should be a record
-    abort(); 
+    abort();
   }
 
   for(i = 0; i < sz; i++){
@@ -286,6 +297,7 @@
 	delete ver.m_impl;
 	vers->erase(i);
       }
+      DBUG_EXECUTE("global", printCache(););
       DBUG_VOID_RETURN;
     }
   }
@@ -296,7 +308,7 @@
                         i, ver.m_version, ver.m_refCount,
                         ver.m_status, ver.m_impl));
   }
-  
+
   abort();
 }
 
@@ -308,85 +320,143 @@
 
   unsigned i;
   const Uint32 len = strlen(tab->m_internalName.c_str());
-  Vector<TableVersion> * vers = 
+  Vector<TableVersion> * vers =
     m_tableHash.getData(tab->m_internalName.c_str(), len);
   if(vers == 0){
-    // Should always tried to retreive it first 
+    // Should always tried to retreive it first
     // and thus there should be a record
-    abort(); 
+    abort();
   }
 
   const Uint32 sz = vers->size();
   if(sz == 0){
-    // Should always tried to retreive it first 
+    // Should always tried to retreive it first
     // and thus there should be a record
-    abort(); 
+    abort();
   }
-  
+
   for(i = 0; i < sz; i++){
     TableVersion & ver = (* vers)[i];
     if(ver.m_impl == tab){
-      if(ver.m_refCount == 0 || ver.m_status == RETREIVING || 
+      if(ver.m_refCount == 0 || ver.m_status == RETREIVING ||
 	 ver.m_version != tab->m_version){
 	DBUG_PRINT("info", ("Releasing with refCount=%d status=%d impl=%p",
                             ver.m_refCount, ver.m_status, ver.m_impl));
 	break;
       }
-      
+
       ver.m_refCount--;
+      DBUG_EXECUTE("global", printCache(););
       DBUG_VOID_RETURN;
     }
   }
-  
+
   for(i = 0; i<sz; i++){
     TableVersion & ver = (* vers)[i];
     DBUG_PRINT("info", ("%d: version: %d refCount: %d status: %d impl: %p",
                         i, ver.m_version, ver.m_refCount,
                         ver.m_status, ver.m_impl));
   }
-  
+
   abort();
 }
 
 void
-GlobalDictCache::alter_table_rep(const char * name, 
-				 Uint32 tableId, 
+GlobalDictCache::alter_table_rep(const char * name,
+				 Uint32 tableId,
 				 Uint32 tableVersion,
 				 bool altered)
 {
+  DBUG_ENTER("alter_table_rep");
+  DBUG_PRINT("enter", ("name: %s, id: %d, ver: %d, altered: %d",
+                       name, tableId, tableVersion, altered));
+  DBUG_EXECUTE("global", printCache(););
   const Uint32 len = strlen(name);
-  Vector<TableVersion> * vers = 
+  Vector<TableVersion> * vers =
     m_tableHash.getData(name, len);
-  
+
   if(vers == 0)
   {
-    return;
+    DBUG_PRINT("exit", ("Unknown table %s", name));
+    DBUG_EXECUTE("global", printCache(););
+    DBUG_VOID_RETURN;
   }
 
   const Uint32 sz = vers->size();
   if(sz == 0)
   {
-    return;
+    DBUG_PRINT("exit", ("No versions of table %s existed", name));
+    DBUG_EXECUTE("global", printCache(););
+    DBUG_VOID_RETURN;
   }
-  
+
   for(Uint32 i = 0; i < sz; i++)
   {
     TableVersion & ver = (* vers)[i];
-    if(ver.m_version == tableVersion && ver.m_impl && 
+    if(ver.m_version == tableVersion && ver.m_impl &&
        ver.m_impl->m_tableId == tableId)
     {
       ver.m_status = DROPPED;
-      ver.m_impl->m_status = altered ? 
+      ver.m_impl->m_status = altered ?
 	NdbDictionary::Object::Altered : NdbDictionary::Object::Invalid;
-      return;
+      DBUG_PRINT("exit", ("Marked table %s id: %d ver: %d",
+                          name, tableId, tableVersion));
+      DBUG_EXECUTE("global", printCache(););
+      DBUG_VOID_RETURN;
     }
 
     if(i == sz - 1 && ver.m_status == RETREIVING)
     {
       ver.m_impl = altered ? &f_altered_table : &f_invalid_table;
-      return;
-    } 
+      DBUG_PRINT("exit", ("Set special impl of %s(%d) ver: %d",
+                          name, tableId, tableVersion));
+      DBUG_EXECUTE("global", printCache(););
+      DBUG_VOID_RETURN;
+    }
+  }
+}
+
+#ifndef DBUG_OFF
+void GlobalDictCache::printCache()
+{
+  DBUG_ENTER("GlobalDictCache::printCache");
+  DBUG_LOCK_FILE;
+  NdbElement_t<Vector<TableVersion> > * curr = m_tableHash.getNext(0);
+  while(curr != 0){
+    fprintf(DBUG_FILE, "* %s len: %d, hash: %d, lk: %d\n",
+            (char*)curr->str, curr->len, curr->hash, curr->localkey1);
+    if (curr->theData){
+      Vector<TableVersion> * vers = curr->theData;
+      const unsigned sz = vers->size();
+      for(unsigned i = 0; i<sz ; i++){
+        TableVersion tv= (*vers)[i];
+        fprintf(DBUG_FILE, " + %d ver: %d, refCount: %d, status: %s\n",
+                i, tv.m_version, tv.m_refCount,
+                tv.m_status == 0 ? "OK" :
+                (tv.m_status == 1 ? "DROPPED" :
+                 (tv.m_status == 2 ? "RETREIVING" : "?"))) ;
+        NdbTableImpl *impl= tv.m_impl;
+        if(impl != 0)
+          fprintf(DBUG_FILE, "     tabId: %d, name: %s, ver: %d, status: %s\n",
+                  impl->m_tableId, impl->m_internalName.c_str(),
+                  impl->m_version,
+                  impl->m_status ==
+                  NdbDictionary::Object::New ? "New" :
+                  (impl->m_status ==
+                   NdbDictionary::Object::Changed ? "Changed" :
+                   (impl->m_status ==
+                    NdbDictionary::Object::Retrieved ? "Retrieved" :
+                    (impl->m_status ==
+                     NdbDictionary::Object::Invalid ? "Invalid" :
+                     (impl->m_status ==
+                      NdbDictionary::Object::Altered ? "Altered" : "?" )))));
+      }
+    }
+    curr = m_tableHash.getNext(curr);
   }
+  DBUG_UNLOCK_FILE;
+  DBUG_VOID_RETURN;
 }
+#endif
 
 template class Vector<GlobalDictCache::TableVersion>;

--- 1.9/ndb/src/ndbapi/DictCache.hpp	2005-08-18 14:09:08 +02:00
+++ 1.10/ndb/src/ndbapi/DictCache.hpp	2005-11-22 10:34:33 +01:00
@@ -46,13 +46,18 @@
 public:
   LocalDictCache();
   ~LocalDictCache();
-  
+
   Ndb_local_table_info * get(const char * name);
-  
+
   void put(const char * name, Ndb_local_table_info *);
   void drop(const char * name);
-  
+
   NdbLinHash<Ndb_local_table_info> m_tableHash; // On name
+
+private:
+#ifndef DBUG_OFF
+  void printCache();
+#endif
 };
 
 /**
@@ -62,14 +67,14 @@
 public:
   GlobalDictCache();
   ~GlobalDictCache();
-  
+
   NdbTableImpl * get(const char * name);
-  
+
   NdbTableImpl* put(const char * name, NdbTableImpl *);
   void drop(NdbTableImpl *);
   void release(NdbTableImpl *);
 
-  void alter_table_rep(const char * name, 
+  void alter_table_rep(const char * name,
 		       Uint32 tableId, Uint32 tableVersion, bool altered);
 public:
   enum Status {
@@ -77,9 +82,11 @@
     DROPPED = 1,
     RETREIVING = 2
   };
-  
+
 private:
+#ifndef DBUG_OFF
   void printCache();
+#endif
 
   struct TableVersion {
     Uint32 m_version;
@@ -87,7 +94,7 @@
     NdbTableImpl * m_impl;
     Status m_status;
   };
-  
+
   NdbLinHash<Vector<TableVersion> > m_tableHash;
   NdbCondition * m_waitForTableCondition;
 };
Thread
bk commit into 5.0 tree (msvensson:1.1988)msvensson22 Nov