From: Date: April 4 2007 5:26pm Subject: bk commit into 5.0 tree (jbruehe:1.2496) BUG#27560 List-Archive: http://lists.mysql.com/commits/23814 X-Bug: 27560 Message-Id: <200704041526.l34FQfk9031808@production.mysql.com> Below is the list of changes that have just been committed into a local 5.0 repository of mysqldev. When mysqldev 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-04-04 17:26:30+02:00, jbruehe@stripped +2 -0 BUG#27560: Memory usage of mysqld grows while doing nothing The query-cache watch thread was continually allocating new thread entries on the THD MEM_ROOT, not freed until server exit. Fixed by using a simple array, auto-expanded as necessary. (Originally done by Tomas on 2007-04-02 18:21:05+02:00; applied to the custom build BR#14007 by Joerg) configure.in@stripped, 2007-04-04 17:23:58+02:00, jbruehe@stripped +1 -1 Put build request number into version string. sql/ha_ndbcluster.cc@stripped, 2007-04-04 17:22:45+02:00, jbruehe@stripped +25 -10 Use a fixed array (auto-expanded as necessary) for temporary copy of open shares, don't keep pushing list entries on the THD mem root. # 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: jbruehe # Host: production.mysql.com # Root: /data0/mysqldev/my/build-200704041500-5.0.38/mysql-5.0.38-release --- 1.432/configure.in 2007-04-04 17:26:41 +02:00 +++ 1.433/configure.in 2007-04-04 17:26:41 +02:00 @@ -7,7 +7,7 @@ AC_CANONICAL_SYSTEM # The Docs Makefile.am parses this line! # remember to also change ndb version below and update version.c in ndb -AM_INIT_AUTOMAKE(mysql, 5.0.38) +AM_INIT_AUTOMAKE(mysql, 5.0.38-br14007) AM_CONFIG_HEADER(config.h) PROTOCOL_VERSION=10 --- 1.300/sql/ha_ndbcluster.cc 2007-04-04 17:26:41 +02:00 +++ 1.301/sql/ha_ndbcluster.cc 2007-04-04 17:26:41 +02:00 @@ -6669,7 +6669,8 @@ DBUG_RETURN(NULL); } - List util_open_tables; + uint share_list_size= 0; + NDB_SHARE **share_list= NULL; set_timespec(abstime, 0); for (;;) { @@ -6699,7 +6700,22 @@ /* Lock mutex and fill list with pointers to all open tables */ NDB_SHARE *share; pthread_mutex_lock(&ndbcluster_mutex); - for (uint i= 0; i < ndbcluster_open_tables.records; i++) + uint i, record_count= ndbcluster_open_tables.records; + if (share_list_size < record_count) + { + NDB_SHARE ** new_share_list= new NDB_SHARE * [record_count]; + if (!new_share_list) + { + sql_print_warning("ndb util thread: malloc failure, " + "query cache not maintained properly"); + pthread_mutex_unlock(&ndbcluster_mutex); + goto next; // At least do not crash + } + delete [] share_list; + share_list_size= record_count; + share_list= new_share_list; + } + for (i= 0; i < record_count; i++) { share= (NDB_SHARE *)hash_element(&ndbcluster_open_tables, i); share->use_count++; /* Make sure the table can't be closed */ @@ -6708,14 +6724,14 @@ i, share->table_name, share->use_count)); /* Store pointer to table */ - util_open_tables.push_back(share); + share_list[i]= share; } pthread_mutex_unlock(&ndbcluster_mutex); - /* Iterate through the open files list */ - List_iterator_fast it(util_open_tables); - while ((share= it++)) + /* Iterate through the open files list */ + for (i= 0; i < record_count; i++) { + share= share_list[i]; /* Split tab- and dbname */ char buf[FN_REFLEN]; char *tabname, *db; @@ -6764,10 +6780,7 @@ /* Decrease the use count and possibly free share */ free_share(share); } - - /* Clear the list of open tables */ - util_open_tables.empty(); - +next: /* Calculate new time to wake up */ int secs= 0; int msecs= ndb_cache_check_time; @@ -6790,6 +6803,8 @@ } } + if (share_list) + delete [] share_list; thd->cleanup(); delete thd; delete ndb;