Skip to content

Commit d4ea179

Browse files
committed
MDEV-13626: Merge InnoDB test cases from MySQL 5.7 (part 7)
Import and adjust the innodb.innodb_buffer_pool_resize tests, except innodb.innodb_buffer_pool_resize_debug, which would time out. buf_pool_clear_hash_index(): Adjust assertions.
1 parent 859fe1f commit d4ea179

7 files changed

+220
-3
lines changed
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

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)