Skip to content

Commit

Permalink
Merge 10.0 into 10.1
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-m committed Jun 12, 2017
2 parents 58c56dd + 75b35a3 commit fa57479
Show file tree
Hide file tree
Showing 25 changed files with 373 additions and 447 deletions.
24 changes: 6 additions & 18 deletions extra/mariabackup/xtrabackup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1899,18 +1899,16 @@ innodb_init(void)
return(TRUE);
}

static my_bool
innodb_end(void)
static void
innodb_end()
{
srv_fast_shutdown = (ulint) innobase_fast_shutdown;
innodb_inited = 0;

msg("xtrabackup: starting shutdown with innodb_fast_shutdown = %lu\n",
srv_fast_shutdown);

if (innobase_shutdown_for_mysql() != DB_SUCCESS) {
goto error;
}
innodb_shutdown();
free(internal_innobase_data_file_path);
internal_innobase_data_file_path = NULL;

Expand All @@ -1921,12 +1919,6 @@ innodb_end(void)
// pthread_mutex_destroy(&commit_threads_m);
// pthread_mutex_destroy(&commit_cond_m);
// pthread_cond_destroy(&commit_cond);

return(FALSE);

error:
msg("xtrabackup: innodb_end(): Error occured.\n");
return(TRUE);
}

/* ================= common ================= */
Expand Down Expand Up @@ -4819,8 +4811,7 @@ xtrabackup_stats_func(int argc, char **argv)
xb_filters_free();

/* shutdown InnoDB */
if(innodb_end())
exit(EXIT_FAILURE);
innodb_end();
}

/* ================= prepare ================= */
Expand Down Expand Up @@ -6763,8 +6754,7 @@ xtrabackup_prepare_func(int argc, char ** argv)
xb_write_galera_info(xtrabackup_incremental);
#endif

if(innodb_end())
goto error_cleanup;
innodb_end();

innodb_free_param();

Expand Down Expand Up @@ -6850,9 +6840,7 @@ xtrabackup_prepare_func(int argc, char ** argv)
if(innodb_init())
goto error;

if(innodb_end())
goto error;

innodb_end();
innodb_free_param();

}
Expand Down
48 changes: 48 additions & 0 deletions mysql-test/suite/innodb/r/row_format_redundant.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
create table t1 (a int not null, d varchar(15) not null, b
varchar(198) not null, c char(156),
fulltext ftsic(c)) engine=InnoDB
row_format=redundant;
insert into t1 values(123, 'abcdef', 'jghikl', 'mnop');
insert into t1 values(456, 'abcdef', 'jghikl', 'mnop');
insert into t1 values(789, 'abcdef', 'jghikl', 'mnop');
insert into t1 values(134, 'kasdfsdsadf', 'adfjlasdkfjasd', 'adfsadflkasdasdfljasdf');
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
SET GLOBAL innodb_file_per_table=OFF;
create table t2 (a int not null, d varchar(15) not null, b
varchar(198) not null, c char(156), fulltext ftsic(c)) engine=InnoDB
row_format=redundant;
insert into t2 select * from t1;
create table t3 (a int not null, d varchar(15) not null, b varchar(198),
c varchar(150), index k1(c(99), b(56)), index k2(b(5), c(10))) engine=InnoDB
row_format=redundant;
insert into t3 values(444, 'dddd', 'bbbbb', 'aaaaa');
insert into t3 values(555, 'eeee', 'ccccc', 'aaaaa');
SET GLOBAL innodb_fast_shutdown=0;
SELECT COUNT(*) FROM t1;
COUNT(*)
4096
SELECT COUNT(*) FROM t2;
COUNT(*)
4096
SELECT COUNT(*) FROM t3;
COUNT(*)
2
TRUNCATE TABLE t1;
ERROR HY000: Table 't1' is read only
TRUNCATE TABLE t2;
ERROR HY000: Table 't2' is read only
TRUNCATE TABLE t3;
ERROR HY000: Table 't3' is read only
TRUNCATE TABLE t1;
TRUNCATE TABLE t2;
TRUNCATE TABLE t3;
DROP TABLE t1,t2,t3;
75 changes: 75 additions & 0 deletions mysql-test/suite/innodb/t/row_format_redundant.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
--source include/innodb_page_size.inc
# Embedded mode doesn't allow restarting
--source include/not_embedded.inc

# MDEV-13059 XtraDB hangs on Windows due to failing to release
# block->lock X-latch in innodb_read_only mode
if (`SELECT count(*) FROM information_schema.plugins WHERE
plugin_name = 'innodb' AND plugin_status = 'active' AND
plugin_description LIKE '%xtradb%'`){
if (`SELECT @@version_compile_os IN ('Win32','Win64','Windows')`) {
skip MDEV-13059 XtraDB hangs on Windows in innodb_read_only mode;
}
}

create table t1 (a int not null, d varchar(15) not null, b
varchar(198) not null, c char(156),
fulltext ftsic(c)) engine=InnoDB
row_format=redundant;

insert into t1 values(123, 'abcdef', 'jghikl', 'mnop');
insert into t1 values(456, 'abcdef', 'jghikl', 'mnop');
insert into t1 values(789, 'abcdef', 'jghikl', 'mnop');
insert into t1 values(134, 'kasdfsdsadf', 'adfjlasdkfjasd', 'adfsadflkasdasdfljasdf');
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;

SET GLOBAL innodb_file_per_table=OFF;
create table t2 (a int not null, d varchar(15) not null, b
varchar(198) not null, c char(156), fulltext ftsic(c)) engine=InnoDB
row_format=redundant;

insert into t2 select * from t1;

create table t3 (a int not null, d varchar(15) not null, b varchar(198),
c varchar(150), index k1(c(99), b(56)), index k2(b(5), c(10))) engine=InnoDB
row_format=redundant;

insert into t3 values(444, 'dddd', 'bbbbb', 'aaaaa');
insert into t3 values(555, 'eeee', 'ccccc', 'aaaaa');

# read-only restart requires the change buffer to be empty; therefore we
# do a slow shutdown.
SET GLOBAL innodb_fast_shutdown=0;
--let $restart_parameters = --innodb-read-only
--source include/restart_mysqld.inc

SELECT COUNT(*) FROM t1;
SELECT COUNT(*) FROM t2;
SELECT COUNT(*) FROM t3;

--error ER_OPEN_AS_READONLY
TRUNCATE TABLE t1;
--error ER_OPEN_AS_READONLY
TRUNCATE TABLE t2;
--error ER_OPEN_AS_READONLY
TRUNCATE TABLE t3;

--let $restart_parameters =
--source include/restart_mysqld.inc

TRUNCATE TABLE t1;
TRUNCATE TABLE t2;
TRUNCATE TABLE t3;

# TODO: Shutdown, corrupt the SYS_TABLES.TYPE of the tables, restart

DROP TABLE t1,t2,t3;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SET @start_value = @@GLOBAL.innodb_sched_priority_cleaner;
SET GLOBAL innodb_sched_priority_cleaner=39;
SELECT @@GLOBAL.innodb_sched_priority_cleaner;
@@GLOBAL.innodb_sched_priority_cleaner
19
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@

# A dynamic, global variable

SET @start_value = @@GLOBAL.innodb_sched_priority_cleaner;
# Test in read-only mode
--let $restart_parameters= --innodb-read-only
--source include/restart_mysqld.inc
--let $restart_parameters=

# This has no actual effect in innodb_read_only mode
SET GLOBAL innodb_sched_priority_cleaner=39;

--source include/restart_mysqld.inc

# Default value
SELECT @@GLOBAL.innodb_sched_priority_cleaner;
Expand Down
5 changes: 2 additions & 3 deletions storage/innobase/buf/buf0flu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ is set to TRUE by the page_cleaner thread when it is spawned and is set
back to FALSE at shutdown by the page_cleaner as well. Therefore no
need to protect it by a mutex. It is only ever read by the thread
doing the shutdown */
UNIV_INTERN ibool buf_page_cleaner_is_active = FALSE;
UNIV_INTERN bool buf_page_cleaner_is_active;

#ifdef UNIV_PFS_THREAD
UNIV_INTERN mysql_pfs_key_t buf_page_cleaner_thread_key;
Expand Down Expand Up @@ -2326,7 +2326,6 @@ DECLARE_THREAD(buf_flush_page_cleaner_thread)(
fprintf(stderr, "InnoDB: page_cleaner thread running, id %lu\n",
os_thread_pf(os_thread_get_curr_id()));
#endif /* UNIV_DEBUG_THREAD_CREATION */
buf_page_cleaner_is_active = TRUE;

while (srv_shutdown_state == SRV_SHUTDOWN_NONE) {

Expand Down Expand Up @@ -2422,7 +2421,7 @@ DECLARE_THREAD(buf_flush_page_cleaner_thread)(
/* We have lived our life. Time to die. */

thread_exit:
buf_page_cleaner_is_active = FALSE;
buf_page_cleaner_is_active = false;

my_thread_end();
/* We count the number of threads in os_thread_exit(). A created
Expand Down
31 changes: 25 additions & 6 deletions storage/innobase/dict/dict0stats_bg.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 2012, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, MariaDB Corporation. All Rights Reserved.
Copyright (c) 2017, 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
Expand Down Expand Up @@ -39,12 +39,18 @@ Created Apr 25, 2012 Vasil Dimov
/** Minimum time interval between stats recalc for a given table */
#define MIN_RECALC_INTERVAL 10 /* seconds */

#define SHUTTING_DOWN() (srv_shutdown_state != SRV_SHUTDOWN_NONE)

/** Event to wake up dict_stats_thread on dict_stats_recalc_pool_add()
or shutdown. Not protected by any mutex. */
UNIV_INTERN os_event_t dict_stats_event;

/** Variable to initiate shutdown the dict stats thread. Note we don't
use 'srv_shutdown_state' because we want to shutdown dict stats thread
before purge thread. */
static bool dict_stats_start_shutdown;

/** Event to wait for shutdown of the dict stats thread */
static os_event_t dict_stats_shutdown_event;

/** This mutex protects the "recalc_pool" variable. */
static ib_mutex_t recalc_pool_mutex;
static ib_mutex_t defrag_pool_mutex;
Expand Down Expand Up @@ -340,11 +346,11 @@ Must be called before dict_stats_thread() is started. */
UNIV_INTERN
void
dict_stats_thread_init()
/*====================*/
{
ut_a(!srv_read_only_mode);

dict_stats_event = os_event_create();
dict_stats_shutdown_event = os_event_create();

/* The recalc_pool_mutex is acquired from:
1) the background stats gathering thread before any other latch
Expand Down Expand Up @@ -389,6 +395,9 @@ dict_stats_thread_deinit()

os_event_free(dict_stats_event);
dict_stats_event = NULL;
os_event_free(dict_stats_shutdown_event);
dict_stats_shutdown_event = NULL;
dict_stats_start_shutdown = false;
}

/*****************************************************************//**
Expand Down Expand Up @@ -532,7 +541,7 @@ DECLARE_THREAD(dict_stats_thread)(void*)
my_thread_init();
ut_a(!srv_read_only_mode);

while (!SHUTTING_DOWN()) {
while (!dict_stats_start_shutdown) {

/* Wake up periodically even if not signaled. This is
because we may lose an event - if the below call to
Expand All @@ -542,7 +551,7 @@ DECLARE_THREAD(dict_stats_thread)(void*)
os_event_wait_time(
dict_stats_event, MIN_RECALC_INTERVAL * 1000000);

if (SHUTTING_DOWN()) {
if (dict_stats_start_shutdown) {
break;
}

Expand All @@ -556,10 +565,20 @@ DECLARE_THREAD(dict_stats_thread)(void*)

srv_dict_stats_thread_active = false;

os_event_set(dict_stats_shutdown_event);
my_thread_end();
/* We count the number of threads in os_thread_exit(). A created
thread should always use that to exit instead of return(). */
os_thread_exit(NULL);

OS_THREAD_DUMMY_RETURN;
}

/** Shut down the dict_stats_thread. */
void
dict_stats_shutdown()
{
dict_stats_start_shutdown = true;
os_event_set(dict_stats_event);
os_event_wait(dict_stats_shutdown_event);
}
11 changes: 0 additions & 11 deletions storage/innobase/fsp/fsp0fsp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2731,7 +2731,6 @@ fsp_reserve_free_extents(
ibool success;
ulint n_pages_added;
size_t total_reserved = 0;
ulint rounds = 0;

ut_ad(mtr);
*n_reserved = n_ext;
Expand Down Expand Up @@ -2811,17 +2810,7 @@ fsp_reserve_free_extents(
space_header, mtr);

if (success && n_pages_added > 0) {

rounds++;
total_reserved += n_pages_added;

if (rounds > 50) {
ib_logf(IB_LOG_LEVEL_INFO,
"Space id %lu trying to reserve %lu extents actually reserved %lu "
" reserve %lu free %lu size %lu rounds %lu total_reserved %llu",
space, n_ext, n_pages_added, reserve, n_free, size, rounds, (ullint) total_reserved);
}

goto try_again;
}

Expand Down
Loading

0 comments on commit fa57479

Please sign in to comment.