1
0
mirror of https://github.com/MariaDB/server.git synced 2026-01-06 05:22:24 +03:00

MDEV-12218 Clean up InnoDB parameter validation

Bind more InnoDB parameters directly to MYSQL_SYSVAR and
remove "shadow variables".

innodb_change_buffering: Declare as ENUM, not STRING.

innodb_flush_method: Declare as ENUM, not STRING.

innodb_log_buffer_size: Bind directly to srv_log_buffer_size,
without rounding it to a multiple of innodb_page_size.

LOG_BUFFER_SIZE: Remove.

SysTablespace::normalize_size(): Renamed from normalize().

innodb_init_params(): A new function to initialize and validate
InnoDB startup parameters.

innodb_init(): Renamed from innobase_init(). Invoke innodb_init_params()
before actually trying to start up InnoDB.

srv_start(bool): Renamed from innobase_start_or_create_for_mysql().
Added the input parameter create_new_db.

SRV_ALL_O_DIRECT_FSYNC: Define only for _WIN32.

xb_normalize_init_values(): Merge to innodb_init_param().
This commit is contained in:
Marko Mäkelä
2018-04-29 09:41:42 +03:00
parent 9ed2b2b2b8
commit 715e4f4320
46 changed files with 623 additions and 923 deletions

View File

@@ -48,6 +48,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
#include <limits>
#include "common.h"
#include "xtrabackup.h"
#include "srv0srv.h"
#include "mysql_version.h"
#include "backup_copy.h"
#include "backup_mysql.h"

View File

@@ -26,6 +26,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
#include "common.h"
#include "xtrabackup.h"
#include "srv0srv.h"
/* TODO: copy-pasted shared definitions from the XtraDB bitmap write code.
Remove these on the first opportunity, i.e. single-binary XtraBackup. */

View File

@@ -28,6 +28,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
#include <my_dir.h>
#include "read_filt.h"
#include "srv0start.h"
#include "srv0srv.h"
struct xb_fil_cur_t {
pfs_os_file_t file; /*!< source file handle */

View File

@@ -4,7 +4,7 @@ MariaBackup: hot backup tool for InnoDB
Originally Created 3/3/2009 Yasufumi Kinoshita
Written by Alexey Kopytov, Aleksandr Kuzminsky, Stewart Smith, Vadim Tkachenko,
Yasufumi Kinoshita, Ignacio Nin and Baron Schwartz.
(c) 2017, MariaDB Corporation.
(c) 2017, 2018, MariaDB Corporation.
Portions written by Marko Mäkelä.
This program is free software; you can redistribute it and/or modify
@@ -223,7 +223,6 @@ long innobase_buffer_pool_awe_mem_mb = 0;
long innobase_file_io_threads = 4;
long innobase_read_io_threads = 4;
long innobase_write_io_threads = 4;
long innobase_log_buffer_size = 1024*1024L;
longlong innobase_page_size = (1LL << 14); /* 16KB */
char* innobase_buffer_pool_filename = NULL;
@@ -236,9 +235,6 @@ are determined in innobase_init below: */
static char* innobase_ignored_opt;
char* innobase_data_home_dir;
char* innobase_data_file_path;
/* The following has a misleading name: starting from 4.0.5, this also
affects Windows: */
char* innobase_unix_file_flush_method;
my_bool innobase_use_doublewrite;
my_bool innobase_use_large_pages;
@@ -621,13 +617,9 @@ enum options_xtrabackup
OPT_INNODB_ADAPTIVE_HASH_INDEX,
OPT_INNODB_DOUBLEWRITE,
OPT_INNODB_FILE_PER_TABLE,
OPT_INNODB_FLUSH_LOG_AT_TRX_COMMIT,
OPT_INNODB_FLUSH_METHOD,
OPT_INNODB_LOCKS_UNSAFE_FOR_BINLOG,
OPT_INNODB_LOG_GROUP_HOME_DIR,
OPT_INNODB_MAX_DIRTY_PAGES_PCT,
OPT_INNODB_MAX_PURGE_LAG,
OPT_INNODB_ROLLBACK_ON_TIMEOUT,
OPT_INNODB_STATUS_FILE,
OPT_INNODB_AUTOEXTEND_INCREMENT,
OPT_INNODB_BUFFER_POOL_SIZE,
@@ -1127,15 +1119,10 @@ struct my_option xb_server_options[] =
(G_PTR*) &innobase_file_per_table, 0, GET_BOOL, NO_ARG,
FALSE, 0, 0, 0, 0, 0},
{"innodb_flush_method", OPT_INNODB_FLUSH_METHOD,
"With which method to flush data.", (G_PTR*) &innobase_unix_file_flush_method,
(G_PTR*) &innobase_unix_file_flush_method, 0, GET_STR, REQUIRED_ARG, 0, 0, 0,
0, 0, 0},
{"innodb_log_buffer_size", OPT_INNODB_LOG_BUFFER_SIZE,
"The size of the buffer which InnoDB uses to write log to the log files on disk.",
(G_PTR*) &innobase_log_buffer_size, (G_PTR*) &innobase_log_buffer_size, 0,
GET_LONG, REQUIRED_ARG, 1024*1024L, 256*1024L, LONG_MAX, 0, 1024, 0},
(G_PTR*) &srv_log_buffer_size, (G_PTR*) &srv_log_buffer_size, 0,
GET_ULONG, REQUIRED_ARG, 1024*1024L, 256*1024L, LONG_MAX, 0, 1024, 0},
{"innodb_log_file_size", OPT_INNODB_LOG_FILE_SIZE,
"Ignored for mysqld option compatibility",
(G_PTR*) &srv_log_file_size, (G_PTR*) &srv_log_file_size, 0,
@@ -1479,11 +1466,6 @@ xb_get_one_option(int optid,
case OPT_INNODB_LOG_FILE_SIZE:
break;
case OPT_INNODB_FLUSH_METHOD:
ADD_PRINT_PARAM_OPT(innobase_unix_file_flush_method);
break;
case OPT_INNODB_PAGE_SIZE:
ADD_PRINT_PARAM_OPT(innobase_page_size);
@@ -1587,15 +1569,14 @@ xb_get_one_option(int optid,
return 0;
}
static my_bool
innodb_init_param(void)
static bool innodb_init_param()
{
srv_is_being_started = TRUE;
/* === some variables from mysqld === */
memset((G_PTR) &mysql_tmpdir_list, 0, sizeof(mysql_tmpdir_list));
if (init_tmpdir(&mysql_tmpdir_list, opt_mysql_tmpdir))
exit(EXIT_FAILURE);
return true;
xtrabackup_tmpdir = my_tmpdir(&mysql_tmpdir_list);
/* dummy for initialize all_charsets[] */
get_charset_name(0);
@@ -1617,7 +1598,7 @@ innodb_init_param(void)
} else {
msg("InnoDB: Error: invalid value of "
"innobase_page_size: %lld", innobase_page_size);
exit(EXIT_FAILURE);
goto error;
}
} else {
srv_page_size_shift = 14;
@@ -1684,6 +1665,9 @@ innodb_init_param(void)
goto error;
}
srv_sys_space.normalize_size();
srv_lock_table_size = 5 * (srv_buf_pool_size >> srv_page_size_shift);
/* -------------- Log files ---------------------------*/
/* The default dir for log files is the datadir of MySQL */
@@ -1707,16 +1691,13 @@ innodb_init_param(void)
srv_adaptive_flushing = FALSE;
srv_file_flush_method_str = innobase_unix_file_flush_method;
srv_log_buffer_size = (ulint) innobase_log_buffer_size;
/* We set srv_pool_size here in units of 1 kB. InnoDB internally
changes the value so that it becomes the number of database pages. */
srv_buf_pool_size = (ulint) xtrabackup_use_memory;
srv_buf_pool_chunk_unit = (ulong)srv_buf_pool_size;
srv_buf_pool_instances = 1;
srv_n_page_cleaners = 1;
srv_n_file_io_threads = (ulint) innobase_file_io_threads;
srv_n_read_io_threads = (ulint) innobase_read_io_threads;
@@ -1732,7 +1713,7 @@ innodb_init_param(void)
srv_locks_unsafe_for_binlog = (ibool) innobase_locks_unsafe_for_binlog;
srv_max_n_open_files = ULINT_UNDEFINED;
srv_max_n_open_files = ULINT_UNDEFINED - 5;
srv_innodb_status = (ibool) innobase_create_status_file;
srv_print_verbose_log = 1;
@@ -1743,20 +1724,7 @@ innodb_init_param(void)
/* We cannot treat characterset here for now!! */
data_mysql_default_charset_coll = (ulint)default_charset_info->number;
ut_a(DATA_MYSQL_BINARY_CHARSET_COLL == my_charset_bin.number);
//innobase_commit_concurrency_init_default();
/* Since we in this module access directly the fields of a trx
struct, and due to different headers and flags it might happen that
mutex_t has a different size in this module and in InnoDB
modules, we check at run time that the size is the same in
these compilation modules. */
/* On 5.5+ srv_use_native_aio is TRUE by default. It is later reset
if it is not supported by the platform in
innobase_start_or_create_for_mysql(). As we don't call it in xtrabackup,
we have to duplicate checks from that function here. */
ut_ad(DATA_MYSQL_BINARY_CHARSET_COLL == my_charset_bin.number);
#ifdef _WIN32
srv_use_native_aio = TRUE;
@@ -1789,16 +1757,27 @@ innodb_init_param(void)
? log_block_calc_checksum_crc32
: log_block_calc_checksum_none;
return(FALSE);
#ifdef _WIN32
srv_use_native_aio = TRUE;
#endif
srv_file_flush_method = IF_WIN(SRV_ALL_O_DIRECT_FSYNC, SRV_FSYNC);
return false;
error:
msg("mariabackup: innodb_init_param(): Error occured.\n");
return(TRUE);
return true;
}
static bool innodb_init()
{
dberr_t err = innobase_start_or_create_for_mysql();
bool create_new_db = false;
/* Check if the data files exist or not. */
dberr_t err = srv_sys_space.check_file_spec(&create_new_db, 5U << 20);
if (err == DB_SUCCESS) {
err = srv_start(create_new_db);
}
if (err != DB_SUCCESS) {
msg("mariabackup: innodb_init() returned %d (%s).\n",
err, ut_strerr(err));
@@ -3583,19 +3562,6 @@ open_or_create_log_file(
return(DB_SUCCESS);
}
/*********************************************************************//**
Normalizes init parameter values to use units we use inside InnoDB.
@return DB_SUCCESS or error code */
static
void
xb_normalize_init_values(void)
/*==========================*/
{
srv_sys_space.normalize();
srv_log_buffer_size >>= srv_page_size_shift;
srv_lock_table_size = 5 * (srv_buf_pool_size >> srv_page_size_shift);
}
/***********************************************************************
Set the open files limit. Based on set_max_open_files().
@@ -3805,42 +3771,6 @@ fail:
return(false);
}
xb_normalize_init_values();
if (srv_file_flush_method_str == NULL) {
/* These are the default options */
srv_file_flush_method = SRV_FSYNC;
} else if (0 == ut_strcmp(srv_file_flush_method_str, "fsync")) {
srv_file_flush_method = SRV_FSYNC;
} else if (0 == ut_strcmp(srv_file_flush_method_str, "O_DSYNC")) {
srv_file_flush_method = SRV_O_DSYNC;
} else if (0 == ut_strcmp(srv_file_flush_method_str, "O_DIRECT")) {
srv_file_flush_method = SRV_O_DIRECT;
msg("mariabackup: using O_DIRECT\n");
} else if (0 == ut_strcmp(srv_file_flush_method_str, "littlesync")) {
srv_file_flush_method = SRV_LITTLESYNC;
} else if (0 == ut_strcmp(srv_file_flush_method_str, "nosync")) {
srv_file_flush_method = SRV_NOSYNC;
} else if (0 == ut_strcmp(srv_file_flush_method_str, "ALL_O_DIRECT")) {
srv_file_flush_method = SRV_ALL_O_DIRECT_FSYNC;
msg("mariabackup: using ALL_O_DIRECT\n");
} else if (0 == ut_strcmp(srv_file_flush_method_str,
"O_DIRECT_NO_FSYNC")) {
srv_file_flush_method = SRV_O_DIRECT_NO_FSYNC;
msg("mariabackup: using O_DIRECT_NO_FSYNC\n");
} else {
msg("mariabackup: Unrecognized value %s for "
"innodb_flush_method\n", srv_file_flush_method_str);
goto fail;
}
#ifdef _WIN32
srv_file_flush_method = SRV_ALL_O_DIRECT_FSYNC;
srv_use_native_aio = TRUE;
#endif
if (srv_buf_pool_size >= 1000 * 1024 * 1024) {
/* Here we still have srv_pool_size counted
in kilobytes (in 4.0 this was in bytes)
@@ -5002,7 +4932,6 @@ xtrabackup_prepare_func(char** argv)
goto error_cleanup;
}
xb_normalize_init_values();
sync_check_init();
ut_d(sync_check_enable());
ut_crc32_init();

View File

@@ -50,9 +50,11 @@ ERROR HY000: Variable 'innodb_change_buffering' is a GLOBAL variable and should
set global innodb_change_buffering=1.1;
ERROR 42000: Incorrect argument type to variable 'innodb_change_buffering'
set global innodb_change_buffering=1;
ERROR 42000: Incorrect argument type to variable 'innodb_change_buffering'
SELECT @@global.innodb_change_buffering;
@@global.innodb_change_buffering
inserts
set global innodb_change_buffering=-2;
ERROR 42000: Incorrect argument type to variable 'innodb_change_buffering'
ERROR 42000: Variable 'innodb_change_buffering' can't be set to the value of '-2'
set global innodb_change_buffering=1e1;
ERROR 42000: Incorrect argument type to variable 'innodb_change_buffering'
set global innodb_change_buffering='some';

View File

@@ -1,27 +1,27 @@
'#---------------------BS_STVARS_029_01----------------------#'
SELECT COUNT(@@GLOBAL.innodb_flush_method);
COUNT(@@GLOBAL.innodb_flush_method)
0
0 Expected
1
1 Expected
'#---------------------BS_STVARS_029_02----------------------#'
SET @@GLOBAL.innodb_flush_method=1;
ERROR HY000: Variable 'innodb_flush_method' is a read only variable
Expected error 'Read only variable'
SELECT COUNT(@@GLOBAL.innodb_flush_method);
COUNT(@@GLOBAL.innodb_flush_method)
0
0 Expected
1
1 Expected
'#---------------------BS_STVARS_029_03----------------------#'
SELECT @@GLOBAL.innodb_flush_method = VARIABLE_VALUE
FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
WHERE VARIABLE_NAME='innodb_flush_method';
@@GLOBAL.innodb_flush_method = VARIABLE_VALUE
NULL
1
1 Expected
SELECT COUNT(@@GLOBAL.innodb_flush_method);
COUNT(@@GLOBAL.innodb_flush_method)
0
0 Expected
1
1 Expected
SELECT COUNT(VARIABLE_VALUE)
FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
WHERE VARIABLE_NAME='innodb_flush_method';
@@ -31,13 +31,13 @@ COUNT(VARIABLE_VALUE)
'#---------------------BS_STVARS_029_04----------------------#'
SELECT @@innodb_flush_method = @@GLOBAL.innodb_flush_method;
@@innodb_flush_method = @@GLOBAL.innodb_flush_method
NULL
1
1 Expected
'#---------------------BS_STVARS_029_05----------------------#'
SELECT COUNT(@@innodb_flush_method);
COUNT(@@innodb_flush_method)
0
0 Expected
1
1 Expected
SELECT COUNT(@@local.innodb_flush_method);
ERROR HY000: Variable 'innodb_flush_method' is a GLOBAL variable
Expected error 'Variable is a GLOBAL variable'
@@ -46,8 +46,8 @@ ERROR HY000: Variable 'innodb_flush_method' is a GLOBAL variable
Expected error 'Variable is a GLOBAL variable'
SELECT COUNT(@@GLOBAL.innodb_flush_method);
COUNT(@@GLOBAL.innodb_flush_method)
0
0 Expected
1
1 Expected
SELECT innodb_flush_method = @@SESSION.innodb_flush_method;
ERROR 42S22: Unknown column 'innodb_flush_method' in 'field list'
Expected error 'Readonly variable'

View File

@@ -0,0 +1,15 @@
call mtr.add_suppression("InnoDB: Failed to set .*DIRECT");
select @@innodb_flush_method;
@@innodb_flush_method
fsync
create table t(a serial) engine=innodb;
FLUSH TABLES;
select @@innodb_flush_method;
@@innodb_flush_method
O_DIRECT_NO_FSYNC
insert into t values(0);
FLUSH TABLES;
select @@innodb_flush_method;
@@innodb_flush_method
fsync
drop table t;

View File

@@ -293,8 +293,8 @@
GLOBAL_VALUE_ORIGIN CONFIG
DEFAULT_VALUE 16777216
VARIABLE_SCOPE GLOBAL
-VARIABLE_TYPE BIGINT
+VARIABLE_TYPE INT
-VARIABLE_TYPE BIGINT UNSIGNED
+VARIABLE_TYPE INT UNSIGNED
VARIABLE_COMMENT The size of the buffer which InnoDB uses to write log to the log files on disk.
NUMERIC_MIN_VALUE 262144
-NUMERIC_MAX_VALUE 9223372036854775807

View File

@@ -363,12 +363,12 @@ GLOBAL_VALUE all
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE all
VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE VARCHAR
VARIABLE_COMMENT Buffer changes to reduce random access: OFF, ON, inserting, deleting, changing, or purging.
VARIABLE_TYPE ENUM
VARIABLE_COMMENT Buffer changes to secondary indexes.
NUMERIC_MIN_VALUE NULL
NUMERIC_MAX_VALUE NULL
NUMERIC_BLOCK_SIZE NULL
ENUM_VALUE_LIST NULL
ENUM_VALUE_LIST none,inserts,deletes,changes,purges,all
READ_ONLY NO
COMMAND_LINE_ARGUMENT REQUIRED
VARIABLE_NAME INNODB_CHANGE_BUFFERING_DEBUG
@@ -543,7 +543,7 @@ VARIABLE_NAME INNODB_DATA_FILE_PATH
SESSION_VALUE NULL
GLOBAL_VALUE ibdata1:12M:autoextend
GLOBAL_VALUE_ORIGIN CONFIG
DEFAULT_VALUE
DEFAULT_VALUE ibdata1:12M:autoextend
VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE VARCHAR
VARIABLE_COMMENT Path to individual files and their sizes.
@@ -989,16 +989,16 @@ READ_ONLY NO
COMMAND_LINE_ARGUMENT OPTIONAL
VARIABLE_NAME INNODB_FLUSH_METHOD
SESSION_VALUE NULL
GLOBAL_VALUE
GLOBAL_VALUE fsync
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE
DEFAULT_VALUE fsync
VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE VARCHAR
VARIABLE_TYPE ENUM
VARIABLE_COMMENT With which method to flush data.
NUMERIC_MIN_VALUE NULL
NUMERIC_MAX_VALUE NULL
NUMERIC_BLOCK_SIZE NULL
ENUM_VALUE_LIST NULL
ENUM_VALUE_LIST fsync,O_DSYNC,littlesync,nosync,O_DIRECT,O_DIRECT_NO_FSYNC
READ_ONLY YES
COMMAND_LINE_ARGUMENT REQUIRED
VARIABLE_NAME INNODB_FLUSH_NEIGHBORS
@@ -1357,7 +1357,7 @@ GLOBAL_VALUE 1048576
GLOBAL_VALUE_ORIGIN CONFIG
DEFAULT_VALUE 16777216
VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE BIGINT
VARIABLE_TYPE BIGINT UNSIGNED
VARIABLE_COMMENT The size of the buffer which InnoDB uses to write log to the log files on disk.
NUMERIC_MIN_VALUE 262144
NUMERIC_MAX_VALUE 9223372036854775807
@@ -2251,7 +2251,7 @@ VARIABLE_NAME INNODB_TEMP_DATA_FILE_PATH
SESSION_VALUE NULL
GLOBAL_VALUE ibtmp1:12M:autoextend
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE
DEFAULT_VALUE ibtmp1:12M:autoextend
VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE VARCHAR
VARIABLE_COMMENT Path to files and their sizes making temp-tablespace.

View File

@@ -48,9 +48,9 @@ set @@session.innodb_change_buffering='some';
#
--error ER_WRONG_TYPE_FOR_VAR
set global innodb_change_buffering=1.1;
--error ER_WRONG_TYPE_FOR_VAR
set global innodb_change_buffering=1;
--error ER_WRONG_TYPE_FOR_VAR
SELECT @@global.innodb_change_buffering;
--error ER_WRONG_VALUE_FOR_VAR
set global innodb_change_buffering=-2;
--error ER_WRONG_TYPE_FOR_VAR
set global innodb_change_buffering=1e1;

View File

@@ -29,7 +29,7 @@
# Displaying default value #
####################################################################
SELECT COUNT(@@GLOBAL.innodb_flush_method);
--echo 0 Expected
--echo 1 Expected
--echo '#---------------------BS_STVARS_029_02----------------------#'
@@ -42,7 +42,7 @@ SET @@GLOBAL.innodb_flush_method=1;
--echo Expected error 'Read only variable'
SELECT COUNT(@@GLOBAL.innodb_flush_method);
--echo 0 Expected
--echo 1 Expected
@@ -60,7 +60,7 @@ WHERE VARIABLE_NAME='innodb_flush_method';
--echo 1 Expected
SELECT COUNT(@@GLOBAL.innodb_flush_method);
--echo 0 Expected
--echo 1 Expected
--disable_warnings
SELECT COUNT(VARIABLE_VALUE)
@@ -86,7 +86,7 @@ SELECT @@innodb_flush_method = @@GLOBAL.innodb_flush_method;
################################################################################
SELECT COUNT(@@innodb_flush_method);
--echo 0 Expected
--echo 1 Expected
--Error ER_INCORRECT_GLOBAL_LOCAL_VAR
SELECT COUNT(@@local.innodb_flush_method);
@@ -97,7 +97,7 @@ SELECT COUNT(@@SESSION.innodb_flush_method);
--echo Expected error 'Variable is a GLOBAL variable'
SELECT COUNT(@@GLOBAL.innodb_flush_method);
--echo 0 Expected
--echo 1 Expected
--Error ER_BAD_FIELD_ERROR
SELECT innodb_flush_method = @@SESSION.innodb_flush_method;

View File

@@ -0,0 +1,26 @@
--source include/have_innodb.inc
# Embedded server tests do not support restarting.
--source include/not_embedded.inc
call mtr.add_suppression("InnoDB: Failed to set .*DIRECT");
--replace_result unbuffered fsync
select @@innodb_flush_method;
create table t(a serial) engine=innodb;
# kill and restart
FLUSH TABLES;
let $shutdown_timeout= 0;
let $restart_parameters=--innodb-flush-method=5;
--source include/restart_mysqld.inc
select @@innodb_flush_method;
insert into t values(0);
# kill and restart
FLUSH TABLES;
let $shutdown_timeout= 0;
let $restart_parameters=--innodb-flush-method=0;
--source include/restart_mysqld.inc
select @@innodb_flush_method;
drop table t;

View File

@@ -224,8 +224,7 @@ btr_search_check_free_space_in_heap(const dict_index_t* index)
/** Creates and initializes the adaptive search system at a database start.
@param[in] hash_size hash table size. */
void
btr_search_sys_create(ulint hash_size)
void btr_search_sys_create(ulint hash_size)
{
/* Search System is divided into n parts.
Each part controls access to distinct set of hash buckets from
@@ -266,8 +265,7 @@ btr_search_sys_create(ulint hash_size)
/** Resize hash index hash table.
@param[in] hash_size hash index hash table size */
void
btr_search_sys_resize(ulint hash_size)
void btr_search_sys_resize(ulint hash_size)
{
/* Step-1: Lock all search latches in exclusive mode. */
btr_search_x_lock_all();
@@ -303,10 +301,14 @@ btr_search_sys_resize(ulint hash_size)
}
/** Frees the adaptive search system at a database shutdown. */
void
btr_search_sys_free()
void btr_search_sys_free()
{
ut_ad(btr_search_sys != NULL && btr_search_latches != NULL);
if (!btr_search_sys) {
ut_ad(!btr_search_latches);
return;
}
ut_ad(btr_search_latches);
/* Step-1: Release the hash tables. */
for (ulint i = 0; i < btr_ahi_parts; ++i) {
@@ -351,9 +353,7 @@ btr_search_disable_ref_count(
/** Disable the adaptive hash search system and empty the index.
@param[in] need_mutex need to acquire dict_sys->mutex */
void
btr_search_disable(
bool need_mutex)
void btr_search_disable(bool need_mutex)
{
dict_table_t* table;
@@ -406,8 +406,7 @@ btr_search_disable(
}
/** Enable the adaptive hash search system. */
void
btr_search_enable()
void btr_search_enable()
{
buf_pool_mutex_enter_all();
if (srv_buf_pool_old_size != srv_buf_pool_size) {
@@ -1080,8 +1079,7 @@ fail:
block->buf_fix_count == 0 or it is an index page which
has already been removed from the buf_pool->page_hash
i.e.: it is in state BUF_BLOCK_REMOVE_HASH */
void
btr_search_drop_page_hash_index(buf_block_t* block)
void btr_search_drop_page_hash_index(buf_block_t* block)
{
ulint n_fields;
ulint n_bytes;
@@ -1652,8 +1650,7 @@ btr_search_move_or_delete_hash_entries(
/** Updates the page hash index when a single record is deleted from a page.
@param[in] cursor cursor which was positioned on the record to delete
using btr_cur_search_, the record is not yet deleted.*/
void
btr_search_update_hash_on_delete(btr_cur_t* cursor)
void btr_search_update_hash_on_delete(btr_cur_t* cursor)
{
hash_table_t* table;
buf_block_t* block;

View File

@@ -1192,11 +1192,11 @@ buf_madvise_do_dump()
buf_chunk_t* chunk;
/* mirrors allocation in log_sys_init() */
if (log_sys->buf)
{
ret+= madvise(log_sys->first_in_use ? log_sys->buf
: log_sys->buf - log_sys->buf_size,
log_sys->buf_size,
if (log_sys->buf) {
ret+= madvise(log_sys->first_in_use
? log_sys->buf
: log_sys->buf - srv_log_buffer_size,
srv_log_buffer_size * 2,
MADV_DODUMP);
}
/* mirrors recv_sys_init() */

View File

@@ -6702,11 +6702,18 @@ void
dict_close(void)
/*============*/
{
ulint i;
if (dict_sys == NULL) {
/* This should only happen if a failure occurred
during redo log processing. */
return;
}
/* Acquire only because it's a pre-condition. */
mutex_enter(&dict_sys->mutex);
/* Free the hash elements. We don't remove them from the table
because we are going to destroy the table anyway. */
for (i = 0; i < hash_get_n_cells(dict_sys->table_hash); i++) {
for (ulint i = 0; i < hash_get_n_cells(dict_sys->table_id_hash); i++) {
dict_table_t* table;
table = static_cast<dict_table_t*>(
@@ -6718,12 +6725,7 @@ dict_close(void)
table = static_cast<dict_table_t*>(
HASH_GET_NEXT(name_hash, prev_table));
ut_ad(prev_table->magic_n == DICT_TABLE_MAGIC_N);
/* Acquire only because it's a pre-condition. */
mutex_enter(&dict_sys->mutex);
dict_table_remove_from_cache(prev_table);
mutex_exit(&dict_sys->mutex);
}
}
@@ -6733,6 +6735,7 @@ dict_close(void)
therefore we don't delete the individual elements. */
hash_table_free(dict_sys->table_id_hash);
mutex_exit(&dict_sys->mutex);
mutex_free(&dict_sys->mutex);
rw_lock_free(dict_operation_lock);
@@ -6742,6 +6745,11 @@ dict_close(void)
mutex_free(&dict_foreign_err_mutex);
if (dict_foreign_err_file) {
fclose(dict_foreign_err_file);
dict_foreign_err_file = NULL;
}
ut_free(dict_sys);
dict_sys = NULL;

View File

@@ -110,6 +110,7 @@ dict_stats_recalc_pool_deinit()
recalc_pool->clear();
UT_DELETE(recalc_pool);
recalc_pool = NULL;
}
/*****************************************************************//**
@@ -307,6 +308,10 @@ dict_stats_thread_deinit()
ut_a(!srv_read_only_mode);
ut_ad(!srv_dict_stats_thread_active);
if (recalc_pool == NULL) {
return;
}
dict_stats_recalc_pool_deinit();
dict_defrag_pool_deinit();

View File

@@ -942,7 +942,7 @@ SysTablespace::open_or_create(
/** Normalize the file size, convert from megabytes to number of pages. */
void
SysTablespace::normalize()
SysTablespace::normalize_size()
{
files_t::iterator end = m_files.end();

View File

@@ -187,12 +187,9 @@ static const long AUTOINC_OLD_STYLE_LOCKING = 0;
static const long AUTOINC_NEW_STYLE_LOCKING = 1;
static const long AUTOINC_NO_LOCKING = 2;
static long innobase_log_buffer_size;
static ulong innobase_open_files;
static long innobase_autoinc_lock_mode;
static ulong innobase_commit_concurrency = 0;
static ulong innobase_read_io_threads;
static ulong innobase_write_io_threads;
static ulong innobase_commit_concurrency;
static ulonglong innobase_buffer_pool_size;
@@ -200,19 +197,20 @@ static ulonglong innobase_buffer_pool_size;
Connected to buf_LRU_old_ratio. */
static uint innobase_old_blocks_pct;
/* The default values for the following char* start-up parameters
are determined in innobase_init below: */
static char* innobase_data_home_dir;
static char* innobase_data_file_path;
static char* innobase_temp_data_file_path;
static char* innobase_change_buffering;
/* The default values for the following char* start-up parameters
are determined in innodb_init_params(). */
static char* innobase_data_home_dir;
static char* innobase_enable_monitor_counter;
static char* innobase_disable_monitor_counter;
static char* innobase_reset_monitor_counter;
static char* innobase_reset_all_monitor_counter;
static char* innobase_file_flush_method;
static ulong innodb_change_buffering;
static ulong innodb_flush_method;
/* This variable can be set in the server configure file, specifying
stopword table to be used */
@@ -222,7 +220,6 @@ static char* innobase_server_stopword_table;
values */
static my_bool innobase_use_atomic_writes;
static my_bool innobase_use_doublewrite;
static my_bool innobase_use_checksums;
static my_bool innobase_locks_unsafe_for_binlog;
static my_bool innobase_rollback_on_timeout;
@@ -433,6 +430,30 @@ static TYPELIB innodb_lock_schedule_algorithm_typelib = {
NULL
};
/** Names of allowed values of innodb_flush_method */
static const char* innodb_flush_method_names[] = {
"fsync",
"O_DSYNC",
"littlesync",
"nosync",
"O_DIRECT",
"O_DIRECT_NO_FSYNC",
#ifdef _WIN32
"unbuffered",
"async_unbuffered" /* alias for "unbuffered" */,
"normal" /* alias for "fsync" */,
#endif
NullS
};
/** Enumeration of innodb_flush_method */
static TYPELIB innodb_flush_method_typelib = {
array_elements(innodb_flush_method_names) - 1,
"innodb_flush_method_typelib",
innodb_flush_method_names,
NULL
};
/* The following counter is used to convey information to InnoDB
about server activity: in case of normal DML ops it is not
sensible to call srv_active_wake_master_thread after each
@@ -444,13 +465,22 @@ static ulong innobase_active_counter = 0;
static hash_table_t* innobase_open_tables;
/** Allowed values of innodb_change_buffering */
static const char* innobase_change_buffering_values[IBUF_USE_COUNT] = {
static const char* innodb_change_buffering_names[] = {
"none", /* IBUF_USE_NONE */
"inserts", /* IBUF_USE_INSERT */
"deletes", /* IBUF_USE_DELETE_MARK */
"changes", /* IBUF_USE_INSERT_DELETE_MARK */
"purges", /* IBUF_USE_DELETE */
"all" /* IBUF_USE_ALL */
"all", /* IBUF_USE_ALL */
NullS
};
/** Enumeration of innodb_change_buffering */
static TYPELIB innodb_change_buffering_typelib = {
array_elements(innodb_change_buffering_names) - 1,
"innodb_change_buffering_typelib",
innodb_change_buffering_names,
NULL
};
/** Retrieve the FTS Relevance Ranking result for doc with doc_id
@@ -3486,28 +3516,15 @@ innobase_space_shutdown()
DBUG_VOID_RETURN;
}
/*********************************************************************//**
Free any resources that were allocated and return failure.
/** Free any resources that were allocated and return failure.
@return always return 1 */
static
int
innobase_init_abort()
/*=================*/
static int innodb_init_abort()
{
DBUG_ENTER("innobase_init_abort");
DBUG_ENTER("innodb_init_abort");
innobase_space_shutdown();
DBUG_RETURN(1);
}
/** Return partitioning flags. */
static uint innobase_partition_flags()
{
/* JAN: TODO: MYSQL 5.7
return(HA_CAN_EXCHANGE_PARTITION | HA_CANNOT_PARTITION_FK);
*/
return (0);
}
/** Update log_checksum_algorithm_ptr with a pointer to the function
corresponding to whether checksums are enabled.
@param[in,out] thd client session, or NULL if at startup
@@ -3584,117 +3601,90 @@ static ulonglong innodb_prepare_commit_versioned(THD* thd, ulonglong *trx_id)
return 0;
}
/*********************************************************************//**
Opens an InnoDB database.
@return 0 on success, 1 on failure */
static
int
innobase_init(
/*==========*/
void *p) /*!< in: InnoDB handlerton */
/** Initialize and normalize innodb_buffer_pool_size. */
static void innodb_buffer_pool_size_init()
{
static char current_dir[3]; /*!< Set if using current lib */
int err;
if (srv_buf_pool_size >= BUF_POOL_SIZE_THRESHOLD) {
if (srv_buf_pool_instances == srv_buf_pool_instances_default) {
#if defined(_WIN32) && !defined(_WIN64)
/* Do not allocate too large of a buffer pool on
Windows 32-bit systems, which can have trouble
allocating larger single contiguous memory blocks. */
srv_buf_pool_size = ulint(
ut_uint64_align_up(srv_buf_pool_size,
srv_buf_pool_chunk_unit));
srv_buf_pool_instances = std::min<ulong>(
MAX_BUFFER_POOLS,
ulong(srv_buf_pool_size
/ srv_buf_pool_chunk_unit));
#else /* defined(_WIN32) && !defined(_WIN64) */
/* Default to 8 instances when size > 1GB. */
srv_buf_pool_instances = 8;
#endif /* defined(_WIN32) && !defined(_WIN64) */
}
} else {
/* If buffer pool is less than 1 GiB, assume fewer
threads. Also use only one buffer pool instance. */
if (srv_buf_pool_instances != srv_buf_pool_instances_default
&& srv_buf_pool_instances != 1) {
/* We can't distinguish whether the user has explicitly
started mysqld with --innodb-buffer-pool-instances=0,
(srv_buf_pool_instances_default is 0) or has not
specified that option at all. Thus we have the
limitation that if the user started with =0, we
will not emit a warning here, but we should actually
do so. */
ib::info()
<< "Adjusting innodb_buffer_pool_instances"
" from " << srv_buf_pool_instances << " to 1"
" since innodb_buffer_pool_size is less than "
<< BUF_POOL_SIZE_THRESHOLD / (1024 * 1024)
<< " MiB";
}
srv_buf_pool_instances = 1;
}
if (srv_buf_pool_chunk_unit * srv_buf_pool_instances
> srv_buf_pool_size) {
/* Size unit of buffer pool is larger than srv_buf_pool_size.
adjust srv_buf_pool_chunk_unit for srv_buf_pool_size. */
srv_buf_pool_chunk_unit
= static_cast<ulong>(srv_buf_pool_size)
/ srv_buf_pool_instances;
if (srv_buf_pool_size % srv_buf_pool_instances != 0) {
++srv_buf_pool_chunk_unit;
}
}
srv_buf_pool_size = buf_pool_size_align(srv_buf_pool_size);
innobase_buffer_pool_size = srv_buf_pool_size;
}
/** Initialize, validate and normalize the InnoDB startup parameters.
@return failure code
@retval 0 on success
@retval HA_ERR_OUT_OF_MEM when out of memory
@retval HA_ERR_INITIALIZATION when some parameters are out of range */
static int innodb_init_params()
{
DBUG_ENTER("innodb_init_params");
static char current_dir[3];
char *default_path;
ulong num_pll_degree;
DBUG_ENTER("innobase_init");
handlerton* innobase_hton= (handlerton*) p;
innodb_hton_ptr = innobase_hton;
innobase_hton->state = SHOW_OPTION_YES;
innobase_hton->db_type = DB_TYPE_INNODB;
innobase_hton->savepoint_offset = sizeof(trx_named_savept_t);
innobase_hton->close_connection = innobase_close_connection;
innobase_hton->kill_query = innobase_kill_query;
innobase_hton->savepoint_set = innobase_savepoint;
innobase_hton->savepoint_rollback = innobase_rollback_to_savepoint;
innobase_hton->savepoint_rollback_can_release_mdl =
innobase_rollback_to_savepoint_can_release_mdl;
innobase_hton->savepoint_release = innobase_release_savepoint;
innobase_hton->prepare_ordered= NULL;
innobase_hton->commit_ordered= innobase_commit_ordered;
innobase_hton->commit = innobase_commit;
innobase_hton->rollback = innobase_rollback;
innobase_hton->prepare = innobase_xa_prepare;
innobase_hton->recover = innobase_xa_recover;
innobase_hton->commit_by_xid = innobase_commit_by_xid;
innobase_hton->rollback_by_xid = innobase_rollback_by_xid;
innobase_hton->commit_checkpoint_request=innobase_checkpoint_request;
innobase_hton->create = innobase_create_handler;
innobase_hton->drop_database = innobase_drop_database;
innobase_hton->panic = innobase_end;
innobase_hton->partition_flags= innobase_partition_flags;
innobase_hton->start_consistent_snapshot =
innobase_start_trx_and_assign_read_view;
innobase_hton->flush_logs = innobase_flush_logs;
innobase_hton->show_status = innobase_show_status;
innobase_hton->flags =
HTON_SUPPORTS_EXTENDED_KEYS | HTON_SUPPORTS_FOREIGN_KEYS | HTON_NATIVE_SYS_VERSIONING;
#ifdef WITH_WSREP
innobase_hton->abort_transaction=wsrep_abort_transaction;
innobase_hton->set_checkpoint=innobase_wsrep_set_checkpoint;
innobase_hton->get_checkpoint=innobase_wsrep_get_checkpoint;
innobase_hton->fake_trx_id=wsrep_fake_trx_id;
#endif /* WITH_WSREP */
if (srv_file_per_table) {
innobase_hton->tablefile_extensions = ha_innobase_exts;
}
innobase_hton->table_options = innodb_table_option_list;
/* System Versioning */
innobase_hton->prepare_commit_versioned
= innodb_prepare_commit_versioned;
innodb_remember_check_sysvar_funcs();
ut_a(DATA_MYSQL_TRUE_VARCHAR == (ulint)MYSQL_TYPE_VARCHAR);
#ifndef DBUG_OFF
static const char test_filename[] = "-@";
char test_tablename[sizeof test_filename
+ sizeof(srv_mysql50_table_name_prefix) - 1];
if ((sizeof(test_tablename)) - 1
!= filename_to_tablename(test_filename,
test_tablename,
sizeof(test_tablename), true)
|| strncmp(test_tablename,
srv_mysql50_table_name_prefix,
sizeof(srv_mysql50_table_name_prefix) - 1)
|| strcmp(test_tablename
+ sizeof(srv_mysql50_table_name_prefix) - 1,
test_filename)) {
sql_print_error("tablename encoding has been changed");
DBUG_RETURN(innobase_init_abort());
}
#endif /* DBUG_OFF */
/* Check that values don't overflow on 32-bit systems. */
if (sizeof(ulint) == 4) {
if (innobase_buffer_pool_size > UINT_MAX32) {
sql_print_error(
"innodb_buffer_pool_size can't be over 4GB"
" on 32-bit systems");
DBUG_RETURN(innobase_init_abort());
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
}
}
os_file_set_umask(my_umask);
/* Setup the memory alloc/free tracing mechanisms before calling
any functions that could possibly allocate memory. */
ut_new_boot();
/* The buffer pool needs to be able to accommodate enough many
pages, even for larger pages */
if (srv_page_size > UNIV_PAGE_SIZE_DEF
@@ -3703,7 +3693,7 @@ innobase_init(
<< srv_page_size << " requires "
<< "innodb_buffer_pool_size > 24M current "
<< innobase_buffer_pool_size;
goto error;
DBUG_RETURN(HA_ERR_INITIALIZATION);
}
#ifdef WITH_WSREP
@@ -3720,7 +3710,7 @@ innobase_init(
sql_print_error("InnoDB: innodb_compression_algorithm = %lu unsupported.\n"
"InnoDB: liblz4 is not installed. \n",
innodb_compression_algorithm);
goto error;
DBUG_RETURN(HA_ERR_INITIALIZATION);
}
#endif
@@ -3729,7 +3719,7 @@ innobase_init(
sql_print_error("InnoDB: innodb_compression_algorithm = %lu unsupported.\n"
"InnoDB: liblzo is not installed. \n",
innodb_compression_algorithm);
goto error;
DBUG_RETURN(HA_ERR_INITIALIZATION);
}
#endif
@@ -3738,7 +3728,7 @@ innobase_init(
sql_print_error("InnoDB: innodb_compression_algorithm = %lu unsupported.\n"
"InnoDB: liblzma is not installed. \n",
innodb_compression_algorithm);
goto error;
DBUG_RETURN(HA_ERR_INITIALIZATION);
}
#endif
@@ -3747,7 +3737,7 @@ innobase_init(
sql_print_error("InnoDB: innodb_compression_algorithm = %lu unsupported.\n"
"InnoDB: libbz2 is not installed. \n",
innodb_compression_algorithm);
goto error;
DBUG_RETURN(HA_ERR_INITIALIZATION);
}
#endif
@@ -3756,7 +3746,7 @@ innobase_init(
sql_print_error("InnoDB: innodb_compression_algorithm = %lu unsupported.\n"
"InnoDB: libsnappy is not installed. \n",
innodb_compression_algorithm);
goto error;
DBUG_RETURN(HA_ERR_INITIALIZATION);
}
#endif
@@ -3764,9 +3754,18 @@ innobase_init(
&& !encryption_key_id_exists(FIL_DEFAULT_ENCRYPTION_KEY)) {
sql_print_error("InnoDB: cannot enable encryption, "
"encryption plugin is not available");
goto error;
DBUG_RETURN(HA_ERR_INITIALIZATION);
}
#ifdef _WIN32
if (!is_filename_allowed(srv_buf_dump_filename,
strlen(srv_buf_dump_filename), FALSE)) {
sql_print_error("InnoDB: innodb_buffer_pool_filename"
" cannot have colon (:) in the file name.");
DBUG_RETURN(HA_ERR_INITIALIZATION);
}
#endif
/* First calculate the default path for innodb_data_home_dir etc.,
in case the user has not given any value.
@@ -3804,13 +3803,7 @@ innobase_init(
if (!srv_page_size_shift) {
sql_print_error("InnoDB: Invalid page size=%lu.\n",
srv_page_size);
DBUG_RETURN(innobase_init_abort());
}
/* Set default InnoDB temp data file size to 12 MB and let it be
auto-extending. */
if (!innobase_data_file_path) {
innobase_data_file_path = (char*) "ibdata1:12M:autoextend";
DBUG_RETURN(HA_ERR_INITIALIZATION);
}
/* This is the first time univ_page_size is used.
@@ -3825,34 +3818,27 @@ innobase_init(
/* Supports raw devices */
if (!srv_sys_space.parse_params(innobase_data_file_path, true)) {
DBUG_RETURN(innobase_init_abort());
DBUG_RETURN(HA_ERR_INITIALIZATION);
}
/* Set default InnoDB temp data file size to 12 MB and let it be
auto-extending. */
if (!innobase_temp_data_file_path) {
innobase_temp_data_file_path = (char*) "ibtmp1:12M:autoextend";
}
/* We set the temporary tablspace id later, after recovery.
The temp tablespace doesn't support raw devices.
Set the name and path. */
srv_tmp_space.set_name("innodb_temporary");
srv_tmp_space.set_path(srv_data_home);
srv_tmp_space.set_flags(FSP_FLAGS_PAGE_SSIZE());
if (!srv_tmp_space.parse_params(innobase_temp_data_file_path, false)) {
DBUG_RETURN(innobase_init_abort());
DBUG_RETURN(HA_ERR_INITIALIZATION);
}
/* Perform all sanity check before we take action of deleting files*/
if (srv_sys_space.intersection(&srv_tmp_space)) {
sql_print_error("%s and %s file names seem to be the same.",
srv_tmp_space.name(), srv_sys_space.name());
DBUG_RETURN(innobase_init_abort());
DBUG_RETURN(HA_ERR_INITIALIZATION);
}
srv_sys_space.normalize_size();
srv_tmp_space.normalize_size();
/* ------------ UNDO tablespaces files ---------------------*/
if (!srv_undo_dir) {
srv_undo_dir = default_path;
@@ -3862,7 +3848,7 @@ innobase_init(
if (strchr(srv_undo_dir, ';')) {
sql_print_error("syntax error in innodb_undo_directory");
DBUG_RETURN(innobase_init_abort());
DBUG_RETURN(HA_ERR_INITIALIZATION);
}
/* -------------- All log files ---------------------------*/
@@ -3877,33 +3863,22 @@ innobase_init(
if (strchr(srv_log_group_home_dir, ';')) {
sql_print_error("syntax error in innodb_log_group_home_dir");
DBUG_RETURN(innobase_init_abort());
DBUG_RETURN(HA_ERR_INITIALIZATION);
}
if (innobase_change_buffering) {
ulint use;
for (use = 0;
use < UT_ARR_SIZE(innobase_change_buffering_values);
use++) {
if (!innobase_strcasecmp(
innobase_change_buffering,
innobase_change_buffering_values[use])) {
ibuf_use = (ibuf_use_t) use;
goto innobase_change_buffering_inited_ok;
}
}
sql_print_error("InnoDB: invalid value"
" innodb_change_buffering=%s",
innobase_change_buffering);
DBUG_RETURN(innobase_init_abort());
if (srv_n_log_files * srv_log_file_size
>= 512ULL * 1024ULL * 1024ULL * 1024ULL) {
/* log_block_convert_lsn_to_no() limits the returned block
number to 1G and given that OS_FILE_LOG_BLOCK_SIZE is 512
bytes, then we have a limit of 512 GB. If that limit is to
be raised, then log_block_convert_lsn_to_no() must be
modified. */
ib::error() << "Combined size of log files must be < 512 GB";
DBUG_RETURN(HA_ERR_INITIALIZATION);
}
innobase_change_buffering_inited_ok:
ut_a((ulint) ibuf_use < UT_ARR_SIZE(innobase_change_buffering_values));
innobase_change_buffering = (char*)
innobase_change_buffering_values[ibuf_use];
DBUG_ASSERT(innodb_change_buffering <= IBUF_USE_ALL);
ibuf_use = ibuf_use_t(innodb_change_buffering);
/* Check that interdependent parameters have sane values. */
if (srv_max_buf_pool_modified_pct < srv_max_dirty_pages_pct_lwm) {
@@ -3939,17 +3914,6 @@ innobase_change_buffering_inited_ok:
srv_io_capacity = srv_max_io_capacity;
}
if (!is_filename_allowed(srv_buf_dump_filename,
strlen(srv_buf_dump_filename), FALSE)) {
sql_print_error("InnoDB: innodb_buffer_pool_filename"
" cannot have colon (:) in the file name.");
DBUG_RETURN(innobase_init_abort());
}
/* --------------------------------------------------*/
srv_file_flush_method_str = innobase_file_flush_method;
if (UNIV_PAGE_SIZE_DEF != srv_page_size) {
ib::info() << "innodb_page_size=" << srv_page_size;
@@ -3976,15 +3940,8 @@ innobase_change_buffering_inited_ok:
}
}
srv_log_buffer_size = (ulint) innobase_log_buffer_size;
srv_buf_pool_size = ulint(innobase_buffer_pool_size);
srv_n_read_io_threads = (ulint) innobase_read_io_threads;
srv_n_write_io_threads = (ulint) innobase_write_io_threads;
srv_use_doublewrite_buf = (ibool) innobase_use_doublewrite;
if (!innobase_use_checksums) {
ib::warn() << "Setting innodb_checksums to OFF is DEPRECATED."
" This option may be removed in future releases. You"
@@ -4064,15 +4021,153 @@ innobase_change_buffering_inited_ok:
unbuffered)
*/
#ifndef _WIN32
if (!innobase_file_flush_method ||
!strstr(innobase_file_flush_method, "O_DIRECT")) {
innobase_file_flush_method =
srv_file_flush_method_str = (char*)"O_DIRECT";
switch (innodb_flush_method) {
case SRV_O_DIRECT:
case SRV_O_DIRECT_NO_FSYNC:
break;
default:
innodb_flush_method = SRV_O_DIRECT;
fprintf(stderr, "InnoDB: using O_DIRECT due to atomic writes.\n");
}
#endif
}
if (srv_read_only_mode) {
ib::info() << "Started in read only mode";
srv_use_doublewrite_buf = FALSE;
}
#ifdef LINUX_NATIVE_AIO
if (srv_use_native_aio) {
ib::info() << "Using Linux native AIO";
}
#elif !defined _WIN32
/* Currently native AIO is supported only on windows and linux
and that also when the support is compiled in. In all other
cases, we ignore the setting of innodb_use_native_aio. */
srv_use_native_aio = FALSE;
#endif
#ifndef _WIN32
ut_ad(innodb_flush_method <= SRV_O_DIRECT_NO_FSYNC);
#else
switch (innodb_flush_method) {
case SRV_ALL_O_DIRECT_FSYNC + 1 /* "async_unbuffered"="unbuffered" */:
innodb_flush_method = SRV_ALL_O_DIRECT_FSYNC;
break;
case SRV_ALL_O_DIRECT_FSYNC + 2 /* "normal"="fsync" */:
innodb_flush_method = SRV_FSYNC;
break;
default:
ut_ad(innodb_flush_method <= SRV_ALL_O_DIRECT_FSYNC);
}
#endif
srv_file_flush_method = srv_flush_t(innodb_flush_method);
innodb_buffer_pool_size_init();
if (srv_n_page_cleaners > srv_buf_pool_instances) {
/* limit of page_cleaner parallelizability
is number of buffer pool instances. */
srv_n_page_cleaners = srv_buf_pool_instances;
}
srv_lock_table_size = 5 * (srv_buf_pool_size >> srv_page_size_shift);
DBUG_RETURN(0);
}
/** Initialize the InnoDB storage engine plugin.
@param[in,out] p InnoDB handlerton
@return error code
@retval 0 on success */
static int innodb_init(void* p)
{
DBUG_ENTER("innodb_init");
handlerton* innobase_hton= static_cast<handlerton*>(p);
innodb_hton_ptr = innobase_hton;
innobase_hton->state = SHOW_OPTION_YES;
innobase_hton->db_type = DB_TYPE_INNODB;
innobase_hton->savepoint_offset = sizeof(trx_named_savept_t);
innobase_hton->close_connection = innobase_close_connection;
innobase_hton->kill_query = innobase_kill_query;
innobase_hton->savepoint_set = innobase_savepoint;
innobase_hton->savepoint_rollback = innobase_rollback_to_savepoint;
innobase_hton->savepoint_rollback_can_release_mdl =
innobase_rollback_to_savepoint_can_release_mdl;
innobase_hton->savepoint_release = innobase_release_savepoint;
innobase_hton->prepare_ordered= NULL;
innobase_hton->commit_ordered= innobase_commit_ordered;
innobase_hton->commit = innobase_commit;
innobase_hton->rollback = innobase_rollback;
innobase_hton->prepare = innobase_xa_prepare;
innobase_hton->recover = innobase_xa_recover;
innobase_hton->commit_by_xid = innobase_commit_by_xid;
innobase_hton->rollback_by_xid = innobase_rollback_by_xid;
innobase_hton->commit_checkpoint_request=innobase_checkpoint_request;
innobase_hton->create = innobase_create_handler;
innobase_hton->drop_database = innobase_drop_database;
innobase_hton->panic = innobase_end;
innobase_hton->start_consistent_snapshot =
innobase_start_trx_and_assign_read_view;
innobase_hton->flush_logs = innobase_flush_logs;
innobase_hton->show_status = innobase_show_status;
innobase_hton->flags =
HTON_SUPPORTS_EXTENDED_KEYS | HTON_SUPPORTS_FOREIGN_KEYS
| HTON_NATIVE_SYS_VERSIONING;
#ifdef WITH_WSREP
innobase_hton->abort_transaction=wsrep_abort_transaction;
innobase_hton->set_checkpoint=innobase_wsrep_set_checkpoint;
innobase_hton->get_checkpoint=innobase_wsrep_get_checkpoint;
innobase_hton->fake_trx_id=wsrep_fake_trx_id;
#endif /* WITH_WSREP */
innobase_hton->tablefile_extensions = ha_innobase_exts;
innobase_hton->table_options = innodb_table_option_list;
/* System Versioning */
innobase_hton->prepare_commit_versioned
= innodb_prepare_commit_versioned;
innodb_remember_check_sysvar_funcs();
compile_time_assert(DATA_MYSQL_TRUE_VARCHAR == MYSQL_TYPE_VARCHAR);
#ifndef DBUG_OFF
static const char test_filename[] = "-@";
char test_tablename[sizeof test_filename
+ sizeof(srv_mysql50_table_name_prefix) - 1];
DBUG_ASSERT(sizeof test_tablename - 1
== filename_to_tablename(test_filename,
test_tablename,
sizeof test_tablename, true));
DBUG_ASSERT(!strncmp(test_tablename,
srv_mysql50_table_name_prefix,
sizeof srv_mysql50_table_name_prefix - 1));
DBUG_ASSERT(!strcmp(test_tablename
+ sizeof srv_mysql50_table_name_prefix - 1,
test_filename));
#endif /* DBUG_OFF */
os_file_set_umask(my_umask);
/* Setup the memory alloc/free tracing mechanisms before calling
any functions that could possibly allocate memory. */
ut_new_boot();
if (int error = innodb_init_params()) {
DBUG_RETURN(error);
}
/* After this point, error handling has to use
innodb_init_abort(). */
#ifdef HAVE_PSI_INTERFACE
/* Register keys with MySQL performance schema */
int count;
@@ -4104,13 +4199,20 @@ innobase_change_buffering_inited_ok:
mysql_cond_register("innodb", all_innodb_conds, count);
#endif /* HAVE_PSI_INTERFACE */
err = innobase_start_or_create_for_mysql();
bool create_new_db = false;
innobase_buffer_pool_size = srv_buf_pool_size;
/* Check whether the data files exist. */
dberr_t err = srv_sys_space.check_file_spec(&create_new_db, 5U << 20);
if (err != DB_SUCCESS) {
DBUG_RETURN(innodb_init_abort());
}
err = srv_start(create_new_db);
if (err != DB_SUCCESS) {
innodb_shutdown();
DBUG_RETURN(innobase_init_abort());
DBUG_RETURN(innodb_init_abort());
} else if (!srv_read_only_mode) {
mysql_thread_create(thd_destructor_thread_key,
&thd_destructor_thread,
@@ -4162,7 +4264,6 @@ innobase_change_buffering_inited_ok:
/* Turn on monitor counters that are default on */
srv_mon_default_on();
/* Unit Tests */
#ifdef UNIV_ENABLE_UNIT_TEST_GET_PARENT_DIR
unit_test_os_file_get_parent_dir();
@@ -4183,9 +4284,6 @@ innobase_change_buffering_inited_ok:
#endif /* UNIV_ENABLE_UNIT_TEST_ROW_RAW_FORMAT_INT */
DBUG_RETURN(0);
error:
DBUG_RETURN(1);
}
/** Shut down the InnoDB storage engine.
@@ -17608,108 +17706,6 @@ innodb_make_page_dirty(
space->release();
}
#endif // UNIV_DEBUG
/*************************************************************//**
Find the corresponding ibuf_use_t value that indexes into
innobase_change_buffering_values[] array for the input
change buffering option name.
@return corresponding IBUF_USE_* value for the input variable
name, or IBUF_USE_COUNT if not able to find a match */
static
ibuf_use_t
innodb_find_change_buffering_value(
/*===============================*/
const char* input_name) /*!< in: input change buffering
option name */
{
for (ulint i = 0;
i < UT_ARR_SIZE(innobase_change_buffering_values);
++i) {
/* found a match */
if (!innobase_strcasecmp(
input_name, innobase_change_buffering_values[i])) {
return(static_cast<ibuf_use_t>(i));
}
}
/* Did not find any match */
return(IBUF_USE_COUNT);
}
/*************************************************************//**
Check if it is a valid value of innodb_change_buffering. This function is
registered as a callback with MySQL.
@return 0 for valid innodb_change_buffering */
static
int
innodb_change_buffering_validate(
/*=============================*/
THD* thd, /*!< in: thread handle */
struct st_mysql_sys_var* var, /*!< in: pointer to system
variable */
void* save, /*!< out: immediate result
for update function */
struct st_mysql_value* value) /*!< in: incoming string */
{
const char* change_buffering_input;
char buff[STRING_BUFFER_USUAL_SIZE];
int len = sizeof(buff);
ut_a(save != NULL);
ut_a(value != NULL);
change_buffering_input = value->val_str(value, buff, &len);
if (change_buffering_input != NULL) {
ibuf_use_t use;
use = innodb_find_change_buffering_value(
change_buffering_input);
if (use != IBUF_USE_COUNT) {
/* Find a matching change_buffering option value. */
*static_cast<const char**>(save) =
innobase_change_buffering_values[use];
return(0);
}
}
/* No corresponding change buffering option for user supplied
"change_buffering_input" */
return(1);
}
/****************************************************************//**
Update the system variable innodb_change_buffering using the "saved"
value. This function is registered as a callback with MySQL. */
static
void
innodb_change_buffering_update(
/*===========================*/
THD* thd, /*!< in: thread handle */
struct st_mysql_sys_var* var, /*!< in: pointer to
system variable */
void* var_ptr,/*!< out: where the
formal string goes */
const void* save) /*!< in: immediate result
from check function */
{
ibuf_use_t use;
ut_a(var_ptr != NULL);
ut_a(save != NULL);
use = innodb_find_change_buffering_value(
*static_cast<const char*const*>(save));
ut_a(use < IBUF_USE_COUNT);
ibuf_use = use;
*static_cast<const char**>(var_ptr) =
*static_cast<const char*const*>(save);
}
/*************************************************************//**
Just emit a warning that the usage of the variable is deprecated.
@return 0 */
@@ -18174,9 +18170,7 @@ innodb_srv_buf_dump_filename_validate(
ut_a(save != NULL);
ut_a(value != NULL);
const char* buf_name = value->val_str(value, buff, &len);
if (buf_name != NULL) {
if (const char* buf_name = value->val_str(value, buff, &len)) {
if (is_filename_allowed(buf_name, len, FALSE)){
*static_cast<const char**>(save) = buf_name;
return(0);
@@ -19261,7 +19255,7 @@ static MYSQL_SYSVAR_STR(data_home_dir, innobase_data_home_dir,
"The common part for InnoDB table spaces.",
NULL, NULL, NULL);
static MYSQL_SYSVAR_BOOL(doublewrite, innobase_use_doublewrite,
static MYSQL_SYSVAR_BOOL(doublewrite, srv_use_doublewrite_buf,
PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
"Enable InnoDB doublewrite buffer (enabled by default)."
" Disable with --skip-innodb-doublewrite.",
@@ -19389,9 +19383,11 @@ static MYSQL_SYSVAR_ULONG(flush_log_at_trx_commit, srv_flush_log_at_trx_commit,
" guarantees in case of crash. 0 and 2 can be faster than 1 or 3.",
NULL, NULL, 1, 0, 3, 0);
static MYSQL_SYSVAR_STR(flush_method, innobase_file_flush_method,
static MYSQL_SYSVAR_ENUM(flush_method, innodb_flush_method,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"With which method to flush data.", NULL, NULL, NULL);
"With which method to flush data.",
NULL, NULL, IF_WIN(SRV_ALL_O_DIRECT_FSYNC, SRV_FSYNC),
&innodb_flush_method_typelib);
static MYSQL_SYSVAR_BOOL(force_load_corrupted, srv_load_corrupted,
PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
@@ -19843,12 +19839,12 @@ static MYSQL_SYSVAR_BOOL(optimize_fulltext_only, innodb_optimize_fulltext_only,
"Only optimize the Fulltext index of the table",
NULL, NULL, FALSE);
static MYSQL_SYSVAR_ULONG(read_io_threads, innobase_read_io_threads,
static MYSQL_SYSVAR_ULONG(read_io_threads, srv_n_read_io_threads,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"Number of background read I/O threads in InnoDB.",
NULL, NULL, 4, 1, 64, 0);
static MYSQL_SYSVAR_ULONG(write_io_threads, innobase_write_io_threads,
static MYSQL_SYSVAR_ULONG(write_io_threads, srv_n_write_io_threads,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"Number of background write I/O threads in InnoDB.",
NULL, NULL, 4, 1, 64, 0);
@@ -19864,10 +19860,10 @@ static MYSQL_SYSVAR_ULONG(page_size, srv_page_size,
NULL, NULL, UNIV_PAGE_SIZE_DEF,
UNIV_PAGE_SIZE_MIN, UNIV_PAGE_SIZE_MAX, 0);
static MYSQL_SYSVAR_LONG(log_buffer_size, innobase_log_buffer_size,
static MYSQL_SYSVAR_ULONG(log_buffer_size, srv_log_buffer_size,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"The size of the buffer which InnoDB uses to write log to the log files on disk.",
NULL, NULL, 16*1024*1024L, 256*1024L, LONG_MAX, 1024);
NULL, NULL, 16L << 20, 256L << 10, LONG_MAX, 1024);
static MYSQL_SYSVAR_ULONGLONG(log_file_size, srv_log_file_size,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
@@ -19947,12 +19943,12 @@ static MYSQL_SYSVAR_ULONG(thread_sleep_delay, srv_thread_sleep_delay,
static MYSQL_SYSVAR_STR(data_file_path, innobase_data_file_path,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"Path to individual files and their sizes.",
NULL, NULL, NULL);
NULL, NULL, "ibdata1:12M:autoextend");
static MYSQL_SYSVAR_STR(temp_data_file_path, innobase_temp_data_file_path,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"Path to files and their sizes making temp-tablespace.",
NULL, NULL, NULL);
NULL, NULL, "ibtmp1:12M:autoextend");
static MYSQL_SYSVAR_STR(undo_directory, srv_undo_dir,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
@@ -20030,12 +20026,10 @@ static MYSQL_SYSVAR_BOOL(numa_interleave, srv_numa_interleave,
NULL, NULL, FALSE);
#endif /* HAVE_LIBNUMA */
static MYSQL_SYSVAR_STR(change_buffering, innobase_change_buffering,
static MYSQL_SYSVAR_ENUM(change_buffering, innodb_change_buffering,
PLUGIN_VAR_RQCMDARG,
"Buffer changes to reduce random access:"
" OFF, ON, inserting, deleting, changing, or purging.",
innodb_change_buffering_validate,
innodb_change_buffering_update, "all");
"Buffer changes to secondary indexes.",
NULL, NULL, IBUF_USE_ALL, &innodb_change_buffering_typelib);
static MYSQL_SYSVAR_UINT(change_buffer_max_size,
srv_change_buffer_max_size,
@@ -20611,7 +20605,7 @@ maria_declare_plugin(innobase)
plugin_author,
"Supports transactions, row-level locking, foreign keys and encryption for tables",
PLUGIN_LICENSE_GPL,
innobase_init, /* Plugin Init */
innodb_init, /* Plugin Init */
NULL, /* Plugin Deinit */
INNODB_VERSION_SHORT,
innodb_status_variables_export,/* status variables */

View File

@@ -454,6 +454,10 @@ void
ibuf_close(void)
/*============*/
{
if (ibuf == NULL) {
return;
}
mutex_free(&ibuf_pessimistic_insert_mutex);
mutex_free(&ibuf_mutex);
@@ -3725,8 +3729,6 @@ ibuf_insert(
case IBUF_USE_INSERT_DELETE_MARK:
case IBUF_USE_ALL:
goto check_watch;
case IBUF_USE_COUNT:
break;
}
break;
case IBUF_OP_DELETE_MARK:
@@ -3740,8 +3742,6 @@ ibuf_insert(
case IBUF_USE_ALL:
ut_ad(!no_counter);
goto check_watch;
case IBUF_USE_COUNT:
break;
}
break;
case IBUF_OP_DELETE:
@@ -3755,8 +3755,6 @@ ibuf_insert(
case IBUF_USE_ALL:
ut_ad(!no_counter);
goto skip_watch;
case IBUF_USE_COUNT:
break;
}
break;
case IBUF_OP_COUNT:

View File

@@ -38,26 +38,20 @@ Created 2/17/1996 Heikki Tuuri
/** Creates and initializes the adaptive search system at a database start.
@param[in] hash_size hash table size. */
void
btr_search_sys_create(ulint hash_size);
void btr_search_sys_create(ulint hash_size);
/** Resize hash index hash table.
@param[in] hash_size hash index hash table size */
void
btr_search_sys_resize(ulint hash_size);
void btr_search_sys_resize(ulint hash_size);
/** Frees the adaptive search system at a database shutdown. */
void
btr_search_sys_free();
void btr_search_sys_free();
/** Disable the adaptive hash search system and empty the index.
@param need_mutex need to acquire dict_sys->mutex */
void
btr_search_disable(
bool need_mutex);
void btr_search_disable(bool need_mutex);
/** Enable the adaptive hash search system. */
void
btr_search_enable();
void btr_search_enable();
/** Returns the value of ref_count. The value is protected by latch.
@param[in] info search info
@@ -123,8 +117,7 @@ btr_search_move_or_delete_hash_entries(
block->buf_fix_count == 0 or it is an index page which
has already been removed from the buf_pool->page_hash
i.e.: it is in state BUF_BLOCK_REMOVE_HASH */
void
btr_search_drop_page_hash_index(buf_block_t* block);
void btr_search_drop_page_hash_index(buf_block_t* block);
/** Drop any adaptive hash index entries that may point to an index
page that may be in the buffer pool, when a page is evicted from the
@@ -153,69 +146,52 @@ btr_search_update_hash_on_insert(btr_cur_t* cursor, rw_lock_t* ahi_latch);
/** Updates the page hash index when a single record is deleted from a page.
@param[in] cursor cursor which was positioned on the record to delete
using btr_cur_search_, the record is not yet deleted.*/
void
btr_search_update_hash_on_delete(btr_cur_t* cursor);
void btr_search_update_hash_on_delete(btr_cur_t* cursor);
/** Validates the search system.
@return true if ok */
bool
btr_search_validate();
bool btr_search_validate();
/** Lock all search latches in exclusive mode. */
UNIV_INLINE
void
btr_search_x_lock_all();
static inline void btr_search_x_lock_all();
/** Unlock all search latches from exclusive mode. */
UNIV_INLINE
void
btr_search_x_unlock_all();
static inline void btr_search_x_unlock_all();
/** Lock all search latches in shared mode. */
UNIV_INLINE
void
btr_search_s_lock_all();
static inline void btr_search_s_lock_all();
#ifdef UNIV_DEBUG
/** Check if thread owns all the search latches.
@param[in] mode lock mode check
@retval true if owns all of them
@retval false if does not own some of them */
UNIV_INLINE
bool
btr_search_own_all(ulint mode);
static inline bool btr_search_own_all(ulint mode);
/** Check if thread owns any of the search latches.
@param[in] mode lock mode check
@retval true if owns any of them
@retval false if owns no search latch */
UNIV_INLINE
bool
btr_search_own_any(ulint mode);
static inline bool btr_search_own_any(ulint mode);
#endif /* UNIV_DEBUG */
/** Unlock all search latches from shared mode. */
UNIV_INLINE
void
btr_search_s_unlock_all();
static inline void btr_search_s_unlock_all();
/** Get the latch based on index attributes.
A latch is selected from an array of latches using pair of index-id, space-id.
@param[in] index index handler
@return latch */
UNIV_INLINE
rw_lock_t*
btr_get_search_latch(const dict_index_t* index);
static inline rw_lock_t* btr_get_search_latch(const dict_index_t* index);
/** Get the hash-table based on index attributes.
A table is selected from an array of tables using pair of index-id, space-id.
@param[in] index index handler
@return hash table */
UNIV_INLINE
hash_table_t*
btr_get_search_table(const dict_index_t* index);
static inline hash_table_t* btr_get_search_table(const dict_index_t* index);
#else /* BTR_CUR_HASH_ADAPT */
# define btr_search_sys_create(size)
# define btr_search_sys_free()
# define btr_search_drop_page_hash_index(block)
# define btr_search_s_lock_all(index)
# define btr_search_s_unlock_all(index)
@@ -230,15 +206,11 @@ btr_get_search_table(const dict_index_t* index);
/** Create and initialize search info.
@param[in,out] heap heap where created
@return own: search info struct */
UNIV_INLINE
btr_search_t*
btr_search_info_create(mem_heap_t* heap)
static inline btr_search_t* btr_search_info_create(mem_heap_t* heap)
MY_ATTRIBUTE((nonnull, warn_unused_result));
/** @return the search info of an index */
UNIV_INLINE
btr_search_t*
btr_search_get_info(dict_index_t* index)
static inline btr_search_t* btr_search_get_info(dict_index_t* index)
{
return(index->search_info);
}

View File

@@ -31,9 +31,7 @@ Created 2/17/1996 Heikki Tuuri
/** Create and initialize search info.
@param[in,out] heap heap where created
@return own: search info struct */
UNIV_INLINE
btr_search_t*
btr_search_info_create(mem_heap_t* heap)
static inline btr_search_t* btr_search_info_create(mem_heap_t* heap)
{
btr_search_t* info = static_cast<btr_search_t*>(
mem_heap_zalloc(heap, sizeof(btr_search_t)));
@@ -54,7 +52,7 @@ btr_search_info_update_slow(btr_search_t* info, btr_cur_t* cursor);
/*********************************************************************//**
Updates the search info. */
UNIV_INLINE
static inline
void
btr_search_info_update(
/*===================*/
@@ -87,9 +85,7 @@ btr_search_info_update(
}
/** Lock all search latches in exclusive mode. */
UNIV_INLINE
void
btr_search_x_lock_all()
static inline void btr_search_x_lock_all()
{
for (ulint i = 0; i < btr_ahi_parts; ++i) {
rw_lock_x_lock(btr_search_latches[i]);
@@ -97,9 +93,7 @@ btr_search_x_lock_all()
}
/** Unlock all search latches from exclusive mode. */
UNIV_INLINE
void
btr_search_x_unlock_all()
static inline void btr_search_x_unlock_all()
{
for (ulint i = 0; i < btr_ahi_parts; ++i) {
rw_lock_x_unlock(btr_search_latches[i]);
@@ -107,9 +101,7 @@ btr_search_x_unlock_all()
}
/** Lock all search latches in shared mode. */
UNIV_INLINE
void
btr_search_s_lock_all()
static inline void btr_search_s_lock_all()
{
for (ulint i = 0; i < btr_ahi_parts; ++i) {
rw_lock_s_lock(btr_search_latches[i]);
@@ -117,9 +109,7 @@ btr_search_s_lock_all()
}
/** Unlock all search latches from shared mode. */
UNIV_INLINE
void
btr_search_s_unlock_all()
static inline void btr_search_s_unlock_all()
{
for (ulint i = 0; i < btr_ahi_parts; ++i) {
rw_lock_s_unlock(btr_search_latches[i]);
@@ -131,9 +121,7 @@ btr_search_s_unlock_all()
@param[in] mode lock mode check
@retval true if owns all of them
@retval false if does not own some of them */
UNIV_INLINE
bool
btr_search_own_all(ulint mode)
static inline bool btr_search_own_all(ulint mode)
{
for (ulint i = 0; i < btr_ahi_parts; ++i) {
if (!rw_lock_own(btr_search_latches[i], mode)) {
@@ -147,9 +135,7 @@ btr_search_own_all(ulint mode)
@param[in] mode lock mode check
@retval true if owns any of them
@retval false if owns no search latch */
UNIV_INLINE
bool
btr_search_own_any(ulint mode)
static inline bool btr_search_own_any(ulint mode)
{
for (ulint i = 0; i < btr_ahi_parts; ++i) {
if (rw_lock_own(btr_search_latches[i], mode)) {
@@ -163,9 +149,7 @@ btr_search_own_any(ulint mode)
/** Get the adaptive hash search index latch for a b-tree.
@param[in] index b-tree index
@return latch */
UNIV_INLINE
rw_lock_t*
btr_get_search_latch(const dict_index_t* index)
static inline rw_lock_t* btr_get_search_latch(const dict_index_t* index)
{
ut_ad(index != NULL);
ut_ad(index->table->space->id == index->table->space_id);
@@ -180,9 +164,7 @@ btr_get_search_latch(const dict_index_t* index)
A table is selected from an array of tables using pair of index-id, space-id.
@param[in] index index handler
@return hash table */
UNIV_INLINE
hash_table_t*
btr_get_search_table(const dict_index_t* index)
static inline hash_table_t* btr_get_search_table(const dict_index_t* index)
{
ut_ad(index != NULL);
ut_ad(index->table->space->id == index->table->space_id);

View File

@@ -27,9 +27,9 @@ Created 04/01/2015 Jan Lindström
#define fil0crypt_h
#ifndef UNIV_INNOCHECKSUM
#include "os0event.h"
#include "my_crypt.h"
#include "fil0fil.h"
#endif /*! UNIV_INNOCHECKSUM */
/**

View File

@@ -36,7 +36,7 @@ Created 10/25/1995 Heikki Tuuri
#include "ibuf0types.h"
// Forward declaration
extern ibool srv_use_doublewrite_buf;
extern my_bool srv_use_doublewrite_buf;
extern struct buf_dblwr_t* buf_dblwr;
struct trx_t;
class page_id_t;

View File

@@ -417,7 +417,8 @@ private:
/** Flags to use for opening the data file */
os_file_create_t m_open_flags;
/** size in database pages */
/** size in megabytes or pages; converted from megabytes to
pages in SysTablespace::normalize_size() */
ulint m_size;
/** ordinal position of this datafile in the tablespace */

View File

@@ -103,7 +103,7 @@ public:
void shutdown();
/** Normalize the file size, convert to extents. */
void normalize();
void normalize_size();
/**
@return true if a new raw device was created. */

View File

@@ -49,19 +49,16 @@ typedef enum {
IBUF_OP_COUNT = 3
} ibuf_op_t;
/** Combinations of operations that can be buffered. Because the enum
values are used for indexing innobase_change_buffering_values[], they
should start at 0 and there should not be any gaps. */
typedef enum {
/** Combinations of operations that can be buffered.
@see innodb_change_buffering_names */
enum ibuf_use_t {
IBUF_USE_NONE = 0,
IBUF_USE_INSERT, /* insert */
IBUF_USE_DELETE_MARK, /* delete */
IBUF_USE_INSERT_DELETE_MARK, /* insert+delete */
IBUF_USE_DELETE, /* delete+purge */
IBUF_USE_ALL, /* insert+delete+purge */
IBUF_USE_COUNT /* number of entries in ibuf_use_t */
} ibuf_use_t;
IBUF_USE_ALL /* insert+delete+purge */
};
/** Operations that can currently be buffered. */
extern ibuf_use_t ibuf_use;

View File

@@ -82,9 +82,7 @@ log_free_check(void);
/** Extends the log buffer.
@param[in] len requested minimum size in bytes */
void
log_buffer_extend(
ulint len);
void log_buffer_extend(ulong len);
/** Check margin not to overwrite transaction log from the last checkpoint.
If would estimate the log write to exceed the log_group_capacity,
@@ -422,8 +420,6 @@ extern my_bool innodb_log_checksums;
/* The counting of lsn's starts from this value: this must be non-zero */
#define LOG_START_LSN ((lsn_t) (16 * OS_FILE_LOG_BLOCK_SIZE))
#define LOG_BUFFER_SIZE (srv_log_buffer_size << srv_page_size_shift)
/* Offsets of a log block header */
#define LOG_BLOCK_HDR_NO 0 /* block number which must be > 0 and
is allowed to wrap around at 2G; the
@@ -470,7 +466,7 @@ extern my_bool innodb_log_checksums;
#define LOG_CHECKPOINT_LSN 8
/** Byte offset of the log record corresponding to LOG_CHECKPOINT_LSN */
#define LOG_CHECKPOINT_OFFSET 16
/** log_sys_t::buf_size at the time of the checkpoint (not used) */
/** srv_log_buffer_size at the time of the checkpoint (not used) */
#define LOG_CHECKPOINT_LOG_BUF_SIZE 24
/** MariaDB 10.2.5 encrypted redo log encryption key version (32 bits)*/
#define LOG_CHECKPOINT_CRYPT_KEY 32
@@ -597,7 +593,7 @@ struct log_t{
update hotspots from residing on the
same memory cache line */
lsn_t lsn; /*!< log sequence number */
ulint buf_free; /*!< first free offset within the log
ulong buf_free; /*!< first free offset within the log
buffer in use */
char pad2[CACHE_LINE_SIZE];/*!< Padding */
@@ -614,7 +610,8 @@ struct log_t{
mtr_commit and still ensure that
insertions in the flush_list happen
in the LSN order. */
byte* buf; /*!< Memory of double the buf_size is
byte* buf; /*!< Memory of double the
srv_log_buffer_size is
allocated here. This pointer will change
however to either the first half or the
second half in turns, so that log
@@ -626,8 +623,7 @@ struct log_t{
bool first_in_use; /*!< true if buf points to the first
half of the aligned(buf_ptr), false
if the second half */
ulint buf_size; /*!< log buffer size of each in bytes */
ulint max_buf_free; /*!< recommended maximum value of
ulong max_buf_free; /*!< recommended maximum value of
buf_free for the buffer in use, after
which the buffer is flushed */
bool check_flush_or_checkpoint;
@@ -644,7 +640,7 @@ struct log_t{
/** The fields involved in the log buffer flush @{ */
ulint buf_next_to_write;/*!< first offset in the log buffer
ulong buf_next_to_write;/*!< first offset in the log buffer
where the byte content may not exist
written to file, e.g., the start
offset of a log record catenated

View File

@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, MariaDB Corporation.
Copyright (c) 2017, 2018, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -26,12 +26,12 @@ Created 12/9/1995 Heikki Tuuri
#include "mach0data.h"
#include "srv0mon.h"
#include "srv0srv.h"
#include "ut0crc32.h"
#ifdef UNIV_LOG_LSN_DEBUG
#include "mtr0types.h"
#endif /* UNIV_LOG_LSN_DEBUG */
extern ulong srv_log_buffer_size;
/************************************************************//**
Gets a log block flush bit.
@@ -376,9 +376,9 @@ log_reserve_and_write_fast(
OS_FILE_LOG_BLOCK_SIZE)),
data_len);
log_sys->buf_free += len;
log_sys->buf_free += ulong(len);
ut_ad(log_sys->buf_free <= log_sys->buf_size);
ut_ad(log_sys->buf_free <= srv_log_buffer_size);
log_sys->lsn += len;

View File

@@ -321,9 +321,9 @@ struct mtr_t {
@param[in] space user or system tablespace */
void set_named_space(fil_space_t* space)
{
ut_ad(m_impl.m_user_space_id == TRX_SYS_SPACE);
ut_ad(!m_impl.m_user_space_id);
ut_d(m_impl.m_user_space_id = space->id);
if (space->id != TRX_SYS_SPACE) {
if (space->id) {
m_impl.m_user_space = space;
}
}

View File

@@ -30,12 +30,6 @@ Created 9/8/1995 Heikki Tuuri
#include "univ.i"
/* Maximum number of threads which can be created in the program;
this is also the size of the wait slot array for MySQL threads which
can wait inside InnoDB */
#define OS_THREAD_MAX_N srv_max_n_threads
/* Possible fixed priorities for threads */
#define OS_THREAD_PRIORITY_NONE 100
#define OS_THREAD_PRIORITY_BACKGROUND 1

View File

@@ -1,6 +1,7 @@
/*****************************************************************************
Copyright (c) 2011, 2014, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2018, MariaDB Corporation.
Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described
@@ -41,9 +42,7 @@ Created 2011/04/18 Sunny Bains
#define srv_conc_h
/** We are prepared for a situation that we have this many threads waiting for
a semaphore inside InnoDB. innobase_start_or_create_for_mysql() sets the
value. */
a semaphore inside InnoDB. srv_start() sets the value. */
extern ulint srv_max_n_threads;
/** The following controls how many threads we let inside InnoDB concurrently:

View File

@@ -48,7 +48,6 @@ Created 10/10/1995 Heikki Tuuri
#include "mysql/psi/psi.h"
#include "univ.i"
#include "log0log.h"
#include "os0event.h"
#include "que0types.h"
#include "trx0types.h"
@@ -346,11 +345,11 @@ extern ulong srv_n_log_files;
/** The InnoDB redo log file size, or 0 when changing the redo log format
at startup (while disallowing writes to the redo log). */
extern ulonglong srv_log_file_size;
extern ulint srv_log_buffer_size;
extern ulong srv_log_buffer_size;
extern ulong srv_flush_log_at_trx_commit;
extern uint srv_flush_log_at_timeout;
extern ulong srv_log_write_ahead_size;
extern char srv_adaptive_flushing;
extern my_bool srv_adaptive_flushing;
extern my_bool srv_flush_sync;
#ifdef WITH_INNODB_DISALLOW_WRITES
@@ -400,8 +399,8 @@ extern ulint srv_lock_table_size;
extern ulint srv_n_file_io_threads;
extern my_bool srv_random_read_ahead;
extern ulong srv_read_ahead_threshold;
extern ulint srv_n_read_io_threads;
extern ulint srv_n_write_io_threads;
extern ulong srv_n_read_io_threads;
extern ulong srv_n_write_io_threads;
/* Defragmentation, Origianlly facebook default value is 100, but it's too high */
#define SRV_DEFRAGMENT_FREQUENCY_DEFAULT 40
@@ -435,8 +434,6 @@ to treat NULL value when collecting statistics. It is not defined
as enum type because the configure option takes unsigned integer type. */
extern ulong srv_innodb_stats_method;
extern char* srv_file_flush_method_str;
extern ulint srv_max_n_open_files;
extern ulong srv_n_page_cleaners;
@@ -471,7 +468,7 @@ extern my_bool srv_stats_include_delete_marked;
extern unsigned long long srv_stats_modified_counter;
extern my_bool srv_stats_sample_traditional;
extern ibool srv_use_doublewrite_buf;
extern my_bool srv_use_doublewrite_buf;
extern ulong srv_doublewrite_batch_size;
extern ulong srv_checksum_algorithm;
@@ -666,7 +663,7 @@ extern PSI_stage_info srv_stage_buffer_pool_load;
/** Alternatives for the file flush option in Unix; see the InnoDB manual
about what these mean */
enum srv_flush_t {
SRV_FSYNC = 1, /*!< fsync, the default */
SRV_FSYNC = 0, /*!< fsync, the default */
SRV_O_DSYNC, /*!< open log files in O_SYNC mode */
SRV_LITTLESYNC, /*!< do not call os_file_flush()
when writing data files, but do flush
@@ -678,16 +675,18 @@ enum srv_flush_t {
the reason for which is that some FS
do not flush meta-data when
unbuffered IO happens */
SRV_O_DIRECT_NO_FSYNC,
SRV_O_DIRECT_NO_FSYNC
/*!< do not use fsync() when using
direct IO i.e.: it can be set to avoid
the fsync() call that we make when
using SRV_UNIX_O_DIRECT. However, in
this case user/DBA should be sure about
the integrity of the meta-data */
SRV_ALL_O_DIRECT_FSYNC
#ifdef _WIN32
,SRV_ALL_O_DIRECT_FSYNC
/*!< Traditional Windows appoach to open
all files without caching, and do FileFlushBuffers()*/
#endif
};
extern enum srv_flush_t srv_file_flush_method;

View File

@@ -44,20 +44,16 @@ only one buffer pool instance is used. */
dberr_t
srv_undo_tablespaces_init(bool create_new_db);
/****************************************************************//**
Starts Innobase and creates a new database if database files
are not found and the user wants.
/** Start InnoDB.
@param[in] create_new_db whether to create a new database
@return DB_SUCCESS or error code */
dberr_t
innobase_start_or_create_for_mysql();
dberr_t srv_start(bool create_new_db);
/** Shut down InnoDB. */
void
innodb_shutdown();
void innodb_shutdown();
/** Shut down background threads that can generate undo log. */
void
srv_shutdown_bg_undo_sources();
void srv_shutdown_bg_undo_sources();
/*************************************************************//**
Copy the file path component of the physical file to parameter. It will

View File

@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2015, 2017, MariaDB Corporation.
Copyright (c) 2015, 2018, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -99,16 +99,11 @@ void
sync_array_print(
FILE* file); /*!< in: file where to print */
/**********************************************************************//**
Create the primary system wait array(s), they are protected by an OS mutex */
void
sync_array_init(
ulint n_threads); /*!< in: Number of slots to create */
/** Create the primary system wait arrays */
void sync_array_init();
/**********************************************************************//**
Close sync array wait sub-system. */
void
sync_array_close();
/** Destroy the sync array wait sub-system. */
void sync_array_close();
/**********************************************************************//**
Get an instance of the sync wait array. */

View File

@@ -172,9 +172,8 @@ for all cases. This is used by ut0lst.h related code. */
/* When this macro is defined then additional test functions will be
compiled. These functions live at the end of each relevant source file
and have "test_" prefix. These functions can be called from the end of
innobase_init() or they can be called from gdb after
innobase_start_or_create_for_mysql() has executed using the call
command. */
innodb_init() or they can be called from gdb after srv_start() has executed
using the call command. */
/*
#define UNIV_COMPILE_TEST_FUNCS
#define UNIV_ENABLE_UNIT_TEST_GET_PARENT_DIR

View File

@@ -48,7 +48,7 @@ lock_wait_table_print(void)
const srv_slot_t* slot = lock_sys.waiting_threads;
for (ulint i = 0; i < OS_THREAD_MAX_N; i++, ++slot) {
for (ulint i = 0; i < srv_max_n_threads; i++, ++slot) {
fprintf(stderr,
"Slot %lu: thread type %lu,"
@@ -72,7 +72,7 @@ lock_wait_table_release_slot(
srv_slot_t* slot) /*!< in: slot to release */
{
#ifdef UNIV_DEBUG
srv_slot_t* upper = lock_sys.waiting_threads + OS_THREAD_MAX_N;
srv_slot_t* upper = lock_sys.waiting_threads + srv_max_n_threads;
#endif /* UNIV_DEBUG */
lock_wait_mutex_enter();
@@ -142,7 +142,7 @@ lock_wait_table_reserve_slot(
slot = lock_sys.waiting_threads;
for (i = OS_THREAD_MAX_N; i--; ++slot) {
for (i = srv_max_n_threads; i--; ++slot) {
if (!slot->in_use) {
slot->in_use = TRUE;
slot->thr = thr;
@@ -163,13 +163,13 @@ lock_wait_table_reserve_slot(
}
ut_ad(lock_sys.last_slot
<= lock_sys.waiting_threads + OS_THREAD_MAX_N);
<= lock_sys.waiting_threads + srv_max_n_threads);
return(slot);
}
}
ib::error() << "There appear to be " << OS_THREAD_MAX_N << " user"
ib::error() << "There appear to be " << srv_max_n_threads << " user"
" threads currently waiting inside InnoDB, which is the upper"
" limit. Cannot continue operation. Before aborting, we print"
" a list of waiting threads.";

View File

@@ -166,12 +166,8 @@ log_buf_pool_get_oldest_modification(void)
/** Extends the log buffer.
@param[in] len requested minimum size in bytes */
void
log_buffer_extend(
ulint len)
void log_buffer_extend(ulong len)
{
ulint move_start;
ulint move_end;
byte tmp_buf[OS_FILE_LOG_BLOCK_SIZE];
log_mutex_enter_all();
@@ -185,21 +181,21 @@ log_buffer_extend(
log_mutex_enter_all();
if (srv_log_buffer_size > (len >> srv_page_size_shift)) {
if (srv_log_buffer_size > len) {
/* Already extended enough by the others */
log_mutex_exit_all();
return;
}
}
if (len >= log_sys->buf_size / 2) {
if (len >= srv_log_buffer_size / 2) {
DBUG_EXECUTE_IF("ib_log_buffer_is_short_crash",
DBUG_SUICIDE(););
/* log_buffer is too small. try to extend instead of crash. */
ib::warn() << "The transaction log size is too large"
" for innodb_log_buffer_size (" << len << " >= "
<< LOG_BUFFER_SIZE << " / 2). Trying to extend it.";
ib::warn() << "The redo log transaction size " << len <<
" exceeds innodb_log_buffer_size="
<< srv_log_buffer_size << " / 2). Trying to extend it.";
}
log_sys->is_extending = true;
@@ -216,10 +212,10 @@ log_buffer_extend(
log_mutex_enter_all();
}
move_start = ut_calc_align_down(
ulong move_start = ut_calc_align_down(
log_sys->buf_free,
OS_FILE_LOG_BLOCK_SIZE);
move_end = log_sys->buf_free;
ulong move_end = log_sys->buf_free;
/* store the last log block in buffer */
ut_memcpy(tmp_buf, log_sys->buf + move_start,
@@ -230,20 +226,19 @@ log_buffer_extend(
/* free previous after getting the right address */
if (!log_sys->first_in_use) {
log_sys->buf -= log_sys->buf_size;
log_sys->buf -= srv_log_buffer_size;
}
ut_free_dodump(log_sys->buf, log_sys->buf_size * 2);
ut_free_dodump(log_sys->buf, srv_log_buffer_size * 2);
/* reallocate log buffer */
srv_log_buffer_size = (len >> srv_page_size_shift) + 1;
log_sys->buf_size = LOG_BUFFER_SIZE;
srv_log_buffer_size = len;
log_sys->buf = static_cast<byte*>(
ut_malloc_dontdump(log_sys->buf_size * 2));
ut_malloc_dontdump(srv_log_buffer_size * 2));
log_sys->first_in_use = true;
log_sys->max_buf_free = log_sys->buf_size / LOG_BUF_FLUSH_RATIO
log_sys->max_buf_free = srv_log_buffer_size / LOG_BUF_FLUSH_RATIO
- LOG_BUF_FLUSH_MARGIN;
/* restore the last log block */
@@ -255,7 +250,7 @@ log_buffer_extend(
log_mutex_exit_all();
ib::info() << "innodb_log_buffer_size was extended to "
<< LOG_BUFFER_SIZE << ".";
<< srv_log_buffer_size << ".";
}
/** Calculate actual length in redo buffer and file including
@@ -384,7 +379,7 @@ loop:
len_upper_limit = LOG_BUF_WRITE_MARGIN + srv_log_write_ahead_size
+ (5 * len) / 4;
if (log_sys->buf_free + len_upper_limit > log_sys->buf_size) {
if (log_sys->buf_free + len_upper_limit > srv_log_buffer_size) {
log_mutex_exit();
DEBUG_SYNC_C("log_buf_size_exceeded");
@@ -464,7 +459,7 @@ part_loop:
log->buf_free += len;
ut_ad(log->buf_free <= log->buf_size);
ut_ad(log->buf_free <= srv_log_buffer_size);
if (str_len > 0) {
goto part_loop;
@@ -722,17 +717,15 @@ log_sys_init()
log_sys->lsn = LOG_START_LSN;
ut_a(LOG_BUFFER_SIZE >= 16 * OS_FILE_LOG_BLOCK_SIZE);
ut_a(LOG_BUFFER_SIZE >= 4U << srv_page_size_shift);
log_sys->buf_size = LOG_BUFFER_SIZE;
ut_ad(srv_log_buffer_size >= 16 * OS_FILE_LOG_BLOCK_SIZE);
ut_ad(srv_log_buffer_size >= 4U << srv_page_size_shift);
log_sys->buf = static_cast<byte*>(
ut_malloc_dontdump(log_sys->buf_size * 2));
ut_malloc_dontdump(srv_log_buffer_size * 2));
log_sys->first_in_use = true;
log_sys->max_buf_free = log_sys->buf_size / LOG_BUF_FLUSH_RATIO
log_sys->max_buf_free = srv_log_buffer_size / LOG_BUF_FLUSH_RATIO
- LOG_BUF_FLUSH_MARGIN;
log_sys->check_flush_or_checkpoint = true;
@@ -837,7 +830,9 @@ log_io_complete(
case SRV_LITTLESYNC:
case SRV_O_DIRECT:
case SRV_O_DIRECT_NO_FSYNC:
#ifdef _WIN32
case SRV_ALL_O_DIRECT_FSYNC:
#endif
fil_flush(SRV_LOG_SPACE_FIRST_ID);
}
@@ -1088,10 +1083,10 @@ log_buffer_switch()
log_sys->first_in_use = false;
ut_ad(log_sys->buf == ut_align(log_sys->buf,
OS_FILE_LOG_BLOCK_SIZE));
log_sys->buf += log_sys->buf_size;
log_sys->buf += srv_log_buffer_size;
} else {
log_sys->first_in_use = true;
log_sys->buf -= log_sys->buf_size;
log_sys->buf -= srv_log_buffer_size;
ut_ad(log_sys->buf == ut_align(log_sys->buf,
OS_FILE_LOG_BLOCK_SIZE));
}
@@ -1262,7 +1257,7 @@ loop:
Needs to be written padded data once. */
pad_size = std::min<ulint>(
ulint(write_ahead_size) - end_offset_in_unit,
log_sys->buf_size - area_end);
srv_log_buffer_size - area_end);
::memset(write_buf + area_end, 0, pad_size);
}
}
@@ -1512,7 +1507,8 @@ log_group_checkpoint(lsn_t end_lsn)
lsn_offset = log_group_calc_lsn_offset(log_sys->next_checkpoint_lsn,
group);
mach_write_to_8(buf + LOG_CHECKPOINT_OFFSET, lsn_offset);
mach_write_to_8(buf + LOG_CHECKPOINT_LOG_BUF_SIZE, log_sys->buf_size);
mach_write_to_8(buf + LOG_CHECKPOINT_LOG_BUF_SIZE,
srv_log_buffer_size);
mach_write_to_8(buf + LOG_CHECKPOINT_END_LSN, end_lsn);
log_block_set_checksum(buf, log_block_calc_checksum_crc32(buf));
@@ -1644,7 +1640,9 @@ log_checkpoint(
case SRV_LITTLESYNC:
case SRV_O_DIRECT:
case SRV_O_DIRECT_NO_FSYNC:
#ifdef _WIN32
case SRV_ALL_O_DIRECT_FSYNC:
#endif
fil_flush_file_spaces(FIL_TYPE_TABLESPACE);
}
@@ -2261,9 +2259,9 @@ log_shutdown()
log_group_close_all();
if (!log_sys->first_in_use) {
log_sys->buf -= log_sys->buf_size;
log_sys->buf -= srv_log_buffer_size;
}
ut_free_dodump(log_sys->buf, log_sys->buf_size * 2);
ut_free_dodump(log_sys->buf, srv_log_buffer_size * 2);
log_sys->buf = NULL;
ut_free(log_sys->checkpoint_buf_ptr);
log_sys->checkpoint_buf_ptr = NULL;

View File

@@ -3175,7 +3175,7 @@ recv_recovery_from_checkpoint_start(lsn_t flush_lsn)
recv_sys->mlog_checkpoint_lsn = 0;
ut_ad(RECV_SCAN_SIZE <= log_sys->buf_size);
ut_ad(RECV_SCAN_SIZE <= srv_log_buffer_size);
group = &log_sys->log;
const lsn_t end_lsn = mach_read_from_8(
@@ -3389,7 +3389,7 @@ recv_recovery_from_checkpoint_start(lsn_t flush_lsn)
srv_start_lsn = recv_sys->recovered_lsn;
}
log_sys->buf_free = (ulint) log_sys->lsn % OS_FILE_LOG_BLOCK_SIZE;
log_sys->buf_free = ulong(log_sys->lsn % OS_FILE_LOG_BLOCK_SIZE);
log_sys->buf_next_to_write = log_sys->buf_free;
log_sys->write_lsn = log_sys->lsn;
@@ -3523,7 +3523,7 @@ recv_reset_logs(
log_sys->next_checkpoint_no = 0;
log_sys->last_checkpoint_lsn = 0;
memset(log_sys->buf, 0, log_sys->buf_size);
memset(log_sys->buf, 0, srv_log_buffer_size);
log_block_init(log_sys->buf, log_sys->lsn);
log_block_set_first_rec_group(log_sys->buf, LOG_BLOCK_HDR_SIZE);

View File

@@ -785,8 +785,8 @@ mtr_t::Command::prepare_write()
ut_ad(len > 0);
ut_ad(n_recs > 0);
if (len > log_sys->buf_size / 2) {
log_buffer_extend((len + 1) * 2);
if (len > srv_log_buffer_size / 2) {
log_buffer_extend(ulong((len + 1) * 2));
}
ut_ad(m_impl->m_n_log_recs == n_recs);

View File

@@ -5207,7 +5207,7 @@ os_file_set_nocache(
ib::error()
<< "Failed to set DIRECTIO_ON on file "
<< file_name << ": " << operation_name
<< file_name << "; " << operation_name << ": "
<< strerror(errno_save) << ","
" continuing anyway.";
}
@@ -5221,9 +5221,9 @@ os_file_set_nocache(
# ifdef UNIV_LINUX
ib::warn()
<< "Failed to set O_DIRECT on file"
<< file_name << ";" << operation_name
<< file_name << "; " << operation_name
<< ": " << strerror(errno_save) << ", "
<< "ccontinuing anyway. O_DIRECT is "
"continuing anyway. O_DIRECT is "
"known to result in 'Invalid argument' "
"on Linux on tmpfs, "
"see MySQL Bug#26662.";
@@ -5239,7 +5239,7 @@ short_warning:
<< "Failed to set O_DIRECT on file "
<< file_name << "; " << operation_name
<< " : " << strerror(errno_save)
<< " continuing anyway.";
<< ", continuing anyway.";
}
}
#endif /* defined(UNIV_SOLARIS) && defined(DIRECTIO_ON) */

View File

@@ -142,7 +142,7 @@ os_thread_create_func(
#endif /* not _WIN32 */
ut_a(os_thread_count <= OS_THREAD_MAX_N);
ut_a(os_thread_count <= srv_max_n_threads);
/* Return the thread_id if the caller requests it. */
if (thread_id != NULL) {

View File

@@ -58,10 +58,8 @@ ulong srv_thread_sleep_delay = 10000;
/** We are prepared for a situation that we have this many threads waiting for
a semaphore inside InnoDB. innobase_start_or_create_for_mysql() sets the
value. */
ulint srv_max_n_threads = 0;
a semaphore inside InnoDB. srv_start() sets the value. */
ulint srv_max_n_threads;
/** The following controls how many threads we let inside InnoDB concurrently:
threads waiting for locks are not counted into the number because otherwise

View File

@@ -170,7 +170,7 @@ use simulated aio we build below with threads.
Currently we support native aio on windows and linux */
my_bool srv_use_native_aio;
my_bool srv_numa_interleave;
/** copy of innodb_use_atomic_writes; @see innobase_init() */
/** copy of innodb_use_atomic_writes; @see innodb_init_params() */
my_bool srv_use_atomic_writes;
/** innodb_compression_algorithm; used with page compression */
ulong innodb_compression_algorithm;
@@ -189,15 +189,15 @@ ulong srv_n_log_files;
/** The InnoDB redo log file size, or 0 when changing the redo log format
at startup (while disallowing writes to the redo log). */
ulonglong srv_log_file_size;
/** copy of innodb_log_buffer_size, but in database pages */
ulint srv_log_buffer_size;
/** innodb_log_buffer_size, in bytes */
ulong srv_log_buffer_size;
/** innodb_flush_log_at_trx_commit */
ulong srv_flush_log_at_trx_commit;
/** innodb_flush_log_at_timeout */
uint srv_flush_log_at_timeout;
/** innodb_page_size */
ulong srv_page_size;
/** log2 of innodb_page_size; @see innobase_init() */
/** log2 of innodb_page_size; @see innodb_init_params() */
ulong srv_page_size_shift;
/** innodb_log_write_ahead_size */
ulong srv_log_write_ahead_size;
@@ -262,10 +262,10 @@ ulint srv_lock_table_size = ULINT_MAX;
/** innodb_idle_flush_pct */
ulong srv_idle_flush_pct;
/** copy of innodb_read_io_threads */
ulint srv_n_read_io_threads;
/** copy of innodb_write_io_threads */
ulint srv_n_write_io_threads;
/** innodb_read_io_threads */
ulong srv_n_read_io_threads;
/** innodb_write_io_threads */
ulong srv_n_write_io_threads;
/** innodb_random_read_ahead */
my_bool srv_random_read_ahead;
@@ -278,13 +278,10 @@ ulong srv_read_ahead_threshold;
buffer in terms of percentage of the buffer pool. */
uint srv_change_buffer_max_size;
char* srv_file_flush_method_str;
enum srv_flush_t srv_file_flush_method;
enum srv_flush_t srv_file_flush_method = IF_WIN(SRV_ALL_O_DIRECT_FSYNC,SRV_FSYNC);
/** copy of innodb_open_files, initialized by innobase_init() */
/** copy of innodb_open_files; @see innodb_init_params() */
ulint srv_max_n_open_files;
/** innodb_io_capacity */
@@ -381,8 +378,7 @@ unsigned long long srv_stats_modified_counter;
based on number of configured pages */
my_bool srv_stats_sample_traditional;
/** copy of innodb_doublewrite */
ibool srv_use_doublewrite_buf;
my_bool srv_use_doublewrite_buf;
/** innodb_doublewrite_batch_size (a debug parameter) specifies the
number of pages to use in LRU and flush_list batch flushing.
@@ -1112,41 +1108,16 @@ srv_free(void)
trx_i_s_cache_free(trx_i_s_cache);
}
/*********************************************************************//**
Normalizes init parameter values to use units we use inside InnoDB. */
static
void
srv_normalize_init_values(void)
/*===========================*/
{
srv_sys_space.normalize();
srv_tmp_space.normalize();
srv_log_buffer_size >>= srv_page_size_shift;
srv_lock_table_size = 5 * (srv_buf_pool_size >> srv_page_size_shift);
}
/*********************************************************************//**
Boots the InnoDB server. */
void
srv_boot(void)
/*==========*/
{
/* Transform the init parameter values given by MySQL to
use units we use inside InnoDB: */
srv_normalize_init_values();
sync_check_init();
/* Reset the system variables in the recovery module. */
recv_sys_var_init();
trx_pool_init();
row_mysql_init();
/* Initialize this module */
srv_init();
}
@@ -2443,10 +2414,6 @@ suspend_thread:
srv_suspend_thread(slot);
/* DO NOT CHANGE THIS STRING. innobase_start_or_create_for_mysql()
waits for database activity to die down when converting < 4.1.x
databases, and relies on this string being exactly as it is. InnoDB
manual also mentions this string in several places. */
srv_main_thread_op_info = "waiting for server activity";
srv_resume_thread(slot);

View File

@@ -133,7 +133,7 @@ bool srv_sys_tablespaces_open;
bool srv_was_started;
/** The original value of srv_log_file_size (innodb_log_file_size) */
static ulonglong srv_log_file_size_requested;
/** TRUE if innobase_start_or_create_for_mysql() has been called */
/** whether srv_start() has been called */
static bool srv_start_has_been_called;
/** Whether any undo log records can be generated */
@@ -195,9 +195,6 @@ static bool thread_started[SRV_MAX_N_IO_THREADS + 6 + 32] = {false};
/** Name of srv_monitor_file */
static char* srv_monitor_file_name;
/** Minimum expected tablespace size. (10M) */
static const ulint MIN_EXPECTED_TABLESPACE_SIZE = 5 * 1024 * 1024;
/** */
#define SRV_MAX_N_PENDING_SYNC_IOS 100
@@ -305,7 +302,7 @@ DECLARE_THREAD(io_handler_thread)(
#endif
/* For read only mode, we don't need ibuf and log I/O thread.
Please see innobase_start_or_create_for_mysql() */
Please see srv_start() */
ulint start = (srv_read_only_mode) ? 0 : 2;
if (segment < start) {
@@ -1446,14 +1443,11 @@ srv_prepare_to_delete_redo_log_files(
DBUG_RETURN(flushed_lsn);
}
/********************************************************************
Starts InnoDB and creates a new database if database files
are not found and the user wants.
/** Start InnoDB.
@param[in] create_new_db whether to create a new database
@return DB_SUCCESS or error code */
dberr_t
innobase_start_or_create_for_mysql()
dberr_t srv_start(bool create_new_db)
{
bool create_new_db = false;
lsn_t flushed_lsn;
dberr_t err = DB_SUCCESS;
ulint srv_n_log_files_found = srv_n_log_files;
@@ -1467,6 +1461,7 @@ innobase_start_or_create_for_mysql()
|| srv_operation == SRV_OPERATION_RESTORE
|| srv_operation == SRV_OPERATION_RESTORE_EXPORT);
if (srv_force_recovery == SRV_FORCE_NO_LOG_REDO) {
srv_read_only_mode = true;
}
@@ -1478,15 +1473,6 @@ innobase_start_or_create_for_mysql()
/* Reset the start state. */
srv_start_state = SRV_START_STATE_NONE;
if (srv_read_only_mode) {
ib::info() << "Started in read only mode";
/* There is no write to InnoDB tablespaces (not even
temporary ones, because also CREATE TEMPORARY TABLE is
refused in read-only mode). */
srv_use_doublewrite_buf = FALSE;
}
compile_time_assert(sizeof(ulint) == sizeof(void*));
#ifdef UNIV_DEBUG
@@ -1542,62 +1528,10 @@ innobase_start_or_create_for_mysql()
srv_is_being_started = true;
#ifdef _WIN32
srv_use_native_aio = TRUE;
#elif defined(LINUX_NATIVE_AIO)
if (srv_use_native_aio) {
ib::info() << "Using Linux native AIO";
}
#else
/* Currently native AIO is supported only on windows and linux
and that also when the support is compiled in. In all other
cases, we ignore the setting of innodb_use_native_aio. */
srv_use_native_aio = FALSE;
#endif /* _WIN32 */
/* Register performance schema stages before any real work has been
started which may need to be instrumented. */
mysql_stage_register("innodb", srv_stages, UT_ARR_SIZE(srv_stages));
if (srv_file_flush_method_str == NULL) {
/* These are the default options */
srv_file_flush_method = IF_WIN(SRV_ALL_O_DIRECT_FSYNC,SRV_FSYNC);
} else if (0 == ut_strcmp(srv_file_flush_method_str, "fsync")) {
srv_file_flush_method = SRV_FSYNC;
} else if (0 == ut_strcmp(srv_file_flush_method_str, "O_DSYNC")) {
srv_file_flush_method = SRV_O_DSYNC;
} else if (0 == ut_strcmp(srv_file_flush_method_str, "O_DIRECT")) {
srv_file_flush_method = SRV_O_DIRECT;
} else if (0 == ut_strcmp(srv_file_flush_method_str, "O_DIRECT_NO_FSYNC")) {
srv_file_flush_method = SRV_O_DIRECT_NO_FSYNC;
} else if (0 == ut_strcmp(srv_file_flush_method_str, "littlesync")) {
srv_file_flush_method = SRV_LITTLESYNC;
} else if (0 == ut_strcmp(srv_file_flush_method_str, "nosync")) {
srv_file_flush_method = SRV_NOSYNC;
#ifdef _WIN32
} else if (0 == ut_strcmp(srv_file_flush_method_str, "normal")) {
srv_file_flush_method = SRV_FSYNC;
} else if (0 == ut_strcmp(srv_file_flush_method_str, "unbuffered")) {
} else if (0 == ut_strcmp(srv_file_flush_method_str,
"async_unbuffered")) {
#endif /* _WIN32 */
} else {
ib::error() << "Unrecognized value "
<< srv_file_flush_method_str
<< " for innodb_flush_method";
err = DB_ERROR;
}
/* Note that the call srv_boot() also changes the values of
some variables to the units used by InnoDB internally */
/* Set the maximum number of threads which can wait for a semaphore
inside InnoDB: this is the 'sync wait array' size, as well as the
maximum number of threads that can wait in the 'srv_conc array' for
@@ -1626,65 +1560,6 @@ innobase_start_or_create_for_mysql()
+ fts_sort_pll_degree * FTS_NUM_AUX_INDEX
* max_connections;
if (srv_buf_pool_size >= BUF_POOL_SIZE_THRESHOLD) {
if (srv_buf_pool_instances == srv_buf_pool_instances_default) {
#if defined(_WIN32) && !defined(_WIN64)
/* Do not allocate too large of a buffer pool on
Windows 32-bit systems, which can have trouble
allocating larger single contiguous memory blocks. */
srv_buf_pool_size = static_cast<ulint>(ut_uint64_align_up(srv_buf_pool_size, srv_buf_pool_chunk_unit));
srv_buf_pool_instances = ut_min(
static_cast<ulong>(MAX_BUFFER_POOLS),
static_cast<ulong>(srv_buf_pool_size / srv_buf_pool_chunk_unit));
#else /* defined(_WIN32) && !defined(_WIN64) */
/* Default to 8 instances when size > 1GB. */
srv_buf_pool_instances = 8;
#endif /* defined(_WIN32) && !defined(_WIN64) */
}
} else {
/* If buffer pool is less than 1 GiB, assume fewer
threads. Also use only one buffer pool instance. */
if (srv_buf_pool_instances != srv_buf_pool_instances_default
&& srv_buf_pool_instances != 1) {
/* We can't distinguish whether the user has explicitly
started mysqld with --innodb-buffer-pool-instances=0,
(srv_buf_pool_instances_default is 0) or has not
specified that option at all. Thus we have the
limitation that if the user started with =0, we
will not emit a warning here, but we should actually
do so. */
ib::info()
<< "Adjusting innodb_buffer_pool_instances"
" from " << srv_buf_pool_instances << " to 1"
" since innodb_buffer_pool_size is less than "
<< BUF_POOL_SIZE_THRESHOLD / (1024 * 1024)
<< " MiB";
}
srv_buf_pool_instances = 1;
}
if (srv_buf_pool_chunk_unit * srv_buf_pool_instances
> srv_buf_pool_size) {
/* Size unit of buffer pool is larger than srv_buf_pool_size.
adjust srv_buf_pool_chunk_unit for srv_buf_pool_size. */
srv_buf_pool_chunk_unit
= static_cast<ulong>(srv_buf_pool_size)
/ srv_buf_pool_instances;
if (srv_buf_pool_size % srv_buf_pool_instances != 0) {
++srv_buf_pool_chunk_unit;
}
}
srv_buf_pool_size = buf_pool_size_align(srv_buf_pool_size);
if (srv_n_page_cleaners > srv_buf_pool_instances) {
/* limit of page_cleaner parallelizability
is number of buffer pool instances. */
srv_n_page_cleaners = srv_buf_pool_instances;
}
srv_boot();
ib::info() << ut_crc32_implementation;
@@ -1815,7 +1690,6 @@ innobase_start_or_create_for_mysql()
#endif /* UNIV_DEBUG */
log_sys_init();
recv_sys_init();
lock_sys.create(srv_lock_table_size);
@@ -1849,27 +1723,6 @@ innobase_start_or_create_for_mysql()
srv_start_state_set(SRV_START_STATE_IO);
}
if (srv_n_log_files * srv_log_file_size >= 512ULL << 30) {
/* log_block_convert_lsn_to_no() limits the returned block
number to 1G and given that OS_FILE_LOG_BLOCK_SIZE is 512
bytes, then we have a limit of 512 GB. If that limit is to
be raised, then log_block_convert_lsn_to_no() must be
modified. */
ib::error() << "Combined size of log files must be < 512 GB";
return(srv_init_abort(DB_ERROR));
}
os_normalize_path(srv_data_home);
/* Check if the data files exist or not. */
err = srv_sys_space.check_file_spec(
&create_new_db, MIN_EXPECTED_TABLESPACE_SIZE);
if (err != DB_SUCCESS) {
return(srv_init_abort(DB_ERROR));
}
srv_startup_is_before_trx_rollback_phase = !create_new_db;
/* Check if undo tablespaces and redo log files exist before creating
@@ -2758,8 +2611,7 @@ srv_fts_close(void)
#endif
/** Shut down background threads that can generate undo log. */
void
srv_shutdown_bg_undo_sources()
void srv_shutdown_bg_undo_sources()
{
if (srv_undo_sources) {
ut_ad(!srv_read_only_mode);
@@ -2774,8 +2626,7 @@ srv_shutdown_bg_undo_sources()
}
/** Shut down InnoDB. */
void
innodb_shutdown()
void innodb_shutdown()
{
ut_ad(!my_atomic_loadptr_explicit(reinterpret_cast<void**>
(&srv_running),
@@ -2865,22 +2716,13 @@ innodb_shutdown()
lock_sys.close();
trx_pool_close();
/* We don't create these mutexes in RO mode because we don't create
the temp files that the cover. */
if (!srv_read_only_mode) {
mutex_free(&srv_monitor_file_mutex);
mutex_free(&srv_misc_tmpfile_mutex);
}
if (dict_sys) {
dict_close();
}
#ifdef BTR_CUR_HASH_ADAPT
if (btr_search_sys) {
btr_search_sys_free();
}
#endif /* BTR_CUR_HASH_ADAPT */
dict_close();
btr_search_sys_free();
/* 3. Free all InnoDB's own mutexes and the os_fast_mutexes inside
them */
@@ -2901,10 +2743,6 @@ innodb_shutdown()
sync_check_close();
if (dict_foreign_err_file) {
fclose(dict_foreign_err_file);
}
if (srv_was_started && srv_print_verbose_log) {
ib::info() << "Shutdown completed; log sequence number "
<< srv_shutdown_lsn

View File

@@ -2,7 +2,7 @@
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, Google Inc.
Copyright (c) 2013, 2017, MariaDB Corporation.
Copyright (c) 2013, 2018, MariaDB Corporation.
Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described
@@ -1157,23 +1157,18 @@ sync_array_print_info(
sync_array_exit(arr);
}
/**********************************************************************//**
Create the primary system wait array(s), they are protected by an OS mutex */
void
sync_array_init(
/*============*/
ulint n_threads) /*!< in: Number of slots to
create in all arrays */
/** Create the primary system wait arrays */
void sync_array_init()
{
ut_a(sync_wait_array == NULL);
ut_a(srv_sync_array_size > 0);
ut_a(n_threads > 0);
ut_a(srv_max_n_threads > 0);
sync_array_size = srv_sync_array_size;
sync_wait_array = UT_NEW_ARRAY_NOKEY(sync_array_t*, sync_array_size);
ulint n_slots = 1 + (n_threads - 1) / sync_array_size;
ulint n_slots = 1 + (srv_max_n_threads - 1) / sync_array_size;
for (ulint i = 0; i < sync_array_size; ++i) {
@@ -1181,11 +1176,8 @@ sync_array_init(
}
}
/**********************************************************************//**
Close sync array wait sub-system. */
void
sync_array_close(void)
/*==================*/
/** Destroy the sync array wait sub-system. */
void sync_array_close()
{
for (ulint i = 0; i < sync_array_size; ++i) {
sync_array_free(sync_wait_array[i]);

View File

@@ -738,7 +738,7 @@ LatchDebug::check_order(
if (srv_is_being_started) {
/* This is violated during trx_sys_create_rsegs()
when creating additional rollback segments when
upgrading in innobase_start_or_create_for_mysql(). */
upgrading in srv_start(). */
break;
}
@@ -1739,7 +1739,7 @@ sync_check_init()
ut_d(LatchDebug::init());
sync_array_init(OS_THREAD_MAX_N);
sync_array_init();
}
/** Free the InnoDB synchronization data structures. */