List:Commits« Previous MessageNext Message »
From:Mayank Prasad Date:August 27 2012 6:43am
Subject:bzr push into mysql-trunk branch (mayank.prasad:4334 to 4335) WL#6372
View as plain text  
 4335 Mayank Prasad	2012-08-27
      wl#6372 : Post-Iris changes to Server defaults
            
      Details:
       - Implemented 
      	. query_cache_size
            	. query_cache_type
            	. sort_buffer_size
            	. innodb_log_file_size
      	. thread_cache_size
              . host_cache_size
      
      NOTE: 
          RTEST test cases changes (addition/modification) will
          be done in next push.

    modified:
      mysys_ssl/my_getopt.cc
      sql/sql_const.h
      sql/sys_vars.cc
      storage/innobase/handler/ha_innodb.cc
      storage/innobase/srv/srv0start.cc
 4334 Aditya A	2012-08-27
      BUG#11761646 - INNODB SHOULD RETRY ON FAILED READ OR WRITE, 
                     NOT IMMEDIATELY PANIC
      Related:
      http://bugs.mysql.com/bug.php?id=54430
      (innodb should retry partial reads/writes where errno was 0)
      
      Summary
      -------
      In the Linux flavours the read and write system calls can 
      do partial reads and writes.
      
      The man page of read says that " The return value is 
      is smaller than the number of bytes requested; this 
      may happen for example because fewer bytes are actually
      available right now (maybe because we were close to
      end-of-file,or  because  we  are  reading from  a pipe, 
      or from a terminal), or because read() was interrupted by
      a signal."         
      
      
      The Fix
      -------
      Initially InnoDB was not handling the partial read and 
      writes.With this fix innodb tries NUM_RETRIES_ON_PARTIAL_IO 
      (which by default is equal to 10)times to read or write the
      partial data .The fix also takes care of partial read and
      write in case of Linux native API's where read and write 
      are asynyncronus operations.
      
      rb:1158 [approved by inaam.rana]

    modified:
      storage/innobase/os/os0file.cc
=== modified file 'mysys_ssl/my_getopt.cc'
--- a/mysys_ssl/my_getopt.cc	revid:aditya.a@stripped
+++ b/mysys_ssl/my_getopt.cc	revid:mayank.prasad@stripped
@@ -150,6 +150,16 @@ void my_getopt_register_get_addr(my_geto
   @return error in case of ambiguous or unknown options,
           0 on success.
 */
+#define SET_OPTIONS_DEFAULT_VALUE(_str, _length, _optend)                    \
+                    optp_temp= longopts;                                     \
+                    opt_found= findopt(_str, _length, &optp_temp, NULL);     \
+                    if(opt_found)                                            \
+                    {                                                        \
+                      void *value;                                           \
+                      value= (void*)optp_temp->value;                        \
+                      if ((error= setval(optp_temp, value, _optend, false))) \
+                           return error;                                     \
+                    }
 int handle_options(int *argc, char ***argv, 
 		   const struct my_option *longopts,
                    my_get_one_option get_one_option)
@@ -163,6 +173,7 @@ int handle_options(int *argc, char ***ar
   void *value;
   int error, i;
   my_bool is_cmdline_arg= 1;
+  my_bool is_thread_cache_size_set= false, is_host_cache_size_set= false;
 
   /* handle_options() assumes arg0 (program name) always exists */
   DBUG_ASSERT(argc && *argc >= 1);
@@ -549,6 +560,15 @@ int handle_options(int *argc, char ***ar
 	return error;
       if (get_one_option && get_one_option(optp->id, optp, argument))
         return EXIT_UNSPECIFIED_ERROR;
+      
+      if(strcmp(optp->name,"thread_cache_size") == 0)
+      {
+        is_thread_cache_size_set= true;
+      }
+      else if(strcmp(optp->name,"host_cache_size") == 0) 
+      {
+        is_host_cache_size_set= true;
+      }
 
       (*argc)--; /* option handled (long), decrease argument count */
     }
@@ -562,6 +582,84 @@ int handle_options(int *argc, char ***ar
     to the program, yet to be (possibly) handled.
   */
   (*argv)[argvpos]= 0;
+ 
+  /*                                                                            
+     If values for thread_cache_size and host_cache_size are not set explicitly
+     set them to default values which are dependent on max_connections.
+     Note: max_connections is being updated depending on max_open_files in
+     init_common_variables(), so its not necessary max_connections would be what 
+     is being set by command-line or in config file.
+  */
+  if(!is_thread_cache_size_set || !is_host_cache_size_set)
+  { 
+    char *optend;
+    const struct my_option *optp_temp;
+    unsigned long default_value, max_connections;
+    static void* max_connections_ptr;
+
+    /* 
+       There is no way to access max_connections global variable here. So keep
+       pointer to address where max_connections is stored. Using this we can
+       get value of max_connections.
+    */
+    optp_temp= longopts;
+    char *opt_str= (char*)"max_connections="; 
+    if((opt_found= findopt(opt_str, 15, &optp_temp, NULL)))
+    {
+      max_connections_ptr= optp_temp->value;
+    }
+
+    /* 
+       Get value of max_connections global variable.
+    */
+    if(max_connections_ptr)
+    {
+      max_connections= *(unsigned long*)max_connections_ptr;
+    }
+   
+    if(!is_thread_cache_size_set)
+    { 
+      char buff[80], *opt_str=(char*)"thread_cache_size=";
+      
+      /*
+         Calculate default value to be set.
+      */
+      default_value= 8 + max_connections/100;
+      default_value= default_value > 100 ? 100 : default_value;
+
+      /*
+         Generate option string based on max_connections.
+      */
+      optend= &buff[0];
+      optend= ullstr(default_value, (char*)optend);
+      SET_OPTIONS_DEFAULT_VALUE(opt_str, 17, optend);
+    }
+
+    if(!is_host_cache_size_set)
+    { 
+      char buff[80], *opt_str=(char*)"host_cache_size=";
+      
+      /*
+         Calculate default value to be set.
+      */
+      if (max_connections <= 500)
+      {
+        default_value= 128 + max_connections;
+      }
+      else
+      {
+        default_value= (628 + ((max_connections - 500) / 20 ));
+        default_value= default_value > 2000 ? 2000 : default_value;
+      }
+
+      /*
+         Generate option string based on max_connections.
+      */
+      optend= &buff[0];
+      optend= ullstr(default_value, (char*)optend);
+      SET_OPTIONS_DEFAULT_VALUE(opt_str, 15, optend);
+    }
+  }
   return 0;
 }
 

=== modified file 'sql/sql_const.h'
--- a/sql/sql_const.h	revid:aditya.a@stripped
+++ b/sql/sql_const.h	revid:mayank.prasad@stripped
@@ -72,7 +72,7 @@
 
 #define MAX_SELECT_NESTING (sizeof(nesting_map)*8-1)
 
-#define DEFAULT_SORT_MEMORY (256U* 1024U)
+#define DEFAULT_SORT_MEMORY (32U* 1024U)
 #define MIN_SORT_MEMORY     (32U * 1024U)
 
 /* Some portable defines */

=== modified file 'sql/sys_vars.cc'
--- a/sql/sys_vars.cc	revid:aditya.a@stripped
+++ b/sql/sys_vars.cc	revid:mayank.prasad@stripped
@@ -2434,7 +2434,7 @@ static Sys_var_ulong Sys_query_cache_siz
        "query_cache_size",
        "The memory allocated to store results from old queries",
        GLOBAL_VAR(query_cache_size), CMD_LINE(REQUIRED_ARG),
-       VALID_RANGE(0, ULONG_MAX), DEFAULT(0), BLOCK_SIZE(1024),
+       VALID_RANGE(0, ULONG_MAX), DEFAULT(1024U*1024U), BLOCK_SIZE(1024),
        NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0),
        ON_UPDATE(fix_query_cache_size));
 
@@ -2474,7 +2474,7 @@ static Sys_var_enum Sys_query_cache_type
        "except SELECT SQL_NO_CACHE ... queries. DEMAND = Cache only "
        "SELECT SQL_CACHE ... queries",
        SESSION_VAR(query_cache_type), CMD_LINE(REQUIRED_ARG),
-       query_cache_type_names, DEFAULT(1), NO_MUTEX_GUARD, NOT_IN_BINLOG,
+       query_cache_type_names, DEFAULT(0), NO_MUTEX_GUARD, NOT_IN_BINLOG,
        ON_CHECK(check_query_cache_type));
 
 static Sys_var_mybool Sys_query_cache_wlock_invalidate(

=== modified file 'storage/innobase/handler/ha_innodb.cc'
--- a/storage/innobase/handler/ha_innodb.cc	revid:aditya.a@stripped
+++ b/storage/innobase/handler/ha_innodb.cc	revid:mayank.prasad@stripped
@@ -15684,7 +15684,7 @@ static MYSQL_SYSVAR_LONG(log_buffer_size
 static MYSQL_SYSVAR_LONGLONG(log_file_size, innobase_log_file_size,
   PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
   "Size of each log file in a log group.",
-  NULL, NULL, 5*1024*1024L, 1*1024*1024L, LONGLONG_MAX, 1024*1024L);
+  NULL, NULL, 48*1024*1024L, 1*1024*1024L, LONGLONG_MAX, 1024*1024L);
 
 static MYSQL_SYSVAR_LONG(log_files_in_group, innobase_log_files_in_group,
   PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,

=== modified file 'storage/innobase/srv/srv0start.cc'
--- a/storage/innobase/srv/srv0start.cc	revid:aditya.a@stripped
+++ b/storage/innobase/srv/srv0start.cc	revid:mayank.prasad@stripped
@@ -583,6 +583,40 @@ srv_normalize_path_for_win(
 /*********************************************************************//**
 Creates or opens the log files and closes them.
 @return	DB_SUCCESS or error code */
+#define CREATE_NEW_LOG_FILE\
+        *log_file_created = TRUE;\
+\
+        ut_print_timestamp(stderr);\
+\
+        fprintf(stderr,\
+            " InnoDB: Log file %s did not exist:"\
+            " new to be created\n",\
+            name);\
+        if (log_file_has_been_opened) {\
+\
+            return(DB_ERROR);\
+        }\
+\
+        fprintf(stderr, "InnoDB: Setting log file %s size to %lu MB\n",\
+            name, (ulong) srv_log_file_size\
+            >> (20 - UNIV_PAGE_SIZE_SHIFT));\
+\
+        fprintf(stderr,\
+            "InnoDB: Database physically writes the file"\
+            " full: wait...\n");\
+\
+        ret = os_file_set_size(name, files[i],\
+                       (os_offset_t) srv_log_file_size\
+                       << UNIV_PAGE_SIZE_SHIFT);\
+        if (!ret) {\
+            fprintf(stderr,\
+                "InnoDB: Error in creating %s:"\
+                " probably out of disk space\n",\
+                name);\
+\
+            return(DB_ERROR);\
+		}
+
 static __attribute__((nonnull, warn_unused_result))
 dberr_t
 open_or_create_log_file(
@@ -660,7 +694,22 @@ open_or_create_log_file(
 
 		if (UNIV_UNLIKELY(size != (os_offset_t) srv_log_file_size
 				  << UNIV_PAGE_SIZE_SHIFT)) {
-
+                  /* If exising logfile size is 5M, then rename it by adding
+                  a suffix -before560 and create new one. */
+                  if(size == 5*1024*1024L)
+                  {
+                       char new_logfile_name[10000]={'\0'};
+                       strcpy(new_logfile_name, name);
+                       strcat(new_logfile_name, "-before560");
+                       os_file_rename(innodb_file_log_key, name,
+                                      new_logfile_name);
+	               files[i] = os_file_create(innodb_file_log_key, name,
+		              	                 OS_FILE_CREATE, OS_FILE_NORMAL,
+			                         OS_LOG_FILE, &ret);
+                       CREATE_NEW_LOG_FILE;
+                  }
+                  else
+                  {
 			fprintf(stderr,
 				"InnoDB: Error: log file %s is"
 				" of different size "UINT64PF" bytes\n"
@@ -671,40 +720,10 @@ open_or_create_log_file(
 				<< UNIV_PAGE_SIZE_SHIFT);
 
 			return(DB_ERROR);
-		}
+		  }
+                }
 	} else {
-		*log_file_created = TRUE;
-
-		ut_print_timestamp(stderr);
-
-		fprintf(stderr,
-			" InnoDB: Log file %s did not exist:"
-			" new to be created\n",
-			name);
-		if (log_file_has_been_opened) {
-
-			return(DB_ERROR);
-		}
-
-		fprintf(stderr, "InnoDB: Setting log file %s size to %lu MB\n",
-			name, (ulong) srv_log_file_size
-			>> (20 - UNIV_PAGE_SIZE_SHIFT));
-
-		fprintf(stderr,
-			"InnoDB: Database physically writes the file"
-			" full: wait...\n");
-
-		ret = os_file_set_size(name, files[i],
-				       (os_offset_t) srv_log_file_size
-				       << UNIV_PAGE_SIZE_SHIFT);
-		if (!ret) {
-			fprintf(stderr,
-				"InnoDB: Error in creating %s:"
-				" probably out of disk space\n",
-				name);
-
-			return(DB_ERROR);
-		}
+               CREATE_NEW_LOG_FILE;
 	}
 
 	ret = os_file_close(files[i]);

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk branch (mayank.prasad:4334 to 4335) WL#6372Mayank Prasad27 Aug