From 1c926b62634e4e650890ef24abca37802e9a807d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 1 Feb 2023 10:55:49 +0200 Subject: [PATCH] MDEV-30527 Assertion !m_freed_pages in mtr_t::start() on DROP TEMPORARY TABLE mtr_t::commit(): Add special handling of innodb_immediate_scrub_data_uncompressed for TEMPORARY TABLE. This fixes a regression that was caused by commit de4030e4d49805a7ded5c0bfee01cc3fd7623522 (MDEV-30400). --- mysql-test/suite/innodb/r/innodb_scrub.result | 15 +++++++++++++++ mysql-test/suite/innodb/t/innodb_scrub.test | 16 ++++++++++++++++ storage/innobase/mtr/mtr0mtr.cc | 13 +++++++++++++ 3 files changed, 44 insertions(+) diff --git a/mysql-test/suite/innodb/r/innodb_scrub.result b/mysql-test/suite/innodb/r/innodb_scrub.result index 1a4db0b541e..b4a418ce2ad 100644 --- a/mysql-test/suite/innodb/r/innodb_scrub.result +++ b/mysql-test/suite/innodb/r/innodb_scrub.result @@ -10,3 +10,18 @@ FLUSH TABLE t1 FOR EXPORT; UNLOCK TABLES; NOT FOUND /unicycle|repairman/ in t1.ibd DROP TABLE t1; +# +# MDEV-30527 Assertion !m_freed_pages in mtr_t::start() +# on DROP TEMPORARY TABLE +# +SET @scrub= @@GLOBAL.innodb_immediate_scrub_data_uncompressed; +SET GLOBAL innodb_immediate_scrub_data_uncompressed= 1; +SET @fpt=@@GLOBAL.innodb_file_per_table; +SET GLOBAL innodb_file_per_table=0; +CREATE TABLE t ENGINE=InnoDB AS SELECT 1; +DROP TABLE t; +SET GLOBAL innodb_file_per_table=@fpt; +CREATE TEMPORARY TABLE tmp ENGINE=InnoDB AS SELECT 1; +DROP TABLE tmp; +SET GLOBAL INNODB_IMMEDIATE_SCRUB_DATA_UNCOMPRESSED= @scrub; +# End of 10.6 tests diff --git a/mysql-test/suite/innodb/t/innodb_scrub.test b/mysql-test/suite/innodb/t/innodb_scrub.test index c7d06187e9f..8fe460da4d3 100644 --- a/mysql-test/suite/innodb/t/innodb_scrub.test +++ b/mysql-test/suite/innodb/t/innodb_scrub.test @@ -27,3 +27,19 @@ FLUSH TABLE t1 FOR EXPORT; UNLOCK TABLES; -- source include/search_pattern_in_file.inc DROP TABLE t1; + +--echo # +--echo # MDEV-30527 Assertion !m_freed_pages in mtr_t::start() +--echo # on DROP TEMPORARY TABLE +--echo # +SET @scrub= @@GLOBAL.innodb_immediate_scrub_data_uncompressed; +SET GLOBAL innodb_immediate_scrub_data_uncompressed= 1; +SET @fpt=@@GLOBAL.innodb_file_per_table; +SET GLOBAL innodb_file_per_table=0; +CREATE TABLE t ENGINE=InnoDB AS SELECT 1; +DROP TABLE t; +SET GLOBAL innodb_file_per_table=@fpt; +CREATE TEMPORARY TABLE tmp ENGINE=InnoDB AS SELECT 1; +DROP TABLE tmp; +SET GLOBAL INNODB_IMMEDIATE_SCRUB_DATA_UNCOMPRESSED= @scrub; +--echo # End of 10.6 tests diff --git a/storage/innobase/mtr/mtr0mtr.cc b/storage/innobase/mtr/mtr0mtr.cc index 1c6c28d874a..45a1424e572 100644 --- a/storage/innobase/mtr/mtr0mtr.cc +++ b/storage/innobase/mtr/mtr0mtr.cc @@ -210,7 +210,20 @@ void mtr_t::commit() srv_stats.log_write_requests.inc(); } else + { + if (m_freed_pages) + { + ut_ad(!m_freed_pages->empty()); + ut_ad(m_freed_space == fil_system.temp_space); + ut_ad(!is_trim_pages()); + for (const auto &range : *m_freed_pages) + m_freed_space->add_free_range(range); + delete m_freed_pages; + m_freed_pages= nullptr; + m_freed_space= nullptr; + } release(); + } release_resources(); }