[MDEV-29699] Assertion `!table_list->table || frm.str || !atomic_replace' failed upon CREATE OR REPLACE with ARCHIVE Created: 2022-10-04  Updated: 2023-05-18  Resolved: 2023-01-25

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

Type: Bug Priority: Critical
Reporter: Elena Stepanova Assignee: Aleksey Midenkov
Resolution: Fixed Votes: 0
Labels: regression

Issue Links:
Problem/Incident
is caused by MDEV-25292 Atomic CREATE OR REPLACE TABLE Stalled
Relates

 Description   

--source include/have_archive.inc
CREATE OR REPLACE TABLE t ENGINE=ARCHIVE AS SELECT 1 AS a;
 
# Cleanup
DROP TABLE t;

10.11 ba875e93

mariadbd: /data/src/10.11/sql/sql_insert.cc:4801: TABLE* select_create::create_table_from_items(THD*, List<Item>*, MYSQL_LOCK**): Assertion `!table_list->table || frm.str || !atomic_replace' failed.
221004 14:21:57 [ERROR] mysqld got signal 6 ;
 
#7  0x00007f699fef9662 in __GI___assert_fail (assertion=0x55d0ff078700 "!table_list->table || frm.str || !atomic_replace", file=0x55d0ff075280 "/data/src/10.11/sql/sql_insert.cc", line=4801, function=0x55d0ff078680 "TABLE* select_create::create_table_from_items(THD*, List<Item>*, MYSQL_LOCK**)") at assert.c:101
#8  0x000055d0fd0306f6 in select_create::create_table_from_items (this=0x6290000e7a38, thd=0x62b00007e218, items=0x7f6996ba8e60, lock=0x7f6996ba8e40) at /data/src/10.11/sql/sql_insert.cc:4801
#9  0x000055d0fd031a5c in select_create::prepare (this=0x6290000e7a38, _values=..., u=0x62b000082650) at /data/src/10.11/sql/sql_insert.cc:4945
#10 0x000055d0fd1cb569 in JOIN::prepare (this=0x6290000e7b88, tables_init=0x0, conds_init=0x0, og_num=0, order_init=0x0, skip_order_by=false, group_init=0x0, having_init=0x0, proc_param_init=0x0, select_lex_arg=0x6290000e6ab0, unit_arg=0x62b000082650) at /data/src/10.11/sql/sql_select.cc:1738
#11 0x000055d0fd1ee41e in mysql_select (thd=0x62b00007e218, tables=0x0, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2201187781376, result=0x6290000e7a38, unit=0x62b000082650, select_lex=0x6290000e6ab0) at /data/src/10.11/sql/sql_select.cc:5046
#12 0x000055d0fd1bec7d in handle_select (thd=0x62b00007e218, lex=0x62b000082578, result=0x6290000e7a38, setup_tables_done_option=0) at /data/src/10.11/sql/sql_select.cc:582
#13 0x000055d0fd3d984e in Sql_cmd_create_table_like::execute (this=0x6290000e6318, thd=0x62b00007e218) at /data/src/10.11/sql/sql_table.cc:12759
#14 0x000055d0fd0e5ec4 in mysql_execute_command (thd=0x62b00007e218, is_called_from_prepared_stmt=false) at /data/src/10.11/sql/sql_parse.cc:5997
#15 0x000055d0fd0f32c0 in mysql_parse (thd=0x62b00007e218, rawbuf=0x6290000e6238 "CREATE OR REPLACE TABLE t ENGINE=ARCHIVE AS SELECT 1 AS a", length=57, parser_state=0x7f6996baaab0) at /data/src/10.11/sql/sql_parse.cc:8037
#16 0x000055d0fd0c9922 in dispatch_command (command=COM_QUERY, thd=0x62b00007e218, packet=0x629000253219 "CREATE OR REPLACE TABLE t ENGINE=ARCHIVE AS SELECT 1 AS a", packet_length=57, blocking=true) at /data/src/10.11/sql/sql_parse.cc:1894
#17 0x000055d0fd0c66fa in do_command (thd=0x62b00007e218, blocking=true) at /data/src/10.11/sql/sql_parse.cc:1407
#18 0x000055d0fd56d292 in do_handle_one_connection (connect=0x608000003038, put_in_cache=true) at /data/src/10.11/sql/sql_connect.cc:1416
#19 0x000055d0fd56cc28 in handle_one_connection (arg=0x608000002fb8) at /data/src/10.11/sql/sql_connect.cc:1318
#20 0x000055d0fe146f94 in pfs_spawn_thread (arg=0x617000004d98) at /data/src/10.11/storage/perfschema/pfs.cc:2201
#21 0x00007f69a03d5ea7 in start_thread (arg=<optimized out>) at pthread_create.c:477
#22 0x00007f699ffc4aef in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

No obvious problem on a non-debug build.

The failure appeared in 10.11 with atomic create or replace

commit 93c8252f02faa8ad8dc5f005e52f1990c29d4a0d (HEAD)
Author: Aleksey Midenkov
Date:   Wed Aug 31 11:55:04 2022 +0300
 
    MDEV-25292 Atomic CREATE OR REPLACE TABLE



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

frm.str is cleared here:

#0  TABLE_SHARE::read_frm_image (this=0x7f1a9c1d05b0, frm=0x7f1a9c1c3f70, len=0x7f1a9c1c3f68) at ../src/sql/table.cc:3604
#1  0x00007f1a9ddea5ed in ha_archive::create (this=0x7f1a840468b0, name=0x7f1a9c1d2110 "./test/#sql-create-170c-3-t", table_arg=0x7f1a9c1d0d78, create_info=0x7f1a9c1d3db0) at ../src/storage/archive/ha_archive.cc:847
#2  0x000055e5fa08c6af in handler::ha_create (this=0x7f1a840468b0, name=0x7f1a9c1d2110 "./test/#sql-create-170c-3-t", form=0x7f1a9c1d0d78, info_arg=0x7f1a9c1d3db0) at ../src/sql/handler.cc:5468
#3  0x000055e5fa08e1ec in ha_create_table (thd=0x7f1a84000d58, path=0x7f1a9c1d2110 "./test/#sql-create-170c-3-t", db=0x7f1a8401dce0 "test", table_name=0x7f1a840199a0 "t", create_info=0x7f1a9c1d3db0, frm=0x7f1a9c1d2800, skip_frm_file=false) at ../src/sql/handler.cc:5937
#4  0x000055e5fa55d8f9 in create_table_impl (thd=0x7f1a84000d58, orig_db=..., orig_table_name=..., db=..., table_name=..., path=..., options=..., create_info=0x7f1a9c1d3db0, alter_info=0x7f1a9c1d3cc0, create_table_mode=1, is_trans=0x0, key_info=0x7f1a9c1d2328, key_count=0x7f1a9c1d2324, frm=0x7f1a9c1d2800) at ../src/sql/sql_table.cc:4968
#5  0x000055e5fa55c36b in mysql_create_table_no_lock (thd=0x7f1a84000d58, orig_db=0x7f1a84014840, orig_table_name=0x7f1a84014850, db=0x7f1a8401cb10, table_name=0x7f1a8401cb20, create_info=0x7f1a9c1d3db0, alter_info=0x7f1a9c1d3cc0, is_trans=0x0, create_table_mode=1, table_list=0x7f1a8401cb10, frm=0x7f1a9c1d2800) at ../src/sql/sql_table.cc:5095
#6  0x000055e5fa3db135 in select_create::create_table_from_items (this=0x7f1a84019350, thd=0x7f1a84000d58, items=0x7f1a9c1d32f8, lock=0x7f1a9c1d32f0) at ../src/sql/sql_insert.cc:4690
#7  0x000055e5fa3dc1bf in select_create::prepare (this=0x7f1a84019350, _values=..., u=0x7f1a84005168) at ../src/sql/sql_insert.cc:4945
#8  0x000055e5fa49f04f in JOIN::prepare (this=0x7f1a84019aa0, tables_init=0x0, conds_init=0x0, og_num=0, order_init=0x0, skip_order_by=false, group_init=0x0, having_init=0x0, proc_param_init=0x0, select_lex_arg=0x7f1a84013fa0, unit_arg=0x7f1a84005168) at ../src/sql/sql_select.cc:1738
#9  0x000055e5fa49923c in mysql_select (thd=0x7f1a84000d58, tables=0x0, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2201187781376, result=0x7f1a84019350, unit=0x7f1a84005168, select_lex=0x7f1a84013fa0) at ../src/sql/sql_select.cc:5046
#10 0x000055e5fa498b7a in handle_select (thd=0x7f1a84000d58, lex=0x7f1a84005090, result=0x7f1a84019350, setup_tables_done_option=0) at ../src/sql/sql_select.cc:582
#11 0x000055e5fa574e40 in Sql_cmd_create_table_like::execute (this=0x7f1a8401d560, thd=0x7f1a84000d58) at ../src/sql/sql_table.cc:12759
#12 0x000055e5fa4308ca in mysql_execute_command (thd=0x7f1a84000d58, is_called_from_prepared_stmt=false) at ../src/sql/sql_parse.cc:5997
#13 0x000055e5fa42197f in mysql_parse (thd=0x7f1a84000d58, rawbuf=0x7f1a84028120 "create or replace table t engine=archive as select 1 as a", length=57, parser_state=0x7f1a9c1d6288) at ../src/sql/sql_parse.cc:8037

The assertion was about create_and_open_tmp_table() must have frm.str to work. But this actually not true, it can create tmp table without frm by discovery which is happening with archive engine.

Comment by Aleksey Midenkov [ 2022-10-04 ]

Please review bb-10.11-midenok

Comment by Oleksandr Byelkin [ 2022-10-06 ]

ok to push (remember my request about branches)

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