List:Commits« Previous MessageNext Message »
From:Ole John Aske Date:June 20 2011 2:40pm
Subject:bzr commit into mysql-5.1-telco-7.0-spj-scan-vs-scan branch
(ole.john.aske:3511)
View as plain text  
#At file:///net/fimafeng09/export/home/tmp/oleja/mysql/mysql-5.1-telco-7.0-spj-scan-scan/ based on revid:ole.john.aske@stripped

 3511 Ole John Aske	2011-06-20
      SPJ: Changed lifetime of NdbQueryDef objects allocated from ha_ndbcluster.
      
      To avoid excessive memory consumption for long running transactions, 
      we have shortened the lifetime of NdbQueryDef objects such that they
      no longer live until the Transaction ends.
      
      NdbQueryDefs will now be deleted when the ndb_pushed_join object which
      created it is destructed.
      
      This also means that the ndb_query_def_list wasn't needed anymore
      and has been removed.

    modified:
      sql/ha_ndbcluster.cc
      sql/ha_ndbcluster.h
      sql/ha_ndbcluster_push.cc
      sql/ha_ndbcluster_push.h
=== modified file 'sql/ha_ndbcluster.cc'
--- a/sql/ha_ndbcluster.cc	2011-06-20 14:24:53 +0000
+++ b/sql/ha_ndbcluster.cc	2011-06-20 14:40:46 +0000
@@ -1121,7 +1121,6 @@ Thd_ndb::Thd_ndb()
   global_schema_lock_count= 0;
   global_schema_lock_error= 0;
   init_alloc_root(&m_batch_mem_root, BATCH_FLUSH_SIZE/4, 0);
-  m_query_defs = NULL;
 }
 
 Thd_ndb::~Thd_ndb()
@@ -1144,7 +1143,6 @@ Thd_ndb::~Thd_ndb()
       }
     }
   }
-  release_query_defs();
   if (ndb)
   {
     delete ndb;
@@ -6796,7 +6794,7 @@ int ha_ndbcluster::reset()
   DBUG_ASSERT(m_active_query == NULL);
   if (m_pushed_join_operation==PUSHED_ROOT)  // Root of pushed query
   {
-    delete m_pushed_join_member;
+    delete m_pushed_join_member;             // Also delete QueryDef
   }
   m_pushed_join_member= NULL;
   m_pushed_join_operation= -1;
@@ -7385,7 +7383,6 @@ int ha_ndbcluster::external_lock(THD *th
           thd_ndb->ndb->closeTransaction(thd_ndb->trans);
           thd_ndb->trans= NULL;
           thd_ndb->m_handler= NULL;
-          thd_ndb->release_query_defs();
         }
       }
     }
@@ -7396,7 +7393,7 @@ int ha_ndbcluster::external_lock(THD *th
       no longer are connected to the active transaction.
 
       And since the handler is no longer part of the transaction 
-      it can't have open cursors, ops or blobs pending.
+      it can't have open cursors, ops, queries or blobs pending.
     */
     m_thd_ndb= NULL;    
 
@@ -7676,7 +7673,6 @@ int ndbcluster_commit(handlerton *hton, 
   ndb->closeTransaction(trans);
   thd_ndb->trans= NULL;
   thd_ndb->m_handler= NULL;
-  thd_ndb->release_query_defs();
 
   /* Clear commit_count for tables changed by transaction */
   NDB_SHARE* share;
@@ -7753,7 +7749,6 @@ static int ndbcluster_rollback(handlerto
   ndb->closeTransaction(trans);
   thd_ndb->trans= NULL;
   thd_ndb->m_handler= NULL;
-  thd_ndb->release_query_defs();
 
   /* Clear list of tables changed by transaction */
   NDB_SHARE* share;
@@ -10185,7 +10180,7 @@ ha_ndbcluster::~ha_ndbcluster() 
   DBUG_ASSERT(m_active_query == NULL);
   if (m_pushed_join_operation==PUSHED_ROOT)
   {
-    delete m_pushed_join_member;
+    delete m_pushed_join_member;             // Also delete QueryDef
   }
   m_pushed_join_member= NULL;
   DBUG_VOID_RETURN;
@@ -13930,46 +13925,6 @@ ha_ndbcluster::read_multi_range_fetch_ne
 #ifndef NO_PUSHED_JOIN
 
 /**
- * This is a list of NdbQueryDef objects that have been created within a 
- * transaction. This list is kept to make sure that they are all released 
- * when the transaction ends.
- * An NdbQueryDef object is required to live longer than any NdbQuery object
- * instantiated from it. Since NdbQueryObjects may be kept until the 
- * transaction ends, this list is necessary.
- */
-class ndb_query_def_list
-{
-public:
-  ndb_query_def_list(const NdbQueryDef* def, const ndb_query_def_list* next):
-    m_def(def), m_next(next){}
-
-  const NdbQueryDef* get_def() const
-  { return m_def; }
-
-  const ndb_query_def_list* get_next() const
-  { return m_next; }
-
-private:
-  const NdbQueryDef* const m_def;
-  const ndb_query_def_list* const m_next;
-};
-
-void
-Thd_ndb::release_query_defs()
-{
-  // DBUG_PRINT("info", ("release_query_defs() this=%p.", this));
-  const ndb_query_def_list* current = m_query_defs;
-  while (current != NULL)
-  {
-    current->get_def()->destroy();
-    const ndb_query_def_list* const previous = current;
-    current = current->get_next();
-    delete previous;
-  }
-  m_query_defs = NULL;
-}
-
-/**
  * Try to find pushable subsets of a join plan.
  * @param hton unused (maybe useful for other engines).
  * @param thd Thread.
@@ -14035,20 +13990,7 @@ int
 ha_ndbcluster::assign_pushed_join(const ndb_pushed_join* pushed_join)
 {
   DBUG_ENTER("assign_pushed_join");
-  const NdbQueryDef* const query_def= &pushed_join->get_query_def();
-
   m_thd_ndb->m_pushed_queries_defined++;
-  /* 
-   * Append query definition to transaction specific list, so that it can be
-   * released when the transaction ends.  
-   */
-  const ndb_query_def_list* const list_item= 
-    new ndb_query_def_list(query_def, m_thd_ndb->m_query_defs);
-  if (unlikely(list_item == NULL))
-  {
-    DBUG_RETURN(HA_ERR_OUT_OF_MEM);
-  }
-  m_thd_ndb->m_query_defs = list_item;
 
   for (uint i = 0; i < pushed_join->get_operation_count(); i++)
   {

=== modified file 'sql/ha_ndbcluster.h'
--- a/sql/ha_ndbcluster.h	2011-06-17 12:41:11 +0000
+++ b/sql/ha_ndbcluster.h	2011-06-20 14:40:46 +0000
@@ -53,7 +53,6 @@ class NdbQueryOperation;
 class NdbQueryOperationTypeWrapper;
 class NdbQueryParamValue;
 class ndb_pushed_join;
-class ndb_query_def_list;
 
 typedef enum ndb_index_type {
   UNDEFINED_INDEX = 0,
@@ -477,10 +476,8 @@ class Thd_ndb 
     This is a list of NdbQueryDef objects that should be released when the
     transaction ends.
   */
-  const ndb_query_def_list* m_query_defs;
   bool valid_ndb(void);
   bool recycle_ndb(THD* thd);
-  void release_query_defs();
 };
 
 struct st_ndb_status {

=== modified file 'sql/ha_ndbcluster_push.cc'
--- a/sql/ha_ndbcluster_push.cc	2011-06-15 07:26:12 +0000
+++ b/sql/ha_ndbcluster_push.cc	2011-06-20 14:40:46 +0000
@@ -148,6 +148,12 @@ ndb_pushed_join::ndb_pushed_join(
   }
 }
 
+ndb_pushed_join::~ndb_pushed_join()
+{
+  if (m_query_def)
+    m_query_def->destroy();
+}
+
 ndb_pushed_builder_ctx::ndb_pushed_builder_ctx(const AQP::Join_plan& plan)
 :
   m_plan(plan),

=== modified file 'sql/ha_ndbcluster_push.h'
--- a/sql/ha_ndbcluster_push.h	2011-04-27 08:23:16 +0000
+++ b/sql/ha_ndbcluster_push.h	2011-06-20 14:40:46 +0000
@@ -94,6 +94,8 @@ public:
   explicit ndb_pushed_join(const ndb_pushed_builder_ctx& builder_ctx,
                            const NdbQueryDef* query_def);
   
+  ~ndb_pushed_join(); 
+
   /** Get the number of pushed table access operations.*/
   uint get_operation_count() const
   { return m_operation_count; }


Attachment: [text/bzr-bundle] bzr/ole.john.aske@oracle.com-20110620144046-b3bhysbmjq3no1m2.bundle
Thread
bzr commit into mysql-5.1-telco-7.0-spj-scan-vs-scan branch(ole.john.aske:3511) Ole John Aske20 Jun