[MDEV-17717] Assertion `!table->pos_in_locked_tables' failed in tc_release_table on flushing RocksDB table under SERIALIZABLE Created: 2018-11-14  Updated: 2019-08-08  Resolved: 2019-08-08

Status: Closed
Project: MariaDB Server
Component/s: Admin statements, Data Definition - Alter Table, Locking, Storage Engine - RocksDB
Affects Version/s: 10.2, 10.3, 10.4
Fix Version/s: 10.2.27, 10.3.18, 10.4.8, 10.5.0

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Michael Widenius
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Duplicate
duplicates MDEV-19591 Assertion `!table->pos_in_locked_tabl... Closed
Relates
relates to MDEV-17998 Deadlock and eventual Assertion `!tab... Closed

 Description   

Run with RocksDB enabled:

--source include/have_binlog_format_row.inc
 
CREATE TABLE t1 (pk INT PRIMARY KEY) ENGINE=RocksDB;
LOCK TABLE t1 WRITE;
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
FLUSH TABLES;
 
# Cleanup
DROP TABLE t1;

10.2 32bebfee

mysqld: /data/src/10.2/sql/table_cache.cc:453: void tc_release_table(TABLE*): Assertion `!table->pos_in_locked_tables' failed.
181114 16:40:23 [ERROR] mysqld got signal 6 ;
 
#7  0x00007fd683225ee2 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
#8  0x000055a483962206 in tc_release_table (table=0x7fd64c081a40) at /data/src/10.2/sql/table_cache.cc:453
#9  0x000055a4836fbe82 in close_thread_table (thd=0x7fd64c000b00, table_ptr=0x7fd64c000be0) at /data/src/10.2/sql/sql_base.cc:903
#10 0x000055a4836fe8ff in Locked_tables_list::unlink_all_closed_tables (this=0x7fd64c004550, thd=0x7fd64c000b00, lock=0x0, reopen_count=0) at /data/src/10.2/sql/sql_base.cc:2367
#11 0x000055a4836feccc in Locked_tables_list::reopen_tables (this=0x7fd64c004550, thd=0x7fd64c000b00, need_reopen=false) at /data/src/10.2/sql/sql_base.cc:2464
#12 0x000055a4836fb0e2 in close_cached_tables (thd=0x7fd64c000b00, tables=0x0, wait_for_refresh=true, timeout=86400) at /data/src/10.2/sql/sql_base.cc:485
#13 0x000055a4838f340f in reload_acl_and_cache (thd=0x7fd64c000b00, options=4, tables=0x0, write_to_binlog=0x7fd66cf3e910) at /data/src/10.2/sql/sql_reload.cc:344
#14 0x000055a483776d25 in mysql_execute_command (thd=0x7fd64c000b00) at /data/src/10.2/sql/sql_parse.cc:5401
#15 0x000055a48377e865 in mysql_parse (thd=0x7fd64c000b00, rawbuf=0x7fd64c012548 "FLUSH TABLES", length=12, parser_state=0x7fd66cf3f200, is_com_multi=false, is_next_command=false) at /data/src/10.2/sql/sql_parse.cc:8012
#16 0x000055a48376c1af in dispatch_command (command=COM_QUERY, thd=0x7fd64c000b00, packet=0x7fd64c18bd11 "FLUSH TABLES", packet_length=12, is_com_multi=false, is_next_command=false) at /data/src/10.2/sql/sql_parse.cc:1824
#17 0x000055a48376ab12 in do_command (thd=0x7fd64c000b00) at /data/src/10.2/sql/sql_parse.cc:1378
#18 0x000055a4838bd06d in do_handle_one_connection (connect=0x55a485e05b20) at /data/src/10.2/sql/sql_connect.cc:1335
#19 0x000055a4838bcdfa in handle_one_connection (arg=0x55a485e05b20) at /data/src/10.2/sql/sql_connect.cc:1241
#20 0x000055a483ce045c in pfs_spawn_thread (arg=0x55a485d51d20) at /data/src/10.2/storage/perfschema/pfs.cc:1862
#21 0x00007fd684ce1494 in start_thread (arg=0x7fd66cf40700) at pthread_create.c:333
#22 0x00007fd6832e293f in clone () from /lib/x86_64-linux-gnu/libc.so.6

Non-debug build produces an error which is probably expected:

query 'FLUSH TABLES' failed: 4057: MyRocks supports only READ COMMITTED and REPEATABLE READ isolation levels. Please change from current isolation level SERIALIZABLE



 Comments   
Comment by Elena Stepanova [ 2018-11-25 ]

There is a similar failure MDEV-17998 which doesn't require RocksDB and happens on 10.1/10.2, but it involves KILL_TIMEOUT on FLUSH TABLES, so it might be a different issue, thus I filed it separately.

Comment by Michael Widenius [ 2019-08-08 ]

This crash happens in debug builds when using LOCK TABLE together with ALTER TABLE or FLUSH TABLES and the command aborts, which causes a call to unlink_all_closed_tables()

The bug was that unlink_all_closed_tables() didn't reset thd->open_tables->pos_in_locked_tables

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