[MDEV-25589] Assertion `!thd || thd->locked_tables_mode || !thd->mdl_context.has_locks() || thd->handler_tables_hash.records || thd->ull_hash.records || thd->global_read_lock.is_acquired()' failed. Created: 2021-05-04  Updated: 2024-01-24

Status: Confirmed
Project: MariaDB Server
Component/s: None
Affects Version/s: 10.2, 10.3, 10.4
Fix Version/s: 10.4

Type: Bug Priority: Minor
Reporter: Ramesh Sivaraman Assignee: Oleksandr Byelkin
Resolution: Unresolved Votes: 0
Labels: crash, not-10.5, not-10.6

Issue Links:
Relates
relates to MDEV-21994 Assertion `!thd || thd->locked_tables... Closed

 Description   

Looks similar to MDEV-21994, but the crash is not due to backup lock and the versions affected are different (ref below)

SET autocommit=FALSE;
ALTER TABLE mysql.columns_priv ENGINE=InnoDB;
FLUSH PRIVILEGES;

Leads to:

10.3.29 eb7c5530eccb7d6782077e5562f5a471d2ccbc01 (Debug)

mysqld: /test/10.3_dbg/sql/sql_reload.cc:213: bool reload_acl_and_cache(THD*, long long unsigned int, TABLE_LIST*, int*): Assertion `!thd || thd->locked_tables_mode || !thd->mdl_context.has_locks() || thd->handler_tables_hash.records || thd->ull_hash.records || thd->global_read_lock.is_acquired()' failed.

10.3.29 eb7c5530eccb7d6782077e5562f5a471d2ccbc01 (Debug)

Core was generated by `/test/MD160321-mariadb-10.3.29-linux-x86_64-dbg/bin/mysqld --no-defaults --core'.
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 0x152df40bd700 (LWP 4059893))]
(gdb) bt
#0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=6) at ../sysdeps/unix/sysv/linux/pthread_kill.c:56
#1  0x000055e0b2960b86 in my_write_core (sig=sig@entry=6) at /test/10.3_dbg/mysys/stacktrace.c:386
#2  0x000055e0b210bb91 in handle_fatal_signal (sig=6) at /test/10.3_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  0x0000152df7819859 in __GI_abort () at abort.c:79
#6  0x0000152df7819729 in __assert_fail_base (fmt=0x152df79af588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x55e0b2a45e28 "!thd || thd->locked_tables_mode || !thd->mdl_context.has_locks() || thd->handler_tables_hash.records || thd->ull_hash.records || thd->global_read_lock.is_acquired()", file=0x55e0b2a45e00 "/test/10.3_dbg/sql/sql_reload.cc", line=213, function=<optimized out>) at assert.c:92
#7  0x0000152df782af36 in __GI___assert_fail (assertion=assertion@entry=0x55e0b2a45e28 "!thd || thd->locked_tables_mode || !thd->mdl_context.has_locks() || thd->handler_tables_hash.records || thd->ull_hash.records || thd->global_read_lock.is_acquired()", file=file@entry=0x55e0b2a45e00 "/test/10.3_dbg/sql/sql_reload.cc", line=line@entry=213, function=function@entry=0x55e0b2a45db0 "bool reload_acl_and_cache(THD*, long long unsigned int, TABLE_LIST*, int*)") at assert.c:101
#8  0x000055e0b1fe24bd in reload_acl_and_cache (thd=thd@entry=0x152d98000d90, options=1, tables=tables@entry=0x0, write_to_binlog=write_to_binlog@entry=0x152df40bae70) at /test/10.3_dbg/sql/sql_class.h:1989
#9  0x000055e0b1e84f0c in mysql_execute_command (thd=thd@entry=0x152d98000d90) at /test/10.3_dbg/sql/sql_parse.cc:5421
#10 0x000055e0b1e894c4 in mysql_parse (thd=thd@entry=0x152d98000d90, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x152df40bc540, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.3_dbg/sql/sql_parse.cc:7867
#11 0x000055e0b1e8bc32 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x152d98000d90, packet=packet@entry=0x152d980198f1 "FLUSH PRIVILEGES", packet_length=packet_length@entry=16, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.3_dbg/sql/sql_class.h:1139
#12 0x000055e0b1e8eddf in do_command (thd=0x152d98000d90) at /test/10.3_dbg/sql/sql_parse.cc:1398
#13 0x000055e0b1fb47db in do_handle_one_connection (connect=connect@entry=0x55e0b64a8cd0) at /test/10.3_dbg/sql/sql_connect.cc:1403
#14 0x000055e0b1fb4a12 in handle_one_connection (arg=0x55e0b64a8cd0) at /test/10.3_dbg/sql/sql_connect.cc:1308
#15 0x0000152df7d1f609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#16 0x0000152df7916293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

10.2.38 (Debug)

mysqld: /test/10.2_dbg/sql/sql_reload.cc:220: bool reload_acl_and_cache(THD*, long long unsigned int, TABLE_LIST*, int*): Assertion `!thd || thd->locked_tables_mode || !thd->mdl_context.has_locks() || thd->handler_tables_hash.records || thd->ull_hash.records || thd->global_read_lock.is_acquired()' failed.

10.2.38 (Debug)

Core was generated by `/test/MD160321-mariadb-10.2.38-linux-x86_64-dbg/bin/mysqld --no-defaults --core'.
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 0x14bf98142700 (LWP 4035190))]
(gdb) bt
#0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=6) at ../sysdeps/unix/sysv/linux/pthread_kill.c:56
#1  0x000055d94e7c7f9a in my_write_core (sig=sig@entry=6) at /test/10.2_dbg/mysys/stacktrace.c:382
#2  0x000055d94e0ae043 in handle_fatal_signal (sig=6) at /test/10.2_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  0x000014bfb31ee859 in __GI_abort () at abort.c:79
#6  0x000014bfb31ee729 in __assert_fail_base (fmt=0x14bfb3384588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x55d94e89d120 "!thd || thd->locked_tables_mode || !thd->mdl_context.has_locks() || thd->handler_tables_hash.records || thd->ull_hash.records || thd->global_read_lock.is_acquired()", file=0x55d94e89d0f8 "/test/10.2_dbg/sql/sql_reload.cc", line=220, function=<optimized out>) at assert.c:92
#7  0x000014bfb31fff36 in __GI___assert_fail (assertion=assertion@entry=0x55d94e89d120 "!thd || thd->locked_tables_mode || !thd->mdl_context.has_locks() || thd->handler_tables_hash.records || thd->ull_hash.records || thd->global_read_lock.is_acquired()", file=file@entry=0x55d94e89d0f8 "/test/10.2_dbg/sql/sql_reload.cc", line=line@entry=220, function=function@entry=0x55d94e89d0a8 "bool reload_acl_and_cache(THD*, long long unsigned int, TABLE_LIST*, int*)") at assert.c:101
#8  0x000055d94dfe36f6 in reload_acl_and_cache (thd=thd@entry=0x14bf54000d90, options=1, tables=tables@entry=0x0, write_to_binlog=write_to_binlog@entry=0x14bf9813ffc0) at /test/10.2_dbg/sql/sql_plist.h:84
#9  0x000055d94dead0ef in mysql_execute_command (thd=thd@entry=0x14bf54000d90) at /test/10.2_dbg/sql/sql_parse.cc:5202
#10 0x000055d94deb0e33 in mysql_parse (thd=thd@entry=0x14bf54000d90, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x14bf98141550, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.2_dbg/sql/sql_parse.cc:7790
#11 0x000055d94deb3933 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x14bf54000d90, packet=packet@entry=0x14bf540195d1 "FLUSH PRIVILEGES", packet_length=packet_length@entry=16, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.2_dbg/sql/sql_class.h:1109
#12 0x000055d94deb673c in do_command (thd=0x14bf54000d90) at /test/10.2_dbg/sql/sql_parse.cc:1381
#13 0x000055d94dfb9bcc in do_handle_one_connection (connect=connect@entry=0x55d951b272e0) at /test/10.2_dbg/sql/sql_connect.cc:1336
#14 0x000055d94dfb9df7 in handle_one_connection (arg=0x55d951b272e0) at /test/10.2_dbg/sql/sql_connect.cc:1241
#15 0x000014bfb36f4609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#16 0x000014bfb32eb293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Bug confirmed present in:
MariaDB: 10.2.38 (dbg), 10.3.29 (dbg)

Bug (or feature/syntax) confirmed not present in:
MariaDB: 10.2.38 (opt), 10.3.29 (opt), 10.4.19 (dbg), 10.4.19 (opt), 10.5.10 (dbg), 10.5.10 (opt), 10.6.0 (dbg), 10.6.0 (opt)



 Comments   
Comment by Ramesh Sivaraman [ 2021-05-04 ]

Found that the same test case crashes 10.4 with similar assertion as MDEV-21994.

10.4.19 1ea6ac3c953f847da033254d5df67f57987a1884 (Debug)

mysqld: /test/10.4_dbg/sql/sql_reload.cc:215: bool reload_acl_and_cache(THD*, long long unsigned int, TABLE_LIST*, int*): Assertion `!thd || thd->locked_tables_mode || !thd->mdl_context.has_locks() || thd->handler_tables_hash.records || thd->ull_hash.records || thd->global_read_lock.is_acquired() || thd->mdl_backup_lock || thd->current_backup_stage != BACKUP_FINISHED' failed.

10.4.19 1ea6ac3c953f847da033254d5df67f57987a1884 (Debug)

 

Core was generated by `/test/MD160321-mariadb-10.4.19-linux-x86_64-dbg/bin/mysqld --no-defaults --core'.
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 0x1499780c3700 (LWP 1263426))]
(gdb) bt
#0 __pthread_kill (threadid=<optimized out>, signo=signo@entry=6) at ../sysdeps/unix/sysv/linux/pthread_kill.c:56
#1 0x0000560997ea6b25 in my_write_core (sig=sig@entry=6) at /test/10.4_dbg/mysys/stacktrace.c:386
#2 0x00005609975a72e6 in handle_fatal_signal (sig=6) at /test/10.4_dbg/sql/signal_handler.cc:344
#3 <signal handler called>
#4 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#5 0x0000149990546859 in __GI_abort () at abort.c:79
#6 0x0000149990546729 in __assert_fail_base (fmt=0x1499906dc588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x560997fc4108 "!thd || thd->locked_tables_mode || !thd->mdl_context.has_locks() || thd->handler_tables_hash.records || thd->ull_hash.records || thd->global_read_lock.is_acquired() || thd->mdl_backup_lock || thd->cur"..., file=0x560997fc40e0 "/test/10.4_dbg/sql/sql_reload.cc", line=215, function=<optimized out>) at assert.c:92
#7 0x0000149990557f36 in _GI__assert_fail (assertion=assertion@entry=0x560997fc4108 "!thd || thd->locked_tables_mode || !thd->mdl_context.has_locks() || thd->handler_tables_hash.records || thd->ull_hash.records || thd->global_read_lock.is_acquired() || thd->mdl_backup_lock || thd->cur"..., file=file@entry=0x560997fc40e0 "/test/10.4_dbg/sql/sql_reload.cc", line=line@entry=215, function=function@entry=0x560997fc4090 "bool reload_acl_and_cache(THD*, long long unsigned int, TABLE_LIST*, int*)") at assert.c:101
#8 0x000056099744f6ad in reload_acl_and_cache (thd=thd@entry=0x149928000d90, options=1, tables=tables@entry=0x0, write_to_binlog=write_to_binlog@entry=0x1499780c0cd0) at /test/10.4_dbg/sql/sql_class.h:1973
#9 0x00005609972da247 in mysql_execute_command (thd=thd@entry=0x149928000d90) at /test/10.4_dbg/sql/sql_parse.cc:5543
#10 0x00005609972deebb in mysql_parse (thd=thd@entry=0x149928000d90, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x1499780c2490, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.4_dbg/sql/sql_parse.cc:7985
#11 0x00005609972e1719 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x149928000d90, packet=packet@entry=0x14992801a351 "FLUSH PRIVILEGES", packet_length=packet_length@entry=16, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.4_dbg/sql/sql_class.h:1170
#12 0x00005609972e4f4e in do_command (thd=0x149928000d90) at /test/10.4_dbg/sql/sql_parse.cc:1373
#13 0x000056099741d726 in do_handle_one_connection (connect=connect@entry=0x56099b901260) at /test/10.4_dbg/sql/sql_connect.cc:1412
#14 0x000056099741d845 in handle_one_connection (arg=0x56099b901260) at /test/10.4_dbg/sql/sql_connect.cc:1316
#15 0x0000149990b03609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#16 0x0000149990643293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:

Comment by Roel Van de Paar [ 2024-01-24 ]

Confirmed 10.4 only. No occurrence in 10.5+

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