List:Internals« Previous MessageNext Message »
From:pekka Date:April 4 2005 8:54am
Subject:bk commit into 4.1 tree (pekka:1.2160) BUG#9280
View as plain text  
Below is the list of changes that have just been committed into a local
4.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
  1.2160 05/04/04 10:53:56 pekka@stripped +3 -0
  ndb - bug#9280 csc#4847 release scan op early to save memory

  ndb/src/ndbapi/NdbScanOperation.cpp
    1.50 05/04/04 10:41:38 pekka@stripped +12 -4
    release scan op of hupped trans at scan close to save memory

  ndb/src/ndbapi/NdbConnection.cpp
    1.34 05/04/04 10:41:38 pekka@stripped +42 -3
    release scan op of hupped trans at scan close to save memory

  ndb/include/ndbapi/NdbConnection.hpp
    1.24 05/04/04 10:41:38 pekka@stripped +1 -0
    release scan op of hupped trans at scan close to save memory

# 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:	tuna.ndb.mysql.com
# Root:	/orca/space/pekka/ndb/version/my41

--- 1.23/ndb/include/ndbapi/NdbConnection.hpp	2005-03-01 13:35:56 +01:00
+++ 1.24/ndb/include/ndbapi/NdbConnection.hpp	2005-04-04 10:41:38 +02:00
@@ -542,6 +542,7 @@
   // Release all cursor operations in connection
   void releaseOps(NdbOperation*);	
   void releaseScanOperations(NdbIndexScanOperation*);	
+  void releaseExecutedScanOperation(NdbIndexScanOperation*);
 
   // Set the transaction identity of the transaction
   void		setTransactionId(Uint64 aTransactionId);

--- 1.33/ndb/src/ndbapi/NdbConnection.cpp	2004-12-22 13:31:05 +01:00
+++ 1.34/ndb/src/ndbapi/NdbConnection.cpp	2005-04-04 10:41:38 +02:00
@@ -880,6 +880,8 @@
 ******************************************************************************/
 void 
 NdbConnection::release(){
+  DBUG_ENTER("NdbConnection::release");
+  DBUG_PRINT("enter", ("this=0x%0x", (UintPtr)this));
   releaseOperations();
   if ( (theTransactionIsStarted == true) &&
        ((theCommitStatus != Committed) &&
@@ -898,6 +900,7 @@
     abort();
   }
 #endif
+  DBUG_VOID_RETURN;
 }//NdbConnection::release()
 
 void
@@ -955,14 +958,47 @@
 void 
 NdbConnection::releaseScanOperations(NdbIndexScanOperation* cursorOp)
 {
+  DBUG_ENTER("NdbConnection::releaseScanOperations");
+  DBUG_PRINT("enter", ("this=0x%x", (UintPtr)this));
   while(cursorOp != 0){
     NdbIndexScanOperation* next = (NdbIndexScanOperation*)cursorOp->next();
     cursorOp->release();
     theNdb->releaseScanOperation(cursorOp);
     cursorOp = next;
   }
+  DBUG_VOID_RETURN;
 }//NdbConnection::releaseScanOperations()
 
+/******************************************************************************
+void releaseExecutedScanOperation();
+
+Remark:         Release scan op when hupp'ed trans closed (save memory)
+******************************************************************************/
+void 
+NdbConnection::releaseExecutedScanOperation(NdbIndexScanOperation* cursorOp)
+{
+  DBUG_ENTER("NdbConnection::releaseExecutedScanOperation");
+  DBUG_PRINT("enter", ("this=0x%x op=0x%x", (UintPtr)this, (UintPtr)cursorOp));
+  // here is one reason to make op lists doubly linked
+  if (m_firstExecutedScanOp == cursorOp) {
+      cursorOp->release();
+      theNdb->releaseScanOperation(cursorOp);
+      m_firstExecutedScanOp = NULL;
+  } else {
+    NdbIndexScanOperation* tOp = m_firstExecutedScanOp;
+    while (tOp->theNext != NULL) {
+      if (tOp->theNext == cursorOp) {
+        tOp->theNext = cursorOp->theNext;
+        cursorOp->release();
+        theNdb->releaseScanOperation(cursorOp);
+        break;
+      }
+      tOp = (NdbIndexScanOperation*)tOp->theNext;
+    }
+  }
+  DBUG_VOID_RETURN;
+}//NdbConnection::releaseExecutedScanOperation()
+
 /*****************************************************************************
 NdbOperation* getNdbOperation(const char* aTableName);
 
@@ -1162,6 +1198,8 @@
 NdbConnection::getNdbScanOperation(const NdbTableImpl * tab)
 { 
   NdbIndexScanOperation* tOp;
+  DBUG_ENTER("NdbConnection::getNdbScanOperation");
+  DBUG_PRINT("enter", ("this=0x%x table=%s", (UintPtr)this, tab->getName()));
   
   tOp = theNdb->getScanOperation();
   if (tOp == NULL)
@@ -1169,15 +1207,16 @@
   
   if (tOp->init(tab, this) != -1) {
     define_scan_op(tOp);
-    return tOp;
+    DBUG_PRINT("exit", ("op=0x%x", tOp));
+    DBUG_RETURN(tOp);
   } else {
     theNdb->releaseScanOperation(tOp);
   }//if
-  return NULL;
+  DBUG_RETURN(NULL);
 
 getNdbOp_error1:
   setOperationErrorCodeAbort(4000);
-  return NULL;
+  DBUG_RETURN(NULL);
 }//NdbConnection::getNdbScanOperation()
 
 void

--- 1.49/ndb/src/ndbapi/NdbScanOperation.cpp	2005-01-19 18:32:31 +01:00
+++ 1.50/ndb/src/ndbapi/NdbScanOperation.cpp	2005-04-04 10:41:38 +02:00
@@ -690,14 +690,19 @@
     TransporterFacade* tp = TransporterFacade::instance();
     Guard guard(tp->theMutexPtr);
     close_impl(tp, forceSend);
-    
-  } while(0);
+  }
   
   theNdbCon->theScanningOp = 0;
   theNdb->closeTransaction(theNdbCon);
-  
   theNdbCon = 0;
-  m_transConnection = NULL;
+  
+  if (m_transConnection) {
+    NdbConnection* tConn = m_transConnection;
+    m_transConnection = NULL;   // avoid recursion
+    NdbIndexScanOperation* tOp = (NdbIndexScanOperation*)this;
+    if (tOp->theNdbCon != NULL) // check not already released
+      tConn->releaseExecutedScanOperation(tOp);
+  }
 }
 
 void
@@ -708,6 +713,8 @@
 
 void NdbScanOperation::release()
 {
+  DBUG_ENTER("NdbScanOperation::release");
+  DBUG_PRINT("enter", ("this=0x%x", (UintPtr)this));
   if(theNdbCon != 0 || m_transConnection != 0){
     closeScan();
   }
@@ -720,6 +727,7 @@
     theSCAN_TABREQ = 0;
   }
   NdbOperation::release();
+  DBUG_VOID_RETURN;
 }
 
 /***************************************************************************
Thread
bk commit into 4.1 tree (pekka:1.2160) BUG#9280pekka4 Apr