Skip to content

Commit 9390ff5

Browse files
committed
MDEV-14958 Merge new release of InnoDB MySQL 5.7.21 to 10.2
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
2 parents 859fe1f + d13fbc6 commit 9390ff5

15 files changed

+294
-93
lines changed

mysql-test/r/partition_innodb.result

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -900,3 +900,30 @@ SELECT b FROM t1 WHERE b = 0;
900900
ERROR HY000: Table definition has changed, please retry transaction
901901
disconnect con1;
902902
DROP TABLE t1;
903+
#
904+
# Bug#26390658 RENAMING A PARTITIONED TABLE DOES NOT UPDATE
905+
# MYSQL.INNODB_TABLE_STATS
906+
#
907+
CREATE DATABASE test_jfg;
908+
CREATE TABLE test_jfg.test_jfg1 (id int(10) unsigned NOT NULL,PRIMARY
909+
KEY (id)) ENGINE=InnoDB DEFAULT CHARSET=latin1 STATS_PERSISTENT=1;
910+
CREATE TABLE test_jfg.test_jfg2 (id int(10) unsigned NOT NULL,PRIMARY
911+
KEY (id)) ENGINE=InnoDB DEFAULT CHARSET=latin1 STATS_PERSISTENT=1
912+
PARTITION BY RANGE ( id ) (PARTITION p1000 VALUES LESS THAN (1000)
913+
ENGINE = InnoDB,PARTITION pmax VALUES LESS THAN MAXVALUE ENGINE =
914+
InnoDB);
915+
SELECT database_name, table_name FROM mysql.innodb_table_stats WHERE
916+
database_name = 'test_jfg';
917+
database_name table_name
918+
test_jfg test_jfg1
919+
test_jfg test_jfg2#P#p1000
920+
test_jfg test_jfg2#P#pmax
921+
RENAME TABLE test_jfg.test_jfg1 TO test_jfg.test_jfg11;
922+
RENAME TABLE test_jfg.test_jfg2 TO test_jfg.test_jfg12;
923+
SELECT database_name, table_name FROM mysql.innodb_table_stats WHERE
924+
database_name = 'test_jfg';
925+
database_name table_name
926+
test_jfg test_jfg11
927+
test_jfg test_jfg12#P#p1000
928+
test_jfg test_jfg12#P#pmax
929+
DROP DATABASE test_jfg;
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
set global innodb_adaptive_hash_index=ON;
2+
select @@innodb_buffer_pool_size;
3+
@@innodb_buffer_pool_size
4+
8388608
5+
set global innodb_buffer_pool_size = 10485760;
6+
Warnings:
7+
Warning 1292 Truncated incorrect innodb_buffer_pool_size value: '10485760'
8+
select @@innodb_buffer_pool_size;
9+
@@innodb_buffer_pool_size
10+
16777216
11+
create table t1 (id int not null, val int not null default '0', primary key (id)) ENGINE=InnoDB ROW_FORMAT=COMPRESSED;
12+
create or replace view view0 as select 1 union all select 1;
13+
set @`v_id` := 0;
14+
set @`v_val` := 0;
15+
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;
16+
set global innodb_buffer_pool_size = 7340032;
17+
Warnings:
18+
Warning 1292 Truncated incorrect innodb_buffer_pool_size value: '7340032'
19+
select @@innodb_buffer_pool_size;
20+
@@innodb_buffer_pool_size
21+
8388608
22+
select count(val) from t1;
23+
count(val)
24+
262144
25+
set global innodb_adaptive_hash_index=OFF;
26+
set global innodb_buffer_pool_size = 25165824;
27+
select @@innodb_buffer_pool_size;
28+
@@innodb_buffer_pool_size
29+
25165824
30+
select count(val) from t1;
31+
count(val)
32+
262144
33+
drop table t1;
34+
drop view view0;
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
select @@innodb_buffer_pool_chunk_size;
2+
@@innodb_buffer_pool_chunk_size
3+
2097152
4+
create table t1 (id int not null, val int not null default '0', primary key (id)) ENGINE=InnoDB ROW_FORMAT=COMPRESSED;
5+
create or replace view view0 as select 1 union all select 1;
6+
set @`v_id` := 0;
7+
set @`v_val` := 0;
8+
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;
9+
set global innodb_buffer_pool_size = 7340032;
10+
Warnings:
11+
Warning 1292 Truncated incorrect innodb_buffer_pool_size value: '7340032'
12+
select count(val) from t1;
13+
count(val)
14+
262144
15+
set global innodb_buffer_pool_size = 16777216;
16+
select count(val) from t1;
17+
count(val)
18+
262144
19+
drop table t1;
20+
drop view view0;
21+
set global innodb_buffer_pool_size = 1048576;
22+
Warnings:
23+
Warning 1292 Truncated incorrect innodb_buffer_pool_size value: '1048576'
24+
select @@innodb_buffer_pool_size;
25+
@@innodb_buffer_pool_size
26+
6291456
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
--innodb-buffer-pool-size=8M
2+
--innodb-page-size=4k
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#
2+
# WL6117 : Resize the InnoDB Buffer Pool Online
3+
#
4+
5+
--source include/have_innodb.inc
6+
--source include/big_test.inc
7+
8+
let $wait_timeout = 180;
9+
let $wait_condition =
10+
SELECT SUBSTR(variable_value, 1, 34) = 'Completed resizing buffer pool at '
11+
FROM information_schema.global_status
12+
WHERE LOWER(variable_name) = 'innodb_buffer_pool_resize_status';
13+
14+
--disable_query_log
15+
set @old_innodb_buffer_pool_size = @@innodb_buffer_pool_size;
16+
set @old_innodb_adaptive_hash_index = @@innodb_adaptive_hash_index;
17+
if (`select (version() like '%debug%') > 0`)
18+
{
19+
set @old_innodb_disable_resize = @@innodb_disable_resize_buffer_pool_debug;
20+
set global innodb_disable_resize_buffer_pool_debug = OFF;
21+
}
22+
--enable_query_log
23+
24+
set global innodb_adaptive_hash_index=ON;
25+
26+
select @@innodb_buffer_pool_size;
27+
28+
# Expand buffer pool
29+
set global innodb_buffer_pool_size = 10485760;
30+
31+
--source include/wait_condition.inc
32+
33+
select @@innodb_buffer_pool_size;
34+
35+
# fill buffer pool
36+
create table t1 (id int not null, val int not null default '0', primary key (id)) ENGINE=InnoDB ROW_FORMAT=COMPRESSED;
37+
create or replace view view0 as select 1 union all select 1;
38+
39+
set @`v_id` := 0;
40+
set @`v_val` := 0;
41+
42+
# 2^18 == 262144 records
43+
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;
44+
45+
# Shrink buffer pool
46+
set global innodb_buffer_pool_size = 7340032;
47+
--source include/wait_condition.inc
48+
49+
select @@innodb_buffer_pool_size;
50+
51+
select count(val) from t1;
52+
53+
set global innodb_adaptive_hash_index=OFF;
54+
55+
# Expand buffer pool to 24MB
56+
set global innodb_buffer_pool_size = 25165824;
57+
--source include/wait_condition.inc
58+
59+
select @@innodb_buffer_pool_size;
60+
61+
select count(val) from t1;
62+
63+
drop table t1;
64+
drop view view0;
65+
66+
--disable_query_log
67+
set global innodb_adaptive_hash_index = @old_innodb_adaptive_hash_index;
68+
set global innodb_buffer_pool_size = @old_innodb_buffer_pool_size;
69+
if (`select (version() like '%debug%') > 0`)
70+
{
71+
set global innodb_disable_resize_buffer_pool_debug = @old_innodb_disable_resize;
72+
}
73+
--enable_query_log
74+
--source include/wait_condition.inc
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
--innodb-buffer-pool-size=16M
2+
--innodb-buffer-pool-chunk-size=2M
3+
--innodb-page-size=4k
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#
2+
# WL6117 : Resize the InnoDB Buffer Pool Online
3+
# (innodb_buffer_pool_chunk_size used case)
4+
#
5+
6+
--source include/have_innodb.inc
7+
--source include/big_test.inc
8+
9+
let $wait_timeout = 180;
10+
let $wait_condition =
11+
SELECT SUBSTR(variable_value, 1, 34) = 'Completed resizing buffer pool at '
12+
FROM information_schema.global_status
13+
WHERE LOWER(variable_name) = 'innodb_buffer_pool_resize_status';
14+
15+
--disable_query_log
16+
set @old_innodb_buffer_pool_size = @@innodb_buffer_pool_size;
17+
if (`select (version() like '%debug%') > 0`)
18+
{
19+
set @old_innodb_disable_resize = @@innodb_disable_resize_buffer_pool_debug;
20+
set global innodb_disable_resize_buffer_pool_debug = OFF;
21+
}
22+
--enable_query_log
23+
24+
select @@innodb_buffer_pool_chunk_size;
25+
26+
# fill buffer pool
27+
create table t1 (id int not null, val int not null default '0', primary key (id)) ENGINE=InnoDB ROW_FORMAT=COMPRESSED;
28+
create or replace view view0 as select 1 union all select 1;
29+
30+
set @`v_id` := 0;
31+
set @`v_val` := 0;
32+
33+
# 2^18 == 262144 records
34+
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;
35+
36+
# Shrink buffer pool to 7MB
37+
set global innodb_buffer_pool_size = 7340032;
38+
--source include/wait_condition.inc
39+
40+
select count(val) from t1;
41+
42+
# Expand buffer pool to 16MB
43+
set global innodb_buffer_pool_size = 16777216;
44+
--source include/wait_condition.inc
45+
46+
select count(val) from t1;
47+
48+
drop table t1;
49+
drop view view0;
50+
51+
# Try to shrink buffer pool to smaller than chunk size
52+
set global innodb_buffer_pool_size = 1048576;
53+
--source include/wait_condition.inc
54+
select @@innodb_buffer_pool_size;
55+
56+
--disable_query_log
57+
set global innodb_buffer_pool_size = @old_innodb_buffer_pool_size;
58+
if (`select (version() like '%debug%') > 0`)
59+
{
60+
set global innodb_disable_resize_buffer_pool_debug = @old_innodb_disable_resize;
61+
}
62+
--enable_query_log
63+
--source include/wait_condition.inc

mysql-test/suite/sys_vars/r/sysvars_innodb.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3046,7 +3046,7 @@ READ_ONLY NO
30463046
COMMAND_LINE_ARGUMENT OPTIONAL
30473047
VARIABLE_NAME INNODB_VERSION
30483048
SESSION_VALUE NULL
3049-
GLOBAL_VALUE 5.7.20
3049+
GLOBAL_VALUE 5.7.21
30503050
GLOBAL_VALUE_ORIGIN COMPILE-TIME
30513051
DEFAULT_VALUE NULL
30523052
VARIABLE_SCOPE GLOBAL

mysql-test/t/partition_innodb.test

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -991,3 +991,31 @@ SELECT b FROM t1 WHERE b = 0;
991991
SELECT b FROM t1 WHERE b = 0;
992992
--disconnect con1
993993
DROP TABLE t1;
994+
995+
--echo #
996+
--echo # Bug#26390658 RENAMING A PARTITIONED TABLE DOES NOT UPDATE
997+
--echo # MYSQL.INNODB_TABLE_STATS
998+
--echo #
999+
1000+
CREATE DATABASE test_jfg;
1001+
1002+
CREATE TABLE test_jfg.test_jfg1 (id int(10) unsigned NOT NULL,PRIMARY
1003+
KEY (id)) ENGINE=InnoDB DEFAULT CHARSET=latin1 STATS_PERSISTENT=1;
1004+
CREATE TABLE test_jfg.test_jfg2 (id int(10) unsigned NOT NULL,PRIMARY
1005+
KEY (id)) ENGINE=InnoDB DEFAULT CHARSET=latin1 STATS_PERSISTENT=1
1006+
PARTITION BY RANGE ( id ) (PARTITION p1000 VALUES LESS THAN (1000)
1007+
ENGINE = InnoDB,PARTITION pmax VALUES LESS THAN MAXVALUE ENGINE =
1008+
InnoDB);
1009+
1010+
--replace_result #p# #P#
1011+
SELECT database_name, table_name FROM mysql.innodb_table_stats WHERE
1012+
database_name = 'test_jfg';
1013+
1014+
RENAME TABLE test_jfg.test_jfg1 TO test_jfg.test_jfg11;
1015+
RENAME TABLE test_jfg.test_jfg2 TO test_jfg.test_jfg12;
1016+
1017+
--replace_result #p# #P#
1018+
SELECT database_name, table_name FROM mysql.innodb_table_stats WHERE
1019+
database_name = 'test_jfg';
1020+
1021+
DROP DATABASE test_jfg;

storage/innobase/buf/buf0buf.cc

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
44
Copyright (c) 2008, Google Inc.
5-
Copyright (c) 2013, 2017, MariaDB Corporation.
5+
Copyright (c) 2013, 2018, MariaDB Corporation.
66
77
Portions of this file contain modifications contributed and copyrighted by
88
Google, Inc. Those modifications are gratefully acknowledged and are described
@@ -3141,11 +3141,26 @@ buf_pool_clear_hash_index()
31413141
see the comments in buf0buf.h */
31423142

31433143
if (!index) {
3144+
# if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
3145+
ut_a(!block->n_pointers);
3146+
# endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
31443147
continue;
31453148
}
31463149

3147-
ut_ad(buf_block_get_state(block)
3148-
== BUF_BLOCK_FILE_PAGE);
3150+
ut_d(buf_page_state state
3151+
= buf_block_get_state(block));
3152+
/* Another thread may have set the
3153+
state to BUF_BLOCK_REMOVE_HASH in
3154+
buf_LRU_block_remove_hashed().
3155+
3156+
The state change in buf_page_realloc()
3157+
is not observable here, because in
3158+
that case we would have !block->index.
3159+
3160+
In the end, the entire adaptive hash
3161+
index will be removed. */
3162+
ut_ad(state == BUF_BLOCK_FILE_PAGE
3163+
|| state == BUF_BLOCK_REMOVE_HASH);
31493164
# if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
31503165
block->n_pointers = 0;
31513166
# endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */

0 commit comments

Comments
 (0)