Skip to content

Commit

Permalink
MDEV-13626: Clean up the buffer pool resizing tests from MySQL 5.7
Browse files Browse the repository at this point in the history
buf_pool_resize(): Simplify the fault injection
for innodb.buf_pool_resize_oom.

innodb.buf_pool_resize_oom: Use a small buffer pool.

innodb.innodb_buffer_pool_load_now: Make use of the sequence engine,
to avoid creating explicit InnoDB record locks. Clean up the
accesses to information_schema.innodb_buffer_page_lru.
  • Loading branch information
dr-m committed Mar 19, 2020
1 parent bfb5e1c commit 9fd692a
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 67 deletions.
32 changes: 18 additions & 14 deletions mysql-test/suite/innodb/r/innodb_buffer_pool_load_now.result
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,36 @@ SET GLOBAL innodb_buffer_pool_dump_pct=100;
CREATE TABLE ib_bp_test
(a INT AUTO_INCREMENT, b VARCHAR(64), c TEXT, PRIMARY KEY (a), KEY (b, c(128)))
ENGINE=INNODB;
SELECT PAGE_NUMBER FROM information_schema.innodb_buffer_page_lru
WHERE table_name = '`test`.`ib_bp_test`';
PAGE_NUMBER
3
4
SELECT SPACE INTO @space FROM information_schema.innodb_buffer_page_lru
WHERE table_name = '`test`.`ib_bp_test`' AND PAGE_NUMBER=3;
INSERT INTO ib_bp_test
SELECT NULL, REPEAT('b', 64), REPEAT('c', 256) FROM seq_1_to_16382;
SELECT COUNT(*) FROM information_schema.innodb_buffer_page_lru
WHERE table_name LIKE '%ib_bp_test%';
WHERE table_name = '`test`.`ib_bp_test`';
COUNT(*)
2
SELECT COUNT(*) FROM information_schema.innodb_buffer_page_lru
WHERE table_name LIKE '%ib_bp_test%';
COUNT(*)
{checked_valid}
596
SET GLOBAL innodb_buffer_pool_dump_now = ON;
SELECT COUNT(*) FROM information_schema.innodb_buffer_page_lru
WHERE table_name LIKE '%ib_bp_test%';
COUNT(*)
0
select count(*) from ib_bp_test where a = 1;
SET GLOBAL innodb_fast_shutdown=0;
SELECT PAGE_NUMBER FROM information_schema.innodb_buffer_page_lru
WHERE table_name = '`test`.`ib_bp_test`';
PAGE_NUMBER
select count(*) from ib_bp_test LIMIT 0;
count(*)
1
SET GLOBAL innodb_buffer_pool_load_now = ON;
SELECT variable_value
FROM information_schema.global_status
WHERE LOWER(variable_name) = 'innodb_buffer_pool_load_status';
variable_value
Buffer pool(s) load completed at TIMESTAMP_NOW
SELECT COUNT(*) FROM information_schema.innodb_buffer_page_lru
WHERE table_name LIKE '%ib_bp_test%';
WHERE table_name = '`test`.`ib_bp_test`';
COUNT(*)
{checked_valid}
596
call mtr.add_suppression("InnoDB: Error parsing");
SET GLOBAL innodb_buffer_pool_load_now = ON;
# Re-write some valid pages to the dump file, make sure the space
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/suite/innodb/t/buf_pool_resize_oom.opt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
--innodb-buffer-pool-size=1G
--innodb-buffer-pool-size=8m --innodb-buffer-pool-chunk-size=1m
2 changes: 0 additions & 2 deletions mysql-test/suite/innodb/t/buf_pool_resize_oom.test
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
--source include/have_innodb.inc
--source include/have_debug.inc
# Allocating 1 GiB of buffer pool is pretty steep!
--source include/big_test.inc
--source include/not_embedded.inc

--echo #
Expand Down
51 changes: 20 additions & 31 deletions mysql-test/suite/innodb/t/innodb_buffer_pool_load_now.test
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
--source include/have_innodb.inc
# include/restart_mysqld.inc does not work in embedded mode
--source include/not_embedded.inc
--source include/have_sequence.inc

--let $file = `SELECT CONCAT(@@datadir, @@global.innodb_buffer_pool_filename)`

Expand All @@ -26,32 +27,19 @@ CREATE TABLE ib_bp_test
(a INT AUTO_INCREMENT, b VARCHAR(64), c TEXT, PRIMARY KEY (a), KEY (b, c(128)))
ENGINE=INNODB;

let $check_cnt =
SELECT PAGE_NUMBER FROM information_schema.innodb_buffer_page_lru
WHERE table_name = '`test`.`ib_bp_test`';

SELECT SPACE INTO @space FROM information_schema.innodb_buffer_page_lru
WHERE table_name = '`test`.`ib_bp_test`' AND PAGE_NUMBER=3;

let SPACE=`SELECT @space`;

INSERT INTO ib_bp_test
SELECT NULL, REPEAT('b', 64), REPEAT('c', 256) FROM seq_1_to_16382;

SELECT COUNT(*) FROM information_schema.innodb_buffer_page_lru
WHERE table_name LIKE '%ib_bp_test%';

--let SPACE = `SELECT space FROM information_schema.innodb_sys_tables WHERE name LIKE '%ib_bp_test%'`

# See that we have a small number of pages in the LRU
--eval $check_cnt

# Here we end up with 16382 rows in the table
--disable_query_log
INSERT INTO ib_bp_test (b, c) VALUES (REPEAT('b', 64), REPEAT('c', 256));
INSERT INTO ib_bp_test (b, c) VALUES (REPEAT('B', 64), REPEAT('C', 256));
let $i=12;
while ($i)
{
--eval INSERT INTO ib_bp_test (b, c) VALUES ($i, $i * $i);
INSERT INTO ib_bp_test (b, c) SELECT b, c FROM ib_bp_test;
dec $i;
}
--enable_query_log

# Accept 83 for 64k page size, 163 for 32k page size, 329 for 16k page size,
# 662 for 8k page size & 1392 for 4k page size
--replace_result 83 {checked_valid} 163 {checked_valid} 329 {checked_valid} 662 {checked_valid} 1392 {checked_valid}
--eval $check_cnt
WHERE table_name = '`test`.`ib_bp_test`';

# Dump
SET GLOBAL innodb_buffer_pool_dump_now = ON;
Expand Down Expand Up @@ -81,6 +69,8 @@ EOF

--move_file $file $file.now

# Complete purge (and change buffer merge).
SET GLOBAL innodb_fast_shutdown=0;
--source include/shutdown_mysqld.inc

# Make sure no dump after shutdown
Expand All @@ -92,10 +82,11 @@ EOF
--move_file $file.now $file

# See that we have no pages in the LRU
--eval $check_cnt
SELECT PAGE_NUMBER FROM information_schema.innodb_buffer_page_lru
WHERE table_name = '`test`.`ib_bp_test`';

# Load the table so that entries in the I_S table do not appear as NULL
select count(*) from ib_bp_test where a = 1;
select count(*) from ib_bp_test LIMIT 0;

# Load
SET GLOBAL innodb_buffer_pool_load_now = ON;
Expand All @@ -117,10 +108,8 @@ FROM information_schema.global_status
WHERE LOWER(variable_name) = 'innodb_buffer_pool_load_status';
--enable_warnings

# Accept 83 for 64k page size, 163 for 32k page size, 329 for 16k page size,
# 662 for 8k page size & 1392 for 4k page size
--replace_result 83 {checked_valid} 163 {checked_valid} 329 {checked_valid} 662 {checked_valid} 1392 {checked_valid}
--eval $check_cnt
SELECT COUNT(*) FROM information_schema.innodb_buffer_page_lru
WHERE table_name = '`test`.`ib_bp_test`';

# Add some total garbage to the dump file
--let IBDUMPFILE = $file
Expand Down
22 changes: 3 additions & 19 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, 2018, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, Google Inc.
Copyright (c) 2013, 2019, MariaDB Corporation.
Copyright (c) 2013, 2020, 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 @@ -2648,23 +2648,6 @@ buf_pool_resize_hash(
buf_pool->zip_hash = new_hash_table;
}

#ifndef DBUG_OFF
/** This is a debug routine to inject an memory allocation failure error. */
static
void
buf_pool_resize_chunk_make_null(buf_chunk_t** new_chunks)
{
static int count = 0;

if (count == 1) {
ut_free(*new_chunks);
*new_chunks = NULL;
}

count++;
}
#endif // DBUG_OFF

/** Resize the buffer pool based on srv_buf_pool_size from
srv_buf_pool_old_size. */
static
Expand Down Expand Up @@ -2931,7 +2914,8 @@ buf_pool_resize()
ut_zalloc_nokey_nofatal(new_chunks_size));

DBUG_EXECUTE_IF("buf_pool_resize_chunk_null",
buf_pool_resize_chunk_make_null(&new_chunks););
ut_free(new_chunks);
new_chunks = NULL;);

if (new_chunks == NULL) {
ib::error() << "buffer pool " << i
Expand Down

0 comments on commit 9fd692a

Please sign in to comment.