1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

Merge 10.1 into 10.2

This commit is contained in:
Marko Mäkelä
2018-06-06 11:25:33 +03:00
20 changed files with 80 additions and 566 deletions

View File

@@ -1,4 +1,4 @@
call mtr.add_suppression("InnoDB: The log sequence numbers [0-9]+ and [0-9]+ in ibdata files do not match the log sequence number [0-9]+ in the ib_logfiles!"); FLUSH TABLES;
CREATE TABLE t1 (a INT PRIMARY KEY, b TEXT) ENGINE=InnoDB; CREATE TABLE t1 (a INT PRIMARY KEY, b TEXT) ENGINE=InnoDB;
CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=InnoDB; CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=InnoDB;
CREATE TABLE t3 (a INT PRIMARY KEY, b TEXT, c TEXT) ENGINE=InnoDB; CREATE TABLE t3 (a INT PRIMARY KEY, b TEXT, c TEXT) ENGINE=InnoDB;

View File

@@ -1,6 +1,13 @@
SET @innodb_defragment_orig=@@GLOBAL.innodb_defragment; SET @innodb_defragment_orig=@@GLOBAL.innodb_defragment;
SET @innodb_optimize_fulltext_orig=@@GLOBAL.innodb_optimize_fulltext_only;
SET GLOBAL innodb_defragment = 1; SET GLOBAL innodb_defragment = 1;
CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(256), KEY(a, b)) ENGINE=INNODB; SET GLOBAL innodb_optimize_fulltext_only = 0;
#
# MDEV-12198 innodb_defragment=1 crashes server on
# OPTIMIZE TABLE when FULLTEXT index exists
#
CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(256),
KEY(a, b), FULLTEXT KEY(b)) ENGINE=INNODB;
OPTIMIZE TABLE t1; OPTIMIZE TABLE t1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 optimize status OK test.t1 optimize status OK
@@ -11,12 +18,15 @@ INSERT INTO t1 VALUES (400000, REPEAT('A', 256));
OPTIMIZE TABLE t1; OPTIMIZE TABLE t1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 optimize status OK test.t1 optimize status OK
DROP TABLE t1;
# #
# MDEV-12198 innodb_defragment=1 crashes server on # MDEV-15824 innodb_defragment=ON trumps
# OPTIMIZE TABLE when FULLTEXT index exists # innodb_optimize_fulltext_only=ON in OPTIMIZE TABLE
# #
CREATE TABLE t1 (c TEXT, FULLTEXT KEY (c)) ENGINE=InnoDB; SET GLOBAL innodb_optimize_fulltext_only = 1;
OPTIMIZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 optimize status OK
SET GLOBAL innodb_defragment = 0;
OPTIMIZE TABLE t1; OPTIMIZE TABLE t1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 optimize status OK test.t1 optimize status OK
@@ -27,3 +37,4 @@ Table Op Msg_type Msg_text
test.t1 optimize status OK test.t1 optimize status OK
DROP TABLE t1; DROP TABLE t1;
SET GLOBAL innodb_defragment = @innodb_defragment_orig; SET GLOBAL innodb_defragment = @innodb_defragment_orig;
SET GLOBAL innodb_optimize_fulltext_only = @innodb_optimize_fulltext_orig;

View File

@@ -6,13 +6,13 @@
# The 7000 in this test is a bit less than half the innodb_page_size. # The 7000 in this test is a bit less than half the innodb_page_size.
--source include/have_innodb_16k.inc --source include/have_innodb_16k.inc
# DEBUG_SYNC must be compiled in. --source include/have_debug.inc
--source include/have_debug_sync.inc --source include/have_debug_sync.inc
# Embedded server does not support restarting # Embedded server does not support restarting
--source include/not_embedded.inc --source include/not_embedded.inc
call mtr.add_suppression("InnoDB: The log sequence numbers [0-9]+ and [0-9]+ in ibdata files do not match the log sequence number [0-9]+ in the ib_logfiles!"); FLUSH TABLES;
CREATE TABLE t1 (a INT PRIMARY KEY, b TEXT) ENGINE=InnoDB; CREATE TABLE t1 (a INT PRIMARY KEY, b TEXT) ENGINE=InnoDB;
CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=InnoDB; CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=InnoDB;

View File

@@ -1,10 +1,17 @@
--source include/have_innodb.inc --source include/have_innodb.inc
SET @innodb_defragment_orig=@@GLOBAL.innodb_defragment; SET @innodb_defragment_orig=@@GLOBAL.innodb_defragment;
SET @innodb_optimize_fulltext_orig=@@GLOBAL.innodb_optimize_fulltext_only;
SET GLOBAL innodb_defragment = 1; SET GLOBAL innodb_defragment = 1;
SET GLOBAL innodb_optimize_fulltext_only = 0;
# Small tests copied from innodb.innodb_defragment --echo #
CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(256), KEY(a, b)) ENGINE=INNODB; --echo # MDEV-12198 innodb_defragment=1 crashes server on
--echo # OPTIMIZE TABLE when FULLTEXT index exists
--echo #
CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(256),
KEY(a, b), FULLTEXT KEY(b)) ENGINE=INNODB;
OPTIMIZE TABLE t1; OPTIMIZE TABLE t1;
INSERT INTO t1 VALUES (100000, REPEAT('A', 256)); INSERT INTO t1 VALUES (100000, REPEAT('A', 256));
@@ -13,16 +20,17 @@ INSERT INTO t1 VALUES (300000, REPEAT('A', 256));
INSERT INTO t1 VALUES (400000, REPEAT('A', 256)); INSERT INTO t1 VALUES (400000, REPEAT('A', 256));
OPTIMIZE TABLE t1; OPTIMIZE TABLE t1;
DROP TABLE t1;
--echo # --echo #
--echo # MDEV-12198 innodb_defragment=1 crashes server on --echo # MDEV-15824 innodb_defragment=ON trumps
--echo # OPTIMIZE TABLE when FULLTEXT index exists --echo # innodb_optimize_fulltext_only=ON in OPTIMIZE TABLE
--echo # --echo #
CREATE TABLE t1 (c TEXT, FULLTEXT KEY (c)) ENGINE=InnoDB; SET GLOBAL innodb_optimize_fulltext_only = 1;
OPTIMIZE TABLE t1; OPTIMIZE TABLE t1;
SET GLOBAL innodb_defragment = 0;
OPTIMIZE TABLE t1;
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (c POINT PRIMARY KEY, SPATIAL INDEX(c)) ENGINE=InnoDB; CREATE TABLE t1 (c POINT PRIMARY KEY, SPATIAL INDEX(c)) ENGINE=InnoDB;
@@ -30,3 +38,4 @@ OPTIMIZE TABLE t1;
DROP TABLE t1; DROP TABLE t1;
SET GLOBAL innodb_defragment = @innodb_defragment_orig; SET GLOBAL innodb_defragment = @innodb_defragment_orig;
SET GLOBAL innodb_optimize_fulltext_only = @innodb_optimize_fulltext_orig;

View File

@@ -40,57 +40,6 @@ Modified 30/07/2014 Jan Lindström jan.lindstrom@mariadb.com
#include <list> #include <list>
/**************************************************//**
Custom nullptr implementation for under g++ 4.6
*******************************************************/
// #pragma once
/*
namespace std
{
// based on SC22/WG21/N2431 = J16/07-0301
struct nullptr_t
{
template<typename any> operator any * () const
{
return 0;
}
template<class any, typename T> operator T any:: * () const
{
return 0;
}
#ifdef _MSC_VER
struct pad {};
pad __[sizeof(void*)/sizeof(pad)];
#else
char __[sizeof(void*)];
#endif
private:
// nullptr_t();// {}
// nullptr_t(const nullptr_t&);
// void operator = (const nullptr_t&);
void operator &() const;
template<typename any> void operator +(any) const
{
// I Love MSVC 2005!
}
template<typename any> void operator -(any) const
{
// I Love MSVC 2005!
}
};
static const nullptr_t __nullptr = {};
}
#ifndef nullptr
#define nullptr std::__nullptr
#endif
*/
/**************************************************//**
End of Custom nullptr implementation for under g++ 4.6
*******************************************************/
/* When there's no work, either because defragment is disabled, or because no /* When there's no work, either because defragment is disabled, or because no
query is submitted, thread checks state every BTR_DEFRAGMENT_SLEEP_IN_USECS.*/ query is submitted, thread checks state every BTR_DEFRAGMENT_SLEEP_IN_USECS.*/
#define BTR_DEFRAGMENT_SLEEP_IN_USECS 1000000 #define BTR_DEFRAGMENT_SLEEP_IN_USECS 1000000

View File

@@ -1140,7 +1140,7 @@ fil_mutex_enter_and_prepare_for_io(
/*===============================*/ /*===============================*/
ulint space_id) /*!< in: space id */ ulint space_id) /*!< in: space id */
{ {
for (ulint count = 0, count2 = 0;;) { for (ulint count = 0;;) {
mutex_enter(&fil_system->mutex); mutex_enter(&fil_system->mutex);
if (space_id >= SRV_LOG_SPACE_FIRST_ID) { if (space_id >= SRV_LOG_SPACE_FIRST_ID) {
@@ -1154,41 +1154,6 @@ fil_mutex_enter_and_prepare_for_io(
break; break;
} }
if (space->stop_ios) {
ut_ad(space->id != 0);
/* We are going to do a rename file and want to stop
new i/o's for a while. */
if (count2 > 20000) {
ib::warn() << "Tablespace " << space->name
<< " has i/o ops stopped for a long"
" time " << count2;
}
mutex_exit(&fil_system->mutex);
/* Wake the i/o-handler threads to make sure pending
i/o's are performed */
os_aio_simulated_wake_handler_threads();
/* The sleep here is just to give IO helper threads a
bit of time to do some work. It is not required that
all IO related to the tablespace being renamed must
be flushed here as we do fil_flush() in
fil_rename_tablespace() as well. */
os_thread_sleep(20000);
/* Flush tablespaces so that we can close modified
files in the LRU list */
fil_flush_file_spaces(FIL_TYPE_TABLESPACE);
os_thread_sleep(20000);
count2++;
continue;
}
fil_node_t* node = UT_LIST_GET_LAST(space->chain); fil_node_t* node = UT_LIST_GET_LAST(space->chain);
ut_ad(space->id == 0 ut_ad(space->id == 0
|| node == UT_LIST_GET_FIRST(space->chain)); || node == UT_LIST_GET_FIRST(space->chain));
@@ -3497,31 +3462,16 @@ fil_rename_tablespace(
const char* new_name, const char* new_name,
const char* new_path_in) const char* new_path_in)
{ {
bool sleep = false;
bool flush = false;
fil_space_t* space; fil_space_t* space;
fil_node_t* node; fil_node_t* node;
ulint count = 0;
ut_a(id != 0); ut_a(id != 0);
ut_ad(strchr(new_name, '/') != NULL); ut_ad(strchr(new_name, '/') != NULL);
retry:
count++;
if (!(count % 1000)) {
ib::warn() << "Cannot rename file " << old_path
<< " (space id " << id << "), retried " << count
<< " times."
" There are either pending IOs or flushes or"
" the file is being extended.";
}
mutex_enter(&fil_system->mutex); mutex_enter(&fil_system->mutex);
space = fil_space_get_by_id(id); space = fil_space_get_by_id(id);
DBUG_EXECUTE_IF("fil_rename_tablespace_failure_1", space = NULL; );
if (space == NULL) { if (space == NULL) {
ib::error() << "Cannot find space id " << id ib::error() << "Cannot find space id " << id
<< " in the tablespace memory cache, though the file '" << " in the tablespace memory cache, though the file '"
@@ -3532,64 +3482,26 @@ func_exit:
return(false); return(false);
} }
if (count > 25000) {
space->stop_ios = false;
goto func_exit;
}
if (space != fil_space_get_by_name(space->name)) { if (space != fil_space_get_by_name(space->name)) {
ib::error() << "Cannot find " << space->name ib::error() << "Cannot find " << space->name
<< " in tablespace memory cache"; << " in tablespace memory cache";
space->stop_ios = false;
goto func_exit; goto func_exit;
} }
if (fil_space_get_by_name(new_name)) { if (fil_space_get_by_name(new_name)) {
ib::error() << new_name ib::error() << new_name
<< " is already in tablespace memory cache"; << " is already in tablespace memory cache";
space->stop_ios = false;
goto func_exit; goto func_exit;
} }
/* We temporarily close the .ibd file because we do not trust that
operating systems can rename an open file. For the closing we have to
wait until there are no pending i/o's or flushes on the file. */
space->stop_ios = true;
/* The following code must change when InnoDB supports /* The following code must change when InnoDB supports
multiple datafiles per tablespace. */ multiple datafiles per tablespace. */
ut_a(UT_LIST_GET_LEN(space->chain) == 1); ut_a(UT_LIST_GET_LEN(space->chain) == 1);
node = UT_LIST_GET_FIRST(space->chain); node = UT_LIST_GET_FIRST(space->chain);
space->n_pending_ops++;
if (node->n_pending > 0
|| node->n_pending_flushes > 0
|| node->being_extended) {
/* There are pending i/o's or flushes or the file is
currently being extended, sleep for a while and
retry */
sleep = true;
} else if (node->modification_counter > node->flush_counter) {
/* Flush the space */
sleep = flush = true;
} else if (node->is_open()) {
/* Close the file */
fil_node_close_file(node);
}
mutex_exit(&fil_system->mutex); mutex_exit(&fil_system->mutex);
if (sleep) {
os_thread_sleep(20000);
if (flush) {
fil_flush(id);
}
sleep = flush = false;
goto retry;
}
ut_ad(space->stop_ios);
char* new_file_name = new_path_in == NULL char* new_file_name = new_path_in == NULL
? fil_make_filepath(NULL, new_name, IBD, false) ? fil_make_filepath(NULL, new_name, IBD, false)
: mem_strdup(new_path_in); : mem_strdup(new_path_in);
@@ -3615,23 +3527,17 @@ func_exit:
/* log_sys->mutex is above fil_system->mutex in the latching order */ /* log_sys->mutex is above fil_system->mutex in the latching order */
ut_ad(log_mutex_own()); ut_ad(log_mutex_own());
mutex_enter(&fil_system->mutex); mutex_enter(&fil_system->mutex);
ut_ad(space->n_pending_ops);
space->n_pending_ops--;
ut_ad(space->name == old_space_name); ut_ad(space->name == old_space_name);
/* We already checked these. */ /* We already checked these. */
ut_ad(space == fil_space_get_by_name(old_space_name)); ut_ad(space == fil_space_get_by_name(old_space_name));
ut_ad(!fil_space_get_by_name(new_space_name)); ut_ad(!fil_space_get_by_name(new_space_name));
ut_ad(node->name == old_file_name); ut_ad(node->name == old_file_name);
bool success; bool success = os_file_rename(
DBUG_EXECUTE_IF("fil_rename_tablespace_failure_2",
goto skip_rename; );
success = os_file_rename(
innodb_data_file_key, old_file_name, new_file_name); innodb_data_file_key, old_file_name, new_file_name);
DBUG_EXECUTE_IF("fil_rename_tablespace_failure_2",
skip_rename: success = false; );
ut_ad(node->name == old_file_name); ut_ad(node->name == old_file_name);
if (success) { if (success) {
@@ -3656,8 +3562,6 @@ func_exit:
old_space_name = new_space_name; old_space_name = new_space_name;
} }
ut_ad(space->stop_ios);
space->stop_ios = false;
mutex_exit(&fil_system->mutex); mutex_exit(&fil_system->mutex);
ut_free(old_file_name); ut_free(old_file_name);

View File

@@ -14626,6 +14626,7 @@ ha_innobase::optimize(
This works OK otherwise, but MySQL locks the entire table during This works OK otherwise, but MySQL locks the entire table during
calls to OPTIMIZE, which is undesirable. */ calls to OPTIMIZE, which is undesirable. */
bool try_alter = true;
/* TODO: Defragment is disabled for now */ /* TODO: Defragment is disabled for now */
if (srv_defragment) { if (srv_defragment) {
@@ -14634,17 +14635,15 @@ ha_innobase::optimize(
err = defragment_table(m_prebuilt->table->name.m_name, NULL, false); err = defragment_table(m_prebuilt->table->name.m_name, NULL, false);
if (err == 0) { if (err == 0) {
return (HA_ADMIN_OK); try_alter = false;
} else { } else {
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
err, err,
"InnoDB: Cannot defragment table %s: returned error code %d\n", "InnoDB: Cannot defragment table %s: returned error code %d\n",
m_prebuilt->table->name, err); m_prebuilt->table->name, err);
if (err == ER_SP_ALREADY_EXISTS) { if(err == ER_SP_ALREADY_EXISTS) {
return (HA_ADMIN_OK); try_alter = false;
} else {
return (HA_ADMIN_TRY_ALTER);
} }
} }
} }
@@ -14655,11 +14654,10 @@ ha_innobase::optimize(
fts_sync_table(m_prebuilt->table, false, true, false); fts_sync_table(m_prebuilt->table, false, true, false);
fts_optimize_table(m_prebuilt->table); fts_optimize_table(m_prebuilt->table);
} }
return(HA_ADMIN_OK); try_alter = false;
} else {
return(HA_ADMIN_TRY_ALTER);
} }
return try_alter ? HA_ADMIN_TRY_ALTER : HA_ADMIN_OK;
} }
/*******************************************************************//** /*******************************************************************//**

View File

@@ -89,10 +89,6 @@ struct fil_space_t {
Protected by log_sys->mutex. Protected by log_sys->mutex.
If and only if this is nonzero, the If and only if this is nonzero, the
tablespace will be in named_spaces. */ tablespace will be in named_spaces. */
bool stop_ios;/*!< true if we want to rename the
.ibd file of tablespace and want to
stop temporarily posting of new i/o
requests on the file */
bool stop_new_ops; bool stop_new_ops;
/*!< we set this true when we start /*!< we set this true when we start
deleting a single-table tablespace. deleting a single-table tablespace.

View File

@@ -1,7 +1,7 @@
/***************************************************************************** /*****************************************************************************
Copyright (c) 2013, 2014, Facebook, Inc. All Rights Reserved. Copyright (c) 2013, 2014, Facebook, Inc. All Rights Reserved.
Copyright (c) 2014, SkySQL Ab. All Rights Reserved. Copyright (c) 2014, 2018, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under 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 the terms of the GNU General Public License as published by the Free Software
@@ -19,7 +19,7 @@ this program; if not, write to the Free Software Foundation, Inc.,
/********************************************************************//** /********************************************************************//**
@file include/ut0timer.h @file include/ut0timer.h
Timer rountines Timer routines
Created 30/07/2014 Jan Lindström jan.lindstrom@skysql.com Created 30/07/2014 Jan Lindström jan.lindstrom@skysql.com
modified from https://github.com/facebook/mysql-5.6/commit/c75a413edeb96eb99bf11d7269bdfea06f96d6b6 modified from https://github.com/facebook/mysql-5.6/commit/c75a413edeb96eb99bf11d7269bdfea06f96d6b6
@@ -28,8 +28,6 @@ modified from https://github.com/facebook/mysql-5.6/commit/c75a413edeb96eb99bf11
#define ut0timer_h #define ut0timer_h
#include "univ.i" #include "univ.i"
#include "data0type.h"
#include <my_rdtsc.h>
/* Current timer stats */ /* Current timer stats */
extern struct my_timer_unit_info ut_timer; extern struct my_timer_unit_info ut_timer;
@@ -47,39 +45,6 @@ Initializes my_timer struct to contain the info for selected timer.*/
UNIV_INTERN UNIV_INTERN
void ut_init_timer(void); void ut_init_timer(void);
/**************************************************************//**
Return time passed since time then, automatically adjusted
for the estimated timer overhead.
@return time passed since "then" */
UNIV_INLINE
ulonglong
ut_timer_since(
/*===========*/
ulonglong then); /*!< in: time where to calculate */
/**************************************************************//**
Get time passed since "then", and update then to now
@return time passed sinche "then" */
UNIV_INLINE
ulonglong
ut_timer_since_and_update(
/*======================*/
ulonglong *then); /*!< in: time where to calculate */
/**************************************************************//**
Convert native timer units in a ulonglong into seconds in a double
@return time in a seconds */
UNIV_INLINE
double
ut_timer_to_seconds(
/*=================*/
ulonglong when); /*!< in: time where to calculate */
/**************************************************************//**
Convert native timer units in a ulonglong into milliseconds in a double
@return time in milliseconds */
UNIV_INLINE
double
ut_timer_to_milliseconds(
/*=====================*/
ulonglong when); /*!< in: time where to calculate */
/**************************************************************//** /**************************************************************//**
Convert native timer units in a ulonglong into microseconds in a double Convert native timer units in a ulonglong into microseconds in a double
@return time in microseconds */ @return time in microseconds */

View File

@@ -1,7 +1,7 @@
/***************************************************************************** /*****************************************************************************
Copyright (c) 2013, 2014, Facebook, Inc. All Rights Reserved. Copyright (c) 2013, 2014, Facebook, Inc. All Rights Reserved.
Copyright (c) 2014, SkySQL Ab. All Rights Reserved. Copyright (c) 2014, 2018, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under 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 the terms of the GNU General Public License as published by the Free Software
@@ -19,69 +19,12 @@ this program; if not, write to the Free Software Foundation, Inc.,
/********************************************************************//** /********************************************************************//**
@file include/ut0timer.ic @file include/ut0timer.ic
Timer rountines Timer routines
Created 30/07/2014 Jan Lindström jan.lindstrom@skysql.com Created 30/07/2014 Jan Lindström jan.lindstrom@skysql.com
modified from https://github.com/facebook/mysql-5.6/commit/c75a413edeb96eb99bf11d7269bdfea06f96d6b6 modified from https://github.com/facebook/mysql-5.6/commit/c75a413edeb96eb99bf11d7269bdfea06f96d6b6
*************************************************************************/ *************************************************************************/
/**************************************************************//**
Return time passed since time then, automatically adjusted
for the estimated timer overhead.
@return time passed since "then" */
UNIV_INLINE
ulonglong
ut_timer_since(
/*===========*/
ulonglong then) /*!< in: time where to calculate */
{
return (ut_timer_now() - then) - ut_timer.overhead;
}
/**************************************************************//**
Get time passed since "then", and update then to now
@return time passed sinche "then" */
UNIV_INLINE
ulonglong
ut_timer_since_and_update(
/*======================*/
ulonglong *then) /*!< in: time where to calculate */
{
ulonglong now = ut_timer_now();
ulonglong ret = (now - (*then)) - ut_timer.overhead;
*then = now;
return ret;
}
/**************************************************************//**
Convert native timer units in a ulonglong into seconds in a double
@return time in a seconds */
UNIV_INLINE
double
ut_timer_to_seconds(
/*=================*/
ulonglong when) /*!< in: time where to calculate */
{
double ret = (double)(when);
ret /= (double)(ut_timer.frequency);
return ret;
}
/**************************************************************//**
Convert native timer units in a ulonglong into milliseconds in a double
@return time in milliseconds */
UNIV_INLINE
double
ut_timer_to_milliseconds(
/*=====================*/
ulonglong when) /*!< in: time where to calculate */
{
double ret = (double)(when);
ret *= 1000.0;
ret /= (double)(ut_timer.frequency);
return ret;
}
/**************************************************************//** /**************************************************************//**
Convert native timer units in a ulonglong into microseconds in a double Convert native timer units in a ulonglong into microseconds in a double
@return time in microseconds */ @return time in microseconds */

View File

@@ -3891,7 +3891,8 @@ os_file_create_simple_func(
/* Use default security attributes and no template file. */ /* Use default security attributes and no template file. */
file = CreateFile( file = CreateFile(
(LPCTSTR) name, access, FILE_SHARE_READ, NULL, (LPCTSTR) name, access,
FILE_SHARE_READ | FILE_SHARE_DELETE, NULL,
create_flag, attributes, NULL); create_flag, attributes, NULL);
if (file == INVALID_HANDLE_VALUE) { if (file == INVALID_HANDLE_VALUE) {
@@ -4135,7 +4136,7 @@ os_file_create_func(
DWORD create_flag; DWORD create_flag;
DWORD share_mode = srv_operation != SRV_OPERATION_NORMAL DWORD share_mode = srv_operation != SRV_OPERATION_NORMAL
? FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE ? FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE
: FILE_SHARE_READ; : FILE_SHARE_READ | FILE_SHARE_DELETE;
if (create_mode != OS_FILE_OPEN && create_mode != OS_FILE_OPEN_RAW) { if (create_mode != OS_FILE_OPEN && create_mode != OS_FILE_OPEN_RAW) {
WAIT_ALLOW_WRITES(); WAIT_ALLOW_WRITES();
@@ -4341,7 +4342,7 @@ os_file_create_simple_no_error_handling_func(
DWORD attributes = 0; DWORD attributes = 0;
DWORD share_mode = srv_operation != SRV_OPERATION_NORMAL DWORD share_mode = srv_operation != SRV_OPERATION_NORMAL
? FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE ? FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE
: FILE_SHARE_READ; : FILE_SHARE_READ | FILE_SHARE_DELETE;
ut_a(name); ut_a(name);

View File

@@ -40,56 +40,6 @@ Modified 30/07/2014 Jan Lindström jan.lindstrom@mariadb.com
#include <list> #include <list>
/**************************************************//**
Custom nullptr implementation for under g++ 4.6
*******************************************************/
/*
// #pragma once
namespace std
{
// based on SC22/WG21/N2431 = J16/07-0301
struct nullptr_t
{
template<typename any> operator any * () const
{
return 0;
}
template<class any, typename T> operator T any:: * () const
{
return 0;
}
#ifdef _MSC_VER
struct pad {};
pad __[sizeof(void*)/sizeof(pad)];
#else
char __[sizeof(void*)];
#endif
private:
// nullptr_t();// {}
// nullptr_t(const nullptr_t&);
// void operator = (const nullptr_t&);
void operator &() const;
template<typename any> void operator +(any) const
{
// I Love MSVC 2005!
}
template<typename any> void operator -(any) const
{
// I Love MSVC 2005!
}
};
static const nullptr_t __nullptr = {};
}
#ifndef nullptr
#define nullptr std::__nullptr
#endif
*/
/**************************************************//**
End of Custom nullptr implementation for under g++ 4.6
*******************************************************/
/* When there's no work, either because defragment is disabled, or because no /* When there's no work, either because defragment is disabled, or because no
query is submitted, thread checks state every BTR_DEFRAGMENT_SLEEP_IN_USECS.*/ query is submitted, thread checks state every BTR_DEFRAGMENT_SLEEP_IN_USECS.*/
#define BTR_DEFRAGMENT_SLEEP_IN_USECS 1000000 #define BTR_DEFRAGMENT_SLEEP_IN_USECS 1000000

View File

@@ -1098,7 +1098,6 @@ fil_mutex_enter_and_prepare_for_io(
{ {
fil_space_t* space; fil_space_t* space;
ulint count = 0; ulint count = 0;
ulint count2 = 0;
retry: retry:
mutex_enter(&fil_system->mutex); mutex_enter(&fil_system->mutex);
@@ -1114,47 +1113,6 @@ retry:
return; return;
} }
if (space->stop_ios) {
ut_ad(space->id != 0);
/* We are going to do a rename file and want to stop new i/o's
for a while */
if (count2 > 20000) {
fputs("InnoDB: Warning: tablespace ", stderr);
ut_print_filename(stderr, space->name);
fprintf(stderr,
" has i/o ops stopped for a long time %lu\n",
(ulong) count2);
}
mutex_exit(&fil_system->mutex);
#ifndef UNIV_HOTBACKUP
/* Wake the i/o-handler threads to make sure pending
i/o's are performed */
os_aio_simulated_wake_handler_threads();
/* The sleep here is just to give IO helper threads a
bit of time to do some work. It is not required that
all IO related to the tablespace being renamed must
be flushed here as we do fil_flush() in
fil_rename_tablespace() as well. */
os_thread_sleep(20000);
#endif /* UNIV_HOTBACKUP */
/* Flush tablespaces so that we can close modified
files in the LRU list */
fil_flush_file_spaces(FIL_TABLESPACE);
os_thread_sleep(20000);
count2++;
goto retry;
}
fil_node_t* node = UT_LIST_GET_LAST(space->chain); fil_node_t* node = UT_LIST_GET_LAST(space->chain);
ut_ad(space->id == 0 || node == UT_LIST_GET_FIRST(space->chain)); ut_ad(space->id == 0 || node == UT_LIST_GET_FIRST(space->chain));
@@ -3249,7 +3207,6 @@ fil_rename_tablespace(
ibool success; ibool success;
fil_space_t* space; fil_space_t* space;
fil_node_t* node; fil_node_t* node;
ulint count = 0;
char* new_path; char* new_path;
char* old_name; char* old_name;
char* old_path; char* old_path;
@@ -3257,25 +3214,10 @@ fil_rename_tablespace(
ut_a(id != 0); ut_a(id != 0);
retry:
count++;
if (!(count % 1000)) {
ut_print_timestamp(stderr);
fputs(" InnoDB: Warning: problems renaming ", stderr);
ut_print_filename(stderr,
old_name_in ? old_name_in : not_given);
fputs(" to ", stderr);
ut_print_filename(stderr, new_name);
fprintf(stderr, ", %lu iterations\n", (ulong) count);
}
mutex_enter(&fil_system->mutex); mutex_enter(&fil_system->mutex);
space = fil_space_get_by_id(id); space = fil_space_get_by_id(id);
DBUG_EXECUTE_IF("fil_rename_tablespace_failure_1", space = NULL; );
if (space == NULL) { if (space == NULL) {
ib_logf(IB_LOG_LEVEL_ERROR, ib_logf(IB_LOG_LEVEL_ERROR,
"Cannot find space id %lu in the tablespace " "Cannot find space id %lu in the tablespace "
@@ -3287,54 +3229,11 @@ retry:
return(FALSE); return(FALSE);
} }
if (count > 25000) {
space->stop_ios = FALSE;
mutex_exit(&fil_system->mutex);
return(FALSE);
}
/* We temporarily close the .ibd file because we do not trust that
operating systems can rename an open file. For the closing we have to
wait until there are no pending i/o's or flushes on the file. */
space->stop_ios = TRUE;
/* The following code must change when InnoDB supports /* The following code must change when InnoDB supports
multiple datafiles per tablespace. */ multiple datafiles per tablespace. */
ut_a(UT_LIST_GET_LEN(space->chain) == 1); ut_a(UT_LIST_GET_LEN(space->chain) == 1);
node = UT_LIST_GET_FIRST(space->chain); node = UT_LIST_GET_FIRST(space->chain);
if (node->n_pending > 0
|| node->n_pending_flushes > 0
|| node->being_extended) {
/* There are pending i/o's or flushes or the file is
currently being extended, sleep for a while and
retry */
mutex_exit(&fil_system->mutex);
os_thread_sleep(20000);
goto retry;
} else if (node->modification_counter > node->flush_counter) {
/* Flush the space */
mutex_exit(&fil_system->mutex);
os_thread_sleep(20000);
fil_flush(id);
goto retry;
} else if (node->open) {
/* Close the file */
fil_node_close_file(node, fil_system);
}
/* Check that the old name in the space is right */ /* Check that the old name in the space is right */
if (old_name_in) { if (old_name_in) {
@@ -3353,17 +3252,9 @@ retry:
space, node, new_name, new_path); space, node, new_name, new_path);
if (success) { if (success) {
DBUG_EXECUTE_IF("fil_rename_tablespace_failure_2",
goto skip_second_rename; );
success = os_file_rename( success = os_file_rename(
innodb_file_data_key, old_path, new_path); innodb_file_data_key, old_path, new_path);
DBUG_EXECUTE_IF("fil_rename_tablespace_failure_2",
skip_second_rename:
success = FALSE; );
if (!success) { if (!success) {
/* We have to revert the changes we made /* We have to revert the changes we made
to the tablespace memory cache */ to the tablespace memory cache */
@@ -3373,8 +3264,6 @@ skip_second_rename:
} }
} }
space->stop_ios = FALSE;
mutex_exit(&fil_system->mutex); mutex_exit(&fil_system->mutex);
#ifndef UNIV_HOTBACKUP #ifndef UNIV_HOTBACKUP

View File

@@ -3231,8 +3231,7 @@ ha_innobase::ha_innobase(
(srv_force_primary_key ? HA_REQUIRE_PRIMARY_KEY : 0 ) | (srv_force_primary_key ? HA_REQUIRE_PRIMARY_KEY : 0 ) |
HA_CAN_FULLTEXT_EXT | HA_CAN_EXPORT), HA_CAN_FULLTEXT_EXT | HA_CAN_EXPORT),
start_of_scan(0), start_of_scan(0),
num_write_row(0), num_write_row(0)
ha_partition_stats(NULL)
{} {}
/*********************************************************************//** /*********************************************************************//**
@@ -14486,6 +14485,7 @@ ha_innobase::optimize(
This works OK otherwise, but MySQL locks the entire table during This works OK otherwise, but MySQL locks the entire table during
calls to OPTIMIZE, which is undesirable. */ calls to OPTIMIZE, which is undesirable. */
bool try_alter = true;
if (srv_defragment) { if (srv_defragment) {
int err; int err;
@@ -14493,7 +14493,7 @@ ha_innobase::optimize(
err = defragment_table(prebuilt->table->name, NULL, false); err = defragment_table(prebuilt->table->name, NULL, false);
if (err == 0) { if (err == 0) {
return (HA_ADMIN_OK); try_alter = false;
} else { } else {
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
err, err,
@@ -14501,9 +14501,7 @@ ha_innobase::optimize(
prebuilt->table->name, err); prebuilt->table->name, err);
if(err == ER_SP_ALREADY_EXISTS) { if(err == ER_SP_ALREADY_EXISTS) {
return (HA_ADMIN_OK); try_alter = false;
} else {
return (HA_ADMIN_TRY_ALTER);
} }
} }
} }
@@ -14514,11 +14512,10 @@ ha_innobase::optimize(
fts_sync_table(prebuilt->table, false, true, false); fts_sync_table(prebuilt->table, false, true, false);
fts_optimize_table(prebuilt->table); fts_optimize_table(prebuilt->table);
} }
return(HA_ADMIN_OK); try_alter = false;
} else {
return(HA_ADMIN_TRY_ALTER);
} }
return try_alter ? HA_ADMIN_TRY_ALTER : HA_ADMIN_OK;
} }
/*******************************************************************//** /*******************************************************************//**
@@ -17490,13 +17487,6 @@ innodb_max_dirty_pages_pct_lwm_update(
srv_max_dirty_pages_pct_lwm = in_val; srv_max_dirty_pages_pct_lwm = in_val;
} }
UNIV_INTERN
void
ha_innobase::set_partition_owner_stats(ha_statistics *stats)
{
ha_partition_stats= stats;
}
/************************************************************//** /************************************************************//**
Validate the file format name and return its corresponding id. Validate the file format name and return its corresponding id.
@return valid file format id */ @return valid file format id */

View File

@@ -1,7 +1,7 @@
/***************************************************************************** /*****************************************************************************
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2000, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2013, 2017, MariaDB Corporation. Copyright (c) 2013, 2018, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under 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 the terms of the GNU General Public License as published by the Free Software
@@ -100,8 +100,6 @@ class ha_innobase: public handler
or undefined */ or undefined */
uint num_write_row; /*!< number of write_row() calls */ uint num_write_row; /*!< number of write_row() calls */
ha_statistics* ha_partition_stats; /*!< stats of the partition owner
handler (if there is one) */
uint store_key_val_for_row(uint keynr, char* buff, uint buff_len, uint store_key_val_for_row(uint keynr, char* buff, uint buff_len,
const uchar* record); const uchar* record);
inline void update_thd(THD* thd); inline void update_thd(THD* thd);
@@ -318,7 +316,6 @@ class ha_innobase: public handler
Alter_inplace_info* ha_alter_info, Alter_inplace_info* ha_alter_info,
bool commit); bool commit);
/** @} */ /** @} */
void set_partition_owner_stats(ha_statistics *stats);
bool check_if_incompatible_data(HA_CREATE_INFO *info, bool check_if_incompatible_data(HA_CREATE_INFO *info,
uint table_changes); uint table_changes);

View File

@@ -275,10 +275,6 @@ struct fil_space_t {
an insert buffer merge request for a an insert buffer merge request for a
page because it actually was for the page because it actually was for the
previous incarnation of the space */ previous incarnation of the space */
ibool stop_ios;/*!< TRUE if we want to rename the
.ibd file of tablespace and want to
stop temporarily posting of new i/o
requests on the file */
bool stop_new_ops; bool stop_new_ops;
/*!< we set this true when we start /*!< we set this true when we start
deleting a single-table tablespace. deleting a single-table tablespace.

View File

@@ -1,7 +1,7 @@
/***************************************************************************** /*****************************************************************************
Copyright (c) 2013, 2014, Facebook, Inc. All Rights Reserved. Copyright (c) 2013, 2014, Facebook, Inc. All Rights Reserved.
Copyright (c) 2014, SkySQL Ab. All Rights Reserved. Copyright (c) 2014, 2018, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under 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 the terms of the GNU General Public License as published by the Free Software
@@ -19,7 +19,7 @@ this program; if not, write to the Free Software Foundation, Inc.,
/********************************************************************//** /********************************************************************//**
@file include/ut0timer.h @file include/ut0timer.h
Timer rountines Timer routines
Created 30/07/2014 Jan Lindström jan.lindstrom@skysql.com Created 30/07/2014 Jan Lindström jan.lindstrom@skysql.com
modified from https://github.com/facebook/mysql-5.6/commit/c75a413edeb96eb99bf11d7269bdfea06f96d6b6 modified from https://github.com/facebook/mysql-5.6/commit/c75a413edeb96eb99bf11d7269bdfea06f96d6b6
@@ -28,8 +28,6 @@ modified from https://github.com/facebook/mysql-5.6/commit/c75a413edeb96eb99bf11
#define ut0timer_h #define ut0timer_h
#include "univ.i" #include "univ.i"
#include "data0type.h"
#include <my_rdtsc.h>
/* Current timer stats */ /* Current timer stats */
extern struct my_timer_unit_info ut_timer; extern struct my_timer_unit_info ut_timer;
@@ -47,39 +45,6 @@ Initializes my_timer struct to contain the info for selected timer.*/
UNIV_INTERN UNIV_INTERN
void ut_init_timer(void); void ut_init_timer(void);
/**************************************************************//**
Return time passed since time then, automatically adjusted
for the estimated timer overhead.
@return time passed since "then" */
UNIV_INLINE
ulonglong
ut_timer_since(
/*===========*/
ulonglong then); /*!< in: time where to calculate */
/**************************************************************//**
Get time passed since "then", and update then to now
@return time passed sinche "then" */
UNIV_INLINE
ulonglong
ut_timer_since_and_update(
/*======================*/
ulonglong *then); /*!< in: time where to calculate */
/**************************************************************//**
Convert native timer units in a ulonglong into seconds in a double
@return time in a seconds */
UNIV_INLINE
double
ut_timer_to_seconds(
/*=================*/
ulonglong when); /*!< in: time where to calculate */
/**************************************************************//**
Convert native timer units in a ulonglong into milliseconds in a double
@return time in milliseconds */
UNIV_INLINE
double
ut_timer_to_milliseconds(
/*=====================*/
ulonglong when); /*!< in: time where to calculate */
/**************************************************************//** /**************************************************************//**
Convert native timer units in a ulonglong into microseconds in a double Convert native timer units in a ulonglong into microseconds in a double
@return time in microseconds */ @return time in microseconds */

View File

@@ -1,7 +1,7 @@
/***************************************************************************** /*****************************************************************************
Copyright (c) 2013, 2014, Facebook, Inc. All Rights Reserved. Copyright (c) 2013, 2014, Facebook, Inc. All Rights Reserved.
Copyright (c) 2014, SkySQL Ab. All Rights Reserved. Copyright (c) 2014, 2018, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under 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 the terms of the GNU General Public License as published by the Free Software
@@ -19,69 +19,12 @@ this program; if not, write to the Free Software Foundation, Inc.,
/********************************************************************//** /********************************************************************//**
@file include/ut0timer.ic @file include/ut0timer.ic
Timer rountines Timer routines
Created 30/07/2014 Jan Lindström jan.lindstrom@skysql.com Created 30/07/2014 Jan Lindström jan.lindstrom@skysql.com
modified from https://github.com/facebook/mysql-5.6/commit/c75a413edeb96eb99bf11d7269bdfea06f96d6b6 modified from https://github.com/facebook/mysql-5.6/commit/c75a413edeb96eb99bf11d7269bdfea06f96d6b6
*************************************************************************/ *************************************************************************/
/**************************************************************//**
Return time passed since time then, automatically adjusted
for the estimated timer overhead.
@return time passed since "then" */
UNIV_INLINE
ulonglong
ut_timer_since(
/*===========*/
ulonglong then) /*!< in: time where to calculate */
{
return (ut_timer_now() - then) - ut_timer.overhead;
}
/**************************************************************//**
Get time passed since "then", and update then to now
@return time passed sinche "then" */
UNIV_INLINE
ulonglong
ut_timer_since_and_update(
/*======================*/
ulonglong *then) /*!< in: time where to calculate */
{
ulonglong now = ut_timer_now();
ulonglong ret = (now - (*then)) - ut_timer.overhead;
*then = now;
return ret;
}
/**************************************************************//**
Convert native timer units in a ulonglong into seconds in a double
@return time in a seconds */
UNIV_INLINE
double
ut_timer_to_seconds(
/*=================*/
ulonglong when) /*!< in: time where to calculate */
{
double ret = (double)(when);
ret /= (double)(ut_timer.frequency);
return ret;
}
/**************************************************************//**
Convert native timer units in a ulonglong into milliseconds in a double
@return time in milliseconds */
UNIV_INLINE
double
ut_timer_to_milliseconds(
/*=====================*/
ulonglong when) /*!< in: time where to calculate */
{
double ret = (double)(when);
ret *= 1000.0;
ret /= (double)(ut_timer.frequency);
return ret;
}
/**************************************************************//** /**************************************************************//**
Convert native timer units in a ulonglong into microseconds in a double Convert native timer units in a ulonglong into microseconds in a double
@return time in microseconds */ @return time in microseconds */

View File

@@ -1437,7 +1437,8 @@ os_file_create_simple_func(
/* Use default security attributes and no template file. */ /* Use default security attributes and no template file. */
file = CreateFile( file = CreateFile(
(LPCTSTR) name, access, FILE_SHARE_READ, NULL, (LPCTSTR) name, access,
FILE_SHARE_READ | FILE_SHARE_DELETE, NULL,
create_flag, attributes, NULL); create_flag, attributes, NULL);
if (file == INVALID_HANDLE_VALUE) { if (file == INVALID_HANDLE_VALUE) {
@@ -1603,7 +1604,7 @@ os_file_create_simple_no_error_handling_func(
DWORD access; DWORD access;
DWORD create_flag; DWORD create_flag;
DWORD attributes = 0; DWORD attributes = 0;
DWORD share_mode = FILE_SHARE_READ; DWORD share_mode = FILE_SHARE_READ | FILE_SHARE_DELETE;
ut_a(name); ut_a(name);
ut_a(!(create_mode & OS_FILE_ON_ERROR_SILENT)); ut_a(!(create_mode & OS_FILE_ON_ERROR_SILENT));
@@ -1925,7 +1926,7 @@ os_file_create_func(
#ifdef __WIN__ #ifdef __WIN__
DWORD create_flag; DWORD create_flag;
DWORD share_mode = FILE_SHARE_READ; DWORD share_mode = FILE_SHARE_READ | FILE_SHARE_DELETE;
on_error_no_exit = create_mode & OS_FILE_ON_ERROR_NO_EXIT on_error_no_exit = create_mode & OS_FILE_ON_ERROR_NO_EXIT
? TRUE : FALSE; ? TRUE : FALSE;

View File

@@ -41,13 +41,20 @@ ELSE()
SET(inst_location ${INSTALL_SUPPORTFILESDIR}) SET(inst_location ${INSTALL_SUPPORTFILESDIR})
ENDIF() ENDIF()
FOREACH(inifile my-huge my-innodb-heavy-4G my-large my-medium my-small wsrep) FOREACH(inifile my-huge my-innodb-heavy-4G my-large my-medium my-small)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${inifile}.cnf.sh CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${inifile}.cnf.sh
${CMAKE_CURRENT_BINARY_DIR}/${inifile}.${ini_file_extension} @ONLY) ${CMAKE_CURRENT_BINARY_DIR}/${inifile}.${ini_file_extension} @ONLY)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${inifile}.${ini_file_extension} INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${inifile}.${ini_file_extension}
DESTINATION ${inst_location} COMPONENT IniFiles) DESTINATION ${inst_location} COMPONENT IniFiles)
ENDFOREACH() ENDFOREACH()
IF(WITH_WSREP)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/wsrep.cnf.sh
${CMAKE_CURRENT_BINARY_DIR}/wsrep.${ini_file_extension} @ONLY)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/wsrep.${ini_file_extension}
DESTINATION ${inst_location} COMPONENT IniFiles)
ENDIF()
IF(UNIX) IF(UNIX)
SET(prefix ${CMAKE_INSTALL_PREFIX}) SET(prefix ${CMAKE_INSTALL_PREFIX})
FOREACH(script mysqld_multi.server mysql-log-rotate binary-configure wsrep_notify) FOREACH(script mysqld_multi.server mysql-log-rotate binary-configure wsrep_notify)