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) List-Archive: http://lists.mysql.com/commits/139535 Message-Id: <20110620144051.5B1A6224@fimafeng09.norway.sun.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============2748104729267991081==" --===============2748104729267991081== MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline #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; } --===============2748104729267991081== MIME-Version: 1.0 Content-Type: text/bzr-bundle; charset="us-ascii"; name="bzr/ole.john.aske@stripped" Content-Transfer-Encoding: 7bit Content-Disposition: inline # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: ole.john.aske@stripped\ # b3bhysbmjq3no1m2 # target_branch: file:///net/fimafeng09/export/home/tmp/oleja/mysql\ # /mysql-5.1-telco-7.0-spj-scan-scan/ # testament_sha1: 272dd4adc9a9c3e2c55b25e6205b129657d701c3 # timestamp: 2011-06-20 16:40:51 +0200 # source_branch: bzr+ssh://oaske@stripped/bzrroot/server\ # /mysql-5.1-telco-7.0/ # base_revision_id: ole.john.aske@stripped\ # 33y3cbegle29h4ut # # Begin bundle IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWeuuHloAA9HfgFAwUOf//34R 7AC////7YAfd0XwDQaGogdA1o0AAZU0JoxoQaGhppoD1AAAAADmATATIwAjExMJhMENMTTAaTQ0K n6U8KbKfqCeghiAGCaDQNAEpoiZITTZNUzU8JNNPRBoNGQyD1Mmag5gEwEyMAIxMTCYTBDTE0wEk ghoACaGlPBJgk9FPJP0o0GmTT1CQ29ZGz3LPr6sacsju7eItbUOZ1vkWpRryap01ZG60MbEpg1rW LKCpuA9iiKBJAWsR72Lc0/zFZRkMErCYBOCBGTj1h2BwAhJhJkgEvz2hh3zrhhBnVyz1fCrsYmrx KVIosVB0SUW1h7XqqitUlR3qpofj2mXni8Td53ejxjw82zFYVsisA+6yXMq2bIhEYjE4lgAUG/EZ wwsU8HgGtFkPdGrACuWEzoh7z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