mirror of
https://github.com/MariaDB/server.git
synced 2025-02-02 03:51:50 +01:00
branches/zip: Correct the initialization of the memory subsystem once
again, to finally put Issue #181 to rest. Revert some parts of r4274. It is best not to call ut_malloc() before srv_general_init(). mem_init(): Do not call ut_mem_init(). srv_general_init(): Initialize the memory subsystem in two phases: first ut_mem_init(), then mem_init(). This is because os_sync_init() and sync_init() depend on ut_mem_init() and mem_init() depends on os_sync_init() or sync_init(). srv_parse_data_file_paths_and_sizes(), srv_parse_log_group_home_dirs(): Remove the output parameters. Assign to the global variables directly. Allocate memory with malloc() instead of ut_malloc(), because these functions will be called before srv_general_init(). srv_free_paths_and_sizes(): New function, for cleaning up after srv_parse_data_file_paths_and_sizes() and srv_parse_log_group_home_dirs(). rb://92 approved by Sunny Bains
This commit is contained in:
parent
09f6d57af9
commit
93ec81bb6d
6 changed files with 67 additions and 72 deletions
|
@ -1988,27 +1988,16 @@ innobase_init(
|
||||||
|
|
||||||
internal_innobase_data_file_path = my_strdup(innobase_data_file_path,
|
internal_innobase_data_file_path = my_strdup(innobase_data_file_path,
|
||||||
MYF(MY_FAE));
|
MYF(MY_FAE));
|
||||||
srv_mem_pool_size = (ulint) innobase_additional_mem_pool_size;
|
|
||||||
|
|
||||||
/* Initialize the InnoDB memory subsystem before calling
|
|
||||||
ut_malloc() in srv_parse_data_file_paths_and_sizes(). */
|
|
||||||
mem_init(srv_mem_pool_size);
|
|
||||||
|
|
||||||
ret = (bool) srv_parse_data_file_paths_and_sizes(
|
ret = (bool) srv_parse_data_file_paths_and_sizes(
|
||||||
internal_innobase_data_file_path,
|
internal_innobase_data_file_path);
|
||||||
&srv_data_file_names,
|
|
||||||
&srv_data_file_sizes,
|
|
||||||
&srv_data_file_is_raw_partition,
|
|
||||||
&srv_n_data_files,
|
|
||||||
&srv_auto_extend_last_data_file,
|
|
||||||
&srv_last_file_size_max);
|
|
||||||
if (ret == FALSE) {
|
if (ret == FALSE) {
|
||||||
sql_print_error(
|
sql_print_error(
|
||||||
"InnoDB: syntax error in innodb_data_file_path");
|
"InnoDB: syntax error in innodb_data_file_path");
|
||||||
mem_free_and_error:
|
mem_free_and_error:
|
||||||
|
srv_free_paths_and_sizes();
|
||||||
my_free(internal_innobase_data_file_path,
|
my_free(internal_innobase_data_file_path,
|
||||||
MYF(MY_ALLOW_ZERO_PTR));
|
MYF(MY_ALLOW_ZERO_PTR));
|
||||||
ut_free_all_mem();
|
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2031,8 +2020,7 @@ mem_free_and_error:
|
||||||
#endif /* UNIG_LOG_ARCHIVE */
|
#endif /* UNIG_LOG_ARCHIVE */
|
||||||
|
|
||||||
ret = (bool)
|
ret = (bool)
|
||||||
srv_parse_log_group_home_dirs(innobase_log_group_home_dir,
|
srv_parse_log_group_home_dirs(innobase_log_group_home_dir);
|
||||||
&srv_log_group_home_dirs);
|
|
||||||
|
|
||||||
if (ret == FALSE || innobase_mirrored_log_groups != 1) {
|
if (ret == FALSE || innobase_mirrored_log_groups != 1) {
|
||||||
sql_print_error("syntax error in innodb_log_group_home_dir, or a "
|
sql_print_error("syntax error in innodb_log_group_home_dir, or a "
|
||||||
|
@ -2113,6 +2101,8 @@ mem_free_and_error:
|
||||||
|
|
||||||
srv_buf_pool_size = (ulint) innobase_buffer_pool_size;
|
srv_buf_pool_size = (ulint) innobase_buffer_pool_size;
|
||||||
|
|
||||||
|
srv_mem_pool_size = (ulint) innobase_additional_mem_pool_size;
|
||||||
|
|
||||||
srv_n_file_io_threads = (ulint) innobase_file_io_threads;
|
srv_n_file_io_threads = (ulint) innobase_file_io_threads;
|
||||||
|
|
||||||
srv_force_recovery = (ulint) innobase_force_recovery;
|
srv_force_recovery = (ulint) innobase_force_recovery;
|
||||||
|
@ -2212,6 +2202,7 @@ innobase_end(handlerton *hton, ha_panic_function type)
|
||||||
if (innobase_shutdown_for_mysql() != DB_SUCCESS) {
|
if (innobase_shutdown_for_mysql() != DB_SUCCESS) {
|
||||||
err = 1;
|
err = 1;
|
||||||
}
|
}
|
||||||
|
srv_free_paths_and_sizes();
|
||||||
my_free(internal_innobase_data_file_path,
|
my_free(internal_innobase_data_file_path,
|
||||||
MYF(MY_ALLOW_ZERO_PTR));
|
MYF(MY_ALLOW_ZERO_PTR));
|
||||||
pthread_mutex_destroy(&innobase_share_mutex);
|
pthread_mutex_destroy(&innobase_share_mutex);
|
||||||
|
|
|
@ -356,7 +356,8 @@ void
|
||||||
srv_free(void);
|
srv_free(void);
|
||||||
/*==========*/
|
/*==========*/
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
Initializes the synchronization primitives and the thread local storage. */
|
Initializes the synchronization primitives, memory system, and the thread
|
||||||
|
local storage. */
|
||||||
UNIV_INTERN
|
UNIV_INTERN
|
||||||
void
|
void
|
||||||
srv_general_init(void);
|
srv_general_init(void);
|
||||||
|
|
|
@ -42,21 +42,8 @@ UNIV_INTERN
|
||||||
ibool
|
ibool
|
||||||
srv_parse_data_file_paths_and_sizes(
|
srv_parse_data_file_paths_and_sizes(
|
||||||
/*================================*/
|
/*================================*/
|
||||||
/* out: TRUE if ok, FALSE if parsing
|
/* out: TRUE if ok, FALSE on parse error */
|
||||||
error */
|
char* str); /* in/out: the data file path string */
|
||||||
char* str, /* in: the data file path string */
|
|
||||||
char*** data_file_names, /* out, own: array of data file
|
|
||||||
names */
|
|
||||||
ulint** data_file_sizes, /* out, own: array of data file sizes
|
|
||||||
in megabytes */
|
|
||||||
ulint** data_file_is_raw_partition,/* out, own: array of flags
|
|
||||||
showing which data files are raw
|
|
||||||
partitions */
|
|
||||||
ulint* n_data_files, /* out: number of data files */
|
|
||||||
ibool* is_auto_extending, /* out: TRUE if the last data file is
|
|
||||||
auto-extending */
|
|
||||||
ulint* max_auto_extend_size); /* out: max auto extend size for the
|
|
||||||
last file if specified, 0 if not */
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
Reads log group home directories from a character string given in
|
Reads log group home directories from a character string given in
|
||||||
the .cnf file. */
|
the .cnf file. */
|
||||||
|
@ -64,10 +51,15 @@ UNIV_INTERN
|
||||||
ibool
|
ibool
|
||||||
srv_parse_log_group_home_dirs(
|
srv_parse_log_group_home_dirs(
|
||||||
/*==========================*/
|
/*==========================*/
|
||||||
/* out: TRUE if ok, FALSE if parsing
|
/* out: TRUE if ok, FALSE on parse error */
|
||||||
error */
|
char* str); /* in/out: character string */
|
||||||
char* str, /* in: character string */
|
/*************************************************************************
|
||||||
char*** log_group_home_dirs); /* out, own: log group home dirs */
|
Frees the memory allocated by srv_parse_data_file_paths_and_sizes()
|
||||||
|
and srv_parse_log_group_home_dirs(). */
|
||||||
|
UNIV_INTERN
|
||||||
|
void
|
||||||
|
srv_free_paths_and_sizes(void);
|
||||||
|
/*==========================*/
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
Adds a slash or a backslash to the end of a string if it is missing
|
Adds a slash or a backslash to the end of a string if it is missing
|
||||||
and the string is not empty. */
|
and the string is not empty. */
|
||||||
|
|
|
@ -162,7 +162,6 @@ mem_init(
|
||||||
size = 1;
|
size = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ut_mem_init();
|
|
||||||
mem_comm_pool = mem_pool_create(size);
|
mem_comm_pool = mem_pool_create(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -960,14 +960,17 @@ srv_free(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
Initializes the synchronization primitives and the thread local storage. */
|
Initializes the synchronization primitives, memory system, and the thread
|
||||||
|
local storage. */
|
||||||
UNIV_INTERN
|
UNIV_INTERN
|
||||||
void
|
void
|
||||||
srv_general_init(void)
|
srv_general_init(void)
|
||||||
/*==================*/
|
/*==================*/
|
||||||
{
|
{
|
||||||
|
ut_mem_init();
|
||||||
os_sync_init();
|
os_sync_init();
|
||||||
sync_init();
|
sync_init();
|
||||||
|
mem_init(srv_mem_pool_size);
|
||||||
thr_local_init();
|
thr_local_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -174,29 +174,19 @@ UNIV_INTERN
|
||||||
ibool
|
ibool
|
||||||
srv_parse_data_file_paths_and_sizes(
|
srv_parse_data_file_paths_and_sizes(
|
||||||
/*================================*/
|
/*================================*/
|
||||||
/* out: TRUE if ok, FALSE if parsing
|
/* out: TRUE if ok, FALSE on parse error */
|
||||||
error */
|
char* str) /* in/out: the data file path string */
|
||||||
char* str, /* in: the data file path string */
|
|
||||||
char*** data_file_names, /* out, own: array of data file
|
|
||||||
names */
|
|
||||||
ulint** data_file_sizes, /* out, own: array of data file sizes
|
|
||||||
in megabytes */
|
|
||||||
ulint** data_file_is_raw_partition,/* out, own: array of flags
|
|
||||||
showing which data files are raw
|
|
||||||
partitions */
|
|
||||||
ulint* n_data_files, /* out: number of data files */
|
|
||||||
ibool* is_auto_extending, /* out: TRUE if the last data file is
|
|
||||||
auto-extending */
|
|
||||||
ulint* max_auto_extend_size) /* out: max auto extend size for the
|
|
||||||
last file if specified, 0 if not */
|
|
||||||
{
|
{
|
||||||
char* input_str;
|
char* input_str;
|
||||||
char* path;
|
char* path;
|
||||||
ulint size;
|
ulint size;
|
||||||
ulint i = 0;
|
ulint i = 0;
|
||||||
|
|
||||||
*is_auto_extending = FALSE;
|
srv_auto_extend_last_data_file = FALSE;
|
||||||
*max_auto_extend_size = 0;
|
srv_last_file_size_max = 0;
|
||||||
|
srv_data_file_names = NULL;
|
||||||
|
srv_data_file_sizes = NULL;
|
||||||
|
srv_data_file_is_raw_partition = NULL;
|
||||||
|
|
||||||
input_str = str;
|
input_str = str;
|
||||||
|
|
||||||
|
@ -273,11 +263,12 @@ srv_parse_data_file_paths_and_sizes(
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
*data_file_names = (char**)ut_malloc(i * sizeof(void*));
|
srv_data_file_names = malloc(i * sizeof *srv_data_file_names);
|
||||||
*data_file_sizes = (ulint*)ut_malloc(i * sizeof(ulint));
|
srv_data_file_sizes = malloc(i * sizeof *srv_data_file_sizes);
|
||||||
*data_file_is_raw_partition = (ulint*)ut_malloc(i * sizeof(ulint));
|
srv_data_file_is_raw_partition = malloc(
|
||||||
|
i * sizeof *srv_data_file_is_raw_partition);
|
||||||
|
|
||||||
*n_data_files = i;
|
srv_n_data_files = i;
|
||||||
|
|
||||||
/* Then store the actual values to our arrays */
|
/* Then store the actual values to our arrays */
|
||||||
|
|
||||||
|
@ -307,13 +298,13 @@ srv_parse_data_file_paths_and_sizes(
|
||||||
|
|
||||||
str = srv_parse_megabytes(str, &size);
|
str = srv_parse_megabytes(str, &size);
|
||||||
|
|
||||||
(*data_file_names)[i] = path;
|
srv_data_file_names[i] = path;
|
||||||
(*data_file_sizes)[i] = size;
|
srv_data_file_sizes[i] = size;
|
||||||
|
|
||||||
if (0 == strncmp(str, ":autoextend",
|
if (0 == strncmp(str, ":autoextend",
|
||||||
(sizeof ":autoextend") - 1)) {
|
(sizeof ":autoextend") - 1)) {
|
||||||
|
|
||||||
*is_auto_extending = TRUE;
|
srv_auto_extend_last_data_file = TRUE;
|
||||||
|
|
||||||
str += (sizeof ":autoextend") - 1;
|
str += (sizeof ":autoextend") - 1;
|
||||||
|
|
||||||
|
@ -323,7 +314,7 @@ srv_parse_data_file_paths_and_sizes(
|
||||||
str += (sizeof ":max:") - 1;
|
str += (sizeof ":max:") - 1;
|
||||||
|
|
||||||
str = srv_parse_megabytes(
|
str = srv_parse_megabytes(
|
||||||
str, max_auto_extend_size);
|
str, &srv_last_file_size_max);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*str != '\0') {
|
if (*str != '\0') {
|
||||||
|
@ -332,21 +323,21 @@ srv_parse_data_file_paths_and_sizes(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
(*data_file_is_raw_partition)[i] = 0;
|
(srv_data_file_is_raw_partition)[i] = 0;
|
||||||
|
|
||||||
if (strlen(str) >= 6
|
if (strlen(str) >= 6
|
||||||
&& *str == 'n'
|
&& *str == 'n'
|
||||||
&& *(str + 1) == 'e'
|
&& *(str + 1) == 'e'
|
||||||
&& *(str + 2) == 'w') {
|
&& *(str + 2) == 'w') {
|
||||||
str += 3;
|
str += 3;
|
||||||
(*data_file_is_raw_partition)[i] = SRV_NEW_RAW;
|
(srv_data_file_is_raw_partition)[i] = SRV_NEW_RAW;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*str == 'r' && *(str + 1) == 'a' && *(str + 2) == 'w') {
|
if (*str == 'r' && *(str + 1) == 'a' && *(str + 2) == 'w') {
|
||||||
str += 3;
|
str += 3;
|
||||||
|
|
||||||
if ((*data_file_is_raw_partition)[i] == 0) {
|
if ((srv_data_file_is_raw_partition)[i] == 0) {
|
||||||
(*data_file_is_raw_partition)[i] = SRV_OLD_RAW;
|
(srv_data_file_is_raw_partition)[i] = SRV_OLD_RAW;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -367,15 +358,15 @@ UNIV_INTERN
|
||||||
ibool
|
ibool
|
||||||
srv_parse_log_group_home_dirs(
|
srv_parse_log_group_home_dirs(
|
||||||
/*==========================*/
|
/*==========================*/
|
||||||
/* out: TRUE if ok, FALSE if parsing
|
/* out: TRUE if ok, FALSE on parse error */
|
||||||
error */
|
char* str) /* in/out: character string */
|
||||||
char* str, /* in: character string */
|
|
||||||
char*** log_group_home_dirs) /* out, own: log group home dirs */
|
|
||||||
{
|
{
|
||||||
char* input_str;
|
char* input_str;
|
||||||
char* path;
|
char* path;
|
||||||
ulint i = 0;
|
ulint i = 0;
|
||||||
|
|
||||||
|
srv_log_group_home_dirs = NULL;
|
||||||
|
|
||||||
input_str = str;
|
input_str = str;
|
||||||
|
|
||||||
/* First calculate the number of directories and check syntax:
|
/* First calculate the number of directories and check syntax:
|
||||||
|
@ -405,7 +396,7 @@ srv_parse_log_group_home_dirs(
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
*log_group_home_dirs = (char**) ut_malloc(i * sizeof(void*));
|
srv_log_group_home_dirs = malloc(i * sizeof *srv_log_group_home_dirs);
|
||||||
|
|
||||||
/* Then store the actual values to our array */
|
/* Then store the actual values to our array */
|
||||||
|
|
||||||
|
@ -424,7 +415,7 @@ srv_parse_log_group_home_dirs(
|
||||||
str++;
|
str++;
|
||||||
}
|
}
|
||||||
|
|
||||||
(*log_group_home_dirs)[i] = path;
|
srv_log_group_home_dirs[i] = path;
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
@ -432,6 +423,24 @@ srv_parse_log_group_home_dirs(
|
||||||
return(TRUE);
|
return(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
Frees the memory allocated by srv_parse_data_file_paths_and_sizes()
|
||||||
|
and srv_parse_log_group_home_dirs(). */
|
||||||
|
UNIV_INTERN
|
||||||
|
void
|
||||||
|
srv_free_paths_and_sizes(void)
|
||||||
|
/*==========================*/
|
||||||
|
{
|
||||||
|
free(srv_data_file_names);
|
||||||
|
srv_data_file_names = NULL;
|
||||||
|
free(srv_data_file_sizes);
|
||||||
|
srv_data_file_sizes = NULL;
|
||||||
|
free(srv_data_file_is_raw_partition);
|
||||||
|
srv_data_file_is_raw_partition = NULL;
|
||||||
|
free(srv_log_group_home_dirs);
|
||||||
|
srv_log_group_home_dirs = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef UNIV_HOTBACKUP
|
#ifndef UNIV_HOTBACKUP
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
I/o-handler thread function. */
|
I/o-handler thread function. */
|
||||||
|
|
Loading…
Add table
Reference in a new issue