[MDEV-26805] SIGSEGV in wait_while_table_is_used Created: 2021-10-11  Updated: 2023-09-27

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

Type: Bug Priority: Major
Reporter: Ramesh Sivaraman Assignee: Oleksandr Byelkin
Resolution: Unresolved Votes: 0
Labels: not-10.2


 Description   

SET SESSION SQL_MODE='';
CREATE TABLE t (c1 int) ;
SET max_session_mem_used=50000;
ALTER TABLE t ADD INDEX (c1);
LOCK TABLE t WRITE;
CREATE OR REPLACE SEQUENCE t;

Leads to:

10.7.1 5cc9cf9a05582307abefd8f3b57548945da86b1a (Optimized)

Core was generated by `/test/MD111021-mariadb-10.7.1-linux-x86_64-opt/bin/mysqld --no-defaults --core-'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00005555ccbe20ae in wait_while_table_is_used (thd=thd@entry=
    0x151d08000c58, table=0x0, function=function@entry=HA_EXTRA_NOT_USED)
    at /test/10.7_opt/sql/sql_base.cc:1313
1313	  if (thd->mdl_context.upgrade_shared_lock(
[Current thread is 1 (Thread 0x151d6849f700 (LWP 683480))]
(gdb) bt
#0  0x00005555ccbe20ae in wait_while_table_is_used (thd=thd@entry=0x151d08000c58, table=0x0, function=function@entry=HA_EXTRA_NOT_USED) at /test/10.7_opt/sql/sql_base.cc:1313
#1  0x00005555cccf751f in mysql_rm_table_no_locks (thd=0x151d08000c58, tables=<optimized out>, current_db=<optimized out>, ddl_log_state=<optimized out>, if_exists=<optimized out>, drop_temporary=<optimized out>, drop_view=<optimized out>, drop_sequence=<optimized out>, dont_log_query=<optimized out>, dont_free_locks=<optimized out>) at /test/10.7_opt/sql/sql_table.cc:1432
#2  0x00005555ccd0705c in mysql_create_table_no_lock (thd=thd@entry=0x151d08000c58, ddl_log_state_create=ddl_log_state_create@entry=0x151d6849da40, ddl_log_state_rm=ddl_log_state_rm@entry=0x151d6849da60, db=db@entry=0x151d080108a0, table_name=table_name@entry=0x151d080108b0, create_info=create_info@entry=0x151d6849dc90, alter_info=0x151d6849dba0, is_trans=0x151d6849da3f, create_table_mode=0, table_list=0x151d08010888) at /test/10.7_opt/sql/handler.h:2254
#3  0x00005555ccd07349 in mysql_create_table (thd=thd@entry=0x151d08000c58, create_table=create_table@entry=0x151d08010888, create_info=create_info@entry=0x151d6849dc90, alter_info=alter_info@entry=0x151d6849dba0) at /test/10.7_opt/sql/sql_table.cc:4658
#4  0x00005555ccd08c29 in Sql_cmd_create_table_like::execute (this=<optimized out>, thd=0x151d08000c58) at /test/10.7_opt/sql/sql_table.cc:11773
#5  0x00005555ccc57d8e in mysql_execute_command (thd=0x151d08000c58, is_called_from_prepared_stmt=<optimized out>) at /test/10.7_opt/sql/sql_parse.cc:5989
#6  0x00005555ccc47f26 in mysql_parse (thd=0x151d08000c58, rawbuf=<optimized out>, length=<optimized out>, parser_state=<optimized out>) at /test/10.7_opt/sql/sql_parse.cc:8028
#7  0x00005555ccc53fad in dispatch_command (command=COM_QUERY, thd=0x151d08000c58, packet=<optimized out>, packet_length=<optimized out>, blocking=<optimized out>) at /test/10.7_opt/sql/sql_class.h:1358
#8  0x00005555ccc55ea8 in do_command (thd=0x151d08000c58, blocking=blocking@entry=true) at /test/10.7_opt/sql/sql_parse.cc:1402
#9  0x00005555ccd71d07 in do_handle_one_connection (connect=<optimized out>, put_in_cache=true) at /test/10.7_opt/sql/sql_connect.cc:1418
#10 0x00005555ccd7204d in handle_one_connection (arg=arg@entry=0x5555cf0e9e08) at /test/10.7_opt/sql/sql_connect.cc:1312
#11 0x00005555cd0c76e3 in pfs_spawn_thread (arg=0x5555cf101e28) at /test/10.7_opt/storage/perfschema/pfs.cc:2201
#12 0x0000151d69de7609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#13 0x0000151d699d6293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Bug confirmed present in:
MariaDB: 10.3.32 (dbg), 10.3.32 (opt), 10.4.22 (dbg), 10.4.22 (opt), 10.5.13 (dbg), 10.5.13 (opt), 10.6.5 (dbg), 10.6.5 (opt), 10.7.1 (dbg), 10.7.1 (opt)

Bug (or feature/syntax) confirmed not present in:
MariaDB: 10.2.41 (dbg), 10.2.41 (opt)



 Comments   
Comment by Oleksandr Byelkin [ 2023-09-27 ]

It looks like fixed

SET SESSION SQL_MODE='';
CREATE TABLE t (c1 int) ;
SET max_session_mem_used=50000;
ALTER TABLE t ADD INDEX (c1);
main.test                                [ fail ]
        Test ended at 2023-09-27 12:02:15
 
CURRENT_TEST: main.test
mysqltest: At line 4: query 'ALTER TABLE t ADD INDEX (c1)' failed: 1290: The MariaDB server is running with the --max-session-mem-used=50000 option so it cannot execute this statement

Comment by Ramesh Sivaraman [ 2023-09-27 ]

sanja Reproduced the issue on latest 10.4 debug build. Please try this test case

SET SESSION SQL_MODE='';
CREATE TABLE t (c1 int) ;
SET max_session_mem_used=50000;
--ERROR 1290
ALTER TABLE t ADD INDEX (c1);
LOCK TABLE t WRITE;
CREATE OR REPLACE SEQUENCE t;

Comment by Oleksandr Byelkin [ 2023-09-27 ]

To be repetable it should be built with DWITH_VALGRIND=OFF

It is an attempt to delete temporary table, probably I saw the same somewhere...

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