diff --git a/mysql-test/suite/innodb/r/innodb_buffer_pool_resize_temporary.result b/mysql-test/suite/innodb/r/innodb_buffer_pool_resize_temporary.result new file mode 100644 index 00000000000..43c2e27a8fb --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb_buffer_pool_resize_temporary.result @@ -0,0 +1,16 @@ +SET @save_limit=@@GLOBAL.innodb_limit_optimistic_insert_debug; +SET @save_disable=@@GLOBAL.innodb_disable_resize_buffer_pool_debug; +SET @save_size=@@GLOBAL.innodb_buffer_pool_size; +SET GLOBAL innodb_limit_optimistic_insert_debug=2; +SET GLOBAL innodb_disable_resize_buffer_pool_debug=OFF; +SET GLOBAL innodb_buffer_pool_size=16777216; +CREATE TEMPORARY TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 SELECT seq FROM seq_1_to_200; +SET GLOBAL innodb_buffer_pool_size=8388608; +SELECT COUNT(*),MIN(a),MAX(a) FROM t1; +COUNT(*) MIN(a) MAX(a) +200 1 200 +DROP TEMPORARY TABLE t1; +SET GLOBAL innodb_limit_optimistic_insert_debug=@save_limit; +SET GLOBAL innodb_buffer_pool_size=@save_size; +SET GLOBAL innodb_disable_resize_buffer_pool_debug=@save_disable; diff --git a/mysql-test/suite/innodb/t/innodb_buffer_pool_resize_temporary.test b/mysql-test/suite/innodb/t/innodb_buffer_pool_resize_temporary.test new file mode 100644 index 00000000000..1390da2745e --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb_buffer_pool_resize_temporary.test @@ -0,0 +1,30 @@ +--source include/have_innodb.inc +--source include/have_sequence.inc +--source include/have_debug.inc + +SET @save_limit=@@GLOBAL.innodb_limit_optimistic_insert_debug; +SET @save_disable=@@GLOBAL.innodb_disable_resize_buffer_pool_debug; +SET @save_size=@@GLOBAL.innodb_buffer_pool_size; +SET GLOBAL innodb_limit_optimistic_insert_debug=2; +SET GLOBAL innodb_disable_resize_buffer_pool_debug=OFF; + +SET GLOBAL innodb_buffer_pool_size=16777216; + +CREATE TEMPORARY TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 SELECT seq FROM seq_1_to_200; + +SET GLOBAL innodb_buffer_pool_size=8388608; + +let $wait_timeout = 60; +let $wait_condition = + SELECT SUBSTR(variable_value, 1, 34) = 'Completed resizing buffer pool at ' + FROM information_schema.global_status + WHERE variable_name = 'INNODB_BUFFER_POOL_RESIZE_STATUS'; +--source include/wait_condition.inc + +SELECT COUNT(*),MIN(a),MAX(a) FROM t1; +DROP TEMPORARY TABLE t1; + +SET GLOBAL innodb_limit_optimistic_insert_debug=@save_limit; +SET GLOBAL innodb_buffer_pool_size=@save_size; +SET GLOBAL innodb_disable_resize_buffer_pool_debug=@save_disable; diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index 9063013496f..e740db82d38 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -2,7 +2,7 @@ Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. -Copyright (c) 2013, 2020, MariaDB Corporation. +Copyright (c) 2013, 2021, MariaDB Corporation. Portions of this file contain modifications contributed and copyrighted by Google, Inc. Those modifications are gratefully acknowledged and are described @@ -1624,8 +1624,10 @@ inline bool buf_pool_t::realloc(buf_block_t *block) + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID, 0xff, 4); MEM_UNDEFINED(block->frame, srv_page_size); block->page.set_state(BUF_BLOCK_REMOVE_HASH); - buf_flush_relocate_on_flush_list(&block->page, - &new_block->page); + if (!fsp_is_system_temporary(id.space())) { + buf_flush_relocate_on_flush_list(&block->page, + &new_block->page); + } block->page.set_corrupt_id(); /* set other flags of buf_block_t */ @@ -1641,17 +1643,13 @@ inline bool buf_pool_t::realloc(buf_block_t *block) new_block->n_fields = 1; new_block->left_side = TRUE; #endif /* BTR_CUR_HASH_ADAPT */ - - hash_lock->write_unlock(); - - /* free block */ ut_d(block->page.set_state(BUF_BLOCK_MEMORY)); - buf_LRU_block_free_non_file_page(block); - } else { - hash_lock->write_unlock(); - buf_LRU_block_free_non_file_page(new_block); + /* free block */ + new_block = block; } + hash_lock->write_unlock(); + buf_LRU_block_free_non_file_page(new_block); return(true); /* free_list was enough */ } diff --git a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h index 09d060eeeeb..c4254f911dc 100644 --- a/storage/innobase/include/buf0buf.h +++ b/storage/innobase/include/buf0buf.h @@ -952,7 +952,7 @@ public: void free_file_page() { ut_ad(state() == BUF_BLOCK_REMOVE_HASH); - ut_d(oldest_modification_= 0); /* for buf_LRU_free_page(this, false) */ + ut_d(oldest_modification_= 0); /* for buf_LRU_block_free_non_file_page() */ set_corrupt_id(); ut_d(set_state(BUF_BLOCK_MEMORY)); } @@ -2167,8 +2167,17 @@ inline void buf_page_t::set_io_fix(buf_io_fix io_fix) inline void buf_page_t::set_corrupt_id() { - ut_ad(!oldest_modification()); #ifdef UNIV_DEBUG + switch (oldest_modification()) { + case 0: + break; + case 1: + ut_ad(fsp_is_system_temporary(id().space())); + ut_d(oldest_modification_= 0); /* for buf_LRU_block_free_non_file_page() */ + break; + default: + ut_ad("block is dirty" == 0); + } switch (state()) { case BUF_BLOCK_REMOVE_HASH: break;