[MDEV-30527] Assertion `!m_freed_pages' failed in mtr_t::start upon dropping temporary table Created: 2023-01-31  Updated: 2023-02-18  Resolved: 2023-02-01

Status: Closed
Project: MariaDB Server
Component/s: Data Definition - Temporary, Storage Engine - InnoDB
Affects Version/s: N/A
Fix Version/s: 10.11.2, 11.0.1, 10.6.12, 10.7.8, 10.8.7, 10.9.5, 10.10.3

Type: Bug Priority: Blocker
Reporter: Elena Stepanova Assignee: Marko Mäkelä
Resolution: Fixed Votes: 0
Labels: regression


 Description   

--source include/have_innodb.inc
 
SET @scrub= @@INNODB_IMMEDIATE_SCRUB_DATA_UNCOMPRESSED;
 
SET GLOBAL INNODB_IMMEDIATE_SCRUB_DATA_UNCOMPRESSED= 1;
CREATE TEMPORARY TABLE tmp ENGINE=InnoDB AS SELECT 1;
DROP TABLE tmp;
 
# Cleanup
SET GLOBAL INNODB_IMMEDIATE_SCRUB_DATA_UNCOMPRESSED= @scrub;

10.6 de4030e4d

mariadbd: /data/src/10.6-bug/storage/innobase/mtr/mtr0mtr.cc:88: void mtr_t::start(): Assertion `!m_freed_pages' failed.
230131 18:28:30 [ERROR] mysqld got signal 6 ;
 
#7  0x00007fbb8ddf4662 in __GI___assert_fail (assertion=0x5567bb58130a "!m_freed_pages", file=0x5567bb581250 "/data/src/10.6-bug/storage/innobase/mtr/mtr0mtr.cc", line=88, function=0x5567bb5812f6 "void mtr_t::start()") at assert.c:101
#8  0x00005567bac84124 in mtr_t::start (this=0x7fbb881857c0) at /data/src/10.6-bug/storage/innobase/mtr/mtr0mtr.cc:88
#9  0x00005567bae05286 in btr_drop_temporary_table (table=...) at /data/src/10.6-bug/storage/innobase/btr/btr0btr.cc:1252
#10 0x00005567bab8e2dc in ha_innobase::delete_table (this=0x7fbb28015dc0, name=0x7fbb2822da48 "/mnt8t/src/10.6-bug/mysql-test/var/tmp/mysqld.1/#sql-temptable-2fdb89-4-f") at /data/src/10.6-bug/storage/innobase/handler/ha_innodb.cc:13470
#11 0x00005567ba765c2d in hton_drop_table (hton=0x5567bdb4cdd8, path=0x7fbb2822da48 "/mnt8t/src/10.6-bug/mysql-test/var/tmp/mysqld.1/#sql-temptable-2fdb89-4-f") at /data/src/10.6-bug/sql/handler.cc:576
#12 0x00005567ba68cb32 in THD::rm_temporary_table (this=0x7fbb28000db8, base=0x5567bdb4cdd8, path=0x7fbb2822da48 "/mnt8t/src/10.6-bug/mysql-test/var/tmp/mysqld.1/#sql-temptable-2fdb89-4-f") at /data/src/10.6-bug/sql/temporary_tables.cc:705
#13 0x00005567ba68eb41 in THD::free_tmp_table_share (this=0x7fbb28000db8, share=0x7fbb2822d498, delete_table=true) at /data/src/10.6-bug/sql/temporary_tables.cc:1468
#14 0x00005567ba68c9be in THD::drop_temporary_table (this=0x7fbb28000db8, table=0x7fbb28224b38, is_trans=0x7fbb8818649e, delete_table=true) at /data/src/10.6-bug/sql/temporary_tables.cc:673
#15 0x00005567ba4c183f in mysql_rm_table_no_locks (thd=0x7fbb28000db8, tables=0x7fbb280156b0, current_db=0x7fbb28000e58, ddl_log_state=0x7fbb88186570, if_exists=false, drop_temporary=false, drop_view=false, drop_sequence=false, dont_log_query=false, dont_free_locks=false) at /data/src/10.6-bug/sql/sql_table.cc:1298
#16 0x00005567ba4c0ed1 in mysql_rm_table (thd=0x7fbb28000db8, tables=0x7fbb280156b0, if_exists=false, drop_temporary=false, drop_sequence=false, dont_log_query=false) at /data/src/10.6-bug/sql/sql_table.cc:1046
#17 0x00005567ba3d57db in mysql_execute_command (thd=0x7fbb28000db8, is_called_from_prepared_stmt=false) at /data/src/10.6-bug/sql/sql_parse.cc:4952
#18 0x00005567ba3df76b in mysql_parse (thd=0x7fbb28000db8, rawbuf=0x7fbb28015600 "DROP TABLE tmp", length=14, parser_state=0x7fbb881873a0) at /data/src/10.6-bug/sql/sql_parse.cc:8019
#19 0x00005567ba3cbd82 in dispatch_command (command=COM_QUERY, thd=0x7fbb28000db8, packet=0x7fbb2800b8b9 "DROP TABLE tmp", packet_length=14, blocking=true) at /data/src/10.6-bug/sql/sql_parse.cc:1896
#20 0x00005567ba3ca75b in do_command (thd=0x7fbb28000db8, blocking=true) at /data/src/10.6-bug/sql/sql_parse.cc:1409
#21 0x00005567ba586c93 in do_handle_one_connection (connect=0x5567be0ba9a8, put_in_cache=true) at /data/src/10.6-bug/sql/sql_connect.cc:1416
#22 0x00005567ba586a03 in handle_one_connection (arg=0x5567be0ba5f8) at /data/src/10.6-bug/sql/sql_connect.cc:1318
#23 0x00005567baaa467a in pfs_spawn_thread (arg=0x5567be001ac8) at /data/src/10.6-bug/storage/perfschema/pfs.cc:2201
#24 0x00007fbb8e2d2ea7 in start_thread (arg=<optimized out>) at pthread_create.c:477
#25 0x00007fbb8debfaef in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

The failure started happening on 10.6 after this commit

Author: Marko Mäkelä
Date:   Tue Jan 24 14:09:21 2023 +0200
 
    MDEV-30400 Assertion height == btr_page_get_level(...) on INSERT

No obvious immediate problem on a non-debug build.



 Comments   
Comment by Marko Mäkelä [ 2023-02-01 ]

Thank you! This code was previously not covered by the regression test suite, Some code that was determined to be unreachable in code coverage analysis for MDEV-30400 was wrongly removed. I can reproduce the assertion failure with the following:

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

The assertion only fails when dropping the temporary table, not when dropping the persistent table that was created in the InnoDB system tablespace (innodb_file_per_table=0).

Comment by Roel Van de Paar [ 2023-02-13 ]

Also ran into this in 11.0 (not upmerged yet). 10.11 looks fine.

CREATE TEMPORARY TABLE t (c INT) ENGINE=InnoDB;
SET GLOBAL innodb_immediate_scrub_data_uncompressed=ON;
TRUNCATE TABLE t;

!m_freed_pages|SIGABRT|mtr_t::start|btr_drop_temporary_table|ha_innobase::truncate|handler::ha_truncate

Also saw a whole set of other related stacks:

!m_freed_pages|SIGABRT|mtr_t::start|btr_drop_temporary_table|ha_innobase::delete_table|hton_drop_table  
!m_freed_pages|SIGABRT|mtr_t::start|btr_free_but_not_root|btr_drop_temporary_table|ha_innobase::delete_table 
!m_freed_pages|SIGABRT|mtr_t::start|trx_undo_seg_free|trx_undo_commit_cleanup|trx_t::commit_in_memory        
!m_freed_pages|SIGABRT|mtr_t::start|trx_undo_truncate_end|trx_undo_try_truncate|row_undo_rec_get             

Comment by Roel Van de Paar [ 2023-02-13 ]

A testcase for this UniqueID/stack (11.0 again only, so this stack seems fixed also):

!m_freed_pages|SIGABRT|mtr_t::start|btr_drop_temporary_table|ha_innobase::delete_table|hton_drop_table 

SET GLOBAL innodb_immediate_scrub_data_uncompressed=1;
CREATE TEMPORARY TABLE tmp SELECT 1;

Comment by Roel Van de Paar [ 2023-02-18 ]

The patch was merged to 11.0 and all related bugs seem gone. Doing new test run to see if any new !m_freed_pages occurrences will show.

Generated at Thu Feb 08 10:16:54 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.