[MDEV-25837] Assertion `thd->locked_tables_mode == LTM_NONE' failed in Locked_tables_list::init_locked_tables Created: 2021-06-01  Updated: 2021-06-29  Resolved: 2021-06-29

Status: Closed
Project: MariaDB Server
Component/s: Locking, Views
Affects Version/s: 10.6
Fix Version/s: 10.6.3

Type: Bug Priority: Blocker
Reporter: Elena Stepanova Assignee: Alexey Botchkov
Resolution: Fixed Votes: 0
Labels: regression

Issue Links:
Problem/Incident
is caused by MDEV-15888 Implement FLUSH TABLES tbl_name [, tb... Closed
Relates
relates to MDEV-25906 SIGSEGV in flush_tables_with_read_loc... Closed

 Description   

CREATE FUNCTION f() RETURNS INTEGER RETURN 1;
CREATE TABLE t (a INT);
CREATE VIEW v AS SELECT 2 FROM t WHERE f() < 3;
FLUSH TABLE v WITH READ LOCK;
 
# Cleanup
UNLOCK TABLES;
DROP VIEW v;
DROP FUNCTION f;
DROP TABLE t;

10.6 b118f92b

mariadbd: /data/src/10.6/sql/sql_base.cc:2274: bool Locked_tables_list::init_locked_tables(THD*): Assertion `thd->locked_tables_mode == LTM_NONE' failed.
210601 17:51:10 [ERROR] mysqld got signal 6 ;
 
#6  0x00007f449af28729 in __assert_fail_base (fmt=0x7f449b0be588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x556c6b81c748 "thd->locked_tables_mode == LTM_NONE", file=0x556c6b81bc80 "/data/src/10.6/sql/sql_base.cc", line=2274, function=<optimized out>) at assert.c:92
#7  0x00007f449af39f36 in __GI___assert_fail (assertion=0x556c6b81c748 "thd->locked_tables_mode == LTM_NONE", file=0x556c6b81bc80 "/data/src/10.6/sql/sql_base.cc", line=2274, function=0x556c6b81c770 "bool Locked_tables_list::init_locked_tables(THD*)") at assert.c:101
#8  0x0000556c6a9bdc8d in Locked_tables_list::init_locked_tables (this=0x7f4484004f68, thd=0x7f4484000db8) at /data/src/10.6/sql/sql_base.cc:2274
#9  0x0000556c6ac69e71 in flush_tables_with_read_lock (thd=0x7f4484000db8, all_tables=0x7f4484015690) at /data/src/10.6/sql/sql_reload.cc:616
#10 0x0000556c6aa7323b in mysql_execute_command (thd=0x7f4484000db8) at /data/src/10.6/sql/sql_parse.cc:5397
#11 0x0000556c6aa7b5b2 in mysql_parse (thd=0x7f4484000db8, rawbuf=0x7f44840155c0 "FLUSH TABLE v WITH READ LOCK", length=28, parser_state=0x7f4495794480) at /data/src/10.6/sql/sql_parse.cc:8016
#12 0x0000556c6aa67a3c in dispatch_command (command=COM_QUERY, thd=0x7f4484000db8, packet=0x7f448400b879 "FLUSH TABLE v WITH READ LOCK", packet_length=28, blocking=true) at /data/src/10.6/sql/sql_parse.cc:1897
#13 0x0000556c6aa663e1 in do_command (thd=0x7f4484000db8, blocking=true) at /data/src/10.6/sql/sql_parse.cc:1406
#14 0x0000556c6ac22be1 in do_handle_one_connection (connect=0x556c6d520ce8, put_in_cache=true) at /data/src/10.6/sql/sql_connect.cc:1410
#15 0x0000556c6ac2293d in handle_one_connection (arg=0x556c6d51e048) at /data/src/10.6/sql/sql_connect.cc:1312
#16 0x0000556c6b18e213 in pfs_spawn_thread (arg=0x556c6d520838) at /data/src/10.6/storage/perfschema/pfs.cc:2201
#17 0x00007f449b451609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#18 0x00007f449b025293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

The failure appeared in 10.6 after this commit:

commit b118f92be6b8d7294f3b57f824559ced3dcccc6b (HEAD -> 10.6, origin/bb-10.6-mdev15888-hf, origin/HEAD, origin/10.6)
Author: Alexey Botchkov
Date:   Tue Feb 9 00:59:55 2021 +0400
 
    MDEV-15888 Implement FLUSH TABLES tbl_name [, tbl_name] ... WITH READ LOCK for views.
    
    Enable the FLUSH TABLES for views. It works now.

No obvious immediate problem on a non-debug build.



 Comments   
Comment by Elena Stepanova [ 2021-06-28 ]

Hopefully it will get fixed along with MDEV-25906, but please make sure before closing. Set to a blocker as a complementary issue to MDEV-25906 which is proven not to be a debug-only problem.

Comment by Alexey Botchkov [ 2021-06-29 ]

proposed fix
https://github.com/MariaDB/server/commit/c2ebe8147d72f62ee10ec0a0815971ebd21aa8ff

Comment by Sergei Golubchik [ 2021-06-29 ]

https://github.com/MariaDB/server/commit/c2ebe8147d72f62ee10ec0a0815971ebd21aa8ff is ok to push

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