[MDEV-17939] Assertion `++loop_count < 2' failed in trx_undo_report_rename Created: 2018-12-08  Updated: 2019-09-11  Resolved: 2019-09-11

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - InnoDB
Affects Version/s: 10.3.3, 10.4.0, 10.2.19
Fix Version/s: 10.2.28, 10.3.19, 10.4.9

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Thirunarayanan Balathandayuthapani
Resolution: Fixed Votes: 0
Labels: None

Attachments: File table_stress1.test    
Issue Links:
Problem/Incident
is caused by MDEV-14717 RENAME TABLE in InnoDB is not crash-safe Closed

 Description   

10.4 fac997feef048de877e39d1366871d5872c61710

mysqld: /home/travis/src/storage/innobase/trx/trx0rec.cc:1999: dberr_t trx_undo_report_rename(trx_t*, const dict_table_t*): Assertion `++loop_count < 2' failed.
181208  6:43:27 [ERROR] mysqld got signal 6 ;
 
#7  0x00007f1021b01c82 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
#8  0x00005634c86b0167 in trx_undo_report_rename (trx=0x7f100c188518, table=0x7f101c7b8068) at /home/travis/src/storage/innobase/trx/trx0rec.cc:1999
#9  0x00005634c861714a in row_rename_table_for_mysql (old_name=0x7f101c8762a0 "test/FTS_", '0' <repeats 13 times>, "6f3_CONFIG", new_name=0x7f101e33dfe8 "test/#sql-ib1782-3932461062", trx=0x7f100c188518, commit=false) at /home/travis/src/storage/innobase/row/row0mysql.cc:4288
#10 0x00005634c861525d in row_drop_table_for_mysql (name=0x7f10201b54e0 "test/FTS_", '0' <repeats 13 times>, "6f3_CONFIG", trx=0x7f100c188518, sqlcom=SQLCOM_DROP_DB, create_failed=false, nonatomic=false) at /home/travis/src/storage/innobase/row/row0mysql.cc:3522
#11 0x00005634c8804f34 in fts_drop_table (trx=0x7f100c188518, table_name=0x7f10201b54e0 "test/FTS_", '0' <repeats 13 times>, "6f3_CONFIG") at /home/travis/src/storage/innobase/fts/fts0fts.cc:1470
#12 0x00005634c88055bf in fts_drop_common_tables (trx=0x7f100c188518, fts_table=0x7f10201b57b0) at /home/travis/src/storage/innobase/fts/fts0fts.cc:1609
#13 0x00005634c880587b in fts_drop_tables (trx=0x7f100c188518, table=0x7f101e29f9f8) at /home/travis/src/storage/innobase/fts/fts0fts.cc:1721
#14 0x00005634c86143e8 in row_drop_ancillary_fts_tables (table=0x7f101e29f9f8, trx=0x7f100c188518) at /home/travis/src/storage/innobase/row/row0mysql.cc:3221
#15 0x00005634c861577a in row_drop_table_for_mysql (name=0x7f10201b62a0 "test/#sql-5d69_10", trx=0x7f100c188518, sqlcom=SQLCOM_TRUNCATE, create_failed=true, nonatomic=false) at /home/travis/src/storage/innobase/row/row0mysql.cc:3713
#16 0x00005634c84c805d in ha_innobase::create (this=0x7f101c11af08, name=0x7f10201b918d "./test/#sql-5d69_10", form=0x7f10201b67a0, create_info=0x7f10201b9510, file_per_table=true, trx=0x7f100c188518) at /home/travis/src/storage/innobase/handler/ha_innodb.cc:12606
#17 0x00005634c84b3ab7 in ha_innobase::create (this=0x7f101c11af08, name=0x7f10201b918d "./test/#sql-5d69_10", form=0x7f10201b67a0, create_info=0x7f10201b9510) at /home/travis/src/storage/innobase/handler/ha_innodb.cc:12651
#18 0x00005634c8294408 in handler::ha_create (this=0x7f101c11af08, name=0x7f10201b918d "./test/#sql-5d69_10", form=0x7f10201b67a0, info_arg=0x7f10201b9510) at /home/travis/src/sql/handler.cc:4595
#19 0x00005634c8295490 in ha_create_table (thd=0x7f101c58bab0, path=0x7f10201b918d "./test/#sql-5d69_10", db=0x7f101c539ec0 "test", table_name=0x7f10201b8cca "#sql-5d69_10", create_info=0x7f10201b9510, frm=0x7f10201b7bb0) at /home/travis/src/sql/handler.cc:4969
#20 0x00005634c805cf07 in mysql_alter_table (thd=0x7f101c58bab0, new_db=0x7f101c590168, new_name=0x7f101c590538, create_info=0x7f10201b9510, table_list=0x7f101c539888, alter_info=0x7f10201b9450, order_num=0, order=0x0, ignore=false) at /home/travis/src/sql/sql_table.cc:9745
#21 0x00005634c80e6faa in Sql_cmd_alter_table::execute (this=0x7f101c53a480, thd=0x7f101c58bab0) at /home/travis/src/sql/sql_alter.cc:497
#22 0x00005634c7f84c0f in mysql_execute_command (thd=0x7f101c58bab0) at /home/travis/src/sql/sql_parse.cc:6290
#23 0x00005634c7f89e08 in mysql_parse (thd=0x7f101c58bab0, rawbuf=0x7f101c5395e8 "ALTER TABLE `table17_innodb_int_autoinc` ADD FOREIGN KEY e (tscol6) REFERENCES t8 (scol10) ON DELETE CASCADE, ADD CONSTRAINT CHECK (`col_bigint_not_null` < 1)  /* QNO 17285 CON_ID 16 */", length=185, parser_state=0x7f10201ba650, is_com_multi=false, is_next_command=false) at /home/travis/src/sql/sql_parse.cc:8092
#24 0x00005634c7f76db6 in dispatch_command (command=COM_QUERY, thd=0x7f101c58bab0, packet=0x7f101c5918d1 "ALTER TABLE `table17_innodb_int_autoinc` ADD FOREIGN KEY e (tscol6) REFERENCES t8 (scol10) ON DELETE CASCADE, ADD CONSTRAINT CHECK (`col_bigint_not_null` < 1)  /* QNO 17285 CON_ID 16 */ ", packet_length=186, is_com_multi=false, is_next_command=false) at /home/travis/src/sql/sql_parse.cc:1851
#25 0x00005634c7f757d3 in do_command (thd=0x7f101c58bab0) at /home/travis/src/sql/sql_parse.cc:1396
#26 0x00005634c80e0fea in do_handle_one_connection (connect=0x5634ca3954b0) at /home/travis/src/sql/sql_connect.cc:1402
#27 0x00005634c80e0d3b in handle_one_connection (arg=0x5634ca3954b0) at /home/travis/src/sql/sql_connect.cc:1308
#28 0x00007f10227466ba in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
#29 0x00007f1021bdb41d in clone () from /lib/x86_64-linux-gnu/libc.so.6

The test case and notes to it are in mleich 's comment



 Comments   
Comment by Marko Mäkelä [ 2018-12-10 ]

I reproduced this once with the MDEV-17938 test case on 10.3, using the following (among other build settings):

CMAKE_CXX_COMPILER=clang++-7
CMAKE_CXX_FLAGS=-O2
WITH_ASAN=ON
CMAKE_BUILD_TYPE=Debug

I did not repeat without -O2.

Also that crash was due to renaming an internal table of a fulltext index before dropping the table, in error handling:

10.3 a72516348b2c5ebb2b6b79c013a79f90e697f2b7

#7  0x0000000001b0b884 in trx_undo_report_rename (trx=0xfe12b96f165, table=0x6170001ab808) at /mariadb/10.3/storage/innobase/trx/trx0rec.cc:1913
#8  0x00000000019a09b2 in row_rename_table_for_mysql (old_name=0x60400014fed0 "test/FTS_", '0' <repeats 13 times>, "a15_CONFIG", new_name=0x6170001c3208 "test/#sql-ib2584-3392764454", trx=0x7f095d4419a8, commit=false, use_fk=140) at /mariadb/10.3/storage/innobase/row/row0mysql.cc:4290
#9  0x000000000199b5d1 in row_drop_table_for_mysql (name=0x6170001ab818 "\320\376\024", trx=0x7f095d4419a8, sqlcom=SQLCOM_DROP_DB, create_failed=<optimized out>, nonatomic=<optimized out>) at /mariadb/10.3/storage/innobase/row/row0mysql.cc:3521
#10 0x0000000001e69758 in fts_drop_table (trx=0x7f095d4419a8, table_name=0x7f095026a240 "test/FTS_", '0' <repeats 13 times>, "a15_CONFIG") at /mariadb/10.3/storage/innobase/fts/fts0fts.cc:1469
#11 0x0000000001e4128c in fts_drop_common_tables (trx=0x7f095d4419a8, fts_table=<optimized out>) at /mariadb/10.3/storage/innobase/fts/fts0fts.cc:1609
#12 fts_drop_tables (trx=0x7f095d4419a8, table=0x617000487388) at /mariadb/10.3/storage/innobase/fts/fts0fts.cc:1721
#13 0x000000000199c9a6 in row_drop_ancillary_fts_tables (table=0x617000487388, trx=0x7f095d4419a8) at /mariadb/10.3/storage/innobase/row/row0mysql.cc:3220
#14 row_drop_table_for_mysql (name=0x7f095026b660 "test/#sql-9f62_191", trx=0x7f095d4419a8, sqlcom=SQLCOM_TRUNCATE, create_failed=<optimized out>, nonatomic=<optimized out>) at /mariadb/10.3/storage/innobase/row/row0mysql.cc:3713
#15 0x00000000016cd141 in ha_innobase::create (this=0x7f095026bb50, name=0x7f095026fc4d "./test/#sql-9f62_191", form=0x7f0900000096, create_info=0xfe12a04d76a, file_per_table=false, trx=0x7f0950266ab0) at /mariadb/10.3/storage/innobase/handler/ha_innodb.cc:12600
#16 0x000000000103f877 in handler::ha_create (this=0x61c00008e8a0, name=0x7f095026fc4d "./test/#sql-9f62_191", form=0x7f095026be60, info_arg=0x7f0950271680) at /mariadb/10.3/sql/handler.cc:4594
#17 0x0000000001042502 in ha_create_table (thd=0x62a0000ae208, path=0xfe12a04d7cd <error: Cannot access memory at address 0xfe12a04d7cd>, db=0x62b0000009c0 "test", table_name=0x7f095026f78a "#sql-9f62_191", create_info=0x7f0950271680, frm=0x7f095026fc4d) at /mariadb/10.3/sql/handler.cc:4968
#18 0x0000000000ba721a in mysql_alter_table (thd=0x62a0000ae208, new_db=0x13, new_name=0x6, create_info=0x7f0950271680, table_list=<optimized out>, alter_info=0x7f0950271860, order_num=<optimized out>, order=<optimized out>, ignore=<optimized out>) at /mariadb/10.3/sql/sql_table.cc:9753
#19 0x0000000000cebe53 in Sql_cmd_alter_table::execute (this=<optimized out>, thd=0x62a0000ae208) at /mariadb/10.3/sql/sql_alter.cc:491
#20 0x000000000096a666 in mysql_execute_command (thd=0x62a0000ae208) at /mariadb/10.3/sql/sql_parse.cc:6284

Comment by Marko Mäkelä [ 2018-12-10 ]

Here is an idea for reproducing (based on the non-deterministic MDEV-17938 test case):

--source include/have_innodb.inc
 
call mtr.add_suppression("InnoDB:");
 
CREATE TABLE t1 (
  pk INT AUTO_INCREMENT,
  f1 VARCHAR(8),
  f2 INT,
  PRIMARY KEY (pk),
  FULLTEXT(f1)
) ENGINE=InnoDB;
 
CREATE TABLE t2 (f INT) ENGINE=InnoDB;
SET @save_dbug = @@session.debug_dbug;
SET debug_dbug = '+d,row_drop_table_add_to_background';
--error ER_CANT_CREATE_TABLE
ALTER TABLE t1 ADD FOREIGN KEY (f2) REFERENCES t2 (f), DROP FOREIGN KEY IF EXISTS x;
SET debug_dbug = @save_dbug;
ALTER TABLE t2 FORCE;
 
# Cleanup
DROP TABLE t1, t2;

It failed to reproduce the error for me.

Comment by Matthias Leich [ 2019-01-31 ]

table_stress1.test is a test case which replayed the problem
- frequent but not all time on
  10.3 4e599c74bb673e6d752bdacffbe014cbfd033b0a 2019-01-30
- nearly all time
  10.4 923415ffdb4ce2ef66d53077414abc2845a768e6
compiled with ASAN.
So some 
./mysql-test-run.pl --mem --repeat=30 table_stress1
is some better choice.

Comment by Elena Stepanova [ 2019-01-31 ]

Please note that apparently neither Matthias nor I encountered it on 10.2, but it was added to affectedVersions by marko, so I'm keeping it there.

Comment by Thirunarayanan Balathandayuthapani [ 2019-09-11 ]

Approved by Marko via Slack

Generated at Thu Feb 08 08:40:17 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.