Merge 10.2 into 10.3
This commit is contained in:
commit
62d21ddac1
@ -1203,6 +1203,7 @@ cleanup:
|
||||
|
||||
|
||||
|
||||
static
|
||||
bool
|
||||
backup_files(const char *from, bool prep_mode)
|
||||
{
|
||||
|
@ -172,7 +172,6 @@ typedef struct xb_filter_entry_struct xb_filter_entry_t;
|
||||
lsn_t checkpoint_lsn_start;
|
||||
lsn_t checkpoint_no_start;
|
||||
static lsn_t log_copy_scanned_lsn;
|
||||
static bool log_copying;
|
||||
static bool log_copying_running;
|
||||
static bool io_watching_thread_running;
|
||||
|
||||
@ -202,9 +201,9 @@ my_bool opt_ssl_verify_server_cert;
|
||||
/* === metadata of backup === */
|
||||
#define XTRABACKUP_METADATA_FILENAME "xtrabackup_checkpoints"
|
||||
char metadata_type[30] = ""; /*[full-backuped|log-applied|incremental]*/
|
||||
lsn_t metadata_from_lsn;
|
||||
static lsn_t metadata_from_lsn;
|
||||
lsn_t metadata_to_lsn;
|
||||
lsn_t metadata_last_lsn;
|
||||
static lsn_t metadata_last_lsn;
|
||||
|
||||
static ds_file_t* dst_log_file;
|
||||
|
||||
@ -2442,25 +2441,12 @@ skip:
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
/** How to copy a redo log segment in backup */
|
||||
enum copy_logfile {
|
||||
/** Initial copying: copy at least one block */
|
||||
COPY_FIRST,
|
||||
/** Tracking while copying data files */
|
||||
COPY_ONLINE,
|
||||
/** Final copying: copy until the end of the log */
|
||||
COPY_LAST
|
||||
};
|
||||
|
||||
/** Copy redo log blocks to the data sink.
|
||||
@param[in] copy how to copy the log
|
||||
@param[in] start_lsn buffer start LSN
|
||||
@param[in] end_lsn buffer end LSN
|
||||
@return last scanned LSN (equals to last copied LSN if copy=COPY_LAST)
|
||||
@param start_lsn buffer start LSN
|
||||
@param end_lsn buffer end LSN
|
||||
@return last scanned LSN
|
||||
@retval 0 on failure */
|
||||
static
|
||||
lsn_t
|
||||
xtrabackup_copy_log(copy_logfile copy, lsn_t start_lsn, lsn_t end_lsn)
|
||||
static lsn_t xtrabackup_copy_log(lsn_t start_lsn, lsn_t end_lsn)
|
||||
{
|
||||
lsn_t scanned_lsn = start_lsn;
|
||||
const byte* log_block = log_sys.buf;
|
||||
@ -2475,6 +2461,9 @@ xtrabackup_copy_log(copy_logfile copy, lsn_t start_lsn, lsn_t end_lsn)
|
||||
&& scanned_checkpoint - checkpoint >= 0x80000000UL) {
|
||||
/* Garbage from a log buffer flush which was made
|
||||
before the most recent database recovery */
|
||||
msg("mariabackup: checkpoint wrap: "
|
||||
LSN_PF ",%zx,%zx\n",
|
||||
scanned_lsn, scanned_checkpoint, checkpoint);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -2495,6 +2484,8 @@ xtrabackup_copy_log(copy_logfile copy, lsn_t start_lsn, lsn_t end_lsn)
|
||||
>= OS_FILE_LOG_BLOCK_SIZE - LOG_BLOCK_TRL_SIZE
|
||||
|| data_len <= LOG_BLOCK_HDR_SIZE) {
|
||||
/* We got a garbage block (abrupt end of the log). */
|
||||
msg("mariabackup: garbage block: " LSN_PF ",%zu\n",
|
||||
scanned_lsn, data_len);
|
||||
break;
|
||||
} else {
|
||||
/* We got a partial block (abrupt end of the log). */
|
||||
@ -2514,7 +2505,7 @@ xtrabackup_copy_log(copy_logfile copy, lsn_t start_lsn, lsn_t end_lsn)
|
||||
|
||||
log_sys.log.scanned_lsn = scanned_lsn;
|
||||
|
||||
end_lsn = copy == COPY_LAST
|
||||
end_lsn = metadata_to_lsn
|
||||
? ut_uint64_align_up(scanned_lsn, OS_FILE_LOG_BLOCK_SIZE)
|
||||
: scanned_lsn & ~lsn_t(OS_FILE_LOG_BLOCK_SIZE - 1);
|
||||
|
||||
@ -2534,10 +2525,8 @@ xtrabackup_copy_log(copy_logfile copy, lsn_t start_lsn, lsn_t end_lsn)
|
||||
}
|
||||
|
||||
/** Copy redo log until the current end of the log is reached
|
||||
@param copy how to copy the log
|
||||
@return whether the operation failed */
|
||||
static bool
|
||||
xtrabackup_copy_logfile(copy_logfile copy)
|
||||
static bool xtrabackup_copy_logfile()
|
||||
{
|
||||
ut_a(dst_log_file != NULL);
|
||||
ut_ad(recv_sys != NULL);
|
||||
@ -2550,32 +2539,28 @@ xtrabackup_copy_logfile(copy_logfile copy)
|
||||
|
||||
start_lsn = ut_uint64_align_down(log_copy_scanned_lsn,
|
||||
OS_FILE_LOG_BLOCK_SIZE);
|
||||
/* When copying the first or last part of the log, retry a few
|
||||
times to ensure that all log up to the last checkpoint will be
|
||||
read. */
|
||||
do {
|
||||
end_lsn = start_lsn + RECV_SCAN_SIZE;
|
||||
|
||||
xtrabackup_io_throttling();
|
||||
|
||||
log_mutex_enter();
|
||||
|
||||
lsn_t lsn= start_lsn;
|
||||
for(int retries= 0; retries < 100; retries++) {
|
||||
if (log_sys.log.read_log_seg(&lsn, end_lsn)) {
|
||||
for (int retries= 0; retries < 100; retries++) {
|
||||
if (log_sys.log.read_log_seg(&lsn, end_lsn)
|
||||
|| lsn != start_lsn) {
|
||||
break;
|
||||
}
|
||||
msg("Retrying read of a redo log block");
|
||||
msg("Retrying read of log at LSN=" LSN_PF "\n", lsn);
|
||||
my_sleep(1000);
|
||||
}
|
||||
|
||||
start_lsn = xtrabackup_copy_log(copy, start_lsn, lsn);
|
||||
start_lsn = (lsn == start_lsn)
|
||||
? 0 : xtrabackup_copy_log(start_lsn, lsn);
|
||||
|
||||
log_mutex_exit();
|
||||
|
||||
if (!start_lsn) {
|
||||
ds_close(dst_log_file);
|
||||
dst_log_file = NULL;
|
||||
msg("mariabackup: Error: xtrabackup_copy_logfile()"
|
||||
" failed.\n");
|
||||
return(true);
|
||||
@ -2601,12 +2586,23 @@ static os_thread_ret_t DECLARE_THREAD(log_copying_thread)(void*)
|
||||
*/
|
||||
my_thread_init();
|
||||
|
||||
do {
|
||||
for (;;) {
|
||||
os_event_reset(log_copying_stop);
|
||||
os_event_wait_time_low(log_copying_stop,
|
||||
xtrabackup_log_copy_interval * 1000ULL,
|
||||
0);
|
||||
} while (log_copying && xtrabackup_copy_logfile(COPY_ONLINE));
|
||||
if (xtrabackup_copy_logfile()) {
|
||||
break;
|
||||
}
|
||||
|
||||
log_mutex_enter();
|
||||
bool completed = metadata_to_lsn
|
||||
&& metadata_to_lsn < log_copy_scanned_lsn;
|
||||
log_mutex_exit();
|
||||
if (completed) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
log_copying_running = false;
|
||||
my_thread_end();
|
||||
@ -2621,7 +2617,7 @@ static os_thread_ret_t DECLARE_THREAD(io_watching_thread)(void*)
|
||||
/* currently, for --backup only */
|
||||
ut_a(xtrabackup_backup);
|
||||
|
||||
while (log_copying) {
|
||||
while (log_copying_running && !metadata_to_lsn) {
|
||||
os_thread_sleep(1000000); /*1 sec*/
|
||||
io_ticket = xtrabackup_throttle;
|
||||
os_event_set(wait_throttle);
|
||||
@ -3638,16 +3634,16 @@ end:
|
||||
|
||||
static void stop_backup_threads()
|
||||
{
|
||||
log_copying = false;
|
||||
|
||||
if (log_copying_stop) {
|
||||
if (log_copying_stop && log_copying_running) {
|
||||
os_event_set(log_copying_stop);
|
||||
msg("mariabackup: Stopping log copying thread.\n");
|
||||
fputs("mariabackup: Stopping log copying thread", stderr);
|
||||
fflush(stderr);
|
||||
while (log_copying_running) {
|
||||
msg(".");
|
||||
putc('.', stderr);
|
||||
fflush(stderr);
|
||||
os_thread_sleep(200000); /*0.2 sec*/
|
||||
}
|
||||
msg("\n");
|
||||
putc('\n', stderr);
|
||||
os_event_destroy(log_copying_stop);
|
||||
}
|
||||
|
||||
@ -3662,10 +3658,10 @@ static void stop_backup_threads()
|
||||
|
||||
/** Implement the core of --backup
|
||||
@return whether the operation succeeded */
|
||||
static
|
||||
bool
|
||||
xtrabackup_backup_low()
|
||||
static bool xtrabackup_backup_low()
|
||||
{
|
||||
ut_ad(!metadata_to_lsn);
|
||||
|
||||
/* read the latest checkpoint lsn */
|
||||
{
|
||||
ulint max_cp_field;
|
||||
@ -3674,13 +3670,15 @@ xtrabackup_backup_low()
|
||||
|
||||
if (recv_find_max_checkpoint(&max_cp_field) == DB_SUCCESS
|
||||
&& log_sys.log.format != 0) {
|
||||
if (max_cp_field == LOG_CHECKPOINT_1) {
|
||||
log_header_read(max_cp_field);
|
||||
}
|
||||
metadata_to_lsn = mach_read_from_8(
|
||||
log_sys.checkpoint_buf + LOG_CHECKPOINT_LSN);
|
||||
msg("mariabackup: The latest check point"
|
||||
" (for incremental): '" LSN_PF "'\n",
|
||||
metadata_to_lsn);
|
||||
} else {
|
||||
metadata_to_lsn = 0;
|
||||
msg("mariabackup: Error: recv_find_max_checkpoint() failed.\n");
|
||||
}
|
||||
log_mutex_exit();
|
||||
@ -3688,11 +3686,7 @@ xtrabackup_backup_low()
|
||||
|
||||
stop_backup_threads();
|
||||
|
||||
if (!dst_log_file || xtrabackup_copy_logfile(COPY_LAST)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ds_close(dst_log_file)) {
|
||||
if (ds_close(dst_log_file) || !metadata_to_lsn) {
|
||||
dst_log_file = NULL;
|
||||
return false;
|
||||
}
|
||||
@ -3771,6 +3765,7 @@ xtrabackup_backup_func()
|
||||
srv_read_only_mode = TRUE;
|
||||
|
||||
srv_operation = SRV_OPERATION_BACKUP;
|
||||
metadata_to_lsn = 0;
|
||||
|
||||
if (xb_close_files)
|
||||
msg("mariabackup: warning: close-files specified. Use it "
|
||||
@ -3781,7 +3776,12 @@ xtrabackup_backup_func()
|
||||
/* initialize components */
|
||||
if(innodb_init_param()) {
|
||||
fail:
|
||||
metadata_to_lsn = log_copying_running;
|
||||
stop_backup_threads();
|
||||
if (dst_log_file) {
|
||||
ds_close(dst_log_file);
|
||||
dst_log_file = NULL;
|
||||
}
|
||||
if (fil_system.is_initialised()) {
|
||||
innodb_shutdown();
|
||||
}
|
||||
@ -3996,9 +3996,7 @@ reread_log_header:
|
||||
goto log_write_fail;
|
||||
}
|
||||
|
||||
/* start flag */
|
||||
log_copying = TRUE;
|
||||
|
||||
log_copying_running = true;
|
||||
/* start io throttle */
|
||||
if(xtrabackup_throttle) {
|
||||
os_thread_id_t io_watching_thread_id;
|
||||
@ -4016,6 +4014,8 @@ reread_log_header:
|
||||
if (err != DB_SUCCESS) {
|
||||
msg("mariabackup: error: xb_load_tablespaces() failed with"
|
||||
" error %s.\n", ut_strerr(err));
|
||||
fail_before_log_copying_thread_start:
|
||||
log_copying_running = false;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@ -4023,11 +4023,10 @@ reread_log_header:
|
||||
log_copy_scanned_lsn = checkpoint_lsn_start;
|
||||
recv_sys->recovered_lsn = log_copy_scanned_lsn;
|
||||
|
||||
if (xtrabackup_copy_logfile(COPY_FIRST))
|
||||
goto fail;
|
||||
if (xtrabackup_copy_logfile())
|
||||
goto fail_before_log_copying_thread_start;
|
||||
|
||||
log_copying_stop = os_event_create(0);
|
||||
log_copying_running = true;
|
||||
os_thread_create(log_copying_thread, NULL, &log_copying_thread_id);
|
||||
|
||||
/* FLUSH CHANGED_PAGE_BITMAPS call */
|
||||
|
@ -56,9 +56,7 @@ extern xb_page_bitmap *changed_page_bitmap;
|
||||
extern char *xtrabackup_incremental;
|
||||
extern my_bool xtrabackup_incremental_force_scan;
|
||||
|
||||
extern lsn_t metadata_from_lsn;
|
||||
extern lsn_t metadata_to_lsn;
|
||||
extern lsn_t metadata_last_lsn;
|
||||
|
||||
extern xb_stream_fmt_t xtrabackup_stream_fmt;
|
||||
extern ibool xtrabackup_stream;
|
||||
|
@ -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 t2 (a INT PRIMARY KEY) ENGINE=InnoDB;
|
||||
CREATE TABLE t3 (a INT PRIMARY KEY, b TEXT, c TEXT) ENGINE=InnoDB;
|
||||
|
@ -1,6 +1,13 @@
|
||||
SET @innodb_defragment_orig=@@GLOBAL.innodb_defragment;
|
||||
SET @innodb_optimize_fulltext_orig=@@GLOBAL.innodb_optimize_fulltext_only;
|
||||
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;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 optimize status OK
|
||||
@ -11,12 +18,15 @@ INSERT INTO t1 VALUES (400000, REPEAT('A', 256));
|
||||
OPTIMIZE TABLE t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 optimize status OK
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# MDEV-12198 innodb_defragment=1 crashes server on
|
||||
# OPTIMIZE TABLE when FULLTEXT index exists
|
||||
# MDEV-15824 innodb_defragment=ON trumps
|
||||
# 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;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 optimize status OK
|
||||
@ -27,3 +37,4 @@ Table Op Msg_type Msg_text
|
||||
test.t1 optimize status OK
|
||||
DROP TABLE t1;
|
||||
SET GLOBAL innodb_defragment = @innodb_defragment_orig;
|
||||
SET GLOBAL innodb_optimize_fulltext_only = @innodb_optimize_fulltext_orig;
|
||||
|
@ -6,13 +6,13 @@
|
||||
# The 7000 in this test is a bit less than half the innodb_page_size.
|
||||
--source include/have_innodb_16k.inc
|
||||
|
||||
# DEBUG_SYNC must be compiled in.
|
||||
--source include/have_debug.inc
|
||||
--source include/have_debug_sync.inc
|
||||
|
||||
# Embedded server does not support restarting
|
||||
--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 t2 (a INT PRIMARY KEY) ENGINE=InnoDB;
|
||||
|
@ -1,10 +1,17 @@
|
||||
--source include/have_innodb.inc
|
||||
|
||||
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_optimize_fulltext_only = 0;
|
||||
|
||||
# Small tests copied from innodb.innodb_defragment
|
||||
CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(256), KEY(a, b)) ENGINE=INNODB;
|
||||
--echo #
|
||||
--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;
|
||||
|
||||
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));
|
||||
|
||||
OPTIMIZE TABLE t1;
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-12198 innodb_defragment=1 crashes server on
|
||||
--echo # OPTIMIZE TABLE when FULLTEXT index exists
|
||||
--echo # MDEV-15824 innodb_defragment=ON trumps
|
||||
--echo # innodb_optimize_fulltext_only=ON in OPTIMIZE TABLE
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (c TEXT, FULLTEXT KEY (c)) ENGINE=InnoDB;
|
||||
|
||||
SET GLOBAL innodb_optimize_fulltext_only = 1;
|
||||
OPTIMIZE TABLE t1;
|
||||
SET GLOBAL innodb_defragment = 0;
|
||||
OPTIMIZE TABLE t1;
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
CREATE TABLE t1 (c POINT PRIMARY KEY, SPATIAL INDEX(c)) ENGINE=InnoDB;
|
||||
@ -30,3 +38,4 @@ OPTIMIZE TABLE t1;
|
||||
DROP TABLE t1;
|
||||
|
||||
SET GLOBAL innodb_defragment = @innodb_defragment_orig;
|
||||
SET GLOBAL innodb_optimize_fulltext_only = @innodb_optimize_fulltext_orig;
|
||||
|
@ -40,57 +40,6 @@ Modified 30/07/2014 Jan Lindström jan.lindstrom@mariadb.com
|
||||
|
||||
#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
|
||||
query is submitted, thread checks state every BTR_DEFRAGMENT_SLEEP_IN_USECS.*/
|
||||
#define BTR_DEFRAGMENT_SLEEP_IN_USECS 1000000
|
||||
|
@ -1106,7 +1106,7 @@ fil_mutex_enter_and_prepare_for_io(
|
||||
/*===============================*/
|
||||
ulint space_id) /*!< in: space id */
|
||||
{
|
||||
for (ulint count = 0, count2 = 0;;) {
|
||||
for (ulint count = 0;;) {
|
||||
mutex_enter(&fil_system.mutex);
|
||||
|
||||
if (space_id >= SRV_LOG_SPACE_FIRST_ID) {
|
||||
@ -1120,41 +1120,6 @@ fil_mutex_enter_and_prepare_for_io(
|
||||
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);
|
||||
ut_ad(space->id == 0
|
||||
|| node == UT_LIST_GET_FIRST(space->chain));
|
||||
@ -3027,86 +2992,33 @@ fil_rename_tablespace(
|
||||
const char* new_name,
|
||||
const char* new_path_in)
|
||||
{
|
||||
bool sleep = false;
|
||||
bool flush = false;
|
||||
fil_space_t* space;
|
||||
fil_node_t* node;
|
||||
ulint count = 0;
|
||||
ut_a(id != 0);
|
||||
|
||||
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);
|
||||
|
||||
space = fil_space_get_by_id(id);
|
||||
|
||||
DBUG_EXECUTE_IF("fil_rename_tablespace_failure_1", space = NULL; );
|
||||
|
||||
if (space == NULL) {
|
||||
ib::error() << "Cannot find space id " << id
|
||||
<< " in the tablespace memory cache, though the file '"
|
||||
<< old_path
|
||||
<< "' in a rename operation should have that id.";
|
||||
func_exit:
|
||||
mutex_exit(&fil_system.mutex);
|
||||
return(false);
|
||||
}
|
||||
|
||||
if (count > 25000) {
|
||||
space->stop_ios = false;
|
||||
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
|
||||
multiple datafiles per tablespace. */
|
||||
ut_a(UT_LIST_GET_LEN(space->chain) == 1);
|
||||
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 */
|
||||
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);
|
||||
}
|
||||
space->n_pending_ops++;
|
||||
|
||||
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
|
||||
? fil_make_filepath(NULL, new_name, IBD, false)
|
||||
: mem_strdup(new_path_in);
|
||||
@ -3125,20 +3037,14 @@ func_exit:
|
||||
/* log_sys.mutex is above fil_system.mutex in the latching order */
|
||||
ut_ad(log_mutex_own());
|
||||
mutex_enter(&fil_system.mutex);
|
||||
ut_ad(space->n_pending_ops);
|
||||
space->n_pending_ops--;
|
||||
ut_ad(space->name == old_space_name);
|
||||
ut_ad(node->name == old_file_name);
|
||||
|
||||
bool success;
|
||||
|
||||
DBUG_EXECUTE_IF("fil_rename_tablespace_failure_2",
|
||||
goto skip_rename; );
|
||||
|
||||
success = os_file_rename(
|
||||
bool success = os_file_rename(
|
||||
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);
|
||||
|
||||
if (success) {
|
||||
@ -3159,8 +3065,6 @@ func_exit:
|
||||
old_space_name = new_space_name;
|
||||
}
|
||||
|
||||
ut_ad(space->stop_ios);
|
||||
space->stop_ios = false;
|
||||
mutex_exit(&fil_system.mutex);
|
||||
|
||||
ut_free(old_file_name);
|
||||
|
@ -14308,23 +14308,22 @@ ha_innobase::optimize(
|
||||
|
||||
This works OK otherwise, but MySQL locks the entire table during
|
||||
calls to OPTIMIZE, which is undesirable. */
|
||||
bool try_alter = true;
|
||||
|
||||
if (srv_defragment) {
|
||||
int err= defragment_table(
|
||||
m_prebuilt->table->name.m_name, NULL, false);
|
||||
|
||||
if (err == 0) {
|
||||
return (HA_ADMIN_OK);
|
||||
try_alter = false;
|
||||
} else {
|
||||
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
|
||||
uint(err),
|
||||
"InnoDB: Cannot defragment table %s: returned error code %d\n",
|
||||
m_prebuilt->table->name, err);
|
||||
|
||||
if (err == ER_SP_ALREADY_EXISTS) {
|
||||
return (HA_ADMIN_OK);
|
||||
} else {
|
||||
return (HA_ADMIN_TRY_ALTER);
|
||||
if(err == ER_SP_ALREADY_EXISTS) {
|
||||
try_alter = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -14335,11 +14334,10 @@ ha_innobase::optimize(
|
||||
fts_sync_table(m_prebuilt->table, false, true, false);
|
||||
fts_optimize_table(m_prebuilt->table);
|
||||
}
|
||||
return(HA_ADMIN_OK);
|
||||
} else {
|
||||
|
||||
return(HA_ADMIN_TRY_ALTER);
|
||||
try_alter = false;
|
||||
}
|
||||
|
||||
return try_alter ? HA_ADMIN_TRY_ALTER : HA_ADMIN_OK;
|
||||
}
|
||||
|
||||
/*******************************************************************//**
|
||||
|
@ -85,10 +85,6 @@ struct fil_space_t {
|
||||
Protected by log_sys.mutex.
|
||||
If and only if this is nonzero, the
|
||||
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;
|
||||
/*!< we set this true when we start
|
||||
deleting a single-table tablespace.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*****************************************************************************
|
||||
|
||||
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
|
||||
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
|
||||
Timer rountines
|
||||
Timer routines
|
||||
|
||||
Created 30/07/2014 Jan Lindström jan.lindstrom@skysql.com
|
||||
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
|
||||
|
||||
#include "univ.i"
|
||||
#include "data0type.h"
|
||||
#include <my_rdtsc.h>
|
||||
|
||||
/* Current timer stats */
|
||||
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
|
||||
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
|
||||
@return time in microseconds */
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*****************************************************************************
|
||||
|
||||
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
|
||||
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
|
||||
Timer rountines
|
||||
Timer routines
|
||||
|
||||
Created 30/07/2014 Jan Lindström jan.lindstrom@skysql.com
|
||||
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
|
||||
@return time in microseconds */
|
||||
|
@ -3844,7 +3844,8 @@ os_file_create_simple_func(
|
||||
/* Use default security attributes and no template file. */
|
||||
|
||||
file = CreateFile(
|
||||
(LPCTSTR) name, access, FILE_SHARE_READ, NULL,
|
||||
(LPCTSTR) name, access,
|
||||
FILE_SHARE_READ | FILE_SHARE_DELETE, NULL,
|
||||
create_flag, attributes, NULL);
|
||||
|
||||
if (file == INVALID_HANDLE_VALUE) {
|
||||
@ -4088,7 +4089,7 @@ os_file_create_func(
|
||||
DWORD create_flag;
|
||||
DWORD share_mode = srv_operation != SRV_OPERATION_NORMAL
|
||||
? 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) {
|
||||
WAIT_ALLOW_WRITES();
|
||||
@ -4294,7 +4295,7 @@ os_file_create_simple_no_error_handling_func(
|
||||
DWORD attributes = 0;
|
||||
DWORD share_mode = srv_operation != SRV_OPERATION_NORMAL
|
||||
? FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE
|
||||
: FILE_SHARE_READ;
|
||||
: FILE_SHARE_READ | FILE_SHARE_DELETE;
|
||||
|
||||
ut_a(name);
|
||||
|
||||
|
@ -41,10 +41,12 @@ ELSE()
|
||||
SET(inst_location ${INSTALL_SUPPORTFILESDIR})
|
||||
ENDIF()
|
||||
|
||||
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}
|
||||
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)
|
||||
SET(prefix ${CMAKE_INSTALL_PREFIX})
|
||||
|
Loading…
x
Reference in New Issue
Block a user