From faee08c10c767375aca26d126fff1a832330fc43 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Mon, 30 Oct 2017 21:39:55 +0100 Subject: [PATCH] MDEV-14114 Intoduce variable for binlog io cache size. --- mysql-test/r/mysqld--help.result | 3 +++ .../sys_vars/r/sysvars_server_notembedded.result | 14 ++++++++++++++ sql/log.cc | 2 +- sql/mysqld.cc | 1 + sql/mysqld.h | 2 +- sql/sys_vars.cc | 7 +++++++ 6 files changed, 27 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/mysqld--help.result b/mysql-test/r/mysqld--help.result index b5d68d6bee2..157148f80f4 100644 --- a/mysql-test/r/mysqld--help.result +++ b/mysql-test/r/mysqld--help.result @@ -67,6 +67,8 @@ The following options may be given as the first argument: --binlog-do-db=name Tells the master it should log updates for the specified database, and exclude all others not explicitly mentioned. + --binlog-file-cache-size=# + The size of file cache for the binary log --binlog-format=name What form of binary logging the master will use: either ROW for row-based binary logging, STATEMENT for @@ -1290,6 +1292,7 @@ binlog-checksum CRC32 binlog-commit-wait-count 0 binlog-commit-wait-usec 100000 binlog-direct-non-transactional-updates FALSE +binlog-file-cache-size 16384 binlog-format MIXED binlog-optimize-thread-scheduling TRUE binlog-row-event-max-size 8192 diff --git a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result index 3d66d99429a..c35ceba837a 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result +++ b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result @@ -220,6 +220,20 @@ NUMERIC_BLOCK_SIZE NULL ENUM_VALUE_LIST OFF,ON READ_ONLY NO COMMAND_LINE_ARGUMENT OPTIONAL +VARIABLE_NAME BINLOG_FILE_CACHE_SIZE +SESSION_VALUE NULL +GLOBAL_VALUE 16384 +GLOBAL_VALUE_ORIGIN COMPILE-TIME +DEFAULT_VALUE 16384 +VARIABLE_SCOPE GLOBAL +VARIABLE_TYPE BIGINT UNSIGNED +VARIABLE_COMMENT The size of file cache for the binary log +NUMERIC_MIN_VALUE 8192 +NUMERIC_MAX_VALUE 18446744073709551615 +NUMERIC_BLOCK_SIZE 4096 +ENUM_VALUE_LIST NULL +READ_ONLY NO +COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME BINLOG_FORMAT SESSION_VALUE MIXED GLOBAL_VALUE MIXED diff --git a/sql/log.cc b/sql/log.cc index 09bd23be2bf..be8b24da8df 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -2391,7 +2391,7 @@ File open_binlog(IO_CACHE *log, const char *log_file_name, const char **errmsg) *errmsg = "Could not open log file"; goto err; } - if (init_io_cache(log, file, IO_SIZE*2, READ_CACHE, 0, 0, + if (init_io_cache(log, file, binlog_file_cache_size, READ_CACHE, 0, 0, MYF(MY_WME|MY_DONT_CHECK_FILESIZE))) { sql_print_error("Failed to create a cache on log (file '%s')", diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 6433ecfb25f..fd794bfe02b 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -506,6 +506,7 @@ ulong slave_ddl_exec_mode_options= SLAVE_EXEC_MODE_IDEMPOTENT; ulonglong slave_type_conversions_options; ulong thread_cache_size=0; ulonglong binlog_cache_size=0; +ulonglong binlog_file_cache_size=0; ulonglong max_binlog_cache_size=0; ulong slave_max_allowed_packet= 0; ulonglong binlog_stmt_cache_size=0; diff --git a/sql/mysqld.h b/sql/mysqld.h index 7dc81787de1..e09b6486e02 100644 --- a/sql/mysqld.h +++ b/sql/mysqld.h @@ -214,7 +214,7 @@ extern volatile ulong cached_thread_count; extern ulong what_to_log,flush_time; extern ulong max_prepared_stmt_count, prepared_stmt_count; extern ulong open_files_limit; -extern ulonglong binlog_cache_size, binlog_stmt_cache_size; +extern ulonglong binlog_cache_size, binlog_stmt_cache_size, binlog_file_cache_size; extern ulonglong max_binlog_cache_size, max_binlog_stmt_cache_size; extern ulong max_binlog_size; extern ulong slave_max_allowed_packet; diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 47d509d3c28..86637d6f78c 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -396,6 +396,13 @@ static Sys_var_ulonglong Sys_binlog_cache_size( CMD_LINE(REQUIRED_ARG), VALID_RANGE(IO_SIZE, SIZE_T_MAX), DEFAULT(32768), BLOCK_SIZE(IO_SIZE)); +static Sys_var_ulonglong Sys_binlog_file_cache_size( + "binlog_file_cache_size", + "The size of file cache for the binary log", + GLOBAL_VAR(binlog_file_cache_size), + CMD_LINE(REQUIRED_ARG), + VALID_RANGE(IO_SIZE*2, SIZE_T_MAX), DEFAULT(IO_SIZE*4), BLOCK_SIZE(IO_SIZE)); + static Sys_var_ulonglong Sys_binlog_stmt_cache_size( "binlog_stmt_cache_size", "The size of the statement cache for " "updates to non-transactional engines for the binary log. "