[MDEV-14646] MariaDB server crashes when REPAIR TABLE is called and *.mad file doesn't exist Created: 2017-12-14  Updated: 2023-04-27

Status: Confirmed
Project: MariaDB Server
Component/s: Storage Engine - Aria
Affects Version/s: 5.5, 10.0, 10.1, 5.5.58, 10.2, 10.3, 10.4
Fix Version/s: 10.4

Type: Bug Priority: Major
Reporter: Michael Graf Assignee: Michael Widenius
Resolution: Unresolved Votes: 0
Labels: crash, not-10.5+
Environment:

Windows 7, any


Attachments: Zip Archive mysqld.exe_171214_073525.zip    
Issue Links:
Relates
relates to MDEV-23824 SIGSEGV in end_io_cache on REPAIR LOC... Closed

 Description   

If the following commands are executed then MariaDB server crashs:

CREATE DATABASE IF NOT EXISTS test_repair_table_error;
 
CREATE TABLE IF NOT EXISTS test_repair_table_error.test_table(
 `ID` INT NOT NULL AUTO_INCREMENT,
 `Name` VARCHAR(50) NOT NULL DEFAULT '0',
 PRIMARY KEY (`ID`)
) COLLATE='latin1_swedish_ci' ENGINE=aria;
 
INSERT INTO test_repair_table_error.test_table (`Name`) VALUES ('testname');
 
-- Delete file table-file test_repair_table_error.test_table.mad
 
REPAIR TABLE test_repair_table_error.test_table; 



 Comments   
Comment by Elena Stepanova [ 2017-12-14 ]

Thanks for the report and test-case.
MTR variation:

CREATE TABLE t1 (i INT) ENGINE=Aria;
INSERT INTO t1 VALUES (1);
 
--let $datadir= `SELECT @@datadir`
--remove_file $datadir/test/t1.MAD
 
REPAIR TABLE t1; 
 
# Cleanup
DROP TABLE t1;

5.5 20089f5a39fa8

#3  <signal handler called>
#4  0x000055d83f8df967 in end_io_cache (info=0x468) at /data/src/10.3/mysys/mf_iocache.c:1986
#5  0x000055d83f3da348 in maria_repair (param=0x7f404c043398, info=0x7f404c0b4d10, name=0x7f40680ec9a0 "./test/t1", rep_quick=0 '\000') at /data/src/10.3/storage/maria/ma_check.c:2874
#6  0x000055d83f346d63 in ha_maria::repair (this=0x7f404c142928, thd=0x7f404c000b00, param=0x7f404c043398, do_optimize=false) at /data/src/10.3/storage/maria/ha_maria.cc:1686
#7  0x000055d83f3460a4 in ha_maria::repair (this=0x7f404c142928, thd=0x7f404c000b00, check_opt=0x7f404c005740) at /data/src/10.3/storage/maria/ha_maria.cc:1469
#8  0x000055d83f12fb95 in handler::ha_repair (this=0x7f404c142928, thd=0x7f404c000b00, check_opt=0x7f404c005740) at /data/src/10.3/sql/handler.cc:4043
#9  0x000055d83efc2052 in mysql_admin_table(THD *, TABLE_LIST *, HA_CHECK_OPT *, const char *, thr_lock_type, bool, bool, uint, int (*)(THD *, TABLE_LIST *, HA_CHECK_OPT *), struct {...}, int (*)(THD *, TABLE_LIST *, HA_CHECK_OPT *)) (thd=0x7f404c000b00, tables=0x7f404c014c10, check_opt=0x7f404c005740, operator_name=0x55d83f9fbfa5 "repair", lock_type=TL_WRITE, open_for_modify=false, repair_table_use_frm=false, extra_open_options=32, prepare_func=0x55d83efbff37 <prepare_for_repair(THD*, TABLE_LIST*, HA_CHECK_OPT*)>, operator_func=(int (handler::*)(handler * const, THD *, HA_CHECK_OPT *)) 0x55d83f12fb54 <handler::ha_repair(THD*, st_ha_check_opt*)>, view_operator_func=0x55d83ef5a92c <view_repair(THD*, TABLE_LIST*, st_ha_check_opt*)>) at /data/src/10.3/sql/sql_admin.cc:802
#10 0x000055d83efc45d3 in Sql_cmd_repair_table::execute (this=0x7f404c015228, thd=0x7f404c000b00) at /data/src/10.3/sql/sql_admin.cc:1400
#11 0x000055d83ee662c7 in mysql_execute_command (thd=0x7f404c000b00) at /data/src/10.3/sql/sql_parse.cc:6248
#12 0x000055d83ee6acd8 in mysql_parse (thd=0x7f404c000b00, rawbuf=0x7f404c014b48 "REPAIR TABLE t1", length=15, parser_state=0x7f40680ee610, is_com_multi=false, is_next_command=false) at /data/src/10.3/sql/sql_parse.cc:7963
#13 0x000055d83ee5866b in dispatch_command (command=COM_QUERY, thd=0x7f404c000b00, packet=0x7f404c00b051 "", packet_length=15, is_com_multi=false, is_next_command=false) at /data/src/10.3/sql/sql_parse.cc:1825
#14 0x000055d83ee5709f in do_command (thd=0x7f404c000b00) at /data/src/10.3/sql/sql_parse.cc:1370
#15 0x000055d83efafc0e in do_handle_one_connection (connect=0x55d841fae9b0) at /data/src/10.3/sql/sql_connect.cc:1420
#16 0x000055d83efaf99b in handle_one_connection (arg=0x55d841fae9b0) at /data/src/10.3/sql/sql_connect.cc:1326
#17 0x000055d83f4380e4 in pfs_spawn_thread (arg=0x55d84204f4b0) at /data/src/10.3/storage/perfschema/pfs.cc:1863
#18 0x00007f406ebb0494 in start_thread (arg=0x7f40680ef700) at pthread_create.c:333
#19 0x00007f406cf9693f in clone () from /lib/x86_64-linux-gnu/libc.so.6

Comment by Alice Sherepa [ 2023-04-27 ]

10.4

mysqld: /10.4/src/sql/sql_error.cc:335: void Diagnostics_area::set_ok_status(ulonglong, ulonglong, const char*): Assertion `!is_set() || (m_status == DA_OK_BULK && is_bulk_op())' failed.
230427 12:36:44 [ERROR] mysqld got signal 6 ;
 
Server version: 10.4.29-MariaDB-debug-log source revision: a959c22e7fbbac9c19cc9e1dfb18284bf7c67046
 
sql/sql_error.cc:340(Diagnostics_area::set_ok_status(unsigned long long, unsigned long long, char const*))[0x55e2466623a1]
sql/sql_class.h:5159(my_ok(THD*, unsigned long long, unsigned long long, char const*))[0x55e2465796ab]
sql/sql_table.cc:2135(mysql_rm_table(THD*, TABLE_LIST*, bool, bool, bool))[0x55e24697f28d]
sql/sql_parse.cc:4949(mysql_execute_command(THD*))[0x55e24673ae3f]
sql/sql_parse.cc:7998(mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool))[0x55e24674fa9f]
sql/sql_parse.cc:1860(dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool))[0x55e2467260df]
sql/sql_parse.cc:1378(do_command(THD*))[0x55e246722c14]
sql/sql_connect.cc:1420(do_handle_one_connection(CONNECT*))[0x55e246b2ee23]
sql/sql_connect.cc:1325(handle_one_connection)[0x55e246b2e6c7]
perfschema/pfs.cc:1871(pfs_spawn_thread)[0x55e2477d0c46]
nptl/pthread_create.c:478(start_thread)[0x7f2d3586d609]
 
Query (0x62b0000a1290): DROP TABLE t1

on 10.5+:

DROP TABLE t1;
Warnings:
Error	29	File './test/t1.MAD' not found (Errcode: 2 "No such file or directory")

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