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.

This creates a plugin function plugin_opt_set_limits_by_name that
allows plugins to adjust the limits of their system variables during
plugin initialization.
  • Loading branch information
grooverdan committed Jan 20, 2025
1 parent cbb24d9 commit 5abd367
Show file tree
Hide file tree
Showing 4 changed files with 14 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
8 changes: 8 additions & 0 deletions sql/sql_plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3804,6 +3804,14 @@ void plugin_opt_set_limits(struct my_option *options,
options->arg_type= OPT_ARG;
}


void plugin_opt_set_limits_by_name(const char *name, size_t name_len,
const struct st_mysql_sys_var *opt)
{
sys_var *sv= intern_find_sys_var(name, name_len);
if (sv)
plugin_opt_set_limits(&sv->option, opt);
}
/**
Creates a set of my_option objects associated with a specified plugin-
handle.
Expand Down
2 changes: 2 additions & 0 deletions sql/sql_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ extern void plugin_thdvar_init(THD *thd);
extern void plugin_thdvar_cleanup(THD *thd);
sys_var *find_plugin_sysvar(st_plugin_int *plugin, st_mysql_sys_var *var);
void plugin_opt_set_limits(struct my_option *, const struct st_mysql_sys_var *);
void plugin_opt_set_limits_by_name(const char *, size_t,
const struct st_mysql_sys_var *);
extern SHOW_COMP_OPTION plugin_status(const char *name, size_t len, int type);
extern bool check_valid_path(const char *path, size_t length);
extern void plugin_mutex_init();
Expand Down
1 change: 1 addition & 0 deletions storage/innobase/handler/ha_innodb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3547,6 +3547,7 @@ static int innodb_init_params()
/* The buffer pool needs to be able to accommodate enough many
pages, even for larger pages */
MYSQL_SYSVAR_NAME(buffer_pool_size).min_val= min_buffer_pool_size();
plugin_opt_set_limits_by_name(STRING_WITH_LEN("innodb_buffer_pool_size"), (struct st_mysql_sys_var *) &mysql_sysvar_buffer_pool_size);

if (innobase_buffer_pool_size < MYSQL_SYSVAR_NAME(buffer_pool_size).min_val) {
ib::error() << "innodb_page_size="
Expand Down

0 comments on commit 5abd367

Please sign in to comment.