List:Commits« Previous MessageNext Message »
From:pekka Date:February 3 2007 9:13am
Subject:bk commit into 5.1 tree (pekka:1.2401)
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, 2007-02-03 10:13:06+01:00, pekka@stripped +4 -0
  ndb - wl#3600 use another SectionSegmentPool for saved sections

  storage/ndb/include/kernel/signaldata/BuildIndx.hpp@stripped, 2007-02-03 10:12:19+01:00, pekka@stripped +2 -2
    wl#3600 use another SectionSegmentPool for saved sections + more checks

  storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp@stripped, 2007-02-03 10:12:19+01:00, pekka@stripped +150 -60
    wl#3600 use another SectionSegmentPool for saved sections + more checks

  storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp@stripped, 2007-02-03 10:12:19+01:00, pekka@stripped +23 -8
    wl#3600 use another SectionSegmentPool for saved sections + more checks

  storage/ndb/src/kernel/vm/TransporterCallback.cpp@stripped, 2007-02-03 10:12:19+01:00, pekka@stripped +17 -6
    wl#3600 use another SectionSegmentPool for saved sections + more checks

# 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-a

--- 1.7/storage/ndb/include/kernel/signaldata/BuildIndx.hpp	2007-01-25 13:30:51 +01:00
+++ 1.8/storage/ndb/include/kernel/signaldata/BuildIndx.hpp	2007-02-03 10:12:19 +01:00
@@ -52,7 +52,7 @@
   Uint32 indexType;
   Uint32 parallelism;
 
-#ifdef wl3600_todo out
+#ifdef wl3600_todo //out
   // Sent data ends here
   Uint32 m_slack[25 - SignalLength - 1];
   Uint32 m_sectionBuffer[MAX_ATTRIBUTES_IN_TABLE * 2];
@@ -64,7 +64,7 @@
 #endif
 };
 
-#ifdef wl3600_todo out
+#ifdef wl3600_todo //out
 inline
 void BuildIndxReq::setColumnOrder(Uint32* indexBuf, Uint32 indexLen, 
 				  Uint32* keyBuf, Uint32 keyLen,

--- 1.143/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp	2007-01-30 12:32:11 +01:00
+++ 1.144/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp	2007-02-03 10:12:19 +01:00
@@ -900,7 +900,7 @@
   
   PageRecordPtr pageRecPtr;
   c_pageRecordArray.getPtr(pageRecPtr, c_writeTableRecord.pageId);
-  copy(&pageRecPtr.p->word[ZPAGE_HEADER_SIZE], tabInfoPtr);
+  ::copy(&pageRecPtr.p->word[ZPAGE_HEADER_SIZE], tabInfoPtr);
   
   memset(&pageRecPtr.p->word[0], 0, 4 * ZPAGE_HEADER_SIZE);
   pageRecPtr.p->word[ZPOS_CHECKSUM] = 
@@ -912,12 +912,12 @@
 
 void
 Dbdict::writeTableFile(Signal* signal, Uint32 tableId,
-                       OpSection opSection, Callback* callback)
+                       OpSection tabInfoSec, Callback* callback)
 {
   ndbrequire(c_writeTableRecord.tableWriteState == WriteTableRecord::IDLE);
   
   {
-    const Uint32 size = opSection.m_head.getSize();
+    const Uint32 size = getSize(tabInfoSec);
     const Uint32 pages = WORDS2PAGES(size);
 
     c_writeTableRecord.no_of_words = size;
@@ -932,7 +932,7 @@
 
     Uint32* dst = &pageRecPtr.p->word[ZPAGE_HEADER_SIZE];
     Uint32 dstSize = ZSIZE_OF_PAGES_IN_WORDS - ZPAGE_HEADER_SIZE;
-    bool ok = copyFromOpSection(opSection, dst, dstSize);
+    bool ok = copyOut(tabInfoSec, dst, dstSize);
     ndbrequire(ok);
 
     memset(&pageRecPtr.p->word[0], 0, 4 * ZPAGE_HEADER_SIZE);
@@ -2168,7 +2168,7 @@
   g_key_descriptor_pool.setSize(tablerecSize);
   c_triggerRecordPool.setSize(c_maxNoOfTriggers);
 
-  c_opSectionBufferPool.setSize(2048); // unit OpSectionSegmentSize
+  c_opSectionPool.setSize(2048); // in 60-word units
   c_schemaOpPool.setSize(256);
   c_schemaOpHash.setSize(256);
   c_schemaTransPool.setSize(2);
@@ -2682,7 +2682,7 @@
   XSchemaFile * xsf = &c_schemaFile[c_schemaRecord.schemaPage != 0];
   ndbrequire(schemaDataPtr.sz % NDB_SF_PAGE_SIZE_IN_WORDS == 0);
   xsf->noOfPages = schemaDataPtr.sz / NDB_SF_PAGE_SIZE_IN_WORDS;
-  copy((Uint32*)&xsf->schemaPage[0], schemaDataPtr);
+  ::copy((Uint32*)&xsf->schemaPage[0], schemaDataPtr);
   releaseSections(signal);
   
   SchemaFile * sf0 = &xsf->schemaPage[0];
@@ -4803,9 +4803,10 @@
   {
     //SegmentedSectionPtr tabInfoPtr;
     //getSection(tabInfoPtr, createTabPtr.p->m_tabInfoPtrI);
-    OpSection& opSection = op_ptr.p->m_section[CreateTabReq::DICT_TAB_INFO];
+    const OpSection& tabInfoSec =
+      getOpSection(op_ptr, CreateTabReq::DICT_TAB_INFO);
     writeTableFile(signal, createTabPtr.p->m_request.tableId,
-                   opSection, &callback);
+                   tabInfoSec, &callback);
   }
   else
   {
@@ -4833,21 +4834,22 @@
   SegmentedSectionPtr fragDataPtr;
   getSection(fragDataPtr, createTabPtr.p->m_fragmentsPtrI);
 #endif
-  OpSection& opSection = op_ptr.p->m_section[CreateTabReq::FRAGMENTATION];
-  ndbrequire(opSection.m_head.getSize() != 0);
+  const OpSection& fragSec =
+    getOpSection(op_ptr, CreateTabReq::FRAGMENTATION);
+  ndbrequire(getSize(fragSec) != 0);
 
   Callback callback;
   callback.m_callbackData = callbackData;
   callback.m_callbackFunction = 
     safe_cast(&Dbdict::createTab_dihComplete);
   
-  createTab_dih(signal, op_ptr, opSection, &callback);
+  createTab_dih(signal, op_ptr, fragSec, &callback);
 }
 
 void
 Dbdict::createTab_dih(Signal* signal, 
 		      SchemaOpPtr op_ptr,
-		      OpSection fragSection,
+		      OpSection fragSec,
 		      Callback * c)
 {
   jam();
@@ -4889,11 +4891,11 @@
     LinearSectionPtr ptr[3];
     Uint32 noOfSections = 0;
 
-    const int32 size = fragSection.m_head.getSize();
+    const Uint32 size = getSize(fragSec);
 
     if (size != 0) {
       jam();
-      bool ok = copyFromOpSection(fragSection, page, 1024);
+      bool ok = copyOut(fragSec, page, 1024);
       ndbrequire(ok);
       ptr[noOfSections].sz = size;
       ptr[noOfSections].p = page;
@@ -6782,13 +6784,14 @@
   c_tableRecordPool.getPtr(tablePtr, impl_req->tableId);
 
   // Write schema for altered table to disk
-  const OpSection& tabInfo = op_ptr.p->m_section[CreateTabReq::DICT_TAB_INFO];
-  const Uint32 sz = tabInfo.m_head.getSize();
+  const OpSection& tabInfoSec =
+    getOpSection(op_ptr, CreateTabReq::DICT_TAB_INFO);
+  const Uint32 size = getSize(tabInfoSec);
   bool savetodisk = !(tablePtr.p->m_bits & TableRecord::TR_Temporary);
   const Uint32 tableVersion = alterTabPtr.p->m_newTablePtr.p->tableVersion;
 
   // Update table record
-  tablePtr.p->packedSize = sz;
+  tablePtr.p->packedSize = size;
   tablePtr.p->tableVersion = tableVersion;
   tablePtr.p->gciTableCreated = impl_req->gci; //wl3600_todo
 
@@ -6800,7 +6803,7 @@
   else
     tabEntry.m_tableState   = SchemaFile::TEMPORARY_TABLE_COMMITTED;
   tabEntry.m_gcp          = impl_req->gci; //wl3600_todo
-  tabEntry.m_info_words   = sz;
+  tabEntry.m_info_words   = size;
   tabEntry.m_transKey = 0;
   tabEntry.zero_unused();
   
@@ -7591,7 +7594,8 @@
   c_tableRecordPool.getPtr(tablePtr, impl_req->tableId);
   bool savetodisk = !(tablePtr.p->m_bits & TableRecord::TR_Temporary);
 
-  const OpSection& tabInfo = op_ptr.p->m_section[CreateTabReq::DICT_TAB_INFO];
+  const OpSection& tabInfoSec =
+    getOpSection(op_ptr, CreateTabReq::DICT_TAB_INFO);
 
   Callback callback;
   callback.m_callbackData = op_ptr.p->op_key;
@@ -7600,7 +7604,7 @@
 
   if (savetodisk)
   {
-    writeTableFile(signal, impl_req->tableId, tabInfo, &callback);
+    writeTableFile(signal, impl_req->tableId, tabInfoSec, &callback);
   }
   else
   {
@@ -8871,7 +8875,7 @@
   char tableName[MAX_TAB_NAME_SIZE];
   SegmentedSectionPtr ssPtr;
   signal->getSection(ssPtr,GetTableIdReq::TABLE_NAME);
-  copy((Uint32*)tableName, ssPtr);
+  ::copy((Uint32*)tableName, ssPtr);
   releaseSections(signal);
     
   DictObject * obj_ptr_p = get_object(tableName, len);
@@ -21670,57 +21674,118 @@
 
 // OpSection
 
+// wl3600_todo SectionSegmentPool method cleanups
+
+extern bool
+import(Ptr<SectionSegment> & first, SectionSegmentPool& thePool,
+       const Uint32 * src, Uint32 len);
+
+extern void 
+copy(Uint32 * & insertPtr, SectionSegmentPool & thePool,
+     const SegmentedSectionPtr & _ptr);
+
+extern void
+release(SectionSegmentPool & thePool, SegmentedSectionPtr & ptr);
+
+void
+Dbdict::verify(const OpSection& op_sec)
+{
+  if (op_sec.m_ptr.isNull()) {
+    ndbrequire(op_sec.m_size == 0);
+  } else {
+    Ptr<SectionSegment> ptr;
+    c_opSectionPool.getPtr(ptr, op_sec.m_ptr.i);
+    ndbrequire(op_sec.m_ptr.p == ptr.p);
+    // first segment stores total size
+    ndbrequire(op_sec.m_size == ptr.p->m_sz);
+  }
+}
+
+Uint32
+Dbdict::getSize(const OpSection& op_sec)
+{
+  verify(op_sec);
+  return op_sec.m_size;
+}
+
 bool
-Dbdict::copyToOpSection(OpSection& opSection, SegmentedSectionPtr ss_ptr)
+Dbdict::copyIn(OpSection& op_sec, const SegmentedSectionPtr& ss_ptr)
 {
-  OpSectionBuffer buffer(c_opSectionBufferPool, opSection.m_head);
-  SimplePropertiesSectionReader r(ss_ptr, getSectionSegmentPool());
+  // wl3600_todo avoid buf
+  const Uint32 size = ZSIZE_OF_PAGES_IN_WORDS;
+  Uint32 buf[size];
+
+  bool ok1 = (ss_ptr.sz <= size);
+  ndbrequire(ok1);
+  ::copy(buf, ss_ptr);
 
-  // undo any ctor-invoked first()
-  r.reset();
+  bool ok2 = copyIn(op_sec, buf, ss_ptr.sz);
+  ndbrequire(ok2);
 
-  const Uint32 size = ss_ptr.sz;
-  Uint32 n = 0;
-  while (n < size) {
-    Uint32 buf[OpSectionSegmentSize];
-    bool ok;
-    Uint32 m = OpSectionSegmentSize;
-    if (m > size - n)
-      m = size - n;
-#if wl3600_todo // plain SectionReader crashes on multiple words
-    m = 1;
-#endif
-    ok = r.getWords(buf, m);
-    ndbrequire(ok);
-    ok = buffer.append(buf, m);
-    if (!ok)
-      return false;
-    n += m;
-  }
-  ndbrequire(n == size && buffer.getSize() == size);
   return true;
 }
 
 bool
-Dbdict::copyFromOpSection(OpSection opSection, Uint32* dst, Uint32 dstSize)
+Dbdict::copyIn(OpSection& op_sec, const Uint32* src, Uint32 srcSize)
 {
-  OpSectionBuffer buffer(c_opSectionBufferPool, opSection.m_head);
-  const Uint32 size = buffer.getSize();
-  if (size > dstSize)
-    return false;
+  ndbrequire(op_sec.m_ptr.isNull());
+  bool ok = ::import(op_sec.m_ptr, c_opSectionPool, src, srcSize);
+  ndbrequire(ok);
+
+  op_sec.m_size = srcSize;
+  verify(op_sec);
+
+  return true;
+}
+
+bool
+Dbdict::copyOut(const OpSection& op_sec, SegmentedSectionPtr& ss_ptr)
+{
+  // wl3600_todo avoid buf
+  const Uint32 size = ZSIZE_OF_PAGES_IN_WORDS;
+  Uint32 buf[size];
 
-  OpSectionBuffer::ConstDataBufferIterator iter;
-  Uint32 n = 0;
-  buffer.first(iter);
-  while (!iter.isNull()) {
-    dst[n] = *iter.data;
-    n++;
-    buffer.next(iter);
+  bool ok1 = copyOut(op_sec, buf, size);
+  ndbrequire(ok1);
+
+  Ptr<SectionSegment> ptr;
+  bool ok2 = ::import(ptr, buf, op_sec.m_size);
+  ndbrequire(ok2);
+  ss_ptr.i = ptr.i;
+  ss_ptr.p = ptr.p;
+  ss_ptr.sz = op_sec.m_size;
+
+  return true;
+}
+
+bool
+Dbdict::copyOut(const OpSection& op_sec, Uint32* dst, Uint32 dstSize)
+{
+  verify(op_sec);
+  if (op_sec.m_size > dstSize) {
+    return false;
   }
-  ndbrequire(n == size);
+  SegmentedSectionPtr ss_ptr;
+  ss_ptr.i = op_sec.m_ptr.i;
+  ss_ptr.p = op_sec.m_ptr.p;
+  ss_ptr.sz = op_sec.m_size;
+  ::copy(dst, c_opSectionPool, ss_ptr);
+
   return true;
 }
 
+void
+Dbdict::release(OpSection& op_sec)
+{
+  verify(op_sec);
+  ndbrequire(!op_sec.m_ptr.isNull());
+  SegmentedSectionPtr ss_ptr;
+  ss_ptr.i = op_sec.m_ptr.i;
+  ss_ptr.p = op_sec.m_ptr.p;
+  ss_ptr.sz = op_sec.m_size;
+  ::release(c_opSectionPool, ss_ptr);
+}
+
 // SchemaOp
 
 const Dbdict::OpInfo&
@@ -21777,6 +21842,11 @@
   const OpInfo& info = getOpInfo(op_ptr);
   (this->*(info.m_release))(op_ptr);
 
+  while (op_ptr.p->m_sections != 0) {
+    jam();
+    releaseOpSection(op_ptr, op_ptr.p->m_sections - 1);
+  }
+
   OpDataPtr data_ptr = op_ptr.p->m_data_ptr;
   Uint32 obj_ptr_i = data_ptr.p->m_obj_ptr_i;
   if (obj_ptr_i != RNIL) {
@@ -21790,6 +21860,13 @@
 
 // save signal sections
 
+const Dbdict::OpSection&
+Dbdict::getOpSection(SchemaOpPtr op_ptr, Uint32 ss_no)
+{
+  ndbrequire(ss_no < op_ptr.p->m_sections);
+  return op_ptr.p->m_section[ss_no];
+}
+
 bool
 Dbdict::saveOpSection(SchemaOpPtr op_ptr,
                       Signal* signal, Uint32 ss_no)
@@ -21805,14 +21882,23 @@
                       SegmentedSectionPtr ss_ptr, Uint32 ss_no)
 {
   ndbrequire(ss_no <= 2 && op_ptr.p->m_sections == ss_no);
-  OpSection& opSection = op_ptr.p->m_section[ss_no];
+  OpSection& op_sec = op_ptr.p->m_section[ss_no];
   op_ptr.p->m_sections++;
 
-  bool ok = copyToOpSection(opSection, ss_ptr);
+  bool ok = copyIn(op_sec, ss_ptr);
   ndbrequire(ok);
   return true;
 }
 
+void
+Dbdict::releaseOpSection(SchemaOpPtr op_ptr, Uint32 ss_no)
+{
+  ndbrequire(ss_no + 1 == op_ptr.p->m_sections);
+  OpSection& op_sec = op_ptr.p->m_section[ss_no];
+  release(op_sec);
+  op_ptr.p->m_sections = ss_no;
+}
+
 // add schema op to trans during parse phase
 
 void
@@ -21987,6 +22073,10 @@
   c_phaseIteratorPool.release(trans_ptr.p->m_iterator_ptr);
   c_schemaTransHash.release(trans_ptr);
   trans_ptr.setNull();
+
+  // only 1 trans at time so it is easy to check for leaks
+  ndbrequire(c_schemaOpPool.getNoOfFree() == c_schemaOpPool.getSize());
+  ndbrequire(c_opSectionPool.getNoOfFree() == c_opSectionPool.getSize());
 }
 
 Dbdict::PhaseIterator&

--- 1.69/storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp	2007-01-30 12:32:11 +01:00
+++ 1.70/storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp	2007-02-03 10:12:19 +01:00
@@ -1365,18 +1365,31 @@
   };
   typedef Ptr<OpData> OpDataPtr;
 
-  // OpSection
-
-  enum { OpSectionSegmentSize = 127 };
-  typedef LocalDataBuffer<OpSectionSegmentSize> OpSectionBuffer;
-  OpSectionBuffer::DataBufferPool c_opSectionBufferPool;
+  /*
+   * OpSection
+   *
+   * Signal sections are released in parse phase and stored
+   * (if needed) under DICT in a separate SectionSegmentPool.
+   */
 
   struct OpSection {
-    OpSectionBuffer::Head m_head;
+    Ptr<SectionSegment> m_ptr;
+    Uint32 m_size;
+    OpSection() {
+      m_ptr.setNull();
+      m_size = 0;
+    }
   };
 
-  bool copyToOpSection(OpSection&, SegmentedSectionPtr);
-  bool copyFromOpSection(OpSection, Uint32* dst, Uint32 size);
+  SectionSegmentPool c_opSectionPool;
+
+  void verify(const OpSection&);
+  Uint32 getSize(const OpSection&);
+  bool copyIn(OpSection&, const SegmentedSectionPtr&);
+  bool copyIn(OpSection&, const Uint32* src, Uint32 srcSize);
+  bool copyOut(const OpSection&, SegmentedSectionPtr&);
+  bool copyOut(const OpSection&, Uint32* dst, Uint32 dstSize);
+  void release(OpSection&);
 
   // SchemaOp
 
@@ -1557,8 +1570,10 @@
   void releaseSchemaOp(SchemaOpPtr& op_ptr);
 
   // copy signal sections to schema op sections
+  const OpSection& getOpSection(SchemaOpPtr, Uint32 ss_no);
   bool saveOpSection(SchemaOpPtr, Signal*, Uint32 ss_no);
   bool saveOpSection(SchemaOpPtr, SegmentedSectionPtr ss_ptr, Uint32 ss_no);
+  void releaseOpSection(SchemaOpPtr, Uint32 ss_no);
 
   // add operation to transaction OpList
   void addSchemaOp(SchemaTransPtr, SchemaOpPtr&);

--- 1.13/storage/ndb/src/kernel/vm/TransporterCallback.cpp	2006-11-21 22:15:39 +01:00
+++ 1.14/storage/ndb/src/kernel/vm/TransporterCallback.cpp	2007-02-03 10:12:19 +01:00
@@ -62,7 +62,8 @@
 }
 
 bool
-import(Ptr<SectionSegment> & first, const Uint32 * src, Uint32 len){
+import(Ptr<SectionSegment> & first, SectionSegmentPool& thePool,
+       const Uint32 * src, Uint32 len){
   /**
    * Dummy data used when setting prev.m_nextSegment for first segment of a
    *   section
@@ -70,7 +71,7 @@
   Uint32 dummyPrev[4]; 
 
   first.p = 0;
-  if(g_sectionSegmentPool.seize(first)){
+  if(thePool.seize(first)){
     ;
   } else {
     return false;
@@ -88,7 +89,7 @@
     src += SectionSegment::DataLength;
     len -= SectionSegment::DataLength;
     prevPtr = currPtr;
-    if(g_sectionSegmentPool.seize(currPtr)){
+    if(thePool.seize(currPtr)){
       ;
     } else {
       first.p->m_lastSegment = prevPtr.i;
@@ -102,6 +103,11 @@
   return true;
 }
 
+bool
+import(Ptr<SectionSegment> & first, const Uint32 * src, Uint32 len){
+  return import(first, g_sectionSegmentPool, src, len);
+}
+
 void
 linkSegments(Uint32 head, Uint32 tail){
   
@@ -180,10 +186,15 @@
 #define relSz(x) ((x + SectionSegment::DataLength - 1) / SectionSegment::DataLength)
 
 void
+release(class SectionSegmentPool & thePool, SegmentedSectionPtr & ptr){
+  thePool.releaseList(relSz(ptr.sz),
+                      ptr.i, 
+                      ptr.p->m_lastSegment);
+}
+
+void
 release(SegmentedSectionPtr & ptr){
-  g_sectionSegmentPool.releaseList(relSz(ptr.sz),
-				   ptr.i, 
-				   ptr.p->m_lastSegment);
+  release(g_sectionSegmentPool, ptr);
 }
 
 void
Thread
bk commit into 5.1 tree (pekka:1.2401)pekka3 Feb