summaryrefslogtreecommitdiff
path: root/storage/xtradb
diff options
context:
space:
mode:
Diffstat (limited to 'storage/xtradb')
-rw-r--r--storage/xtradb/buf/buf0lru.cc14
-rw-r--r--storage/xtradb/handler/ha_innodb.cc126
-rw-r--r--storage/xtradb/include/buf0lru.h8
-rw-r--r--storage/xtradb/row/row0merge.cc17
4 files changed, 79 insertions, 86 deletions
diff --git a/storage/xtradb/buf/buf0lru.cc b/storage/xtradb/buf/buf0lru.cc
index 5f3a8627055..13bf5e79f2d 100644
--- a/storage/xtradb/buf/buf0lru.cc
+++ b/storage/xtradb/buf/buf0lru.cc
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2017, 2018, MariaDB Corporation.
+Copyright (c) 2017, 2019, 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
@@ -2408,8 +2408,8 @@ buf_LRU_old_ratio_update_instance(
buf_pool_t* buf_pool,/*!< in: buffer pool instance */
uint old_pct,/*!< in: Reserve this percentage of
the buffer pool for "old" blocks. */
- ibool adjust) /*!< in: TRUE=adjust the LRU list;
- FALSE=just assign buf_pool->LRU_old_ratio
+ bool adjust) /*!< in: true=adjust the LRU list;
+ false=just assign buf_pool->LRU_old_ratio
during the initialization of InnoDB */
{
uint ratio;
@@ -2447,17 +2447,17 @@ buf_LRU_old_ratio_update_instance(
Updates buf_pool->LRU_old_ratio.
@return updated old_pct */
UNIV_INTERN
-ulint
+uint
buf_LRU_old_ratio_update(
/*=====================*/
uint old_pct,/*!< in: Reserve this percentage of
the buffer pool for "old" blocks. */
- ibool adjust) /*!< in: TRUE=adjust the LRU list;
- FALSE=just assign buf_pool->LRU_old_ratio
+ bool adjust) /*!< in: true=adjust the LRU list;
+ false=just assign buf_pool->LRU_old_ratio
during the initialization of InnoDB */
{
ulint i;
- ulint new_ratio = 0;
+ uint new_ratio = 0;
for (i = 0; i < srv_buf_pool_instances; i++) {
buf_pool_t* buf_pool;
diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc
index 9076e8d95a0..4c1e45ea2f5 100644
--- a/storage/xtradb/handler/ha_innodb.cc
+++ b/storage/xtradb/handler/ha_innodb.cc
@@ -17815,11 +17815,13 @@ innodb_adaptive_hash_index_update(
const void* save) /*!< in: immediate result
from check function */
{
+ mysql_mutex_unlock(&LOCK_global_system_variables);
if (*(my_bool*) save) {
btr_search_enable();
} else {
btr_search_disable();
}
+ mysql_mutex_lock(&LOCK_global_system_variables);
}
/****************************************************************//**
@@ -17840,7 +17842,9 @@ innodb_cmp_per_index_update(
/* Reset the stats whenever we enable the table
INFORMATION_SCHEMA.innodb_cmp_per_index. */
if (!srv_cmp_per_index_enabled && *(my_bool*) save) {
+ mysql_mutex_unlock(&LOCK_global_system_variables);
page_zip_reset_stat_per_index();
+ mysql_mutex_lock(&LOCK_global_system_variables);
}
srv_cmp_per_index_enabled = !!(*(my_bool*) save);
@@ -17861,9 +17865,11 @@ innodb_old_blocks_pct_update(
const void* save) /*!< in: immediate result
from check function */
{
- innobase_old_blocks_pct = static_cast<uint>(
- buf_LRU_old_ratio_update(
- *static_cast<const uint*>(save), TRUE));
+ mysql_mutex_unlock(&LOCK_global_system_variables);
+ uint ratio = buf_LRU_old_ratio_update(*static_cast<const uint*>(save),
+ true);
+ mysql_mutex_lock(&LOCK_global_system_variables);
+ innobase_old_blocks_pct = ratio;
}
/****************************************************************//**
@@ -17881,9 +17887,10 @@ innodb_change_buffer_max_size_update(
const void* save) /*!< in: immediate result
from check function */
{
- innobase_change_buffer_max_size =
- (*static_cast<const uint*>(save));
+ innobase_change_buffer_max_size = *static_cast<const uint*>(save);
+ mysql_mutex_unlock(&LOCK_global_system_variables);
ibuf_max_size_update(innobase_change_buffer_max_size);
+ mysql_mutex_lock(&LOCK_global_system_variables);
}
#ifdef UNIV_DEBUG
@@ -17927,6 +17934,7 @@ innodb_make_page_dirty(
{
mtr_t mtr;
ulong space_id = *static_cast<const ulong*>(save);
+ mysql_mutex_unlock(&LOCK_global_system_variables);
mtr_start(&mtr);
@@ -17944,6 +17952,7 @@ innodb_make_page_dirty(
MLOG_2BYTES, &mtr);
}
mtr_commit(&mtr);
+ mysql_mutex_lock(&LOCK_global_system_variables);
}
#endif // UNIV_DEBUG
@@ -18589,8 +18598,11 @@ innodb_buffer_pool_evict_update(
{
if (const char* op = *static_cast<const char*const*>(save)) {
if (!strcmp(op, "uncompressed")) {
+ mysql_mutex_unlock(&LOCK_global_system_variables);
for (uint tries = 0; tries < 10000; tries++) {
if (innodb_buffer_pool_evict_uncompressed()) {
+ mysql_mutex_lock(
+ &LOCK_global_system_variables);
return;
}
@@ -19127,7 +19139,9 @@ purge_run_now_set(
check function */
{
if (*(my_bool*) save && trx_purge_state() != PURGE_STATE_DISABLED) {
+ mysql_mutex_unlock(&LOCK_global_system_variables);
trx_purge_run();
+ mysql_mutex_lock(&LOCK_global_system_variables);
}
}
@@ -19150,7 +19164,9 @@ purge_stop_now_set(
check function */
{
if (*(my_bool*) save && trx_purge_state() != PURGE_STATE_DISABLED) {
+ mysql_mutex_unlock(&LOCK_global_system_variables);
trx_purge_stop();
+ mysql_mutex_lock(&LOCK_global_system_variables);
}
}
@@ -19172,6 +19188,8 @@ checkpoint_now_set(
check function */
{
if (*(my_bool*) save) {
+ mysql_mutex_unlock(&LOCK_global_system_variables);
+
while (log_sys->last_checkpoint_lsn < log_sys->lsn) {
log_make_checkpoint_at(LSN_MAX, TRUE);
fil_flush_file_spaces(FIL_LOG);
@@ -19185,6 +19203,8 @@ checkpoint_now_set(
"system tablespace at checkpoint err=%s",
ut_strerr(err));
}
+
+ mysql_mutex_lock(&LOCK_global_system_variables);
}
}
@@ -19206,8 +19226,10 @@ buf_flush_list_now_set(
check function */
{
if (*(my_bool*) save) {
+ mysql_mutex_unlock(&LOCK_global_system_variables);
buf_flush_list(ULINT_MAX, LSN_MAX, NULL);
buf_flush_wait_batch_end(NULL, BUF_FLUSH_LIST);
+ mysql_mutex_lock(&LOCK_global_system_variables);
}
}
@@ -19334,7 +19356,9 @@ buffer_pool_dump_now(
check function */
{
if (*(my_bool*) save && !srv_read_only_mode) {
+ mysql_mutex_unlock(&LOCK_global_system_variables);
buf_dump_start();
+ mysql_mutex_lock(&LOCK_global_system_variables);
}
}
@@ -19357,7 +19381,9 @@ buffer_pool_load_now(
check function */
{
if (*(my_bool*) save && !srv_read_only_mode) {
+ mysql_mutex_unlock(&LOCK_global_system_variables);
buf_load_start();
+ mysql_mutex_lock(&LOCK_global_system_variables);
}
}
@@ -19380,96 +19406,71 @@ buffer_pool_load_abort(
check function */
{
if (*(my_bool*) save && !srv_read_only_mode) {
+ mysql_mutex_unlock(&LOCK_global_system_variables);
buf_load_abort();
+ mysql_mutex_lock(&LOCK_global_system_variables);
}
}
/** Update innodb_status_output or innodb_status_output_locks,
which control InnoDB "status monitor" output to the error log.
-@param[in] thd thread handle
-@param[in] var system variable
-@param[out] var_ptr current value
+@param[out] var current value
@param[in] save to-be-assigned value */
static
void
-innodb_status_output_update(
-/*========================*/
- THD* thd __attribute__((unused)),
- struct st_mysql_sys_var* var __attribute__((unused)),
- void* var_ptr __attribute__((unused)),
- const void* save __attribute__((unused)))
+innodb_status_output_update(THD*,st_mysql_sys_var*,void*var,const void*save)
{
- *static_cast<my_bool*>(var_ptr) = *static_cast<const my_bool*>(save);
+ *static_cast<my_bool*>(var) = *static_cast<const my_bool*>(save);
+ mysql_mutex_unlock(&LOCK_global_system_variables);
/* Wakeup server monitor thread. */
os_event_set(srv_monitor_event);
+ mysql_mutex_lock(&LOCK_global_system_variables);
}
-/******************************************************************
-Update the system variable innodb_encryption_threads */
+/** Update the system variable innodb_encryption_threads.
+@param[in] save to-be-assigned value */
static
void
-innodb_encryption_threads_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 */
+innodb_encryption_threads_update(THD*,st_mysql_sys_var*,void*,const void*save)
{
+ mysql_mutex_unlock(&LOCK_global_system_variables);
fil_crypt_set_thread_cnt(*static_cast<const uint*>(save));
+ mysql_mutex_lock(&LOCK_global_system_variables);
}
-/******************************************************************
-Update the system variable innodb_encryption_rotate_key_age */
+/** Update the system variable innodb_encryption_rotate_key_age.
+@param[in] save to-be-assigned value */
static
void
-innodb_encryption_rotate_key_age_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 */
+innodb_encryption_rotate_key_age_update(THD*,st_mysql_sys_var*,void*,
+ const void*save)
{
+ mysql_mutex_unlock(&LOCK_global_system_variables);
fil_crypt_set_rotate_key_age(*static_cast<const uint*>(save));
+ mysql_mutex_lock(&LOCK_global_system_variables);
}
-/******************************************************************
-Update the system variable innodb_encryption_rotation_iops */
+/** Update the system variable innodb_encryption_rotation_iops.
+@param[in] save to-be-assigned value */
static
void
-innodb_encryption_rotation_iops_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 */
+innodb_encryption_rotation_iops_update(THD*,st_mysql_sys_var*,void*,
+ const void*save)
{
+ mysql_mutex_unlock(&LOCK_global_system_variables);
fil_crypt_set_rotation_iops(*static_cast<const uint*>(save));
+ mysql_mutex_lock(&LOCK_global_system_variables);
}
-/******************************************************************
-Update the system variable innodb_encrypt_tables*/
+/** Update the system variable innodb_encrypt_tables.
+@param[in] save to-be-assigned value */
static
void
-innodb_encrypt_tables_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 */
+innodb_encrypt_tables_update(THD*,st_mysql_sys_var*,void*,const void*save)
{
+ mysql_mutex_unlock(&LOCK_global_system_variables);
fil_crypt_set_encrypt_tables(*static_cast<const ulong*>(save));
+ mysql_mutex_lock(&LOCK_global_system_variables);
}
static SHOW_VAR innodb_status_variables_export[]= {
@@ -20907,12 +20908,15 @@ innobase_disallow_writes_update(
variable */
const void* save) /* in: temporary storage */
{
- *(my_bool*)var_ptr = *(my_bool*)save;
+ const my_bool val = *static_cast<const my_bool*>(save);
+ *static_cast<my_bool*>(var_ptr) = val;
ut_a(srv_allow_writes_event);
- if (*(my_bool*)var_ptr)
+ mysql_mutex_unlock(&LOCK_global_system_variables);
+ if (val)
os_event_reset(srv_allow_writes_event);
else
os_event_set(srv_allow_writes_event);
+ mysql_mutex_lock(&LOCK_global_system_variables);
}
static MYSQL_SYSVAR_BOOL(disallow_writes, innobase_disallow_writes,
diff --git a/storage/xtradb/include/buf0lru.h b/storage/xtradb/include/buf0lru.h
index e0f2277b6a2..69ada4abb70 100644
--- a/storage/xtradb/include/buf0lru.h
+++ b/storage/xtradb/include/buf0lru.h
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2017, 2018, MariaDB Corporation.
+Copyright (c) 2017, 2019, 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
@@ -208,13 +208,13 @@ buf_LRU_make_block_old(
Updates buf_pool->LRU_old_ratio.
@return updated old_pct */
UNIV_INTERN
-ulint
+uint
buf_LRU_old_ratio_update(
/*=====================*/
uint old_pct,/*!< in: Reserve this percentage of
the buffer pool for "old" blocks. */
- ibool adjust);/*!< in: TRUE=adjust the LRU list;
- FALSE=just assign buf_pool->LRU_old_ratio
+ bool adjust);/*!< in: true=adjust the LRU list;
+ false=just assign buf_pool->LRU_old_ratio
during the initialization of InnoDB */
/********************************************************************//**
Update the historical stats that we are collecting for LRU eviction
diff --git a/storage/xtradb/row/row0merge.cc b/storage/xtradb/row/row0merge.cc
index c496376e846..70ddb888fb3 100644
--- a/storage/xtradb/row/row0merge.cc
+++ b/storage/xtradb/row/row0merge.cc
@@ -27,6 +27,7 @@ Completed by Sunny Bains and Marko Makela
#include <my_config.h>
#include <log.h>
#include <sql_class.h>
+#include <math.h>
#include "row0merge.h"
#include "row0ext.h"
@@ -42,15 +43,8 @@ Completed by Sunny Bains and Marko Makela
#include "row0import.h"
#include "handler0alter.h"
#include "ha_prototypes.h"
-#include "math.h" /* log2() */
#include "fil0crypt.h"
-float my_log2f(float n)
-{
- /* log(n) / log(2) is log2. */
- return (float)(log((double)n) / log((double)2));
-}
-
/* Ignore posix_fadvise() on those platforms where it does not exist */
#if defined __WIN__
# define posix_fadvise(fd, offset, len, advice) /* nothing */
@@ -2516,18 +2510,13 @@ row_merge_sort(
/* Record the number of merge runs we need to perform */
num_runs = file->offset;
- /* Find the number N which 2^N is greater or equal than num_runs */
- /* N is merge sort running count */
- total_merge_sort_count = (ulint) ceil(my_log2f(num_runs));
- if(total_merge_sort_count <= 0) {
- total_merge_sort_count=1;
- }
-
/* If num_runs are less than 1, nothing to merge */
if (num_runs <= 1) {
DBUG_RETURN(error);
}
+ total_merge_sort_count = ceil(log2f(num_runs));
+
/* "run_offset" records each run's first offset number */
run_offset = (ulint*) mem_alloc(file->offset * sizeof(ulint));