List:Commits« Previous MessageNext Message »
From:kroki Date:October 27 2006 3:25pm
Subject:bk commit into 5.1 tree (kroki:1.2328) BUG#21915
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of tomash. When tomash 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, 2006-10-27 17:25:21+04:00, kroki@stripped +2 -0
  BUG#21915: Changing limits of table_cache when setting max_connections
  
  If the user has specified --max-connections=N or --table-open-cache=M
  options to the server, a warning could be given that some values were
  recalculated, and table-open-cache could we assigned greater value.
  
  Note that both warning and increase of table-open-cache were totally
  harmless.
  
  This patch fixes recalculation code to ensure that table-open-cache will
  be never increased automatically and that warning will be given only if
  some values had to be decreased due to operation system limits.
  
  No test case is provided because we neither can't predict nor control
  operation system limits on maximal number of open files.

  sql/mysql_priv.h@stripped, 2006-10-27 17:25:15+04:00, kroki@stripped +2 -0
    Add constants for table_open_cache minimum and default values.

  sql/mysqld.cc@stripped, 2006-10-27 17:25:15+04:00, kroki@stripped +34 -10
    Fix max_connections and table_cache_size recomputation.

# 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:	kroki
# Host:	moonlight.intranet
# Root:	/home/tomash/src/mysql_ab/mysql-5.1-bug21915

--- 1.452/sql/mysql_priv.h	2006-10-27 17:25:30 +04:00
+++ 1.453/sql/mysql_priv.h	2006-10-27 17:25:30 +04:00
@@ -140,6 +140,8 @@ MY_LOCALE *my_locale_by_name(const char 
 #define MAX_ACCEPT_RETRY	10	// Test accept this many times
 #define MAX_FIELDS_BEFORE_HASH	32
 #define USER_VARS_HASH_SIZE     16
+#define TABLE_OPEN_CACHE_MIN    64
+#define TABLE_OPEN_CACHE_DEFAULT 64
 
 /* 
  Value of 9236 discovered through binary search 2006-09-26 on Ubuntu Dapper

--- 1.583/sql/mysqld.cc	2006-10-27 17:25:30 +04:00
+++ 1.584/sql/mysqld.cc	2006-10-27 17:25:30 +04:00
@@ -2663,19 +2663,43 @@ static int init_common_variables(const c
 
   /* connections and databases needs lots of files */
   {
-    uint files, wanted_files;
+    uint files, wanted_files, max_open_files;
 
-    wanted_files= 10+(uint) max(max_connections*5,
-				 max_connections+table_cache_size*2);
-    set_if_bigger(wanted_files, open_files_limit);
-    files= my_set_max_open_files(wanted_files);
+    /* MyISAM requires two file handles per table. */
+    wanted_files= 10+max_connections+table_cache_size*2;
+    /*
+      We are trying to allocate no less than max_connections*5 file
+      handles (i.e. we are trying to set the limit so that they will
+      be available).  In addition, we allocate no less than how much
+      was already allocated.  However below we report a warning and
+      recompute values only if we got less file handles than were
+      explicitly requested.  No warning and re-computation occur if we
+      can't get max_connections*5 but still got no less than was
+      requested (value of wanted_files).
+    */
+    max_open_files= max(max(wanted_files, max_connections*5),
+                        open_files_limit);
+    files= my_set_max_open_files(max_open_files);
 
     if (files < wanted_files)
     {
       if (!open_files_limit)
       {
-	max_connections=	(ulong) min((files-10),max_connections);
-	table_cache_size= (ulong) max((files-10-max_connections)/2,64);
+        /*
+          If we have requested too much file handles than we bring
+          max_connections in supported bounds.
+        */
+        max_connections= (ulong) min(files-10-TABLE_OPEN_CACHE_MIN*2,
+                                     max_connections);
+        /*
+          Decrease table_cache_size according to max_connections, but
+          not below TABLE_OPEN_CACHE_MIN.  Outer min() ensures that we
+          never increase table_cache_size automatically (that could
+          happen if max_connections is decreased above).
+        */
+        table_cache_size= (ulong) min(max((files-10-max_connections)/2,
+                                          TABLE_OPEN_CACHE_MIN),
+                                      table_cache_size);    
 	DBUG_PRINT("warning",
 		   ("Changed limits: max_open_files: %u  max_connections: %ld  table_cache: %ld",
 		    files, max_connections, table_cache_size));
@@ -6198,15 +6222,15 @@ The minimum value for this variable is 4
   {"table_cache", OPT_TABLE_OPEN_CACHE,
    "Deprecated; use --table_open_cache instead.",
    (gptr*) &table_cache_size, (gptr*) &table_cache_size, 0, GET_ULONG,
-   REQUIRED_ARG, 64, 1, 512*1024L, 0, 1, 0},
+   REQUIRED_ARG, TABLE_OPEN_CACHE_DEFAULT, 1, 512*1024L, 0, 1, 0},
   {"table_definition_cache", OPT_TABLE_DEF_CACHE,
    "The number of cached table definitions.",
    (gptr*) &table_def_size, (gptr*) &table_def_size,
    0, GET_ULONG, REQUIRED_ARG, 128, 1, 512*1024L, 0, 1, 0},
   {"table_open_cache", OPT_TABLE_OPEN_CACHE,
    "The number of cached open tables.",
-   (gptr*) &table_cache_size, (gptr*) &table_cache_size,
-   0, GET_ULONG, REQUIRED_ARG, 64, 1, 512*1024L, 0, 1, 0},
+   (gptr*) &table_cache_size, (gptr*) &table_cache_size, 0, GET_ULONG,
+   REQUIRED_ARG, TABLE_OPEN_CACHE_DEFAULT, 1, 512*1024L, 0, 1, 0},
   {"table_lock_wait_timeout", OPT_TABLE_LOCK_WAIT_TIMEOUT,
    "Timeout in seconds to wait for a table level lock before returning an "
    "error. Used only if the connection has active cursors.",
Thread
bk commit into 5.1 tree (kroki:1.2328) BUG#21915kroki27 Oct