Commit be995467 authored by Sergey Vojtovich's avatar Sergey Vojtovich

MDEV-4786 - merge 10.0-monty - 10.0

Fixed main.partition_open_files_limit, innodb.innodb_bug12400341 failures.

These testcases use --max-connections=N command line option, which
was declared PARSE_EARLY during the merge. Embedded didn't handle
early options and failed to start due to unknown command line
option.

libmysqld/lib_sql.cc:
  Let embedded handle early options.
sql/mysqld.cc:
  Moved handling of early options to a separate function.
sql/mysqld.h:
  Moved handling of early options to a separate function.
parent d89b19d4
...@@ -542,6 +542,10 @@ int init_embedded_server(int argc, char **argv, char **groups) ...@@ -542,6 +542,10 @@ int init_embedded_server(int argc, char **argv, char **groups)
system_charset_info= &my_charset_utf8_general_ci; system_charset_info= &my_charset_utf8_general_ci;
sys_var_init(); sys_var_init();
int ho_error= handle_early_options();
if (ho_error != 0)
return 1;
if (init_common_variables()) if (init_common_variables())
{ {
mysql_server_end(); mysql_server_end();
......
...@@ -5038,24 +5038,12 @@ int mysqld_main(int argc, char **argv) ...@@ -5038,24 +5038,12 @@ int mysqld_main(int argc, char **argv)
sys_var_init(); sys_var_init();
#ifdef WITH_PERFSCHEMA_STORAGE_ENGINE
/* /*
The performance schema needs to be initialized as early as possible, Initialize the array of performance schema instrument configurations.
before to-be-instrumented objects of the server are initialized.
*/ */
int ho_error; init_pfs_instrument_array();
DYNAMIC_ARRAY all_early_options; #endif /* WITH_PERFSCHEMA_STORAGE_ENGINE */
my_getopt_register_get_addr(NULL);
/* Skip unknown options so that they may be processed later */
my_getopt_skip_unknown= TRUE;
/* prepare all_early_options array */
my_init_dynamic_array(&all_early_options, sizeof(my_option), 100, 25, MYF(0));
add_many_options(&all_early_options, pfs_early_options,
array_elements(pfs_early_options));
sys_var_add_options(&all_early_options, sys_var::PARSE_EARLY);
add_terminator(&all_early_options);
/* /*
Logs generated while parsing the command line Logs generated while parsing the command line
options are buffered and printed later. options are buffered and printed later.
...@@ -5065,23 +5053,11 @@ int mysqld_main(int argc, char **argv) ...@@ -5065,23 +5053,11 @@ int mysqld_main(int argc, char **argv)
my_charset_error_reporter= buffered_option_error_reporter; my_charset_error_reporter= buffered_option_error_reporter;
pfs_param.m_pfs_instrument= const_cast<char*>(""); pfs_param.m_pfs_instrument= const_cast<char*>("");
#ifdef WITH_PERFSCHEMA_STORAGE_ENGINE int ho_error= handle_early_options();
/*
Initialize the array of performance schema instrument configurations.
*/
init_pfs_instrument_array();
#endif /* WITH_PERFSCHEMA_STORAGE_ENGINE */
ho_error= handle_options(&remaining_argc, &remaining_argv,
(my_option*)(all_early_options.buffer),
mysqld_get_one_option);
delete_dynamic(&all_early_options);
#ifdef WITH_PERFSCHEMA_STORAGE_ENGINE #ifdef WITH_PERFSCHEMA_STORAGE_ENGINE
if (ho_error == 0) if (ho_error == 0)
{ {
/* Add back the program name handle_options removes */
remaining_argc++;
remaining_argv--;
if (pfs_param.m_enabled && !opt_help && !opt_bootstrap) if (pfs_param.m_enabled && !opt_help && !opt_bootstrap)
{ {
/* Add sizing hints from the server sizing parameters. */ /* Add sizing hints from the server sizing parameters. */
...@@ -6514,6 +6490,51 @@ pthread_handler_t handle_connections_shared_memory(void *arg) ...@@ -6514,6 +6490,51 @@ pthread_handler_t handle_connections_shared_memory(void *arg)
Handle start options Handle start options
******************************************************************************/ ******************************************************************************/
/**
Process command line options flagged as 'early'.
Some components needs to be initialized as early as possible,
because the rest of the server initialization depends on them.
Options that needs to be parsed early includes:
- the performance schema, when compiled in,
- options related to the help,
- options related to the bootstrap
The performance schema needs to be initialized as early as possible,
before to-be-instrumented objects of the server are initialized.
*/
int handle_early_options()
{
int ho_error;
DYNAMIC_ARRAY all_early_options;
my_getopt_register_get_addr(NULL);
/* Skip unknown options so that they may be processed later */
my_getopt_skip_unknown= TRUE;
/* prepare all_early_options array */
my_init_dynamic_array(&all_early_options, sizeof(my_option), 100, 25, MYF(0));
add_many_options(&all_early_options, pfs_early_options,
array_elements(pfs_early_options));
sys_var_add_options(&all_early_options, sys_var::PARSE_EARLY);
add_terminator(&all_early_options);
ho_error= handle_options(&remaining_argc, &remaining_argv,
(my_option*)(all_early_options.buffer),
mysqld_get_one_option);
if (ho_error == 0)
{
/* Add back the program name handle_options removes */
remaining_argc++;
remaining_argv--;
}
delete_dynamic(&all_early_options);
return ho_error;
}
/** /**
System variables are automatically command-line options (few System variables are automatically command-line options (few
exceptions are documented in sys_var.h), so don't need exceptions are documented in sys_var.h), so don't need
...@@ -8346,6 +8367,7 @@ mysqld_get_one_option(int optid, ...@@ -8346,6 +8367,7 @@ mysqld_get_one_option(int optid,
break; break;
case OPT_PFS_INSTRUMENT: case OPT_PFS_INSTRUMENT:
#ifdef WITH_PERFSCHEMA_STORAGE_ENGINE #ifdef WITH_PERFSCHEMA_STORAGE_ENGINE
#ifndef EMBEDDED_LIBRARY
/* Parse instrument name and value from argument string */ /* Parse instrument name and value from argument string */
char* name = argument,*p, *val; char* name = argument,*p, *val;
...@@ -8409,6 +8431,7 @@ mysqld_get_one_option(int optid, ...@@ -8409,6 +8431,7 @@ mysqld_get_one_option(int optid,
"'%s'", argument); "'%s'", argument);
return 0; return 0;
} }
#endif /* EMBEDDED_LIBRARY */
#endif #endif
break; break;
} }
......
...@@ -203,6 +203,7 @@ extern handlerton *myisam_hton; ...@@ -203,6 +203,7 @@ extern handlerton *myisam_hton;
extern handlerton *heap_hton; extern handlerton *heap_hton;
extern const char *load_default_groups[]; extern const char *load_default_groups[];
extern struct my_option my_long_options[]; extern struct my_option my_long_options[];
int handle_early_options();
extern int mysqld_server_started, mysqld_server_initialized; extern int mysqld_server_started, mysqld_server_initialized;
extern "C" MYSQL_PLUGIN_IMPORT int orig_argc; extern "C" MYSQL_PLUGIN_IMPORT int orig_argc;
extern "C" MYSQL_PLUGIN_IMPORT char **orig_argv; extern "C" MYSQL_PLUGIN_IMPORT char **orig_argv;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment