[MDEV-29831] Galera crashes when running CoR for a locked table after setting the minimum memory for a user session Created: 2022-10-20  Updated: 2023-05-18  Resolved: 2023-01-26

Status: Closed
Project: MariaDB Server
Component/s: Data Definition - Create Table, Galera
Affects Version/s: 10.11
Fix Version/s: N/A

Type: Bug Priority: Critical
Reporter: Ramesh Sivaraman Assignee: Aleksey Midenkov
Resolution: Fixed Votes: 0
Labels: regression

Issue Links:
Blocks
blocks MDEV-25292 Atomic CREATE OR REPLACE TABLE Stalled
Problem/Incident
is caused by MDEV-25292 Atomic CREATE OR REPLACE TABLE Stalled
Relates
relates to MDEV-29544 SIGSEGV in HA_CREATE_INFO::finalize_l... Closed

 Description   

SET SESSION max_session_mem_used=8192;
CREATE TABLE t1 (a INT, KEY(a)) ENGINE=InnoDB;
SET autocommit=OFF;
CREATE TABLE t2 (id INT NOT NULL PRIMARY KEY, DATA INT) ENGINE=MEMORY;
INSERT INTO t2(id) VALUES ('11');
ALTER TABLE t1 ADD COLUMN f3 INT NOT NULL DEFAULT 10;
LOCK TABLE t1 WRITE, t2 READ;
CREATE OR REPLACE TABLE t1 SELECT 1;

Leads to:

10.11.0 c4994b468bb971eaf2d8ca41a390acb9838a333f (Optimized)

Core was generated by `/test/mtest/10.11/mariadb-10.11.0-linux-x86_64/bin/mysqld --defaults-file=/test'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=11)
    at ../sysdeps/unix/sysv/linux/pthread_kill.c:56
[Current thread is 1 (Thread 0x145c5c084700 (LWP 3124119))]
(gdb) bt
#0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=11) at ../sysdeps/unix/sysv/linux/pthread_kill.c:56
#1  0x00005592d76a4daf in my_write_core (sig=sig@entry=11) at /test/mtest/10.11/mysys/stacktrace.c:424
#2  0x00005592d71e6fd0 in handle_fatal_signal (sig=11) at /test/mtest/10.11/sql/signal_handler.cc:355
#3  <signal handler called>
#4  0x00005592d705266d in HA_CREATE_INFO::finalize_locked_tables (thd=0x145c20000c58, operation_failed=true, this=0x145c5c080f50) at /test/mtest/10.11/sql/sql_table.cc:4647
#5  HA_CREATE_INFO::finalize_locked_tables (this=0x145c5c080f50, thd=0x145c20000c58, operation_failed=operation_failed@entry=true) at /test/mtest/10.11/sql/sql_table.cc:4622
#6  0x00005592d6f65cd2 in select_create::abort_result_set (this=0x145c200121d8) at /test/mtest/10.11/sql/sql_insert.cc:5557
#7  select_create::abort_result_set (this=0x145c200121d8) at /test/mtest/10.11/sql/sql_insert.cc:5449
#8  0x00005592d6f6c2c2 in select_create::send_eof (this=0x145c200121d8) at /test/mtest/10.11/sql/sql_insert.cc:5367
#9  0x00005592d701d63a in JOIN::exec_inner (this=0x145c20012360) at /test/mtest/10.11/sql/sql_select.cc:4690
#10 0x00005592d701dcf2 in JOIN::exec (this=this@entry=0x145c20012360) at /test/mtest/10.11/sql/sql_select.cc:4591
#11 0x00005592d701bed1 in mysql_select (thd=0x145c20000c58, tables=0x0, fields=@0x145c20011520: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x145c20011778, last = 0x145c20011778, elements = 1}, <No data fields>}, conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=<optimized out>, result=0x145c200121d8, unit=0x145c20004ed8, select_lex=0x145c20011280) at /test/mtest/10.11/sql/sql_select.cc:5071
#12 0x00005592d701c687 in handle_select (thd=thd@entry=0x145c20000c58, lex=lex@entry=0x145c20004e00, result=result@entry=0x145c200121d8, setup_tables_done_option=setup_tables_done_option@entry=0) at /test/mtest/10.11/sql/sql_select.cc:582
#13 0x00005592d70624bd in Sql_cmd_create_table_like::execute (this=<optimized out>, thd=0x145c20000c58) at /test/mtest/10.11/sql/sql_table.cc:12940
#14 0x00005592d6fa975e in mysql_execute_command (thd=0x145c20000c58, is_called_from_prepared_stmt=<optimized out>) at /test/mtest/10.11/sql/sql_parse.cc:5997
#15 0x00005592d6f993f7 in mysql_parse (thd=0x145c20000c58, rawbuf=<optimized out>, length=<optimized out>, parser_state=<optimized out>) at /test/mtest/10.11/sql/sql_parse.cc:8023
#16 0x00005592d6f98c41 in wsrep_mysql_parse (thd=0x145c20000c58, rawbuf=0x145c20010a60 "CREATE OR REPLACE TABLE t1 SELECT 1", length=35, parser_state=0x145c5c0833d0) at /test/mtest/10.11/sql/sql_parse.cc:7834
#17 0x00005592d6fa6f44 in dispatch_command (command=COM_QUERY, thd=0x145c20000c58, packet=0x145c20008739 "CREATE OR REPLACE TABLE t1 SELECT 1", packet_length=<optimized out>, blocking=<optimized out>) at /test/mtest/10.11/sql/sql_class.h:1346
#18 0x00005592d6fa795e in do_command (thd=0x145c20000c58, blocking=blocking@entry=true) at /test/mtest/10.11/sql/sql_parse.cc:1407
#19 0x00005592d70c44b7 in do_handle_one_connection (connect=<optimized out>, put_in_cache=true) at /test/mtest/10.11/sql/sql_connect.cc:1416
#20 0x00005592d70c47ed in handle_one_connection (arg=arg@entry=0x5592da9353c8) at /test/mtest/10.11/sql/sql_connect.cc:1318
#21 0x00005592d73f022d in pfs_spawn_thread (arg=0x5592da94dec8) at /test/mtest/10.11/storage/perfschema/pfs.cc:2201
#22 0x0000145c90f5a609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#23 0x0000145c90b2b133 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

10.11.0 950e4f584da2ee937d98ea824e34aa895d737ea3 (Debug)

Core was generated by `/test/GAL_MD171022-mariadb-10.11.0-linux-x86_64-dbg/bin/mysqld --defaults-file='.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=11)
    at ../sysdeps/unix/sysv/linux/pthread_kill.c:56
[Current thread is 1 (Thread 0x151d335fa700 (LWP 3309109))]
(gdb) bt
#0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=11) at ../sysdeps/unix/sysv/linux/pthread_kill.c:56
#1  0x000055930b1466d1 in my_write_core (sig=sig@entry=11) at /test/10.11_dbg/mysys/stacktrace.c:424
#2  0x000055930aa22da4 in handle_fatal_signal (sig=11) at /test/10.11_dbg/sql/signal_handler.cc:355
#3  <signal handler called>
#4  0x000055930a81391f in HA_CREATE_INFO::finalize_locked_tables (this=0x151d335f7010, thd=0x151d0c000d48, operation_failed=operation_failed@entry=true) at /test/10.11_dbg/sql/sql_table.cc:4570
#5  0x000055930a6fccfa in select_create::abort_result_set (this=0x151d0c0149a8) at /test/10.11_dbg/sql/sql_insert.cc:5536
#6  0x000055930a703de7 in select_create::send_eof (this=0x151d0c0149a8) at /test/10.11_dbg/sql/sql_insert.cc:5346
#7  0x000055930a7d0005 in JOIN::exec_inner (this=this@entry=0x151d0c014af0) at /test/10.11_dbg/sql/sql_select.cc:4690
#8  0x000055930a7d0f27 in JOIN::exec (this=this@entry=0x151d0c014af0) at /test/10.11_dbg/sql/sql_select.cc:4591
#9  0x000055930a7ceed9 in mysql_select (thd=thd@entry=0x151d0c000d48, tables=0x0, fields=@0x151d0c013cf0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x151d0c013f48, last = 0x151d0c013f48, elements = 1}, <No data fields>}, conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2201190402560, result=0x151d0c0149a8, unit=0x151d0c004f88, select_lex=0x151d0c013a50) at /test/10.11_dbg/sql/sql_select.cc:5071
#10 0x000055930a7cf64a in handle_select (thd=thd@entry=0x151d0c000d48, lex=lex@entry=0x151d0c004eb0, result=result@entry=0x151d0c0149a8, setup_tables_done_option=setup_tables_done_option@entry=0) at /test/10.11_dbg/sql/sql_select.cc:582
#11 0x000055930a822f16 in Sql_cmd_create_table_like::execute (this=<optimized out>, thd=0x151d0c000d48) at /test/10.11_dbg/sql/sql_table.cc:12814
#12 0x000055930a74e430 in mysql_execute_command (thd=thd@entry=0x151d0c000d48, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /test/10.11_dbg/sql/sql_parse.cc:5997
#13 0x000055930a736b31 in mysql_parse (thd=thd@entry=0x151d0c000d48, rawbuf=rawbuf@entry=0x151d0c013230 "CREATE OR REPLACE TABLE t1 SELECT 1", length=length@entry=35, parser_state=parser_state@entry=0x151d335f9300) at /test/10.11_dbg/sql/sql_parse.cc:8023
#14 0x000055930a736531 in wsrep_mysql_parse (thd=thd@entry=0x151d0c000d48, rawbuf=0x151d0c013230 "CREATE OR REPLACE TABLE t1 SELECT 1", length=35, parser_state=parser_state@entry=0x151d335f9300) at /test/10.11_dbg/sql/sql_parse.cc:7834
#15 0x000055930a744151 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x151d0c000d48, packet=packet@entry=0x151d0c00af09 "CREATE OR REPLACE TABLE t1 SELECT 1", packet_length=packet_length@entry=35, blocking=blocking@entry=true) at /test/10.11_dbg/sql/sql_class.h:1346
#16 0x000055930a746587 in do_command (thd=0x151d0c000d48, blocking=blocking@entry=true) at /test/10.11_dbg/sql/sql_parse.cc:1407
#17 0x000055930a8a41b0 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x55930cc23578, put_in_cache=put_in_cache@entry=true) at /test/10.11_dbg/sql/sql_connect.cc:1416
#18 0x000055930a8a4682 in handle_one_connection (arg=0x55930cc23578) at /test/10.11_dbg/sql/sql_connect.cc:1318
#19 0x0000151d81760609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#20 0x0000151d8134c133 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Bug confirmed present in:
MariaDB: 10.11.0 (dbg), 10.11.0 (opt)

Bug (or feature/syntax) confirmed not present in:
MariaDB: 10.3.37 (dbg), 10.3.37 (opt), 10.4.27 (dbg), 10.4.27 (opt), 10.5.18 (dbg), 10.5.18 (opt), 10.6.11 (dbg), 10.6.11 (opt), 10.7.7 (dbg), 10.7.7 (opt), 10.8.6 (dbg), 10.8.6 (opt), 10.9.4 (dbg), 10.9.4 (opt), 10.10.2 (dbg), 10.10.2 (opt)



 Comments   
Comment by Aleksey Midenkov [ 2022-10-24 ]

This test doesn't run correctly:

--source include/galera_cluster.inc
--source include/have_innodb.inc
 
USE test;
--connection node_1
 
SET SESSION max_session_mem_used=8192;
CREATE TABLE t1 (a INT, KEY(a)) ENGINE=InnoDB;
SET autocommit=OFF;
CREATE TABLE t2 (id INT NOT NULL PRIMARY KEY, DATA INT) ENGINE=MEMORY;
INSERT INTO t2(id) VALUES ('11');
ALTER TABLE t1 ADD COLUMN f3 INT NOT NULL DEFAULT 10;
LOCK TABLE t1 WRITE, t2 READ;
CREATE OR REPLACE TABLE t1 SELECT 1;
unlock tables;
drop tables t2, t1;
 
--source include/galera_end.inc

950e4f584da

CURRENT_TEST: galera.z
mysqltest: At line 11: query 'INSERT INTO t2(id) VALUES ('11')' failed: ER_OPTION_PREVENTS_STATEMENT (1290): The MariaDB server is running with the --max-session-mem-used=8192 option so it cannot execute this statement

The same happens with test without galera. Please provide correct test case.

Comment by Ramesh Sivaraman [ 2022-10-25 ]

midenok Can you try with the following test case. The error was expected and was handled by the error code to complete the test case execution.

--source include/galera_cluster.inc
--source include/have_innodb.inc
 
USE test;
--connection node_1
SET SESSION max_session_mem_used=8192;
CREATE TABLE t1 (a INT, KEY(a)) ENGINE=InnoDB;
SET autocommit=OFF;
CREATE TABLE t2 (id INT NOT NULL PRIMARY KEY, DATA INT) ENGINE=MEMORY;
--error ER_OPTION_PREVENTS_STATEMENT
INSERT INTO t2(id) VALUES ('11');
--error ER_OPTION_PREVENTS_STATEMENT
ALTER TABLE t1 ADD COLUMN f3 INT NOT NULL DEFAULT 10;
LOCK TABLE t1 WRITE, t2 READ;
CREATE OR REPLACE TABLE t1 SELECT 1;
unlock tables;
drop tables t2, t1;

Comment by Aleksey Midenkov [ 2022-10-31 ]

Please review bb-10.11-midenok

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