From b2324fa28f4124f3782d2952747108a5bdd64399 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Mon, 20 Jan 2025 23:53:58 +1100 Subject: [PATCH] MDEV-35889 set information_schema.system_variables NUMERIC_MIN_VALUE ... for the innodb_buffer_pool_size system variable based on innodb_page_size. The innodb_buffer_pool_size is dependent on the innodb_page_size. While the minimum is enforced for resizing the minimum isn't exposed by the information_schema.system_variables table. Add a bunch of assertions to ensure that the plugin relations between default, minimum, maximum and block size hold. Expose the plugin_var point from sys_var and while retreiving fill_sysvars update the limits in case the plugin happens to have changed them. --- mysql-test/suite/innodb/t/restart.test | 5 +++-- sql/set_var.cc | 3 +++ sql/set_var.h | 1 + sql/sql_plugin.cc | 10 +++++++++- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/mysql-test/suite/innodb/t/restart.test b/mysql-test/suite/innodb/t/restart.test index dba2c1e500bfa..4848b149fc3e8 100644 --- a/mysql-test/suite/innodb/t/restart.test +++ b/mysql-test/suite/innodb/t/restart.test @@ -95,10 +95,11 @@ let $wait_condition = --disable_cursor_protocol SELECT @@innodb_buffer_pool_size INTO @innodb_buffer_pool_size_orig; -SELECT CEILING((256 + 64) * @@innodb_page_size / 1048576) * 1048576 INTO @min_pool_size; +SELECT CAST(NUMERIC_MIN_VALUE AS UNSIGNED) INTO @min_pool_size FROM information_schema.system_variables WHERE variable_name='INNODB_BUFFER_POOL_SIZE'; +SET @out_of_bounds_pool_size=@min_pool_size - @@innodb_buffer_pool_chunk_size; --enable_cursor_protocol --error ER_WRONG_VALUE_FOR_VAR -EXECUTE IMMEDIATE 'SET GLOBAL innodb_buffer_pool_size = ?' USING (@min_pool_size -1); +EXECUTE IMMEDIATE 'SET GLOBAL innodb_buffer_pool_size = ?' USING (@out_of_bounds_pool_size); SHOW WARNINGS; diff --git a/sql/set_var.cc b/sql/set_var.cc index a06a81fd9a691..9f0341f2af2e6 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -1117,6 +1117,9 @@ int fill_sysvars(THD *thd, TABLE_LIST *tables, COND *cond) mysql_mutex_lock(&LOCK_global_system_variables); + if (var->cast_pluginvar()) + plugin_opt_set_limits(&var->option, var->cast_mysql_sys_var()); + // SESSION_VALUE store_var(fields[1], var, OPT_SESSION, &strbuf); diff --git a/sql/set_var.h b/sql/set_var.h index 58b23e14bf78c..75b954801e66c 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -111,6 +111,7 @@ class sys_var: protected Value_source // for double_from_string_with_check of sys_var_pluginvar, and 0 otherwise. */ virtual sys_var_pluginvar *cast_pluginvar() { return 0; } + virtual const struct st_mysql_sys_var *cast_mysql_sys_var() const { return nullptr; } bool check(THD *thd, set_var *var); const uchar *value_ptr(THD *thd, enum_var_type type, const LEX_CSTRING *base) const; diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index b773c8ec95472..fe4c4135a334b 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -315,6 +315,7 @@ class sys_var_pluginvar: public sys_var, public Sql_alloc st_plugin_int *p, st_mysql_sys_var *plugin_var_arg, const char *substitute); sys_var_pluginvar *cast_pluginvar() override { return this; } + virtual const struct st_mysql_sys_var *cast_mysql_sys_var() const override { return plugin_var; } uchar* real_value_ptr(THD *thd, enum_var_type type) const; TYPELIB* plugin_var_typelib(void) const; const uchar* do_value_ptr(THD *thd, enum_var_type type, const LEX_CSTRING *base) const; @@ -3683,9 +3684,14 @@ bool sys_var_pluginvar::global_update(THD *thd, set_var *var) #define OPTION_SET_LIMITS(type, options, opt) \ options->var_type= type; \ + assert((opt)->def_val >= (opt)->min_val); \ + assert((opt)->def_val <= (opt)->max_val); \ options->def_value= (opt)->def_val; \ + assert((opt)->min_val <= (opt)->max_val); \ options->min_value= (opt)->min_val; \ options->max_value= (opt)->max_val; \ + assert((opt)->blk_sz == 0 || ((opt)->min_val % (opt)->blk_sz) == 0); \ + assert((opt)->blk_sz == 0 || ((opt)->max_val % (opt)->blk_sz) == 0); \ options->block_size= (long) (opt)->blk_sz #define OPTION_SET_LIMITS_DOUBLE(options, opt) \ @@ -3693,7 +3699,9 @@ bool sys_var_pluginvar::global_update(THD *thd, set_var *var) options->def_value= (longlong) getopt_double2ulonglong((opt)->def_val); \ options->min_value= (longlong) getopt_double2ulonglong((opt)->min_val); \ options->max_value= getopt_double2ulonglong((opt)->max_val); \ - options->block_size= (long) (opt)->blk_sz; + options->block_size= (long) (opt)->blk_sz; \ + assert(options->def_value >= options->min_value); \ + assert(options->def_value <= options->max_value); void plugin_opt_set_limits(struct my_option *options, const struct st_mysql_sys_var *opt)