List:Commits« Previous MessageNext Message »
From:pekka Date:December 25 2006 9:58pm
Subject:bk commit into 5.1 tree (pekka:1.2375)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of pekka. When pekka 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@stripped, 2006-12-25 23:58:26+02:00, pekka@stripped +2 -0
  ndb - wl#3600

  storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp@stripped, 2006-12-25 23:57:53+02:00, pekka@stripped +101 -4
    wl#3600 basic schema op in DICT

  storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp@stripped, 2006-12-25 23:57:53+02:00, pekka@stripped +206 -0
    wl#3600 basic schema op in DICT

# 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:	pekka
# Host:	clam.(none)
# Root:	/export/space/pekka/ndb/version/my52-wl3600

--- 1.117/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp	2006-12-25 12:43:39 +02:00
+++ 1.118/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp	2006-12-25 23:57:53 +02:00
@@ -1510,6 +1510,7 @@
   c_file_hash(c_file_pool),
   c_filegroup_hash(c_filegroup_pool),
   c_obj_hash(c_obj_pool),
+  c_schemaOpHash(c_schemaOpPool),
   c_schemaTransHash(c_schemaTransPool),
   c_opCreateTable(c_opRecordPool),
   c_opDropTable(c_opRecordPool),
@@ -2077,6 +2078,8 @@
   g_key_descriptor_pool.setSize(tablerecSize);
   c_triggerRecordPool.setSize(c_maxNoOfTriggers);
 
+  c_schemaOpPool.setSize(256);
+  c_schemaOpHash.setSize(256);
   c_schemaTransPool.setSize(2);
   c_schemaTransHash.setSize(2);
   
@@ -16358,6 +16361,89 @@
   return error.errorCount != 0;
 }
 
+// SchemaOp
+
+const Dbdict::OpInfo&
+Dbdict::getOpInfo(SchemaOpPtr op_ptr)
+{
+  OpDataPtr data_ptr = op_ptr.p->m_data_ptr;
+  ndbrequire(!data_ptr.isNull());
+  return data_ptr.p->m_opInfo;
+}
+
+bool
+Dbdict::seizeSchemaOp(SchemaOpPtr& op_ptr, Uint32 op_key, const OpInfo& info)
+{
+  if (!findSchemaOp(op_ptr, op_key)) {
+    jam();
+    if (c_schemaOpHash.seize(op_ptr)) {
+      jam();
+      new (op_ptr.p) SchemaOp();
+      op_ptr.p->op_key = op_key;
+      if ((this->*(info.m_seize))(op_ptr)) {
+        jam();
+        c_schemaOpHash.add(op_ptr);
+        const OpDataPtr& data_ptr = op_ptr.p->m_data_ptr;
+        D("seizeSchemaOp" << V(op_ptr.i) << V(data_ptr.i) << hex << V(op_key));
+        return true;
+      }
+      c_schemaOpHash.release(op_ptr);
+    }
+  }
+  op_ptr.setNull();
+  return false;
+}
+
+bool
+Dbdict::findSchemaOp(SchemaOpPtr& op_ptr, Uint32 op_key)
+{
+  SchemaOp op_rec;
+  op_rec.op_key = op_key;
+  if (c_schemaOpHash.find(op_ptr, op_rec)) {
+    jam();
+    const OpDataPtr& data_ptr = op_ptr.p->m_data_ptr;
+    ndbrequire(!data_ptr.isNull());
+    D("findSchemaOp" << V(op_ptr.i) << V(data_ptr.i) << hex << V(op_key));
+    return true;
+  }
+  return false;
+}
+
+void
+Dbdict::releaseSchemaOp(SchemaOpPtr& op_ptr)
+{
+  D("releaseSchemaOp" << V(op_ptr.i) << *op_ptr.p);
+  const OpInfo& info = getOpInfo(op_ptr);
+  (this->*(info.m_release))(op_ptr);
+  OpDataPtr& data_ptr = op_ptr.p->m_data_ptr;
+  DictObjectPtr& obj_ptr = data_ptr.p->m_obj_ptr;
+  if (!obj_ptr.isNull()) {
+    jam();
+    obj_ptr.p->m_op_ptr.setNull();
+  }
+  c_schemaOpHash.release(op_ptr);
+  op_ptr.setNull();
+}
+
+void
+Dbdict::addSchemaOp(SchemaTransPtr trans_ptr, SchemaOpPtr& op_ptr)
+{
+  LocalDLFifoList<SchemaOp> list(c_schemaOpPool, trans_ptr.p->m_opList);
+#if VM_TRACE
+  SchemaOpPtr loop_ptr;
+  list.first(loop_ptr);
+  while (loop_ptr.i != RNIL) {
+    ndbrequire(loop_ptr.i != op_ptr.i);
+    ndbrequire(loop_ptr.p->op_key != op_ptr.p->op_key);
+    list.next(loop_ptr);
+  }
+#endif
+  list.add(op_ptr);
+  op_ptr.p->m_trans_ptr = trans_ptr;
+}
+
+// SchemaTrans
+
 bool
 Dbdict::seizeSchemaTrans(SchemaTransPtr& trans_ptr, Uint32 trans_key)
 {
@@ -16376,8 +16462,6 @@
   return false;
 }
 
-// SchemaTrans seize / find / release
-
 bool
 Dbdict::seizeSchemaTrans(SchemaTransPtr& trans_ptr)
 {
@@ -16405,14 +16489,12 @@
 void
 Dbdict::releaseSchemaTrans(SchemaTransPtr& trans_ptr)
 {
-#if wl3600_todo
   LocalDLFifoList<SchemaOp> list(c_schemaOpPool, trans_ptr.p->m_opList);
   SchemaOpPtr op_ptr;
   while (list.first(op_ptr)) {
     list.remove(op_ptr);
     releaseSchemaOp(op_ptr);
   }
-#endif
   c_schemaTransHash.release(trans_ptr);
   trans_ptr.setNull();
 }
@@ -16838,6 +16920,21 @@
   out << V(errorCode);
   out << V(errorLine);
   out << V(errorNodeId);
+  out << ")";
+}
+
+NdbOut&
+operator<<(NdbOut& out, const Dbdict::SchemaOp& a)
+{
+  a.print(out);
+  return out;
+}
+
+void
+Dbdict::SchemaOp::print(NdbOut& out) const
+{
+  out << " (SchemaOp";
+  out << hex << V(op_key);
   out << ")";
 }
 

--- 1.48/storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp	2006-12-25 12:43:39 +02:00
+++ 1.49/storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp	2006-12-25 23:57:53 +02:00
@@ -641,7 +641,11 @@
       }
       return false;
     }
+
+    // active operation on this object
+    Ptr<struct SchemaOp> m_op_ptr;
   };
+  typedef Ptr<DictObject> DictObjectPtr;
   
   DLHashTable<DictObject> c_obj_hash; // Name
   ArrayPool<DictObject> c_obj_pool;
@@ -1203,6 +1207,203 @@
     ref->masterNodeId = c_masterNodeId;
   }
 
+  // OpInfo
+
+  struct OpInfo {
+    Uint32 m_impl_req_gsn;
+    Uint32 m_impl_req_length;
+
+    // seize / release
+    bool (Dbdict::*m_seize)(SchemaOpPtr&);
+    void (Dbdict::*m_release)(SchemaOpPtr&);
+
+    // parse phase
+    void (Dbdict::*m_parse)(Signal*, SchemaTransPtr);
+    bool (Dbdict::*m_subops)(Signal*, SchemaOpPtr);
+    void (Dbdict::*m_reply)(Signal*, SchemaOpPtr);
+
+    // run phases
+    void (Dbdict::*m_prepare)(Signal*, SchemaOpPtr);
+    void (Dbdict::*m_commit)(Signal*, SchemaOpPtr);
+    void (Dbdict::*m_complete)(Signal*, SchemaOpPtr);
+  };
+
+  // OpData
+
+  struct OpData {
+    const OpInfo& m_opInfo;
+
+    // DictObject operated on
+    DictObjectPtr m_obj_ptr;
+
+    OpData(const OpInfo& info) :
+      m_opInfo(info)
+    {
+      m_obj_ptr.setNull();
+    }
+  };
+  typedef Ptr<OpData> OpDataPtr;
+
+  // SchemaOp
+
+  struct SchemaOp {
+    // ArrayPool
+    Uint32 nextPool;
+
+    // DLHashTable
+    Uint32 op_key;
+    Uint32 nextHash;
+    Uint32 prevHash;
+    Uint32 hashValue() const {
+      return op_key;
+    }
+    bool equal(const SchemaOp& rec) const {
+      return op_key == rec.op_key;
+    }
+
+    // DLFifoList
+    Uint32 nextList;
+    Uint32 prevList;
+
+    // the op belongs to this trans
+    SchemaTransPtr m_trans_ptr;
+
+    // type specific data record
+    OpDataPtr m_data_ptr;
+
+    SchemaOp() :
+      op_key(0)
+    {
+      m_trans_ptr.setNull();
+      m_data_ptr.setNull();
+    }
+
+#ifdef VM_TRACE
+    void print(NdbOut& out) const;
+#endif
+  };
+
+  ArrayPool<SchemaOp> c_schemaOpPool;
+  DLHashTable<SchemaOp> c_schemaOpHash;
+
+  const OpInfo& getOpInfo(SchemaOpPtr op_ptr);
+
+  // set or get the data record cast to the specific type
+
+  template <class T>
+  inline void
+  setOpData(SchemaOpPtr op_ptr, const Ptr<T> t_ptr)
+  {
+    OpDataPtr& data_ptr = op_ptr.p->m_data_ptr;
+    data_ptr.i = t_ptr.i;
+    data_ptr.p = static_cast<OpData*>(t_ptr.p);
+  }
+
+  template <class T>
+  inline void
+  getOpData(SchemaOpPtr op_ptr, Ptr<T>& t_ptr)
+  {
+    OpDataPtr data_ptr = op_ptr.p->m_data_ptr;
+    t_ptr.i = data_ptr.i;
+    t_ptr.p = static_cast<T*>(data_ptr.p);
+  }
+
+  // OpInfo m_seize and m_release
+
+  template <class T>
+  inline bool
+  seizeOpData(SchemaOpPtr op_ptr)
+  {
+    OpDataPtr& data_ptr = op_ptr.p->m_data_ptr;
+    ArrayPool<T>& pool = T::getPool(this);
+    Ptr<T> t_ptr;
+    if (pool.seize(t_ptr)) {
+      new (t_ptr.p) T();
+      setOpData<T>(op_ptr, t_ptr);
+      return true;
+    }
+    data_ptr.setNull();
+    return false;
+  }
+
+  template <class T>
+  inline void
+  releaseOpData(SchemaOpPtr op_ptr)
+  {
+    OpDataPtr& data_ptr = op_ptr.p->m_data_ptr;
+    ArrayPool<T>& pool = T::getPool(this);
+    Ptr<T> t_ptr;
+    getOpData<T>(op_ptr, t_ptr);
+    pool.release(t_ptr);
+    data_ptr.setNull();
+  }
+
+  // seize / find / release, atomic on op rec + data rec
+
+  bool seizeSchemaOp(SchemaOpPtr& op_ptr, Uint32 op_key, const OpInfo& info);
+
+  template <class T>
+  inline bool
+  seizeSchemaOp(SchemaOpPtr& op_ptr, Uint32 op_key)
+  {
+    return seizeSchemaOp(op_ptr, op_key, T::g_op_info);
+  }
+
+  template <class T>
+  inline bool
+  seizeSchemaOp(SchemaOpPtr& op_ptr, Ptr<T>& t_ptr, Uint32 op_key)
+  {
+    if (seizeSchemaOp<T>(op_ptr, op_key)) {
+      getOpData<T>(op_ptr, t_ptr);
+      return true;
+    }
+    return false;
+  }
+
+  template <class T>
+  inline bool
+  seizeSchemaOp(SchemaOpPtr& op_ptr)
+  {
+    Uint32 op_key = c_opRecordSequence + 1;
+    if (seizeSchemaOp<T>(op_ptr, op_key)) {
+      c_opRecordSequence = op_key;
+      return true;
+    }
+    return false;
+  }
+
+  template <class T>
+  inline bool
+  seizeSchemaOp(SchemaOpPtr& op_ptr, Ptr<T>& t_ptr)
+  {
+    if (seizeSchemaOp<T>(op_ptr)) {
+      getOpData<T>(op_ptr, t_ptr);
+      return true;
+    }
+    return false;
+  }
+
+  bool findSchemaOp(SchemaOpPtr& op_ptr, Uint32 op_key);
+
+  template <class T>
+  inline bool
+  findSchemaOp(SchemaOpPtr& op_ptr, Ptr<T>& t_ptr, Uint32 op_key)
+  {
+    if (findSchemaOp(op_ptr, op_key)) {
+      getOpData(op_ptr, t_ptr);
+      return true;
+    }
+    return false;
+  }
+
+  void releaseSchemaOp(SchemaOpPtr& op_ptr);
+
+  // add operation to transaction OpList
+  void addSchemaOp(SchemaTransPtr, SchemaOpPtr&);
+
+  // list of SchemaOp (sans pool)
+  typedef DLFifoList<SchemaOp>::Head OpList;
+
   // SchemaTrans
 
   struct SchemaTrans {
@@ -1228,6 +1429,9 @@
     NdbNodeBitmask m_failedNodes;
     SafeCounterHandle m_counter;
 
+    // list of schema ops under this tx
+    OpList m_opList;
+
     ErrorInfo m_error;
 
     SchemaTrans() :
@@ -2764,9 +2968,11 @@
   void send_drop_fg(Signal*, SchemaOperation*, DropFilegroupImplReq::RequestInfo);
 
   void drop_undofile_prepare_start(Signal* signal, SchemaOperation*);
+
 #ifdef VM_TRACE
   NdbOut debugOut;
   friend NdbOut& operator<<(NdbOut& out, const ErrorInfo&);
+  friend NdbOut& operator<<(NdbOut& out, const SchemaOp&);
   friend NdbOut& operator<<(NdbOut& out, const SchemaTrans&);
 #endif
 };
Thread
bk commit into 5.1 tree (pekka:1.2375)pekka25 Dec