Skip to content

Commit

Permalink
MDEV-35889 set information_schema.system_variables NUMERIC_MIN_VALUE ...
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
grooverdan committed Jan 24, 2025
1 parent 77ea99a commit 7e51e20
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
5 changes: 3 additions & 2 deletions mysql-test/suite/innodb/t/restart.test
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
3 changes: 3 additions & 0 deletions sql/set_var.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
1 change: 1 addition & 0 deletions sql/set_var.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 9 additions & 0 deletions sql/sql_plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -3683,14 +3684,22 @@ 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) \
options->var_type= GET_DOUBLE; \
assert((opt)->def_val >= (opt)->min_val); \
assert((opt)->def_val <= (opt)->max_val); \
options->def_value= (longlong) getopt_double2ulonglong((opt)->def_val); \
assert((opt)->min_val <= (opt)->max_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;
Expand Down

0 comments on commit 7e51e20

Please sign in to comment.