Skip to content

Commit 55e0c34

Browse files
committed
MDEV-37263 Hang or crash when shrinking innodb_buffer_pool_size
buf_pool_t::shrink(): If we run out of pages to evict from buf_pool.LRU, abort the operation. Also, do not leak the spare block that we may have allocated.
1 parent 733c58a commit 55e0c34

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
call mtr.add_suppression("innodb_buffer_pool_size change aborted");
2+
CREATE TABLE t (c INT) ENGINE=InnoDB PARTITION BY HASH(c) PARTITIONS 512;
3+
BEGIN;
4+
SELECT * FROM t LOCK IN SHARE MODE;
5+
c
6+
SET @save_size = @@GLOBAL.innodb_buffer_pool_size;
7+
SET GLOBAL innodb_buffer_pool_size=6291456;
8+
COMMIT;
9+
SET GLOBAL innodb_buffer_pool_size=6291456;
10+
SET GLOBAL innodb_buffer_pool_size = @save_size;
11+
DROP TABLE t;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--source include/have_innodb.inc
2+
--source include/have_partition.inc
3+
call mtr.add_suppression("innodb_buffer_pool_size change aborted");
4+
CREATE TABLE t (c INT) ENGINE=InnoDB PARTITION BY HASH(c) PARTITIONS 512;
5+
BEGIN;
6+
SELECT * FROM t LOCK IN SHARE MODE;
7+
SET @save_size = @@GLOBAL.innodb_buffer_pool_size;
8+
--error 0,ER_WRONG_USAGE
9+
SET GLOBAL innodb_buffer_pool_size=6291456;
10+
COMMIT;
11+
--error 0,ER_WRONG_USAGE
12+
SET GLOBAL innodb_buffer_pool_size=6291456;
13+
SET GLOBAL innodb_buffer_pool_size = @save_size;
14+
DROP TABLE t;

storage/innobase/buf/buf0buf.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1823,6 +1823,12 @@ ATTRIBUTE_COLD buf_pool_t::shrink_status buf_pool_t::shrink(size_t size)
18231823
goto next;
18241824
}
18251825

1826+
if (block)
1827+
buf_LRU_block_free_non_file_page(block);
1828+
1829+
if (!UT_LIST_GET_LEN(LRU) && n_blocks_to_withdraw)
1830+
return SHRINK_ABORT;
1831+
18261832
if (UT_LIST_GET_LEN(free) + UT_LIST_GET_LEN(LRU) < usable_size() / 20)
18271833
return SHRINK_ABORT;
18281834

0 commit comments

Comments
 (0)