Bug #6241 sync my_default_record_cache_size with read_buff_size on dynamic update
Submitted: 25 Oct 2004 3:50
Reporter: Masaki Fujimoto Email Updates:
Status: Open Impact on me:
None 
Category:MySQL Server: General Severity:S4 (Feature request)
Version:4.0.21 OS:Any (any)
Assigned to: CPU Architecture:Any

[25 Oct 2004 3:50] Masaki Fujimoto
Description:
read_buffer_size is listed as "dynamic system variables" at

http://dev.mysql.com/doc/mysql/en/Dynamic_System_Variables.html

and I'm sure global_system_variables.read_buff_size is updated with "SET GLOBAL
read_buffer_size=xxxx;". However, the another global variable
"my_default_record_cache_size" is not updated in this case while other global
variables like "myisam_max_temp_length" and "myisam_max_extra_temp_length"
are updated with "fix_myisam_max_extra_sort_file_size()" etc...

IMHO it's better to update my_default_record_cache_size, too, in case 
global_system_variables.read_buff_size is updated dynamically (since this value
affects not only cachesize of IO_CACHE but the block size of Append_Block event
indirectly and so on, as you know...).

How to repeat:
The typical case may be like this:

$ mysql test
> LOAD DATA INFILE '/tmp/infile.txt' ...
> \q

$ mysqlbinlog ...
(snip)
# at 17903090
#041025 12:41:53 server id 1  log_pos 17903090
#Append_block: file_id: 2  block_len: 1048576
(snip)

(and then I wanted to reduce block_len of Append_block events without shutdown)

$ mysql test
> SET GLOBAL read_buffer_size=16384
> \q

$ mysql test
> LOAD DATA INFILE '/tmp/infile.txt' ...
> \q

$ mysqlbinlog ...
(snip)
# at 27403119
#041025 12:48:51 server id 1  log_pos 27403119
#Append_block: file_id: 3  block_len: 1048576
(snip)

(block_len still remains to be not 16K but 1M...)

Suggested fix:
something like this?

diff -u set_var.cc.bak set_var.cc                            [~/work/mysql-4.0.21/sql]
--- set_var.cc.bak      Tue Sep  7 07:29:37 2004
+++ set_var.cc  Mon Oct 25 12:32:00 2004
@@ -85,6 +85,7 @@
 static void fix_key_buffer_size(THD *thd, enum_var_type type);
 static void fix_myisam_max_extra_sort_file_size(THD *thd, enum_var_type type);
 static void fix_myisam_max_sort_file_size(THD *thd, enum_var_type type);
+static void fix_read_buff_size(THD *thd, enum_var_type type);
 static void fix_max_binlog_size(THD *thd, enum_var_type type);
 static void fix_max_relay_log_size(THD *thd, enum_var_type type);
 static void fix_max_connections(THD *thd, enum_var_type type);
@@ -200,8 +201,7 @@
                                            &SV::net_retry_count,
                                            fix_net_retry_count);
 sys_var_thd_bool       sys_new_mode("new", &SV::new_mode);
-sys_var_thd_ulong      sys_read_buff_size("read_buffer_size",
-                                          &SV::read_buff_size);
+sys_var_thd_ulong      sys_read_buff_size("read_buffer_size", &SV::read_buff_size, fix_read_buff_siz
e);
 sys_var_bool_ptr       sys_readonly("read_only", &opt_readonly);
 sys_var_thd_ulong      sys_read_rnd_buff_size("read_rnd_buffer_size",
                                               &SV::read_rnd_buff_size);
@@ -679,6 +679,13 @@
 {
   myisam_max_temp_length=
     (my_off_t) global_system_variables.myisam_max_sort_file_size;
+}
+
+static void
+fix_read_buff_size(THD *thd, enum_var_type type)
+{
+  my_default_record_cache_size=
+    (my_off_t) global_system_variables.read_buff_size;
 }

 /*
[15 Oct 2021 5:41] William Kosasih
Current mysql server version: 8.0.26

I would like to second this.
I agree with Masaki, I think it would make sense for my_default_record_cache_size to be updated as well when changing global_system_variables.read_buff_size.

This prevented me from increasing records_in_block in heap_create.cc:261, without having to restart the server.