[MDEV-28514] Assertion `file->s->base.reclength < file->s->vreclength || !table->s->stored_fields' failed in ha_myisam::setup_vcols_for_repair Created: 2022-05-08  Updated: 2023-11-28

Status: Confirmed
Project: MariaDB Server
Component/s: Storage Engine - MyISAM, Virtual Columns
Affects Version/s: 10.2, 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, 10.10, 10.11, 11.0
Fix Version/s: 10.4, 10.5, 10.6, 10.11

Type: Bug Priority: Major
Reporter: Roel Van de Paar Assignee: Nikita Malyavin
Resolution: Unresolved Votes: 0
Labels: affects-tests, regression-10.4

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

 Description   

Possibly connected to MDEV-19011

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

Leads to:

10.9.0 0b14dbd45b5a1c02616d611876158d44b92b77bf (Debug)

mysqld: /test/10.9_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.9.0 0b14dbd45b5a1c02616d611876158d44b92b77bf (Debug)

Core was generated by `/test/MD030522-mariadb-10.9.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 0x154fc26dc700 (LWP 392869))]
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x0000154ff4294859 in __GI_abort () at abort.c:79
#2  0x0000154ff4294729 in __assert_fail_base (fmt=0x154ff442a588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x5642316273b0 "file->s->base.reclength < file->s->vreclength || !table->s->stored_fields", file=0x564231627068 "/test/10.9_dbg/storage/myisam/ha_myisam.cc", line=982, function=<optimized out>) at assert.c:92
#3  0x0000154ff42a6006 in __GI___assert_fail (assertion=assertion@entry=0x5642316273b0 "file->s->base.reclength < file->s->vreclength || !table->s->stored_fields", file=file@entry=0x564231627068 "/test/10.9_dbg/storage/myisam/ha_myisam.cc", line=line@entry=982, function=function@entry=0x564231627378 "void ha_myisam::setup_vcols_for_repair(HA_CHECK*)") at assert.c:101
#4  0x000056423117c3aa in ha_myisam::setup_vcols_for_repair (this=this@entry=0x154f64023940, param=param@entry=0x154f6402d3f0) at /test/10.9_dbg/storage/myisam/ha_myisam.cc:982
#5  0x000056423117c85f in ha_myisam::check (this=0x154f64023940, thd=0x154f64000db8, check_opt=<optimized out>) at /test/10.9_dbg/storage/myisam/ha_myisam.cc:1031
#6  0x0000564230a9005f in handler::ha_check (this=this@entry=0x154f64023940, thd=thd@entry=0x154f64000db8, check_opt=check_opt@entry=0x154f64006278) at /test/10.9_dbg/sql/handler.cc:4949
#7  0x0000564230d496b3 in ha_partition::handle_opt_part (this=this@entry=0x154f64023070, thd=thd@entry=0x154f64000db8, check_opt=check_opt@entry=0x154f64006278, part_id=part_id@entry=0, flag=flag@entry=3) at /test/10.9_dbg/sql/ha_partition.cc:1391
#8  0x0000564230d49835 in ha_partition::handle_opt_partitions (this=0x154f64023070, thd=0x154f64000db8, check_opt=0x154f64006278, flag=flag@entry=3) at /test/10.9_dbg/sql/ha_partition.cc:1568
#9  0x0000564230d49b56 in ha_partition::check (this=<optimized out>, thd=<optimized out>, check_opt=<optimized out>) at /test/10.9_dbg/sql/ha_partition.cc:1299
#10 0x0000564230a9005f in handler::ha_check (this=0x154f64023070, thd=0x154f64000db8, check_opt=0x154f64006278) at /test/10.9_dbg/sql/handler.cc:4949
#11 0x0000564230915764 in mysql_admin_table (thd=thd@entry=0x154f64000db8, tables=tables@entry=0x154f64013ca0, check_opt=check_opt@entry=0x154f64006278, operator_name=operator_name@entry=0x564231a5d120 <msg_check>, lock_type=lock_type@entry=TL_READ_NO_INSERT, org_open_for_modify=org_open_for_modify@entry=false, repair_table_use_frm=false, extra_open_options=32, prepare_func=0x0, operator_func=(int (handler::*)(class handler * const, class THD *, HA_CHECK_OPT *)) 0x564230a8fff8 <handler::ha_check(THD*, st_ha_check_opt*)>, view_operator_func=0x5642308b3615 <view_check(THD*, TABLE_LIST*, st_ha_check_opt*)>, is_cmd_replicated=false) at /test/10.9_dbg/sql/sql_admin.cc:874
#12 0x00005642309183a4 in Sql_cmd_check_table::execute (this=<optimized out>, thd=0x154f64000db8) at /test/10.9_dbg/sql/sql_admin.cc:1487
#13 0x00005642307af03a in mysql_execute_command (thd=thd@entry=0x154f64000db8, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /test/10.9_dbg/sql/sql_parse.cc:6006
#14 0x000056423079767b in mysql_parse (thd=thd@entry=0x154f64000db8, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x154fc26db470) at /test/10.9_dbg/sql/sql_parse.cc:8046
#15 0x00005642307a4f79 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x154f64000db8, packet=packet@entry=0x154f6400b699 "", packet_length=packet_length@entry=14, blocking=blocking@entry=true) at /test/10.9_dbg/sql/sql_class.h:1364
#16 0x00005642307a7686 in do_command (thd=0x154f64000db8, blocking=blocking@entry=true) at /test/10.9_dbg/sql/sql_parse.cc:1408
#17 0x0000564230904d02 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x564233f7ede8, put_in_cache=put_in_cache@entry=true) at /test/10.9_dbg/sql/sql_connect.cc:1418
#18 0x000056423090520b in handle_one_connection (arg=0x564233f7ede8) at /test/10.9_dbg/sql/sql_connect.cc:1312
#19 0x0000154ff47a5609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#20 0x0000154ff4391163 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Bug confirmed present in:
MariaDB: 10.2.44 (dbg), 10.3.35 (dbg), 10.4.25 (dbg), 10.5.16 (dbg), 10.6.8 (dbg), 10.7.4 (dbg), 10.8.3 (dbg), 10.9.0 (dbg)

Bug (or feature/syntax) confirmed not present in:
MariaDB: 10.2.44 (opt), 10.3.35 (opt), 10.4.25 (opt), 10.5.16 (opt), 10.6.8 (opt), 10.7.4 (opt), 10.8.3 (opt), 10.9.0 (opt)
MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.51 (dbg), 5.6.51 (opt), 5.7.37 (dbg), 5.7.37 (opt), 8.0.28 (dbg), 8.0.28 (opt)



 Comments   
Comment by Roel Van de Paar [ 2022-05-08 ]

UniqueID's thus far for this bug and MDEV-26035, and where they are found (ref EOL):

file->s->base.reclength < file->s->vreclength || !table->s->stored_fields|SIGABRT|ha_myisam::setup_vcols_for_repair|ha_myisam::check|handler::ha_check|ha_partition::handle_opt_part  # Original testcase (10.2+)
file->s->base.reclength < file->s->vreclength || !table->s->stored_fields|SIGABRT|ha_myisam::setup_vcols_for_repair|ha_myisam::check|handler::ha_check|mysql_admin_table  # Testcase below (10.4+ only)
file->s->base.reclength < file->s->vreclength || !table->s->stored_fields|SIGABRT|ha_myisam::setup_vcols_for_repair|ha_myisam::enable_indexes|ha_myisam::end_bulk_insert|handler::ha_end_bulk_insert  # MDEV-26035
file->s->base.reclength < file->s->vreclength || !table->s->stored_fields|SIGABRT|ha_myisam::setup_vcols_for_repair|ha_myisam::repair|handler::ha_repair|mysql_admin_table # Second testcase below (10.4+ only)

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

Additional testcase which only triggers on 10.4

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

Leads to:

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 0x14f759c26700 (LWP 2642937))]
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x000014f776bf3859 in __GI_abort () at abort.c:79
#2  0x000014f776bf3729 in __assert_fail_base (fmt=0x14f776d89588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x5578f67646d0 "file->s->base.reclength < file->s->vreclength || !table->s->stored_fields", file=0x5578f6764388 "/test/10.11_dbg/storage/myisam/ha_myisam.cc", line=982, function=<optimized out>) at assert.c:92
#3  0x000014f776c04fd6 in __GI___assert_fail (assertion=assertion@entry=0x5578f67646d0 "file->s->base.reclength < file->s->vreclength || !table->s->stored_fields", file=file@entry=0x5578f6764388 "/test/10.11_dbg/storage/myisam/ha_myisam.cc", line=line@entry=982, function=function@entry=0x5578f6764698 "void ha_myisam::setup_vcols_for_repair(HA_CHECK*)") at assert.c:101
#4  0x00005578f62a3b2a in ha_myisam::setup_vcols_for_repair (this=this@entry=0x14f71c021a50, param=param@entry=0x14f71c0277a0) at /test/10.11_dbg/storage/myisam/ha_myisam.cc:982
#5  0x00005578f62a3fdf in ha_myisam::check (this=0x14f71c021a50, thd=0x14f71c000db8, check_opt=<optimized out>) at /test/10.11_dbg/storage/myisam/ha_myisam.cc:1031
#6  0x00005578f5bcbb6e in handler::ha_check (this=0x14f71c021a50, thd=0x14f71c000db8, check_opt=0x14f71c006298) at /test/10.11_dbg/sql/handler.cc:4966
#7  0x00005578f5a4cf3a in mysql_admin_table (thd=thd@entry=0x14f71c000db8, tables=tables@entry=0x14f71c013cf0, check_opt=check_opt@entry=0x14f71c006298, operator_name=operator_name@entry=0x5578f6c30d80 <msg_check>, lock_type=lock_type@entry=TL_READ_NO_INSERT, org_open_for_modify=org_open_for_modify@entry=false, repair_table_use_frm=false, extra_open_options=32, prepare_func=0x0, operator_func=(int (handler::*)(class handler * const, class THD *, HA_CHECK_OPT *)) 0x5578f5bcbb06 <handler::ha_check(THD*, st_ha_check_opt*)>, view_operator_func=0x5578f59e9956 <view_check(THD*, TABLE_LIST*, st_ha_check_opt*)>, is_cmd_replicated=false) at /test/10.11_dbg/sql/sql_admin.cc:874
#8  0x00005578f5a4fb7a in Sql_cmd_check_table::execute (this=<optimized out>, thd=0x14f71c000db8) at /test/10.11_dbg/sql/sql_admin.cc:1487
#9  0x00005578f58e21fa in mysql_execute_command (thd=thd@entry=0x14f71c000db8, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /test/10.11_dbg/sql/sql_parse.cc:5997
#10 0x00005578f58ca882 in mysql_parse (thd=thd@entry=0x14f71c000db8, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x14f759c25330) at /test/10.11_dbg/sql/sql_parse.cc:8035
#11 0x00005578f58d7e6a in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x14f71c000db8, packet=packet@entry=0x14f71c00b6e9 "", packet_length=packet_length@entry=13, blocking=blocking@entry=true) at /test/10.11_dbg/sql/sql_class.h:1339
#12 0x00005578f58da574 in do_command (thd=0x14f71c000db8, blocking=blocking@entry=true) at /test/10.11_dbg/sql/sql_parse.cc:1407
#13 0x00005578f5a3c1da in do_handle_one_connection (connect=<optimized out>, connect@entry=0x5578f7e091e8, put_in_cache=put_in_cache@entry=true) at /test/10.11_dbg/sql/sql_connect.cc:1418
#14 0x00005578f5a3c6e3 in handle_one_connection (arg=0x5578f7e091e8) at /test/10.11_dbg/sql/sql_connect.cc:1312
#15 0x000014f777104609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#16 0x000014f776cf0133 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Bug confirmed present in:
MariaDB: 10.4.27 (dbg), 10.5.18 (dbg), 10.6.10 (dbg), 10.7.6 (dbg), 10.8.5 (dbg), 10.9.2 (dbg), 10.10.2 (dbg), 10.11.0 (dbg)

Bug (or feature/syntax) confirmed not present in:
MariaDB: 10.3.37 (dbg), 10.3.37 (opt), 10.4.27 (opt), 10.5.18 (opt), 10.6.10 (opt), 10.7.6 (opt), 10.8.5 (opt), 10.9.2 (opt), 10.10.2 (opt), 10.11.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)

10.3 Is unaffected by this test:

10.3.37 a1055ab35d29437b717e83b1a388eaa02901c42f (Debug)

10.3.37-dbg>CREATE TABLE t (f BIT,UNIQUE KEY(f) USING HASH) ENGINE=MyISAM;
Query OK, 0 rows affected (0.004 sec)
 
10.3.37-dbg>CHECK TABLE t;
+--------+-------+----------+----------+
| Table  | Op    | Msg_type | Msg_text |
+--------+-------+----------+----------+
| test.t | check | status   | OK       |
+--------+-------+----------+----------+
1 row in set (0.001 sec)
 
10.3.37-dbg>

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

Likely connected with MDEV-26035. Updated UniqueID list above to include both bugs. Please fix together.

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

Additional stack in 10.4 to 10.11 with this testcase using REPAIR:

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

UniqueID added:

file->s->base.reclength < file->s->vreclength || !table->s->stored_fields|SIGABRT|ha_myisam::setup_vcols_for_repair|ha_myisam::repair|handler::ha_repair|mysql_admin_table

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

In connection with the last testcase, I was once saw (in automation, so the data dir was clean etc.) a stack from MDEV-23701. This is somewhat likely unrelated to this bug, but noting it here for completeness. Ref here.

Comment by Roel Van de Paar [ 2023-01-31 ]

Additional stack with this testcase using OPTIMIZE (affects 10.3-11.0 dbg):

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

UniqueID added:

file->s->base.reclength < file->s->vreclength || !table->s->stored_fields|SIGABRT|ha_myisam::setup_vcols_for_repair|ha_myisam::optimize|handler::ha_optimize|ha_partition::handle_opt_part

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