[MDEV-23297] Assertion `info->dfile.file == share->bitmap.file.file' failed in _ma_scan_init_block_record, ERROR 1030 (HY000): Got error 9 "Bad file descriptor" from storage engine Aria Created: 2020-07-27  Updated: 2023-12-23

Status: Confirmed
Project: MariaDB Server
Component/s: Storage Engine - Aria
Affects Version/s: 10.2, 10.3, 10.4, 10.5, 10.6, 10.11, 11.0, 11.1, 11.2, 11.3, 11.4
Fix Version/s: 10.4, 10.5, 10.6, 10.11, 11.0, 11.1, 11.2, 11.3

Type: Bug Priority: Major
Reporter: Roel Van de Paar Assignee: Michael Widenius
Resolution: Unresolved Votes: 0
Labels: not-10.1


 Description   

USE test;
SET SQL_MODE='';
CREATE TABLE t1(pk INT PRIMARY KEY) ENGINE=Aria;
SELECT * FROM t1 WHERE a IS NULL OR a > 0;
CREATE TEMPORARY TABLE t3 (c1 INT NOT NULL) ENGINE=Aria;
DELETE a3,a2 FROM t2 AS a1 INNER JOIN t3 AS a2, t3 AS a3;
REPAIR TABLE t1, t2, t3;
INSERT INTO t3 SELECT * FROM t3;

Leads to:

10.5.5 054f10365c49b70a3868edc0c955ffe187f8344c (Debug)

mysqld: /test/10.5_dbg/storage/maria/ma_blockrec.c:5261: _ma_scan_init_block_record: Assertion `info->dfile.file == share->bitmap.file.file' failed.

10.5.5 054f10365c49b70a3868edc0c955ffe187f8344c (Debug)

Core was generated by `/test/MD200720-mariadb-10.5.5-linux-x86_64-dbg/bin/mysqld --no-defaults --core-'.
Program terminated with signal SIGABRT, Aborted.
#0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=6)
    at ../sysdeps/unix/sysv/linux/pthread_kill.c:57
[Current thread is 1 (Thread 0x1515fde06700 (LWP 3574415))]
(gdb) bt
#0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=6) at ../sysdeps/unix/sysv/linux/pthread_kill.c:57
#1  0x000055fc1c42e82d in my_write_core (sig=sig@entry=6) at /test/10.5_dbg/mysys/stacktrace.c:518
#2  0x000055fc1bbe875c in handle_fatal_signal (sig=6) at /test/10.5_dbg/sql/signal_handler.cc:330
#3  <signal handler called>
#4  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#5  0x00001515fc09c8b1 in __GI_abort () at abort.c:79
#6  0x00001515fc08c42a in __assert_fail_base (fmt=0x1515fc213a38 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x55fc1c7c03d8 "info->dfile.file == share->bitmap.file.file", file=file@entry=0x55fc1c7bf748 "/test/10.5_dbg/storage/maria/ma_blockrec.c", line=line@entry=5261, function=function@entry=0x55fc1c7c1cb0 <__PRETTY_FUNCTION__.20442> "_ma_scan_init_block_record") at assert.c:92
#7  0x00001515fc08c4a2 in __GI___assert_fail (assertion=assertion@entry=0x55fc1c7c03d8 "info->dfile.file == share->bitmap.file.file", file=file@entry=0x55fc1c7bf748 "/test/10.5_dbg/storage/maria/ma_blockrec.c", line=line@entry=5261, function=function@entry=0x55fc1c7c1cb0 <__PRETTY_FUNCTION__.20442> "_ma_scan_init_block_record") at assert.c:101
#8  0x000055fc1be94276 in _ma_scan_init_block_record (info=0x1515d9d4c088) at /test/10.5_dbg/storage/maria/ma_blockrec.c:5261
#9  0x000055fc1be893f1 in maria_scan_init (info=0x1515d9d4c088) at /test/10.5_dbg/storage/maria/ma_scan.c:29
#10 0x000055fc1be382af in ha_maria::rnd_init (this=<optimized out>, scan=<optimized out>) at /test/10.5_dbg/storage/maria/ha_maria.cc:2491
#11 0x000055fc1bbf2ece in handler::ha_rnd_init (scan=true, this=0x1515d9d18ea0) at /test/10.5_dbg/sql/handler.h:3374
#12 handler::read_first_row (this=0x1515d9d18ea0, buf=0x1515d9c57fa8 "\377", primary_key=64) at /test/10.5_dbg/sql/handler.cc:3301
#13 0x000055fc1b98ed84 in handler::ha_read_first_row (primary_key=<optimized out>, buf=<optimized out>, this=0x1515d9d18ea0) at /test/10.5_dbg/sql/sql_class.h:6985
#14 join_read_system (tab=tab@entry=0x1515d9c76770) at /test/10.5_dbg/sql/sql_select.cc:21179
#15 0x000055fc1b99dad9 in join_read_const_table (thd=0x1515d9c15088, tab=tab@entry=0x1515d9c76770, pos=pos@entry=0x1515d9c76d20) at /test/10.5_dbg/sql/sql_select.cc:21073
#16 0x000055fc1b9b78f4 in make_join_statistics (keyuse_array=0x1515d9c76168, tables_list=@0x1515d9c74aa0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x1515d9c75da0, last = 0x1515d9c75da0, elements = 1}, <No data fields>}, join=0x1515d9c75e78) at /test/10.5_dbg/sql/sql_select.cc:5078
#17 JOIN::optimize_inner (this=this@entry=0x1515d9c75e78) at /test/10.5_dbg/sql/sql_select.cc:2242
#18 0x000055fc1b9b96ce in JOIN::optimize (this=this@entry=0x1515d9c75e78) at /test/10.5_dbg/sql/sql_select.cc:1618
#19 0x000055fc1b9ba058 in mysql_select (thd=thd@entry=0x1515d9c15088, tables=<optimized out>, fields=@0x1515d9c749b0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x1515d9c74e10, last = 0x1515d9c74e10, elements = 1}, <No data fields>}, conds=0x0, og_num=0, order=<optimized out>, group=0x0, having=0x0, proc_param=0x0, select_options=2202244745984, result=0x1515d9c75dc0, unit=0x1515d9c190a0, select_lex=0x1515d9c74860) at /test/10.5_dbg/sql/sql_select.cc:4641
#20 0x000055fc1b9ba3d4 in handle_select (thd=thd@entry=0x1515d9c15088, lex=lex@entry=0x1515d9c18fd8, result=result@entry=0x1515d9c75dc0, setup_tables_done_option=setup_tables_done_option@entry=1073741824) at /test/10.5_dbg/sql/sql_select.cc:417
#21 0x000055fc1b93dd53 in mysql_execute_command (thd=thd@entry=0x1515d9c15088) at /test/10.5_dbg/sql/sql_parse.cc:4691
#22 0x000055fc1b948b8a in mysql_parse (thd=thd@entry=0x1515d9c15088, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x1515fde05350, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.5_dbg/sql/sql_parse.cc:7993
#23 0x000055fc1b93563c in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x1515d9c15088, packet=packet@entry=0x1515d9c67089 "INSERT INTO t3 SELECT * FROM t3", packet_length=packet_length@entry=31, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.5_dbg/sql/sql_parse.cc:1866
#24 0x000055fc1b933e16 in do_command (thd=0x1515d9c15088) at /test/10.5_dbg/sql/sql_parse.cc:1347
#25 0x000055fc1ba904af in do_handle_one_connection (connect=<optimized out>, connect@entry=0x1515dccc9808, put_in_cache=put_in_cache@entry=true) at /test/10.5_dbg/sql/sql_connect.cc:1411
#26 0x000055fc1ba90bcb in handle_one_connection (arg=arg@entry=0x1515dccc9808) at /test/10.5_dbg/sql/sql_connect.cc:1313
#27 0x000055fc1bef4dca in pfs_spawn_thread (arg=0x1515fac46508) at /test/10.5_dbg/storage/perfschema/pfs.cc:2201
#28 0x00001515fcd7f6db in start_thread (arg=0x1515fde06700) at pthread_create.c:463
#29 0x00001515fc17da3f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Bug confirmed present in:
MariaDB: 10.2.33 (dbg), 10.3.24 (dbg), 10.4.14 (dbg), 10.5.5 (dbg)

Bug confirmed not present in:
MariaDB: 10.1.46 (dbg), 10.1.46 (opt), 10.2.33 (opt), 10.3.24 (opt), 10.4.14 (opt), 10.5.5 (opt)
MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.47 (dbg), 5.6.47 (opt), 5.7.29 (dbg), 5.7.29 (opt), 8.0.19 (dbg), 8.0.19 (opt)



 Comments   
Comment by Roel Van de Paar [ 2023-12-23 ]

Additional testcase:

CREATE TEMPORARY TABLE t3 (c DECIMAL(1,1) KEY,c2 INT,c3 BLOB) ENGINE=Aria;
INSERT INTO t3 VALUES (0,0,0);
SET GLOBAL table_open_cache=1;
INSERT INTO t3 SELECT * FROM t3;
REPAIR TABLE t,t2,t3;
INSERT INTO t3 SELECT * FROM t3;

Leads to:

11.3.0 126157061b4376496c034a809ea4943e863d1465 (Debug)

mariadbd: /test/11.3_dbg/storage/maria/ma_blockrec.c:5289: _ma_scan_init_block_record: Assertion `info->dfile.file == share->bitmap.file.file' failed.

11.3.0 126157061b4376496c034a809ea4943e863d1465 (Debug)

Core was generated by `/test/MD311023-mariadb-11.3.0-linux-x86_64-dbg/bin/mariadbd --no-defaults --cor'.
Program terminated with signal SIGABRT, Aborted.
#0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=23417169397312)
    at ./nptl/pthread_kill.c:44
[Current thread is 1 (Thread 0x154c3c104640 (LWP 1104446))]
(gdb) bt
#0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=23417169397312) at ./nptl/pthread_kill.c:44
#1  __pthread_kill_internal (signo=6, threadid=23417169397312) at ./nptl/pthread_kill.c:78
#2  __GI___pthread_kill (threadid=23417169397312, signo=signo@entry=6) at ./nptl/pthread_kill.c:89
#3  0x0000154c45842476 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#4  0x0000154c458287f3 in __GI_abort () at ./stdlib/abort.c:79
#5  0x0000154c4582871b in __assert_fail_base (fmt=0x154c459dd130 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x56031f5fb638 "info->dfile.file == share->bitmap.file.file", file=0x56031f5fac88 "/test/11.3_dbg/storage/maria/ma_blockrec.c", line=5289, function=<optimized out>) at ./assert/assert.c:92
#6  0x0000154c45839e96 in __GI___assert_fail (assertion=assertion@entry=0x56031f5fb638 "info->dfile.file == share->bitmap.file.file", file=file@entry=0x56031f5fac88 "/test/11.3_dbg/storage/maria/ma_blockrec.c", line=line@entry=5289, function=function@entry=0x56031f5fc3f0 <__PRETTY_FUNCTION__.17> "_ma_scan_init_block_record") at ./assert/assert.c:101
#7  0x000056031ed5eaf9 in _ma_scan_init_block_record (info=0x154c00025778) at /test/11.3_dbg/storage/maria/ma_blockrec.c:5289
#8  0x000056031ed55978 in maria_scan_init (info=0x154c00025778) at /test/11.3_dbg/storage/maria/ma_scan.c:29
#9  0x000056031ed14eb7 in ha_maria::rnd_init (this=<optimized out>, scan=<optimized out>) at /test/11.3_dbg/storage/maria/ha_maria.cc:2644
#10 0x000056031eb0b88d in handler::ha_rnd_init (scan=true, this=0x154c0001d3c0) at /test/11.3_dbg/sql/handler.h:3516
#11 handler::read_first_row (this=0x154c0001d3c0, buf=0x154c0001ceb8 "\377\200", primary_key=<optimized out>) at /test/11.3_dbg/sql/handler.cc:3875
#12 0x000056031e86d2b4 in handler::ha_read_first_row (primary_key=<optimized out>, buf=<optimized out>, this=0x154c0001d3c0) at /test/11.3_dbg/sql/sql_class.h:7680
#13 join_read_system (tab=tab@entry=0x154c00016068) at /test/11.3_dbg/sql/sql_select.cc:24051
#14 0x000056031e876946 in join_read_const_table (thd=0x154c00000d58, tab=tab@entry=0x154c00016068, pos=pos@entry=0x154c00016700) at /test/11.3_dbg/sql/sql_select.cc:23955
#15 0x000056031e888ab0 in make_join_statistics (join=join@entry=0x154c00015398, tables_list=@0x154c00013f00: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x154c000152b8, last = 0x154c000152b8, elements = 1}, <No data fields>}, keyuse_array=keyuse_array@entry=0x154c00015700) at /test/11.3_dbg/sql/sql_select.cc:5722
#16 0x000056031e891ac5 in JOIN::optimize_inner (this=this@entry=0x154c00015398) at /test/11.3_dbg/sql/sql_select.cc:2626
#17 0x000056031e89203c in JOIN::optimize (this=this@entry=0x154c00015398) at /test/11.3_dbg/sql/sql_select.cc:1944
#18 0x000056031e89215c in mysql_select (thd=thd@entry=0x154c00000d58, tables=0x154c00014308, fields=@0x154c00013fa0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x154c000142c0, last = 0x154c00015f18, elements = 3}, <No data fields>}, conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=37385559870208, result=0x154c000152d8, unit=0x154c000051c0, select_lex=0x154c00013ce8) at /test/11.3_dbg/sql/sql_select.cc:5243
#19 0x000056031e8929e6 in handle_select (thd=thd@entry=0x154c00000d58, lex=lex@entry=0x154c000050e0, result=result@entry=0x154c000152d8, setup_tables_done_option=setup_tables_done_option@entry=35184372088832) at /test/11.3_dbg/sql/sql_select.cc:628
#20 0x000056031e8009d7 in mysql_execute_command (thd=thd@entry=0x154c00000d58, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /test/11.3_dbg/sql/sql_parse.cc:4577
#21 0x000056031e805193 in mysql_parse (thd=thd@entry=0x154c00000d58, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x154c3c1031e0) at /test/11.3_dbg/sql/sql_parse.cc:7742
#22 0x000056031e807509 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x154c00000d58, packet=packet@entry=0x154c0000b1b9 "INSERT INTO t3 SELECT * FROM t3", packet_length=packet_length@entry=31, blocking=blocking@entry=true) at /test/11.3_dbg/sql/sql_class.h:251
#23 0x000056031e809625 in do_command (thd=0x154c00000d58, blocking=blocking@entry=true) at /test/11.3_dbg/sql/sql_parse.cc:1406
#24 0x000056031e96e54d in do_handle_one_connection (connect=<optimized out>, connect@entry=0x5603226165c8, put_in_cache=put_in_cache@entry=true) at /test/11.3_dbg/sql/sql_connect.cc:1418
#25 0x000056031e96e842 in handle_one_connection (arg=arg@entry=0x5603226165c8) at /test/11.3_dbg/sql/sql_connect.cc:1320
#26 0x000056031edb3a28 in pfs_spawn_thread (arg=0x5603225bd168) at /test/11.3_dbg/storage/perfschema/pfs.cc:2201
#27 0x0000154c45894ac3 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
#28 0x0000154c45926660 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81

Optimized builds give this error:

11.3.0 126157061b4376496c034a809ea4943e863d1465 (Optimized)

11.3.0-opt>INSERT INTO t3 SELECT * FROM t3;
ERROR 1030 (HY000): Got error 9 "Bad file descriptor" from storage engine Aria

11.3.0 126157061b4376496c034a809ea4943e863d1465 (Optimized)

2023-12-23 14:27:13 4 [ERROR] Got error 9 when reading table '/test/MD311023-mariadb-11.3.0-linux-x86_64-opt/data/#sql-temptable-15af16-4-0'

The original bug testcase does not produce this error on optimized builds, so this may be an additional, related bug.

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