Skip to content

Commit

Permalink
MDEV-14958 Merge new release of InnoDB MySQL 5.7.21 to 10.2
Browse files Browse the repository at this point in the history
Two follow-up tasks were filed for MySQL 5.7.21 changes that
were not applied here:

MDEV-15179 performance_schema.file_instances does not reflect RENAME TABLE
MDEV-14222 Unnecessary 'cascade' memory allocation for every updated
row when there is no FOREIGN KEY
  • Loading branch information
dr-m committed Feb 2, 2018
2 parents 859fe1f + d13fbc6 commit 9390ff5
Show file tree
Hide file tree
Showing 15 changed files with 294 additions and 93 deletions.
27 changes: 27 additions & 0 deletions mysql-test/r/partition_innodb.result
Original file line number Diff line number Diff line change
Expand Up @@ -900,3 +900,30 @@ SELECT b FROM t1 WHERE b = 0;
ERROR HY000: Table definition has changed, please retry transaction
disconnect con1;
DROP TABLE t1;
#
# Bug#26390658 RENAMING A PARTITIONED TABLE DOES NOT UPDATE
# MYSQL.INNODB_TABLE_STATS
#
CREATE DATABASE test_jfg;
CREATE TABLE test_jfg.test_jfg1 (id int(10) unsigned NOT NULL,PRIMARY
KEY (id)) ENGINE=InnoDB DEFAULT CHARSET=latin1 STATS_PERSISTENT=1;
CREATE TABLE test_jfg.test_jfg2 (id int(10) unsigned NOT NULL,PRIMARY
KEY (id)) ENGINE=InnoDB DEFAULT CHARSET=latin1 STATS_PERSISTENT=1
PARTITION BY RANGE ( id ) (PARTITION p1000 VALUES LESS THAN (1000)
ENGINE = InnoDB,PARTITION pmax VALUES LESS THAN MAXVALUE ENGINE =
InnoDB);
SELECT database_name, table_name FROM mysql.innodb_table_stats WHERE
database_name = 'test_jfg';
database_name table_name
test_jfg test_jfg1
test_jfg test_jfg2#P#p1000
test_jfg test_jfg2#P#pmax
RENAME TABLE test_jfg.test_jfg1 TO test_jfg.test_jfg11;
RENAME TABLE test_jfg.test_jfg2 TO test_jfg.test_jfg12;
SELECT database_name, table_name FROM mysql.innodb_table_stats WHERE
database_name = 'test_jfg';
database_name table_name
test_jfg test_jfg11
test_jfg test_jfg12#P#p1000
test_jfg test_jfg12#P#pmax
DROP DATABASE test_jfg;
34 changes: 34 additions & 0 deletions mysql-test/suite/innodb/r/innodb_buffer_pool_resize.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
set global innodb_adaptive_hash_index=ON;
select @@innodb_buffer_pool_size;
@@innodb_buffer_pool_size
8388608
set global innodb_buffer_pool_size = 10485760;
Warnings:
Warning 1292 Truncated incorrect innodb_buffer_pool_size value: '10485760'
select @@innodb_buffer_pool_size;
@@innodb_buffer_pool_size
16777216
create table t1 (id int not null, val int not null default '0', primary key (id)) ENGINE=InnoDB ROW_FORMAT=COMPRESSED;
create or replace view view0 as select 1 union all select 1;
set @`v_id` := 0;
set @`v_val` := 0;
replace into t1 select (@`v_id` := (@`v_id` + 4) mod 4294967296) as id, (@`v_val` := (@`v_val` + 4) mod 4294967296) as val from view0 v0, view0 v1, view0 v2, view0 v3, view0 v4, view0 v5, view0 v6, view0 v7, view0 v8, view0 v9, view0 v10, view0 v11, view0 v12, view0 v13, view0 v14, view0 v15, view0 v16, view0 v17;
set global innodb_buffer_pool_size = 7340032;
Warnings:
Warning 1292 Truncated incorrect innodb_buffer_pool_size value: '7340032'
select @@innodb_buffer_pool_size;
@@innodb_buffer_pool_size
8388608
select count(val) from t1;
count(val)
262144
set global innodb_adaptive_hash_index=OFF;
set global innodb_buffer_pool_size = 25165824;
select @@innodb_buffer_pool_size;
@@innodb_buffer_pool_size
25165824
select count(val) from t1;
count(val)
262144
drop table t1;
drop view view0;
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
select @@innodb_buffer_pool_chunk_size;
@@innodb_buffer_pool_chunk_size
2097152
create table t1 (id int not null, val int not null default '0', primary key (id)) ENGINE=InnoDB ROW_FORMAT=COMPRESSED;
create or replace view view0 as select 1 union all select 1;
set @`v_id` := 0;
set @`v_val` := 0;
replace into t1 select (@`v_id` := (@`v_id` + 4) mod 4294967296) as id, (@`v_val` := (@`v_val` + 4) mod 4294967296) as val from view0 v0, view0 v1, view0 v2, view0 v3, view0 v4, view0 v5, view0 v6, view0 v7, view0 v8, view0 v9, view0 v10, view0 v11, view0 v12, view0 v13, view0 v14, view0 v15, view0 v16, view0 v17;
set global innodb_buffer_pool_size = 7340032;
Warnings:
Warning 1292 Truncated incorrect innodb_buffer_pool_size value: '7340032'
select count(val) from t1;
count(val)
262144
set global innodb_buffer_pool_size = 16777216;
select count(val) from t1;
count(val)
262144
drop table t1;
drop view view0;
set global innodb_buffer_pool_size = 1048576;
Warnings:
Warning 1292 Truncated incorrect innodb_buffer_pool_size value: '1048576'
select @@innodb_buffer_pool_size;
@@innodb_buffer_pool_size
6291456
2 changes: 2 additions & 0 deletions mysql-test/suite/innodb/t/innodb_buffer_pool_resize.opt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--innodb-buffer-pool-size=8M
--innodb-page-size=4k
74 changes: 74 additions & 0 deletions mysql-test/suite/innodb/t/innodb_buffer_pool_resize.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#
# WL6117 : Resize the InnoDB Buffer Pool Online
#

--source include/have_innodb.inc
--source include/big_test.inc

let $wait_timeout = 180;
let $wait_condition =
SELECT SUBSTR(variable_value, 1, 34) = 'Completed resizing buffer pool at '
FROM information_schema.global_status
WHERE LOWER(variable_name) = 'innodb_buffer_pool_resize_status';

--disable_query_log
set @old_innodb_buffer_pool_size = @@innodb_buffer_pool_size;
set @old_innodb_adaptive_hash_index = @@innodb_adaptive_hash_index;
if (`select (version() like '%debug%') > 0`)
{
set @old_innodb_disable_resize = @@innodb_disable_resize_buffer_pool_debug;
set global innodb_disable_resize_buffer_pool_debug = OFF;
}
--enable_query_log

set global innodb_adaptive_hash_index=ON;

select @@innodb_buffer_pool_size;

# Expand buffer pool
set global innodb_buffer_pool_size = 10485760;

--source include/wait_condition.inc

select @@innodb_buffer_pool_size;

# fill buffer pool
create table t1 (id int not null, val int not null default '0', primary key (id)) ENGINE=InnoDB ROW_FORMAT=COMPRESSED;
create or replace view view0 as select 1 union all select 1;

set @`v_id` := 0;
set @`v_val` := 0;

# 2^18 == 262144 records
replace into t1 select (@`v_id` := (@`v_id` + 4) mod 4294967296) as id, (@`v_val` := (@`v_val` + 4) mod 4294967296) as val from view0 v0, view0 v1, view0 v2, view0 v3, view0 v4, view0 v5, view0 v6, view0 v7, view0 v8, view0 v9, view0 v10, view0 v11, view0 v12, view0 v13, view0 v14, view0 v15, view0 v16, view0 v17;

# Shrink buffer pool
set global innodb_buffer_pool_size = 7340032;
--source include/wait_condition.inc

select @@innodb_buffer_pool_size;

select count(val) from t1;

set global innodb_adaptive_hash_index=OFF;

# Expand buffer pool to 24MB
set global innodb_buffer_pool_size = 25165824;
--source include/wait_condition.inc

select @@innodb_buffer_pool_size;

select count(val) from t1;

drop table t1;
drop view view0;

--disable_query_log
set global innodb_adaptive_hash_index = @old_innodb_adaptive_hash_index;
set global innodb_buffer_pool_size = @old_innodb_buffer_pool_size;
if (`select (version() like '%debug%') > 0`)
{
set global innodb_disable_resize_buffer_pool_debug = @old_innodb_disable_resize;
}
--enable_query_log
--source include/wait_condition.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
--innodb-buffer-pool-size=16M
--innodb-buffer-pool-chunk-size=2M
--innodb-page-size=4k
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#
# WL6117 : Resize the InnoDB Buffer Pool Online
# (innodb_buffer_pool_chunk_size used case)
#

--source include/have_innodb.inc
--source include/big_test.inc

let $wait_timeout = 180;
let $wait_condition =
SELECT SUBSTR(variable_value, 1, 34) = 'Completed resizing buffer pool at '
FROM information_schema.global_status
WHERE LOWER(variable_name) = 'innodb_buffer_pool_resize_status';

--disable_query_log
set @old_innodb_buffer_pool_size = @@innodb_buffer_pool_size;
if (`select (version() like '%debug%') > 0`)
{
set @old_innodb_disable_resize = @@innodb_disable_resize_buffer_pool_debug;
set global innodb_disable_resize_buffer_pool_debug = OFF;
}
--enable_query_log

select @@innodb_buffer_pool_chunk_size;

# fill buffer pool
create table t1 (id int not null, val int not null default '0', primary key (id)) ENGINE=InnoDB ROW_FORMAT=COMPRESSED;
create or replace view view0 as select 1 union all select 1;

set @`v_id` := 0;
set @`v_val` := 0;

# 2^18 == 262144 records
replace into t1 select (@`v_id` := (@`v_id` + 4) mod 4294967296) as id, (@`v_val` := (@`v_val` + 4) mod 4294967296) as val from view0 v0, view0 v1, view0 v2, view0 v3, view0 v4, view0 v5, view0 v6, view0 v7, view0 v8, view0 v9, view0 v10, view0 v11, view0 v12, view0 v13, view0 v14, view0 v15, view0 v16, view0 v17;

# Shrink buffer pool to 7MB
set global innodb_buffer_pool_size = 7340032;
--source include/wait_condition.inc

select count(val) from t1;

# Expand buffer pool to 16MB
set global innodb_buffer_pool_size = 16777216;
--source include/wait_condition.inc

select count(val) from t1;

drop table t1;
drop view view0;

# Try to shrink buffer pool to smaller than chunk size
set global innodb_buffer_pool_size = 1048576;
--source include/wait_condition.inc
select @@innodb_buffer_pool_size;

--disable_query_log
set global innodb_buffer_pool_size = @old_innodb_buffer_pool_size;
if (`select (version() like '%debug%') > 0`)
{
set global innodb_disable_resize_buffer_pool_debug = @old_innodb_disable_resize;
}
--enable_query_log
--source include/wait_condition.inc
2 changes: 1 addition & 1 deletion mysql-test/suite/sys_vars/r/sysvars_innodb.result
Original file line number Diff line number Diff line change
Expand Up @@ -3046,7 +3046,7 @@ READ_ONLY NO
COMMAND_LINE_ARGUMENT OPTIONAL
VARIABLE_NAME INNODB_VERSION
SESSION_VALUE NULL
GLOBAL_VALUE 5.7.20
GLOBAL_VALUE 5.7.21
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE NULL
VARIABLE_SCOPE GLOBAL
Expand Down
28 changes: 28 additions & 0 deletions mysql-test/t/partition_innodb.test
Original file line number Diff line number Diff line change
Expand Up @@ -991,3 +991,31 @@ SELECT b FROM t1 WHERE b = 0;
SELECT b FROM t1 WHERE b = 0;
--disconnect con1
DROP TABLE t1;

--echo #
--echo # Bug#26390658 RENAMING A PARTITIONED TABLE DOES NOT UPDATE
--echo # MYSQL.INNODB_TABLE_STATS
--echo #

CREATE DATABASE test_jfg;

CREATE TABLE test_jfg.test_jfg1 (id int(10) unsigned NOT NULL,PRIMARY
KEY (id)) ENGINE=InnoDB DEFAULT CHARSET=latin1 STATS_PERSISTENT=1;
CREATE TABLE test_jfg.test_jfg2 (id int(10) unsigned NOT NULL,PRIMARY
KEY (id)) ENGINE=InnoDB DEFAULT CHARSET=latin1 STATS_PERSISTENT=1
PARTITION BY RANGE ( id ) (PARTITION p1000 VALUES LESS THAN (1000)
ENGINE = InnoDB,PARTITION pmax VALUES LESS THAN MAXVALUE ENGINE =
InnoDB);

--replace_result #p# #P#
SELECT database_name, table_name FROM mysql.innodb_table_stats WHERE
database_name = 'test_jfg';

RENAME TABLE test_jfg.test_jfg1 TO test_jfg.test_jfg11;
RENAME TABLE test_jfg.test_jfg2 TO test_jfg.test_jfg12;

--replace_result #p# #P#
SELECT database_name, table_name FROM mysql.innodb_table_stats WHERE
database_name = 'test_jfg';

DROP DATABASE test_jfg;
21 changes: 18 additions & 3 deletions storage/innobase/buf/buf0buf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, Google Inc.
Copyright (c) 2013, 2017, MariaDB Corporation.
Copyright (c) 2013, 2018, MariaDB Corporation.
Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described
Expand Down Expand Up @@ -3141,11 +3141,26 @@ buf_pool_clear_hash_index()
see the comments in buf0buf.h */

if (!index) {
# if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
ut_a(!block->n_pointers);
# endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
continue;
}

ut_ad(buf_block_get_state(block)
== BUF_BLOCK_FILE_PAGE);
ut_d(buf_page_state state
= buf_block_get_state(block));
/* Another thread may have set the
state to BUF_BLOCK_REMOVE_HASH in
buf_LRU_block_remove_hashed().
The state change in buf_page_realloc()
is not observable here, because in
that case we would have !block->index.
In the end, the entire adaptive hash
index will be removed. */
ut_ad(state == BUF_BLOCK_FILE_PAGE
|| state == BUF_BLOCK_REMOVE_HASH);
# if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
block->n_pointers = 0;
# endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
Expand Down
31 changes: 11 additions & 20 deletions storage/innobase/handler/ha_innodb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13762,26 +13762,6 @@ innobase_rename_table(

error = row_rename_table_for_mysql(norm_from, norm_to, trx, TRUE);

if (error == DB_TABLE_NOT_FOUND) {
/* May be partitioned table, which consists of partitions
named table_name#P#partition_name[#SP#subpartition_name].

We are doing a DDL operation. */
++trx->will_lock;
trx_set_dict_operation(trx, TRX_DICT_OP_INDEX);
trx_start_if_not_started(trx, true);
error = row_rename_partitions_for_mysql(norm_from, norm_to,
trx);
if (error == DB_TABLE_NOT_FOUND) {
ib::error() << "Table " << ut_get_name(trx, norm_from)
<< " does not exist in the InnoDB internal"
" data dictionary though MariaDB is trying to"
" rename the table. Have you copied the .frm"
" file of the table to the MariaDB database"
" directory from another database? "
<< TROUBLESHOOTING_MSG;
}
}
if (error != DB_SUCCESS) {
if (error == DB_TABLE_NOT_FOUND
&& innobase_get_lower_case_table_names() == 1) {
Expand Down Expand Up @@ -22566,8 +22546,19 @@ innodb_buffer_pool_size_validate(

*static_cast<longlong*>(save) = requested_buf_pool_size;

if (srv_buf_pool_size == static_cast<ulint>(intbuf)) {
buf_pool_mutex_exit_all();
/* nothing to do */
return(0);
}

if (srv_buf_pool_size == requested_buf_pool_size) {
buf_pool_mutex_exit_all();
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
ER_WRONG_ARGUMENTS,
"innodb_buffer_pool_size must be at least"
" innodb_buffer_pool_chunk_size=%lu",
srv_buf_pool_chunk_unit);
/* nothing to do */
return(0);
}
Expand Down
12 changes: 0 additions & 12 deletions storage/innobase/include/row0mysql.h
Original file line number Diff line number Diff line change
Expand Up @@ -494,18 +494,6 @@ row_rename_table_for_mysql(
bool commit) /*!< in: whether to commit trx */
MY_ATTRIBUTE((nonnull, warn_unused_result));

/** Renames a partitioned table for MySQL.
@param[in] old_name Old table name.
@param[in] new_name New table name.
@param[in,out] trx Transaction.
@return error code or DB_SUCCESS */
dberr_t
row_rename_partitions_for_mysql(
const char* old_name,
const char* new_name,
trx_t* trx)
MY_ATTRIBUTE((nonnull, warn_unused_result));

/*********************************************************************//**
Scans an index for either COOUNT(*) or CHECK TABLE.
If CHECK TABLE; Checks that the index contains entries in an ascending order,
Expand Down
Loading

0 comments on commit 9390ff5

Please sign in to comment.