MDEV-24659 Assertion !fsp_is_system_temporary(bpage->id().space()) failed in buf_flush_relocate_on_flush_list()

When commit 5eb539555b36a60944eefeb84d5d6d436ba61e63 (MDEV-12227)
removed the pages of temporary tables from the buf_pool.flush_list,
an adjustment to the buffer pool resizing was forgotten.

buf_pool_t::realloc(): Do not invoke buf_flush_relocate_on_flush_list()
for pages that belong to the temporary tablespace. Also, deduplicate
some code at the end.

buf_page_t::set_corrupt_id(): Tolerate oldest_modification()==1
(the dummy value) for temporary tablespace pages. The revised
buf_pool_t::realloc() may invoke this on dirty temporary tablespace pages.
This commit is contained in:
Marko Mäkelä 2021-01-23 17:45:03 +02:00
parent bf1f9b59c7
commit 84b8f529c7
4 changed files with 66 additions and 13 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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 */
}

View File

@ -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;