[MDEV-25463] Assertion `!thd->mdl_context.has_locks()' failed in dispatch_command_return do_command(THD*, bool) Created: 2021-04-20  Updated: 2023-06-06

Status: Open
Project: MariaDB Server
Component/s: Galera
Affects Version/s: 10.4, 10.5, 10.6
Fix Version/s: 10.4, 10.5

Type: Bug Priority: Major
Reporter: Ramesh Sivaraman Assignee: Daniele Sciascia
Resolution: Unresolved Votes: 0
Labels: not-10.2, not-10.3


 Description   

SET @@global.wsrep_on=OFF;
XA START 'a';
SELECT GET_LOCK('test', 0) = 0 expect_1;
XA END 'a';
CACHE INDEX t1 PARTITION (ALL) KEY (`inx_b`,`PRIMARY`) IN default;
SELECT SLEEP(3);

Leads to

8751aa7397b2e698fa0b46ec3e60abb9e2fd7e1b (Debug)

mysqld: /test/10.6_dbg/sql/sql_parse.cc:1344: dispatch_command_return do_command(THD*, bool): Assertion `!thd->mdl_context.has_locks()' failed.

8751aa7397b2e698fa0b46ec3e60abb9e2fd7e1b (Debug)

Core was generated by `/test/GAL_MD200421-mariadb-10.6.0-linux-x86_64-dbg/bin/mysqld --defaults-file=/'.
Program terminated with signal SIGABRT, Aborted.
#0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=6)
    at ../sysdeps/unix/sysv/linux/pthread_kill.c:56
[Current thread is 1 (Thread 0x145920c11700 (LWP 1787885))]
(gdb) bt
#0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=6) at ../sysdeps/unix/sysv/linux/pthread_kill.c:56
#1  0x0000555d7f20270f in my_write_core (sig=sig@entry=6) at /test/10.6_dbg/mysys/stacktrace.c:424
#2  0x0000555d7e997c86 in handle_fatal_signal (sig=6) at /test/10.6_dbg/sql/signal_handler.cc:343
#3  <signal handler called>
#4  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#5  0x0000145932e05859 in __GI_abort () at abort.c:79
#6  0x0000145932e05729 in __assert_fail_base (fmt=0x145932f9b588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x555d7f3748cd "!thd->mdl_context.has_locks()", file=0x555d7f3714d8 "/test/10.6_dbg/sql/sql_parse.cc", line=1344, function=<optimized out>) at assert.c:92
#7  0x0000145932e16f36 in __GI___assert_fail (assertion=assertion@entry=0x555d7f3748cd "!thd->mdl_context.has_locks()", file=file@entry=0x555d7f3714d8 "/test/10.6_dbg/sql/sql_parse.cc", line=line@entry=1344, function=function@entry=0x555d7f3746d0 "dispatch_command_return do_command(THD*, bool)") at assert.c:101
#8  0x0000555d7e6d33df in do_command (thd=0x1458c4000db8, blocking=blocking@entry=true) at /test/10.6_dbg/sql/sql_plist.h:82
#9  0x0000555d7e82e26d in do_handle_one_connection (connect=<optimized out>, connect@entry=0x555d81543798, put_in_cache=put_in_cache@entry=true) at /test/10.6_dbg/sql/sql_connect.cc:1410
#10 0x0000555d7e82e875 in handle_one_connection (arg=arg@entry=0x555d81543798) at /test/10.6_dbg/sql/sql_connect.cc:1312
#11 0x0000555d7ecdf2f7 in pfs_spawn_thread (arg=0x555d815bb508) at /test/10.6_dbg/storage/perfschema/pfs.cc:2201
#12 0x0000145933313609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#13 0x0000145932f02293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

675c22c065110be03a5fab82442d2c3dc32aefff (Debug)

mysqld: /test/10.5_dbg/sql/sql_parse.cc:1310: bool do_command(THD*): Assertion `!thd->mdl_context.has_locks()' failed.

675c22c065110be03a5fab82442d2c3dc32aefff (Debug)

Core was generated by `/test/GAL_MD200421-mariadb-10.5.10-linux-x86_64-dbg/bin/mysqld --defaults-file='.
Program terminated with signal SIGABRT, Aborted.
#0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=6)
    at ../sysdeps/unix/sysv/linux/pthread_kill.c:56
[Current thread is 1 (Thread 0x146ff0c73700 (LWP 2137671))]
(gdb) bt
#0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=6) at ../sysdeps/unix/sysv/linux/pthread_kill.c:56
#1  0x00005637321831a6 in my_write_core (sig=sig@entry=6) at /test/10.5_dbg/mysys/stacktrace.c:424
#2  0x00005637318ca92e in handle_fatal_signal (sig=6) at /test/10.5_dbg/sql/signal_handler.cc:343
#3  <signal handler called>
#4  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#5  0x0000147026121859 in __GI_abort () at abort.c:79
#6  0x0000147026121729 in __assert_fail_base (fmt=0x1470262b7588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x5637322f5e9d "!thd->mdl_context.has_locks()", file=0x5637322f2bf8 "/test/10.5_dbg/sql/sql_parse.cc", line=1310, function=<optimized out>) at assert.c:92
#7  0x0000147026132f36 in __GI___assert_fail (assertion=assertion@entry=0x5637322f5e9d "!thd->mdl_context.has_locks()", file=file@entry=0x5637322f2bf8 "/test/10.5_dbg/sql/sql_parse.cc", line=line@entry=1310, function=function@entry=0x5637322f5e54 "bool do_command(THD*)") at assert.c:101
#8  0x00005637316013a4 in do_command (thd=0x146fb0000db8) at /test/10.5_dbg/sql/sql_plist.h:82
#9  0x000056373175e514 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x563734611e58, put_in_cache=put_in_cache@entry=true) at /test/10.5_dbg/sql/sql_connect.cc:1410
#10 0x000056373175ec1b in handle_one_connection (arg=arg@entry=0x563734611e58) at /test/10.5_dbg/sql/sql_connect.cc:1312
#11 0x0000563731c1a747 in pfs_spawn_thread (arg=0x563734679bf8) at /test/10.5_dbg/storage/perfschema/pfs.cc:2201
#12 0x000014702662f609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#13 0x000014702621e293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

57caff245cbdcbdfda6f022de7f354f05a790656 (Debug)

mysqld: /test/10.4_dbg/sql/sql_parse.cc:1313: bool do_command(THD*): Assertion `!thd->mdl_context.has_locks()' failed.

57caff245cbdcbdfda6f022de7f354f05a790656 (Debug)

Core was generated by `/test/GAL_MD200421-mariadb-10.4.19-linux-x86_64-dbg/bin/mysqld --defaults-file='.
Program terminated with signal SIGABRT, Aborted.
#0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=6)
    at ../sysdeps/unix/sysv/linux/pthread_kill.c:56
[Current thread is 1 (Thread 0x148174feb700 (LWP 2129843))]
(gdb) bt
#0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=6) at ../sysdeps/unix/sysv/linux/pthread_kill.c:56
#1  0x000055e54eb0819d in my_write_core (sig=sig@entry=6) at /test/10.4_dbg/mysys/stacktrace.c:386
#2  0x000055e54e210cda in handle_fatal_signal (sig=6) at /test/10.4_dbg/sql/signal_handler.cc:356
#3  <signal handler called>
#4  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#5  0x00001481b9911859 in __GI_abort () at abort.c:79
#6  0x00001481b9911729 in __assert_fail_base (fmt=0x1481b9aa7588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x55e54ebe4933 "!thd->mdl_context.has_locks()", file=0x55e54ebe2438 "/test/10.4_dbg/sql/sql_parse.cc", line=1313, function=<optimized out>) at assert.c:92
#7  0x00001481b9922f36 in __GI___assert_fail (assertion=assertion@entry=0x55e54ebe4933 "!thd->mdl_context.has_locks()", file=file@entry=0x55e54ebe2438 "/test/10.4_dbg/sql/sql_parse.cc", line=line@entry=1313, function=function@entry=0x55e54ebe48ea "bool do_command(THD*)") at assert.c:101
#8  0x000055e54df4aa9e in do_command (thd=0x148134000d90) at /test/10.4_dbg/sql/sql_plist.h:82
#9  0x000055e54e08588f in do_handle_one_connection (connect=connect@entry=0x55e551a10db0) at /test/10.4_dbg/sql/sql_connect.cc:1412
#10 0x000055e54e0859ae in handle_one_connection (arg=0x55e551a10db0) at /test/10.4_dbg/sql/sql_connect.cc:1316
#11 0x00001481b9ece609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#12 0x00001481b9a0e293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95



 Comments   
Comment by Ramesh Sivaraman [ 2021-06-10 ]

Another testcase

CREATE TABLE t (a TEXT , KEY a (a));
SELECT get_lock ('a',0);
SET wsrep_on=OFF;
INSERT INTO t VALUES ('a');
ALTER TABLE t LOCK=EXCLUSIVE,RENAME TO t2;
CREATE TABLE t1 (a INT) SELECT * FROM t2 LOCK IN share mode;
SELECT 1;

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