[MDEV-26035] Assertion `file->s->base.reclength < file- >s->vreclength || !table->s->stored_fields' upon creating HASH index Created: 2021-06-28  Updated: 2023-11-28

Status: Confirmed
Project: MariaDB Server
Component/s: Virtual Columns
Affects Version/s: 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, 10.10, 10.11
Fix Version/s: 10.4, 10.5, 10.6

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Nikita Malyavin
Resolution: Unresolved Votes: 0
Labels: affects-tests

Issue Links:
Problem/Incident
is caused by MDEV-371 Unique indexes for blobs Closed
Relates
relates to MDEV-19011 Assertion `file->s->base.reclength < ... Closed
relates to MDEV-28514 Assertion `file->s->base.reclength < ... Confirmed

 Description   

Note: Bugfix for MDEV-19011 is already in the main trees.

CREATE TABLE t (f bit, key (f)) ENGINE=MyISAM;
CREATE UNIQUE INDEX ind USING HASH ON t(f);
 
# Cleanup
DROP TABLE t;

10.4 09b03ff3

mysqld: /data/src/10.4/storage/myisam/ha_myisam.cc:981: void ha_myisam::setup_vcols_for_repair(HA_CHECK*): Assertion `file->s->base.reclength < file->s->vreclength || !table->s->stored_fields' failed.
210628 18:59:51 [ERROR] mysqld got signal 6 ;
 
#7  0x00007f554ea80f36 in __GI___assert_fail (assertion=0x56039470ec48 "file->s->base.reclength < file->s->vreclength || !table->s->stored_fields", file=0x56039470e798 "/data/src/10.4/storage/myisam/ha_myisam.cc", line=981, function=0x56039470ec10 "void ha_myisam::setup_vcols_for_repair(HA_CHECK*)") at assert.c:101
#8  0x000056039419b146 in ha_myisam::setup_vcols_for_repair (this=0x7f5538046658, param=0x7f55380475f8) at /data/src/10.4/storage/myisam/ha_myisam.cc:981
#9  0x000056039419d6f4 in ha_myisam::enable_indexes (this=0x7f5538046658, mode=2) at /data/src/10.4/storage/myisam/ha_myisam.cc:1651
#10 0x000056039419de24 in ha_myisam::end_bulk_insert (this=0x7f5538046658) at /data/src/10.4/storage/myisam/ha_myisam.cc:1848
#11 0x0000560393a0c2ef in handler::ha_end_bulk_insert (this=0x7f5538046658) at /data/src/10.4/sql/handler.cc:4427
#12 0x000056039378c146 in copy_data_between_tables (thd=0x7f5538000d90, from=0x7f55380415a0, to=0x7f55380457f0, create=..., ignore=false, order_num=0, order=0x0, copied=0x7f55488ff658, deleted=0x7f55488ff660, keys_onoff=Alter_info::LEAVE_AS_IS, alter_ctx=0x7f55489010d0) at /data/src/10.4/sql/sql_table.cc:11003
#13 0x0000560393789c7b in mysql_alter_table (thd=0x7f5538000d90, new_db=0x7f55380148c8, new_name=0x7f55380148d8, create_info=0x7f5548901e60, table_list=0x7f55380148b0, alter_info=0x7f5548901da0, order_num=0, order=0x0, ignore=false) at /data/src/10.4/sql/sql_table.cc:10353
#14 0x0000560393691d74 in mysql_execute_command (thd=0x7f5538000d90) at /data/src/10.4/sql/sql_parse.cc:4242
#15 0x000056039369e89b in mysql_parse (thd=0x7f5538000d90, rawbuf=0x7f55380147a8 "CREATE UNIQUE INDEX ind USING HASH ON t(f)", length=42, parser_state=0x7f55489024d0, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:7992
#16 0x000056039368abdb in dispatch_command (command=COM_QUERY, thd=0x7f5538000d90, packet=0x7f553800ac01 "", packet_length=42, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:1857
#17 0x0000560393689441 in do_command (thd=0x7f5538000d90) at /data/src/10.4/sql/sql_parse.cc:1373
#18 0x000056039381a962 in do_handle_one_connection (connect=0x560397666f20) at /data/src/10.4/sql/sql_connect.cc:1412
#19 0x000056039381a6ab in handle_one_connection (arg=0x560397666f20) at /data/src/10.4/sql/sql_connect.cc:1316
#20 0x000056039424719c in pfs_spawn_thread (arg=0x56039763fd20) at /data/src/10.4/storage/perfschema/pfs.cc:1869
#21 0x00007f554ef99609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#22 0x00007f554eb6c293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Not reproducible on 10.3, apparently related to MDEV-371.
Not reproducible with INT instead of BIT, I didn't check other data types.
No obvious problems with InnoDB instead of MyISAM, or with MyISAM on a non-debug build.

If Aria is used instead, both debug and release builds produce an error:

query 'CREATE UNIQUE INDEX ind USING HASH ON t(f)' failed: 1071: Specified key was too long; max key length is 1000 bytes

This error is not limited to BIT, happens with INT as well.



 Comments   
Comment by Alice Sherepa [ 2021-10-20 ]

--  source include/have_sequence.inc
 
CREATE or replace TABLE t (f bit(1), UNIQUE KEY (f) USING hash, KEY f1 (f)) engine=myisam;
INSERT INTO t SELECT 1;
INSERT INTO t SELECT seq from seq_1_to_100;

on debug it is failing after the first insert:

10.4 a736a3174a4e7c0d92a38

mysqld: /10.4/src/storage/myisam/ha_myisam.cc:981: void ha_myisam::setup_vcols_for_repair(HA_CHECK*): Assertion `file->s->base.reclength < file->s->vreclength || !table->s->stored_fields' failed.
211020 17:18:53 [ERROR] mysqld got signal 6 ;
 
Server version: 10.4.22-MariaDB-debug-log
 
stdlib/abort.c:81(__GI_abort)[0x7f44b5635859]
intl/loadmsgcat.c:509(get_sysdep_segment_value)[0x7f44b5635729]
:0(__GI___assert_fail)[0x7f44b5646f36]
myisam/ha_myisam.cc:983(ha_myisam::setup_vcols_for_repair(st_handler_check_param*))[0x55cb201c1349]
myisam/ha_myisam.cc:1653(ha_myisam::enable_indexes(unsigned int))[0x55cb201c7aaa]
myisam/ha_myisam.cc:1848(ha_myisam::end_bulk_insert())[0x55cb201c9168]
sql/handler.cc:4441(handler::ha_end_bulk_insert())[0x55cb1f0f31d9]
sql/sql_insert.cc:4038(select_insert::prepare_eof())[0x55cb1e825352]
sql/sql_insert.cc:4138(select_insert::send_eof())[0x55cb1e826de0]
sql/sql_select.cc:4413(JOIN::exec_inner())[0x55cb1e9955f6]
sql/sql_select.cc:4317(JOIN::exec())[0x55cb1e993f5e]
sql/sql_select.cc:4757(mysql_select(THD*, TABLE_LIST*, unsigned int, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*))[0x55cb1e99815e]
sql/sql_select.cc:436(handle_select(THD*, LEX*, select_result*, unsigned long))[0x55cb1e969292]
sql/sql_parse.cc:4712(mysql_execute_command(THD*))[0x55cb1e8ca5d7]
sql/sql_parse.cc:7995(mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool))[0x55cb1e8e1415]
sql/sql_parse.cc:1860(dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool))[0x55cb1e8b7b90]
sql/sql_parse.cc:1373(do_command(THD*))[0x55cb1e8b460d]
sql/sql_connect.cc:1420(do_handle_one_connection(CONNECT*))[0x55cb1ecae0d9]
sql/sql_connect.cc:1317(handle_one_connection)[0x55cb1ecad832]
perfschema/pfs.cc:1871(pfs_spawn_thread)[0x55cb20385679]
nptl/pthread_create.c:478(start_thread)[0x7f44b5b5d609]
x86_64/clone.S:97(__GI___clone)[0x7f44b5732293]
 
Query (0x62b0000a1290): INSERT INTO t SELECT 1

on non-debug I am getting:

10.6.4

211020 17:10:41 [ERROR] mysqld got signal 11 ;
 
Server version: 10.6.4-MariaDB
 
mysys/stacktrace.c:213(my_print_stacktrace)[0x556db8a8499e]
sql/signal_handler.cc:225(handle_fatal_signal)[0x556db84561d7]
sigaction.c:0(__restore_rt)[0x7f8f06b103c0]
sql/sql_plist.h:126(I_P_List<MDL_ticket, I_P_List_adapter<MDL_ticket, &MDL_ticket::next_in_context, &MDL_ticket::prev_in_context>, I_P_List_null_counter, I_P_List_no_push_back<MDL_ticket> >::remove(MDL_ticket*))[0x556db833fdc1]
sql/sql_plist.h:196(I_P_List_iterator<MDL_ticket, I_P_List<MDL_ticket, I_P_List_adapter<MDL_ticket, &MDL_ticket::next_in_context, &MDL_ticket::prev_in_context>, I_P_List_null_counter, I_P_List_no_push_back<MDL_ticket> > >::operator++(int))[0x556db833fe35]
sql/sql_class.h:5000(THD::release_transactional_locks())[0x556db8238be6]
sql/sql_parse.cc:8031(mysql_parse(THD*, char*, unsigned int, Parser_state*))[0x556db823da6b]
sql/sql_parse.cc:1955(dispatch_command(enum_server_command, THD*, char*, unsigned int, bool))[0x556db823fcd7]
sql/sql_parse.cc:1406(do_command(THD*, bool))[0x556db8241373]
sql/sql_connect.cc:1418(do_handle_one_connection(CONNECT*, bool))[0x556db8335f97]
sql/sql_connect.cc:1318(handle_one_connection)[0x556db8336234]
perfschema/pfs.cc:2204(pfs_spawn_thread)[0x556db86bd8d2]
nptl/pthread_create.c:478(start_thread)[0x7f8f06b04609]
x86_64/clone.S:97(__GI___clone)[0x7f8f066f2293]
 
Query (0x7f8ea8012d50): INSERT INTO t SELECT seq from seq_1_to_100

Comment by Roel Van de Paar [ 2022-06-08 ]

Ran into this one as well

CREATE TABLE t (c BIT KEY,c2 BIT) ENGINE=MyISAM;
CREATE UNIQUE INDEX i1 USING HASH ON t (c);

Leads to:

10.10.0 081a284712bb661349e2e3802077b12211cede3e (Debug)

mysqld: /test/10.10_dbg/storage/myisam/ha_myisam.cc:982: void ha_myisam::setup_vcols_for_repair(HA_CHECK*): Assertion `file->s->base.reclength < file->s->vreclength || !table->s->stored_fields' failed.

10.10.0 081a284712bb661349e2e3802077b12211cede3e (Debug)

Core was generated by `/test/MD310522-mariadb-10.10.0-linux-x86_64-dbg/bin/mysqld --no-defaults --core'.
Program terminated with signal SIGABRT, Aborted.
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
[Current thread is 1 (Thread 0x148b340ae700 (LWP 2837868))]
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x0000148b4b61b859 in __GI_abort () at abort.c:79
#2  0x0000148b4b61b729 in __assert_fail_base (fmt=0x148b4b7b1588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x55bb758a05b0 "file->s->base.reclength < file->s->vreclength || !table->s->stored_fields", file=0x55bb758a0268 "/test/10.10_dbg/storage/myisam/ha_myisam.cc", line=982, function=<optimized out>) at assert.c:92
#3  0x0000148b4b62cfd6 in __GI___assert_fail (assertion=assertion@entry=0x55bb758a05b0 "file->s->base.reclength < file->s->vreclength || !table->s->stored_fields", file=file@entry=0x55bb758a0268 "/test/10.10_dbg/storage/myisam/ha_myisam.cc", line=line@entry=982, function=function@entry=0x55bb758a0578 "void ha_myisam::setup_vcols_for_repair(HA_CHECK*)") at assert.c:101
#4  0x000055bb753efa10 in ha_myisam::setup_vcols_for_repair (this=this@entry=0x148afc02a630, param=param@entry=0x148afc032080) at /test/10.10_dbg/storage/myisam/ha_myisam.cc:982
#5  0x000055bb753f152d in ha_myisam::enable_indexes (this=this@entry=0x148afc02a630, mode=mode@entry=2) at /test/10.10_dbg/storage/myisam/ha_myisam.cc:1652
#6  0x000055bb753f16d6 in ha_myisam::end_bulk_insert (this=0x148afc02a630) at /test/10.10_dbg/storage/myisam/ha_myisam.cc:1849
#7  0x000055bb74d0307b in handler::ha_end_bulk_insert (this=0x148afc02a630) at /test/10.10_dbg/sql/handler.cc:5019
#8  0x000055bb74af9206 in copy_data_between_tables (alter_ctx=0x148b340ac210, keys_onoff=<optimized out>, deleted=<synthetic pointer>, copied=<synthetic pointer>, order=<optimized out>, order_num=<optimized out>, ignore=<optimized out>, create=@0x148b340acaf0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x0, last = 0x0, elements = 4294967280}, <No data fields>}, to=0x148afc0295d8, from=0x148afc01b808, thd=0x148afc000db8) at /test/10.10_dbg/sql/sql_table.cc:11707
#9  mysql_alter_table (thd=thd@entry=0x148afc000db8, new_db=new_db@entry=0x148afc013d50, new_name=new_name@entry=0x148afc013d60, create_info=create_info@entry=0x148b340ad030, table_list=<optimized out>, table_list@entry=0x148afc013d38, alter_info=alter_info@entry=0x148b340acf40, order_num=<optimized out>, order=<optimized out>, ignore=<optimized out>, if_exists=<optimized out>) at /test/10.10_dbg/sql/sql_table.cc:10877
#10 0x000055bb74a18aa9 in mysql_execute_command (thd=thd@entry=0x148afc000db8, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /test/10.10_dbg/sql/structs.h:569
#11 0x000055bb74a05e3a in mysql_parse (thd=thd@entry=0x148afc000db8, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x148b340ad470) at /test/10.10_dbg/sql/sql_parse.cc:8036
#12 0x000055bb74a13422 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x148afc000db8, packet=packet@entry=0x148afc00b6d9 "", packet_length=packet_length@entry=42, blocking=blocking@entry=true) at /test/10.10_dbg/sql/sql_class.h:1364
#13 0x000055bb74a15b2c in do_command (thd=0x148afc000db8, blocking=blocking@entry=true) at /test/10.10_dbg/sql/sql_parse.cc:1407
#14 0x000055bb74b753c0 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x55bb76dafa28, put_in_cache=put_in_cache@entry=true) at /test/10.10_dbg/sql/sql_connect.cc:1418
#15 0x000055bb74b758c9 in handle_one_connection (arg=0x55bb76dafa28) at /test/10.10_dbg/sql/sql_connect.cc:1312
#16 0x0000148b4bb2c609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#17 0x0000148b4b718133 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Bug confirmed present in:
MariaDB: 10.4.26 (dbg), 10.5.17 (dbg), 10.6.9 (dbg), 10.7.5 (dbg), 10.8.4 (dbg), 10.9.2 (dbg), 10.10.0 (dbg)

Bug (or feature/syntax) confirmed not present in:
MariaDB: 10.3.36 (dbg), 10.3.36 (opt), 10.4.26 (opt), 10.5.17 (opt), 10.6.9 (opt), 10.7.5 (opt), 10.8.4 (opt), 10.9.2 (opt), 10.10.0 (opt)
MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.51 (dbg), 5.6.51 (opt), 5.7.38 (dbg), 5.7.38 (opt), 8.0.29 (dbg), 8.0.29 (opt)

Comment by Roel Van de Paar [ 2022-09-15 ]

Please also verify any fix with this testcase (same versions affected):

CREATE TABLE t (f BIT,UNIQUE KEY(f) USING HASH) ENGINE=MyISAM;
OPTIMIZE TABLE t;

Which yields a bit different stack:

10.11.0 bc563f1a4b0b38de3b41fd0f0d3d8b7f1aacbd8b (Debug)

mysqld: /test/10.11_dbg/storage/myisam/ha_myisam.cc:982: void ha_myisam::setup_vcols_for_repair(HA_CHECK*): Assertion `file->s->base.reclength < file->s->vreclength || !table->s->stored_fields' failed.

10.11.0 bc563f1a4b0b38de3b41fd0f0d3d8b7f1aacbd8b (Debug)

Core was generated by `/test/MD190822-mariadb-10.11.0-linux-x86_64-dbg/bin/mysqld --no-defaults --core'.
Program terminated with signal SIGABRT, Aborted.
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
[Current thread is 1 (Thread 0x14c42e40c700 (LWP 3766859))]
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x000014c457991859 in __GI_abort () at abort.c:79
#2  0x000014c457991729 in __assert_fail_base (fmt=0x14c457b27588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x556e8b6776d0 "file->s->base.reclength < file->s->vreclength || !table->s->stored_fields", file=0x556e8b677388 "/test/10.11_dbg/storage/myisam/ha_myisam.cc", line=982, function=<optimized out>) at assert.c:92
#3  0x000014c4579a2fd6 in __GI___assert_fail (assertion=assertion@entry=0x556e8b6776d0 "file->s->base.reclength < file->s->vreclength || !table->s->stored_fields", file=file@entry=0x556e8b677388 "/test/10.11_dbg/storage/myisam/ha_myisam.cc", line=line@entry=982, function=function@entry=0x556e8b677698 "void ha_myisam::setup_vcols_for_repair(HA_CHECK*)") at assert.c:101
#4  0x0000556e8b1b6b2a in ha_myisam::setup_vcols_for_repair (this=this@entry=0x14c3dc021a50, param=param@entry=0x14c3dc0316c0) at /test/10.11_dbg/storage/myisam/ha_myisam.cc:982
#5  0x0000556e8b1b836b in ha_myisam::optimize (this=0x14c3dc021a50, thd=0x14c3dc000db8, check_opt=0x14c3dc006298) at /test/10.11_dbg/storage/myisam/ha_myisam.cc:1221
#6  0x0000556e8aadf1b4 in handler::ha_optimize (this=0x14c3dc021a50, thd=0x14c3dc000db8, check_opt=0x14c3dc006298) at /test/10.11_dbg/sql/handler.cc:5119
#7  0x0000556e8a95ff3a in mysql_admin_table (thd=thd@entry=0x14c3dc000db8, tables=tables@entry=0x14c3dc013cf8, check_opt=check_opt@entry=0x14c3dc006298, operator_name=operator_name@entry=0x556e8bb43d60 <msg_optimize>, lock_type=lock_type@entry=TL_WRITE, org_open_for_modify=org_open_for_modify@entry=true, repair_table_use_frm=false, extra_open_options=0, prepare_func=0x0, operator_func=(int (handler::*)(class handler * const, class THD *, HA_CHECK_OPT *)) 0x556e8aadf118 <handler::ha_optimize(THD*, st_ha_check_opt*)>, view_operator_func=0x0, is_cmd_replicated=true) at /test/10.11_dbg/sql/sql_admin.cc:874
#8  0x0000556e8a962cc4 in Sql_cmd_optimize_table::execute (this=<optimized out>, thd=0x14c3dc000db8) at /test/10.11_dbg/sql/sql_admin.cc:1523
#9  0x0000556e8a7f51fa in mysql_execute_command (thd=thd@entry=0x14c3dc000db8, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /test/10.11_dbg/sql/sql_parse.cc:5997
#10 0x0000556e8a7dd882 in mysql_parse (thd=thd@entry=0x14c3dc000db8, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x14c42e40b330) at /test/10.11_dbg/sql/sql_parse.cc:8035
#11 0x0000556e8a7eae6a in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x14c3dc000db8, packet=packet@entry=0x14c3dc00b6e9 "", packet_length=packet_length@entry=16, blocking=blocking@entry=true) at /test/10.11_dbg/sql/sql_class.h:1339
#12 0x0000556e8a7ed574 in do_command (thd=0x14c3dc000db8, blocking=blocking@entry=true) at /test/10.11_dbg/sql/sql_parse.cc:1407
#13 0x0000556e8a94f1da in do_handle_one_connection (connect=<optimized out>, connect@entry=0x556e8cdec328, put_in_cache=put_in_cache@entry=true) at /test/10.11_dbg/sql/sql_connect.cc:1418
#14 0x0000556e8a94f6e3 in handle_one_connection (arg=0x556e8cdec328) at /test/10.11_dbg/sql/sql_connect.cc:1312
#15 0x000014c457ea2609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#16 0x000014c457a8e133 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Comment by Roel Van de Paar [ 2023-06-30 ]

And with

CREATE TABLE t (b INT,c INT,d BIT,v BIT AS (d) VIRTUAL,KEY(b,v)) ENGINE=MyISAM PARTITION BY HASH (b);
REPAIR TABLE t USE_FRM;

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