[MDEV-19297] InnoDB: Failing assertion: thr->magic_n == QUE_THR_MAGIC_N upon dropping a versioned table Created: 2019-04-21  Updated: 2020-05-24  Resolved: 2020-05-24

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - InnoDB, Versioned Tables
Affects Version/s: 10.4
Fix Version/s: 10.4.7

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Aleksey Midenkov
Resolution: Fixed Votes: 0
Labels: None


 Description   

--source include/have_innodb.inc
 
CREATE TABLE t1 (
  f1 BOOLEAN,
  f2 DOUBLE,
  f3 VARCHAR(128),
  f4 BIGINT,
  s DATETIME,
  e DATETIME,
  PERIOD FOR app(s,e),
  row_start BIGINT UNSIGNED AS ROW START,
  row_end BIGINT UNSIGNED AS ROW END,
  PERIOD FOR SYSTEM_TIME(row_start,row_end)
) WITH SYSTEM VERSIONING ENGINE=InnoDB;
INSERT INTO t1 (s,e) VALUES
  ('2022-12-11 14:22:34', '2025-12-17 07:42:44'),
  ('2014-05-22 00:00:00', '2015-12-28 20:53:28'),
  ('2020-12-13 00:00:00', '2024-11-12 00:00:00');
DELETE FROM t1 FOR PORTION OF app FROM '2021-08-23 09:25:15' TO '2022-10-15 13:27:04';
DELETE FROM t1 FOR PORTION OF app FROM '2023-01-08 14:22:34' TO '2025-12-16 13:32:12';
DELETE FROM t1;
INSERT INTO t1 SELECT * FROM t1 FOR SYSTEM_TIME ALL;
DELETE FROM t1 FOR PORTION OF app FROM '2022-11-12 14:22:34' TO '2030-05-11 09:42:44' LIMIT 3;
DELETE HISTORY FROM t1;
DROP TABLE t1;

10.4 a65d3b2c

2019-04-21 20:03:15 0x7f7c618d6700  InnoDB: Assertion failure in file /data/src/10.4/storage/innobase/que/que0que.cc line 435
InnoDB: Failing assertion: thr->magic_n == QUE_THR_MAGIC_N
 
#5  0x00007f7c67d653fa in abort () from /lib/x86_64-linux-gnu/libc.so.6
#6  0x000055caa2968a7c in ut_dbg_assertion_failed (expr=0x55caa2ff5190 "thr->magic_n == QUE_THR_MAGIC_N", file=0x55caa2ff5050 "/data/src/10.4/storage/innobase/que/que0que.cc", line=435) at /data/src/10.4/storage/innobase/ut/ut0dbg.cc:60
#7  0x000055caa284fef9 in que_graph_free_recursive (node=0x7f7c10152c48) at /data/src/10.4/storage/innobase/que/que0que.cc:435
#8  0x000055caa28a8c7e in row_prebuilt_free (prebuilt=0x7f7c10151ba8, dict_locked=0) at /data/src/10.4/storage/innobase/row/row0mysql.cc:1006
#9  0x000055caa273d54e in ha_innobase::close (this=0x7f7c101a13d8) at /data/src/10.4/storage/innobase/handler/ha_innodb.cc:6542
#10 0x000055caa24c727a in handler::ha_close (this=0x7f7c101a13d8) at /data/src/10.4/sql/handler.cc:2968
#11 0x000055caa22ac858 in closefrm (table=0x7f7c1000d320) at /data/src/10.4/sql/table.cc:4000
#12 0x000055caa23f639d in intern_close_table (table=0x7f7c1000d320) at /data/src/10.4/sql/table_cache.cc:222
#13 0x000055caa23f927f in tdc_remove_table (thd=0x7f7c10000b00, remove_type=TDC_RT_REMOVE_ALL, db=0x7f7c10015d48 "test", table_name=0x7f7c10015668 "t1", kill_delayed_threads=false) at /data/src/10.4/sql/table_cache.cc:1151
#14 0x000055caa225f3be in mysql_rm_table_no_locks (thd=0x7f7c10000b00, tables=0x7f7c100156a0, if_exists=false, drop_temporary=false, drop_view=false, drop_sequence=false, dont_log_query=false, dont_free_locks=false) at /data/src/10.4/sql/sql_table.cc:2488
#15 0x000055caa225e4c3 in mysql_rm_table (thd=0x7f7c10000b00, tables=0x7f7c100156a0, if_exists=false, drop_temporary=false, drop_sequence=false) at /data/src/10.4/sql/sql_table.cc:2114
#16 0x000055caa218f671 in mysql_execute_command (thd=0x7f7c10000b00) at /data/src/10.4/sql/sql_parse.cc:5111
#17 0x000055caa2199a13 in mysql_parse (thd=0x7f7c10000b00, rawbuf=0x7f7c100155e8 "DROP TABLE t1", length=13, parser_state=0x7f7c618d5180, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:8154
#18 0x000055caa218546a in dispatch_command (command=COM_QUERY, thd=0x7f7c10000b00, packet=0x7f7c1013a2c1 "DROP TABLE t1", packet_length=13, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:1832
#19 0x000055caa2183c50 in do_command (thd=0x7f7c10000b00) at /data/src/10.4/sql/sql_parse.cc:1365
#20 0x000055caa22fc033 in do_handle_one_connection (connect=0x55caa5b30360) at /data/src/10.4/sql/sql_connect.cc:1398
#21 0x000055caa22fbda4 in handle_one_connection (arg=0x55caa5b30360) at /data/src/10.4/sql/sql_connect.cc:1301
#22 0x000055caa27202f5 in pfs_spawn_thread (arg=0x55caa5bb8020) at /data/src/10.4/storage/perfschema/pfs.cc:1862
#23 0x00007f7c69e51494 in start_thread (arg=0x7f7c618d6700) at pthread_create.c:333
#24 0x00007f7c67e1993f in clone () from /lib/x86_64-linux-gnu/libc.so.6

All of debug, ASAN and non-debug builds fail in the same way.



 Comments   
Comment by Elena Stepanova [ 2020-05-16 ]

Doesn't fail on the current 10.4 a4996f95 or 10.5 69077dea

Comment by Elena Stepanova [ 2020-05-24 ]

The behavior was first transformed into MDEV-19814 after this patch:

commit 48a662dae5cd5dcc2d3cd9cd03104b5152c1d23c 7056812ed15abb398089b9c6aa6d7bf5c3cb8c0e
Author:     Eugene Kosov
AuthorDate: Sun May 19 23:15:55 2019 +0300
Commit:     Marko Mäkelä
CommitDate: Mon May 20 10:23:17 2019 +0300
 
    MDEV-19486 Server crashes in row_upd or row_upd_del_mark_clust_rec on REPLACE into a versioned table
    
    row_insert_for_mysql(): InnoDB sets values for row_start and row_end.
    And this function used to return those values to server in
    ha_innobase::write_row().  This buggy behavior was removed. Also,
    a piece of code in this function was reformatted.
    
    upd_node_t::make_versioned_helper(): Assert that the preallocated size
    of the update vector is not exceeded.

And then eventually the test case started passing on 10.4 after this merge

commit 4c7a74396497ae28779016b5bd59283aeee0b6f4
Merge: de9e3930940 29df1003d9f
Author: Eugene Kosov
Date:   Fri Jul 26 15:22:31 2019 +0300
 
    Merge 10.3 into 10.4

which included

commit f6d0d309fa4ffe1d5890c09447d947103143a68a
Author: Aleksey Midenkov
Date:   Tue Jul 23 13:27:57 2019 +0300
 
    MDEV-19814 Assertion `update->n_fields < ulint(table->n_cols + table->n_v_cols)' on DELETE HISTORY
    
    Turn off versioned_write for DELETE HISTORY.

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