[MDEV-21755] Assertion `0' failed in add_to_locked_mutex upon shutdown or DROP TABLE Created: 2020-02-17  Updated: 2021-02-21  Resolved: 2021-02-21

Status: Closed
Project: MariaDB Server
Component/s: Locking, Storage Engine - Aria
Affects Version/s: 10.2, 10.3
Fix Version/s: 10.5.4, 10.2.33, 10.3.24, 10.4.14

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: not-10.4

Issue Links:
Relates
relates to MDEV-18088 Assertion `share->in_trans == 0' fail... Closed
relates to MDEV-21754 Assertion `file->trn == trn' failed i... Closed

 Description   

CREATE TABLE t1 (a INT) ENGINE=Aria;
CREATE VIEW v1 AS SELECT * FROM t1;
CREATE TABLE t2 (b INT) ENGINE=Aria;
CREATE TABLE t3 (a INT);
LOCK TABLES t1 WRITE CONCURRENT, v1 WRITE, t2 WRITE CONCURRENT;
--error ER_BAD_FIELD_ERROR
ALTER TABLE t1 CHANGE x xx INT;
--connect (con1,localhost,root,,test)
REPLACE INTO t3 VALUES (NULL);
--connection default
--error ER_TABLE_NOT_LOCKED_FOR_WRITE
FLUSH TABLES;
DELETE FROM t1;

10.2 93dc3e26

2020-02-17 21:45:51 140619617933056 [Note] /data/bld/10.2-debug-nightly/bin/mysqld (initiated by: root[root] @ localhost [127.0.0.1]): Normal shutdown
2020-02-17 21:45:51 140619617933056 [Note] Event Scheduler: Purging the queue. 0 events
mysqld: /data/src/10.2/mysys/thr_mutex.c:747: add_to_locked_mutex: Assertion `0' failed.
200217 21:45:51 [ERROR] mysqld got signal 6 ;
 
stdlib/abort.c:91(__GI_abort)[0x7fe49436b42a]
assert/assert.c:92(__assert_fail_base)[0x7fe494362e67]
/lib/x86_64-linux-gnu/libc.so.6(+0x2bf12)[0x7fe494362f12]
mysys/thr_mutex.c:749(add_to_locked_mutex)[0x562c1ea5fd2c]
mysys/thr_mutex.c:723(add_used_to_locked_mutex)[0x562c1ea5fc30]
mysys/thr_mutex.c:387(safe_mutex_lock)[0x562c1ea5efc0]
psi/mysql_thread.h:673(inline_mysql_mutex_lock)[0x562c1e925920]
maria/ma_close.c:68(maria_close)[0x562c1e925dfd]
maria/ha_maria.cc:1278(ha_maria::close())[0x562c1e8a1ed4]
sql/handler.cc:2650(handler::ha_close())[0x562c1e317853]
sql/table.cc:3490(closefrm(TABLE*))[0x562c1e19b2a6]
sql/table_cache.cc:223(intern_close_table(TABLE*))[0x562c1e288d67]
sql/table_cache.cc:334(tc_purge(bool))[0x562c1e28918b]
sql/sql_base.cc:376(close_cached_tables(THD*, TABLE_LIST*, bool, unsigned long))[0x562c1e01d5ed]
sql/table_cache.cc:648(tdc_start_shutdown())[0x562c1e28a20c]
sql/mysqld.cc:2225(clean_up(bool))[0x562c1df9be5c]
sql/mysqld.cc:2100(unireg_end())[0x562c1df9b95c]
sql/mysqld.cc:2026(kill_server(void*))[0x562c1df9b856]
sql/mysqld.cc:2051(kill_server_thread)[0x562c1df9b898]
perfschema/pfs.cc:1871(pfs_spawn_thread)[0x562c1e9fd6de]
nptl/pthread_create.c:456(start_thread)[0x7fe4962eb4a4]
x86_64/clone.S:99(clone)[0x7fe49441fd0f]

Coredump isn't created.

If I add a cleanup section to the end of the MTR test case, the assertion fails on DROP TABLE rather than on shutdown, but the server hangs before it finally aborts. The coredump is still not created.

CREATE TABLE t1 (a INT) ENGINE=Aria;
CREATE VIEW v1 AS SELECT * FROM t1;
CREATE TABLE t2 (b INT) ENGINE=Aria;
CREATE TABLE t3 (a INT);
LOCK TABLES t1 WRITE CONCURRENT, v1 WRITE, t2 WRITE CONCURRENT;
--error ER_BAD_FIELD_ERROR
ALTER TABLE t1 CHANGE x xx INT;
--connect (con1,localhost,root,,test)
REPLACE INTO t3 VALUES (NULL);
--connection default
--error ER_TABLE_NOT_LOCKED_FOR_WRITE
FLUSH TABLES;
DELETE FROM t1;
 
# Cleanup
UNLOCK TABLES;
--disconnect con1
DROP VIEW v1;
DROP TABLE t1, t2, t3;

10.2 93dc3e26

mysqld: /data/src/10.2/mysys/thr_mutex.c:747: add_to_locked_mutex: Assertion `0' failed.
200217 21:48:51 [ERROR] mysqld got signal 6 ;
 
linux/raise.c:51(__GI_raise)[0x7f5db397cfff]
stdlib/abort.c:91(__GI_abort)[0x7f5db397e42a]
assert/assert.c:92(__assert_fail_base)[0x7f5db3975e67]
/lib/x86_64-linux-gnu/libc.so.6(+0x2bf12)[0x7f5db3975f12]
mysys/thr_mutex.c:749(add_to_locked_mutex)[0x55d52ade3d2c]
mysys/thr_mutex.c:723(add_used_to_locked_mutex)[0x55d52ade3c30]
mysys/thr_mutex.c:387(safe_mutex_lock)[0x55d52ade2fc0]
psi/mysql_thread.h:673(inline_mysql_mutex_lock)[0x55d52aca9920]
maria/ma_close.c:68(maria_close)[0x55d52aca9dfd]
maria/ha_maria.cc:1278(ha_maria::close())[0x55d52ac25ed4]
sql/handler.cc:2650(handler::ha_close())[0x55d52a69b853]
sql/table.cc:3490(closefrm(TABLE*))[0x55d52a51f2a6]
sql/table_cache.cc:223(intern_close_table(TABLE*))[0x55d52a60cd67]
sql/table_cache.cc:1131(tdc_remove_table(THD*, enum_tdc_remove_table_type, char const*, char const*, bool))[0x55d52a60f7fa]
sql/sql_table.cc:2440(mysql_rm_table_no_locks(THD*, TABLE_LIST*, bool, bool, bool, bool, bool))[0x55d52a4db229]
sql/sql_table.cc:2089(mysql_rm_table(THD*, TABLE_LIST*, char, char))[0x55d52a4da5f5]
sql/sql_parse.cc:4505(mysql_execute_command(THD*))[0x55d52a41985b]
sql/sql_parse.cc:7739(mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool))[0x55d52a423bea]
sql/sql_parse.cc:1833(dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool))[0x55d52a411f43]
sql/sql_parse.cc:1384(do_command(THD*))[0x55d52a410897]
sql/sql_connect.cc:1336(do_handle_one_connection(CONNECT*))[0x55d52a5658d3]
sql/sql_connect.cc:1242(handle_one_connection)[0x55d52a56563e]
perfschema/pfs.cc:1871(pfs_spawn_thread)[0x55d52ad816de]
nptl/pthread_create.c:456(start_thread)[0x7f5db58fe4a4]
x86_64/clone.S:99(clone)[0x7f5db3a32d0f]
 
Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (0x7f5d9c012448): DROP TABLE t1, t2, t3
Connection ID (thread ID): 4
Status: NOT_KILLED

Reproducible on 10.2, 10.3.
Not reproducible on 10.1, 10.4.
No visible effect on a non-debug build.
Is likely to be related to MDEV-21754.



 Comments   
Comment by Elena Stepanova [ 2020-12-17 ]

I think it may have been fixed by some of the changes since then. I'll try to make sure.

Comment by Elena Stepanova [ 2021-02-21 ]

The failure stopped happening on 10.2 after this commit:

commit be647ff14d6196af825f05020acee8f18af4773d (HEAD)
Author: Monty
Date:   Fri May 22 18:02:24 2020 +0300
 
    Fixed deadlock with LOCK TABLES and ALTER TABLE

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