[MDEV-27674] SIGFPE or assertion failure in row_ins_cascade_calc_update_vec Created: 2022-01-28  Updated: 2023-04-27

Status: Open
Project: MariaDB Server
Component/s: Storage Engine - InnoDB, Virtual Columns
Affects Version/s: 10.2, 10.3, 10.4, 10.5, 10.6, 10.7, 10.8
Fix Version/s: 10.4, 10.5, 10.6

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Vladislav Lesin
Resolution: Unresolved Votes: 0
Labels: None


 Description   

--source include/have_innodb.inc
 
CREATE TABLE t1 (
    a INT,
    b VARCHAR(8),
    c DATETIME,
    d DECIMAL,
    vd DECIMAL AS (d),
    vb VARCHAR(8) AS (b),
    PRIMARY KEY (c,a),
    KEY (a,b),
    KEY(vb)
) ENGINE=InnoDB;
INSERT INTO t1 (a,c) VALUES (1,'2022-12-12');
CREATE TABLE t2 (a INT, FOREIGN KEY (a) REFERENCES t1 (a) ON UPDATE CASCADE) ENGINE=InnoDB;
INSERT INTO t2 (a) VALUES (1);
UPDATE t1 SET b = 'foo';
 
# Cleanup
DROP TABLE t2, t1;

10.2 8d9b1aa0 debug

#2  0x0000557ffe4fcdde in handle_fatal_signal (sig=8) at /data/src/10.2/sql/signal_handler.cc:355
#3  <signal handler called>
#4  0x0000557ffe815205 in row_ins_cascade_calc_update_vec (node=0x7fde0409fe20, foreign=0x7fde040a88f0, heap=0x7fde04010ea0, trx=0x7fde5a128120) at /data/src/10.2/storage/innobase/row/row0ins.cc:603
#5  0x0000557ffe8171df in row_ins_foreign_check_on_constraint (thr=0x7fde040990c0, foreign=0x7fde040a88f0, pcur=0x7fde59551170, entry=0x7fde0418c460, mtr=0x7fde59551510) at /data/src/10.2/storage/innobase/row/row0ins.cc:1290
#6  0x0000557ffe8182a7 in row_ins_check_foreign_constraint (check_ref=0, foreign=0x7fde040a88f0, table=0x7fde0411fbb0, entry=0x7fde0418c460, thr=0x7fde040990c0) at /data/src/10.2/storage/innobase/row/row0ins.cc:1748
#7  0x0000557ffe88ab30 in row_upd_check_references_constraints (node=0x7fde0409fe20, pcur=0x7fde59551b60, table=0x7fde0411fbb0, index=0x7fde04038790, offsets=0x7fde0409b6a0, thr=0x7fde040990c0, mtr=0x7fde59551de0) at /data/src/10.2/storage/innobase/row/row0upd.cc:328
#8  0x0000557ffe88f405 in row_upd_sec_index_entry (node=0x7fde0409fe20, thr=0x7fde040990c0) at /data/src/10.2/storage/innobase/row/row0upd.cc:2503
#9  0x0000557ffe88f764 in row_upd_sec_step (node=0x7fde0409fe20, thr=0x7fde040990c0) at /data/src/10.2/storage/innobase/row/row0upd.cc:2579
#10 0x0000557ffe891731 in row_upd (node=0x7fde0409fe20, thr=0x7fde040990c0) at /data/src/10.2/storage/innobase/row/row0upd.cc:3315
#11 0x0000557ffe891a7d in row_upd_step (thr=0x7fde040990c0) at /data/src/10.2/storage/innobase/row/row0upd.cc:3432
#12 0x0000557ffe83b6ce in row_update_for_mysql (prebuilt=0x7fde0409f200) at /data/src/10.2/storage/innobase/row/row0mysql.cc:1805
#13 0x0000557ffe70118b in ha_innobase::update_row (this=0x7fde04035688, old_row=0x7fde0403a0c8 "\377\001", new_row=0x7fde0403a0a0 "\366\001") at /data/src/10.2/storage/innobase/handler/ha_innodb.cc:9039
#14 0x0000557ffe50c978 in handler::ha_update_row (this=0x7fde04035688, old_data=0x7fde0403a0c8 "\377\001", new_data=0x7fde0403a0a0 "\366\001") at /data/src/10.2/sql/handler.cc:6150
#15 0x0000557ffe37453d in mysql_update (thd=0x7fde04000d90, table_list=0x7fde040127d8, fields=..., values=..., conds=0x0, order_num=0, order=0x0, limit=18446744073709551615, handle_duplicates=DUP_ERROR, ignore=false, found_return=0x7fde59552c50, updated_return=0x7fde59552d00) at /data/src/10.2/sql/sql_update.cc:823
#16 0x0000557ffe2829ff in mysql_execute_command (thd=0x7fde04000d90) at /data/src/10.2/sql/sql_parse.cc:4056
#17 0x0000557ffe28e4f0 in mysql_parse (thd=0x7fde04000d90, rawbuf=0x7fde04012708 "UPDATE t1 SET b = 'foo'", length=23, parser_state=0x7fde595535e0, is_com_multi=false, is_next_command=false) at /data/src/10.2/sql/sql_parse.cc:7793
#18 0x0000557ffe27c893 in dispatch_command (command=COM_QUERY, thd=0x7fde04000d90, packet=0x7fde04008b61 "UPDATE t1 SET b = 'foo'", packet_length=23, is_com_multi=false, is_next_command=false) at /data/src/10.2/sql/sql_parse.cc:1827
#19 0x0000557ffe27b3ac in do_command (thd=0x7fde04000d90) at /data/src/10.2/sql/sql_parse.cc:1381
#20 0x0000557ffe3d3190 in do_handle_one_connection (connect=0x558001d6ca40) at /data/src/10.2/sql/sql_connect.cc:1336
#21 0x0000557ffe3d2f04 in handle_one_connection (arg=0x558001d6ca40) at /data/src/10.2/sql/sql_connect.cc:1241
#22 0x0000557ffebdb819 in pfs_spawn_thread (arg=0x558001d56b40) at /data/src/10.2/storage/perfschema/pfs.cc:1869
#23 0x00007fde5f5b1ea7 in start_thread (arg=<optimized out>) at pthread_create.c:477
#24 0x00007fde5f1b6def in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

10.2 8d9b1aa0 non-debug

2022-01-28 23:36:55 0x7fb111476700  InnoDB: Assertion failure in file /data/src/10.2/storage/innobase/row/row0mysql.cc line 353
 
#5  0x00007fb116fe9537 in __GI_abort () at abort.c:79
#6  0x000055d1a92c7b13 in ut_dbg_assertion_failed (expr=expr@entry=0x0, file=file@entry=0x55d1a9bfa658 "/data/src/10.2/storage/innobase/row/row0mysql.cc", line=line@entry=353) at /data/src/10.2/storage/innobase/ut/ut0dbg.cc:60
#7  0x000055d1a92b2eee in row_mysql_pad_col (mbminlen=<optimized out>, pad=pad@entry=0x7fb0c817bb93 "\310\260\177", len=len@entry=1) at /data/src/10.2/storage/innobase/row/row0mysql.cc:353
#8  0x000055d1a979cf81 in row_ins_cascade_calc_update_vec (trx=0x7fb11201a070, heap=0x7fb0c817bae0, foreign=0x7fb0c80b2398, node=<optimized out>) at /data/src/10.2/storage/innobase/row/row0ins.cc:614
#9  row_ins_foreign_check_on_constraint (mtr=0x7fb111472a70, entry=<optimized out>, pcur=0x7fb111472570, foreign=0x7fb0c80b2398, thr=0x7fb0c80bb8b8) at /data/src/10.2/storage/innobase/row/row0ins.cc:1290
#10 row_ins_check_foreign_constraint (check_ref=check_ref@entry=0, foreign=foreign@entry=0x7fb0c80b2398, table=table@entry=0x7fb0c80689e8, entry=entry@entry=0x7fb0c817b8a8, thr=thr@entry=0x7fb0c80bb8b8) at /data/src/10.2/storage/innobase/row/row0ins.cc:1748
#11 0x000055d1a97d651c in row_upd_check_references_constraints (node=<optimized out>, pcur=<optimized out>, table=<optimized out>, index=<optimized out>, offsets=<optimized out>, thr=<optimized out>, mtr=<optimized out>) at /data/src/10.2/storage/innobase/row/row0upd.cc:328
#12 0x000055d1a97dc0f8 in row_upd_check_references_constraints (mtr=0x7fb111473380, thr=0x7fb0c80bb8b8, offsets=<optimized out>, index=0x7fb0c802f498, table=<optimized out>, pcur=0x7fb111473100, node=0x7fb0c802c5a8) at /data/src/10.2/storage/innobase/row/row0upd.cc:2362
#13 row_upd_sec_index_entry (node=<optimized out>, thr=<optimized out>) at /data/src/10.2/storage/innobase/row/row0upd.cc:2503
#14 0x000055d1a97dc797 in row_upd_sec_step (thr=0x7fb0c80bb8b8, node=0x7fb0c802c5a8) at /data/src/10.2/storage/innobase/row/row0upd.cc:2579
#15 row_upd (thr=0x7fb0c80bb8b8, node=0x7fb0c802c5a8) at /data/src/10.2/storage/innobase/row/row0upd.cc:3315
#16 row_upd_step (thr=thr@entry=0x7fb0c80bb8b8) at /data/src/10.2/storage/innobase/row/row0upd.cc:3432
#17 0x000055d1a97af93d in row_update_for_mysql (prebuilt=0x7fb0c802b9c8) at /data/src/10.2/storage/innobase/row/row0mysql.cc:1805
#18 0x000055d1a96fdd9f in ha_innobase::update_row (this=0x7fb0c8177ed0, old_row=0x7fb0c80a1560 "\377\001", new_row=0x7fb0c80a1538 "\366\001") at /data/src/10.2/storage/innobase/handler/ha_innodb.cc:9039
#19 0x000055d1a9561fb0 in handler::ha_update_row (this=0x7fb0c8177ed0, old_data=0x7fb0c80a1560 "\377\001", new_data=0x7fb0c80a1538 "\366\001") at /data/src/10.2/sql/handler.cc:6150
#20 0x000055d1a94524ae in mysql_update (thd=thd@entry=0x7fb0c8000c48, table_list=<optimized out>, fields=..., values=..., conds=<optimized out>, order_num=<optimized out>, order=<optimized out>, limit=18446744073709551615, handle_duplicates=DUP_ERROR, ignore=false, found_return=0x7fb111473f80, updated_return=0x7fb111474030) at /data/src/10.2/sql/sql_update.cc:823
#21 0x000055d1a93a8600 in mysql_execute_command (thd=<optimized out>) at /data/src/10.2/sql/sql_parse.cc:4056
#22 0x000055d1a93ad7db in mysql_parse (thd=thd@entry=0x7fb0c8000c48, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x7fb1114755a0, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /data/src/10.2/sql/sql_parse.cc:7793
#23 0x000055d1a93b09bd in dispatch_command (command=COM_QUERY, thd=0x7fb0c8000c48, packet=<optimized out>, packet_length=<optimized out>, is_com_multi=<optimized out>, is_next_command=<optimized out>) at /data/src/10.2/sql/sql_class.h:182
#24 0x000055d1a93b1c89 in do_command (thd=0x7fb0c8000c48) at /data/src/10.2/sql/sql_parse.cc:1381
#25 0x000055d1a948b846 in do_handle_one_connection (connect=connect@entry=0x55d1ac3d0258) at /data/src/10.2/sql/sql_connect.cc:1336
#26 0x000055d1a948b9bb in handle_one_connection (arg=arg@entry=0x55d1ac3d0258) at /data/src/10.2/sql/sql_connect.cc:1241
#27 0x000055d1a9a17fc2 in pfs_spawn_thread (arg=0x55d1ac6d3388) at /data/src/10.2/storage/perfschema/pfs.cc:1869
#28 0x00007fb1174a4ea7 in start_thread (arg=<optimized out>) at pthread_create.c:477
#29 0x00007fb1170c1def in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Reproducible on debug and non-debug builds above, all of 10.2-10.8, including older releases (tried 10.4.6).



 Comments   
Comment by Marko Mäkelä [ 2022-04-29 ]

I debugged this with ./mtr --rr on a 10.6-based branch.
As far as I can tell, the UPDATE statement should not touch the child table t2 at all, because the column t1.a will not be affected by it. When the crash occurs, row_ins_cascade_calc_update_vec() is attempting to convert the string value b='foo' to something that could applied to the INT column t2.a. The immediate reason why the assertion fails is because the column does not use any collation.

The function row_upd_sec_index_entry() is being invoked on the index (a,b) on table t1, which indeed is affected by the UPDATE of the column b. It looks like row_upd_check_references_constraints() or its call needs to be refined, to notice that column a is not actually being updated, and therefore no CASCADE operation must take place.

As part of fixing this, you should check why the presence of the indexed virtual column vb is necessary for this test to fail.

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