Below is the list of changes that have just been committed into a local
5.0 repository of knielsen. When knielsen 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-02 15:50:57+02:00, knielsen@ymer.(none) +1 -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.
sql/ha_ndbcluster.cc@stripped, 2007-04-02 15:50:42+02:00, knielsen@ymer.(none) +28 -9
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: knielsen
# Host: ymer.(none)
# Root: /usr/local/mysql/mysql-5.0-bug27560
--- 1.303/sql/ha_ndbcluster.cc 2007-04-02 15:51:31 +02:00
+++ 1.304/sql/ha_ndbcluster.cc 2007-04-02 15:51:31 +02:00
@@ -6695,7 +6695,15 @@ pthread_handler_t ndb_util_thread_func(v
DBUG_RETURN(NULL);
}
- List<NDB_SHARE> util_open_tables;
+ uint share_list_size= 50;
+ NDB_SHARE **share_list= new NDB_SHARE * [share_list_size];
+ if (!share_list)
+ {
+ thd->cleanup();
+ delete thd;
+ delete ndb;
+ DBUG_RETURN(NULL);
+ }
set_timespec(abstime, 0);
for (;;)
{
@@ -6725,7 +6733,20 @@ pthread_handler_t ndb_util_thread_func(v
/* 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 record_count= ndbcluster_open_tables.records;
+ if (share_list_size < record_count)
+ {
+ uint new_share_list_size= share_list_size*3/2;
+ if (share_list_size < record_count)
+ share_list_size= record_count;
+ NDB_SHARE ** new_share_list= new NDB_SHARE * [new_share_list_size];
+ if (!new_share_list_size)
+ continue; // At least do not crash
+ delete [] share_list;
+ share_list_size= new_share_list_size;
+ share_list= new_share_list;
+ }
+ for (uint 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 */
@@ -6734,14 +6755,14 @@ pthread_handler_t ndb_util_thread_func(v
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<NDB_SHARE> it(util_open_tables);
- while ((share= it++))
+ /* Iterate through the open files list */
+ for (uint i= 0; i < record_count; i++)
{
+ share= share_list[i];
/* Split tab- and dbname */
char buf[FN_REFLEN];
char *tabname, *db;
@@ -6791,9 +6812,6 @@ pthread_handler_t ndb_util_thread_func(v
free_share(share);
}
- /* Clear the list of open tables */
- util_open_tables.empty();
-
/* Calculate new time to wake up */
int secs= 0;
int msecs= ndb_cache_check_time;
@@ -6816,6 +6834,7 @@ pthread_handler_t ndb_util_thread_func(v
}
}
+ delete [] share_list;
thd->cleanup();
delete thd;
delete ndb;
| Thread |
|---|
| • bk commit into 5.0 tree (knielsen:1.2428) BUG#27560 | knielsen | 2 Apr |