[MDEV-20661] Virtual fields are not recalculated on system fields value assignment Created: 2019-09-24  Updated: 2020-07-20  Resolved: 2020-07-20

Status: Closed
Project: MariaDB Server
Component/s: Data types, Versioned Tables, Virtual Columns
Affects Version/s: 10.3, 10.4, 10.5
Fix Version/s: 10.3.24, 10.4.14, 10.5.5

Type: Bug Priority: Critical
Reporter: Elena Stepanova Assignee: Aleksey Midenkov
Resolution: Fixed Votes: 0
Labels: affects-tests

Issue Links:
Relates
relates to MDEV-371 Unique indexes for blobs Closed
relates to MDEV-20610 Assertion failed or btr_validate_inde... Confirmed
relates to MDEV-20618 Assertion `btr_validate_index(index, ... Closed
relates to MDEV-20763 Table corruption or Assertion `btr_va... Closed
relates to MDEV-22061 InnoDB: Assertion of missing row in s... Closed

 Description   

Corruption errors or Assertion `btr_validate_index(index, 0)' failed in row_upd_sec_index_entry upon DELETE HISTORY

Note: We have a variety of btr_validate_index bugs, so it might be one of them. But I can't tell which one it would be a duplicate of, so I'm filing it separately just in case.

--source include/have_innodb.inc
CREATE TABLE t1 (
  a varchar(4096),
  UNIQUE KEY (a)
) ENGINE=InnoDB WITH SYSTEM VERSIONING;
 
INSERT INTO t1 VALUES ('foo'),('bar');
UPDATE IGNORE t1 SET a = 'qux';
DELETE HISTORY FROM t1;
 
# Cleanup
DROP TABLE t1;

10.4 debug b4417142

mysqld: /data/src/10.4/storage/innobase/row/row0upd.cc:2425: dberr_t row_upd_sec_index_entry(upd_node_t*, que_thr_t*): Assertion `btr_validate_index(index, 0)' failed.
190924 19:49:20 [ERROR] mysqld got signal 6 ;
 
#7  0x00007f889f0d1f12 in __GI___assert_fail (assertion=0x55b3d858f1c5 "btr_validate_index(index, 0)", file=0x55b3d858ea28 "/data/src/10.4/storage/innobase/row/row0upd.cc", line=2425, function=0x55b3d8591920 <row_upd_sec_index_entry(upd_node_t*, que_thr_t*)::__PRETTY_FUNCTION__> "dberr_t row_upd_sec_index_entry(upd_node_t*, que_thr_t*)") at assert.c:101
#8  0x000055b3d7db7fbb in row_upd_sec_index_entry (node=0x7f8844072b00, thr=0x7f8844072e68) at /data/src/10.4/storage/innobase/row/row0upd.cc:2425
#9  0x000055b3d7db87b6 in row_upd_sec_step (node=0x7f8844072b00, thr=0x7f8844072e68) at /data/src/10.4/storage/innobase/row/row0upd.cc:2539
#10 0x000055b3d7dbb721 in row_upd (node=0x7f8844072b00, thr=0x7f8844072e68) at /data/src/10.4/storage/innobase/row/row0upd.cc:3315
#11 0x000055b3d7dbbb67 in row_upd_step (thr=0x7f8844072e68) at /data/src/10.4/storage/innobase/row/row0upd.cc:3430
#12 0x000055b3d7d596a3 in row_update_for_mysql (prebuilt=0x7f884414e788) at /data/src/10.4/storage/innobase/row/row0mysql.cc:1889
#13 0x000055b3d7bb8e96 in ha_innobase::delete_row (this=0x7f884414d338, record=0x7f88441385e8 "\374\003") at /data/src/10.4/storage/innobase/handler/ha_innodb.cc:8971
#14 0x000055b3d797aff8 in handler::ha_delete_row (this=0x7f884414d338, buf=0x7f88441385e8 "\374\003") at /data/src/10.4/sql/handler.cc:6782
#15 0x000055b3d7b352fb in TABLE::delete_row (this=0x7f884414c4d0) at /data/src/10.4/sql/sql_delete.cc:297
#16 0x000055b3d7b321d4 in mysql_delete (thd=0x7f8844000b00, table_list=0x7f8844013200, conds=0x0, order_list=0x7f88440054b0, limit=18446744073709551615, options=0, result=0x0) at /data/src/10.4/sql/sql_delete.cc:834
#17 0x000055b3d7610811 in mysql_execute_command (thd=0x7f8844000b00) at /data/src/10.4/sql/sql_parse.cc:4723
#18 0x000055b3d761c04f in mysql_parse (thd=0x7f8844000b00, rawbuf=0x7f8844013128 "DELETE HISTORY FROM t1", length=22, parser_state=0x7f88984a2170, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:7912
#19 0x000055b3d76072e2 in dispatch_command (command=COM_QUERY, thd=0x7f8844000b00, packet=0x7f884419e1a1 "DELETE HISTORY FROM t1", packet_length=22, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:1841
#20 0x000055b3d760596f in do_command (thd=0x7f8844000b00) at /data/src/10.4/sql/sql_parse.cc:1359
#21 0x000055b3d778cdef in do_handle_one_connection (connect=0x55b3daa64250) at /data/src/10.4/sql/sql_connect.cc:1412
#22 0x000055b3d778cb3e in handle_one_connection (arg=0x55b3daa64250) at /data/src/10.4/sql/sql_connect.cc:1316
#23 0x000055b3d818c2ed in pfs_spawn_thread (arg=0x55b3da9a7f00) at /data/src/10.4/storage/perfschema/pfs.cc:1862
#24 0x00007f88a0c464a4 in start_thread (arg=0x7f88984a3700) at pthread_create.c:456
#25 0x00007f889f18ed0f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:97

10.4 non-debug b4417142

2019-09-24 19:52:15 9 [ERROR] InnoDB: Record in index `a` of table `test`.`t1` was not found on update: TUPLE (info_bits=0, 2 fields): {[8]g  " [  (0x67F29822F85B939F),[6]      (0x000000000202)} at: COMPACT RECORD(info_bits=0, 2 fields): {[8])& Ex   (0x29269F4578D5ADD8),[6]      (0x000000000201)}

Same test case, but with MyISAM:

mysqltest: At line 9: query 'DELETE HISTORY FROM t1' failed: 126: Index for table './test/t1.MYI' is corrupt; try to repair it

Error log

2019-09-24 19:57:50 9 [ERROR] mysqld: Index for table './test/t1.MYI' is corrupt; try to repair it
2019-09-24 19:57:50 9 [ERROR] mysqld: Index for table './test/t1.MYI' is corrupt; try to repair it
2019-09-24 19:57:50 9 [ERROR] Got an error from thread_id=9, /data/src/10.4/storage/myisam/mi_delete.c:121
2019-09-24 19:57:50 9 [ERROR] MySQL thread id 9, OS thread handle 140687717869312, query id 25 localhost root Updating
DELETE HISTORY FROM t1
2019-09-24 19:57:50 9 [ERROR] mysqld: Index for table 't1' is corrupt; try to repair it

Also reproducible on 10.5 8887effe.
The test case is not applicable to 10.3 due to the long index.



 Comments   
Comment by Alice Sherepa [ 2020-02-13 ]

I'm getting the same assertion on 10.5, but without using system versioning

#6  0x00007fdadd561bd7 in __assert_fail_base (fmt=<optimized out>, assertion=assertion@entry=0x5599470899dd "btr_validate_index(index, 0)", file=file@entry=0x559947089238 "/10.5/storage/innobase/row/row0upd.cc", line=line@entry=2422, function=function@entry=0x55994708c0c0 <row_upd_sec_index_entry(upd_node_t*, que_thr_t*)::__PRETTY_FUNCTION__> "dberr_t row_upd_sec_index_entry(upd_node_t*, que_thr_t*)") at assert.c:92
#7  0x00007fdadd561c82 in __GI___assert_fail (assertion=0x5599470899dd "btr_validate_index(index, 0)", file=0x559947089238 "/10.5/storage/innobase/row/row0upd.cc", line=2422, function=0x55994708c0c0 <row_upd_sec_index_entry(upd_node_t*, que_thr_t*)::__PRETTY_FUNCTION__> "dberr_t row_upd_sec_index_entry(upd_node_t*, que_thr_t*)") at assert.c:101
#8  0x000055994691b3ad in row_upd_sec_index_entry (node=0x7fda601486b0, thr=0x7fda601489e8) at /10.5/storage/innobase/row/row0upd.cc:2422
#9  0x000055994691bd4f in row_upd_sec_step (node=0x7fda601486b0, thr=0x7fda601489e8) at /10.5/storage/innobase/row/row0upd.cc:2546
#10 0x000055994691edfe in row_upd (node=0x7fda601486b0, thr=0x7fda601489e8) at /10.5/storage/innobase/row/row0upd.cc:3326
#11 0x000055994691f246 in row_upd_step (thr=0x7fda601489e8) at /10.5/storage/innobase/row/row0upd.cc:3441
#12 0x00005599468bc0b1 in row_update_for_mysql (prebuilt=0x7fda60147eb8) at /10.5/storage/innobase/row/row0mysql.cc:1889
#13 0x000055994670de9a in ha_innobase::delete_row (this=0x7fda60145038, record=0x7fda60140398 "\371\377\377\377\177\a") at /10.5/storage/innobase/handler/ha_innodb.cc:8719
#14 0x00005599461f54a9 in handler::ha_delete_row (this=0x7fda60145038, buf=0x7fda60140398 "\371\377\377\377\177\a") at /10.5/sql/handler.cc:6787
#15 0x00005599463c115d in TABLE::delete_row (this=0x7fda601441c0) at /10.5/sql/sql_delete.cc:278
#16 0x00005599463bdf8f in mysql_delete (thd=0x7fda60000b00, table_list=0x7fda600123f0, conds=0x7fda60012d40, order_list=0x7fda600054d8, limit=3, options=0, result=0x0) at /10.5/sql/sql_delete.cc:789
#17 0x0000559945e9a124 in mysql_execute_command (thd=0x7fda60000b00) at /10.5/sql/sql_parse.cc:4738
#18 0x0000559945ea59e0 in mysql_parse (thd=0x7fda60000b00, rawbuf=0x7fda60012188 "DELETE IGNORE FROM `v1` WHERE `pk` BETWEEN 2 AND 8 ORDER BY `col_int`,`col_int_key`,`pk` LIMIT 3", length=149, parser_state=0x7fdac4f50440, is_com_multi=false, is_next_command=false) at /10.5/sql/sql_parse.cc:7991
#19 0x0000559945e90a6a in dispatch_command (command=COM_QUERY, thd=0x7fda60000b00, packet=0x7fda600086c1 "DELETE IGNORE FROM `v1` WHERE `pk` BETWEEN 2 AND 8 ORDER BY `col_int`,`col_int_key`,`pk` LIMIT 3", packet_length=149, is_com_multi=false, is_next_command=false) at /10.5/sql/sql_parse.cc:1846
#20 0x0000559945e8f198 in do_command (thd=0x7fda60000b00) at /10.5/sql/sql_parse.cc:1364
#21 0x0000559946030bd6 in do_handle_one_connection (connect=0x55994996e770, put_in_cache=true) at /10.5/sql/sql_connect.cc:1422
#22 0x00005599460308da in handle_one_connection (arg=0x55994996e770) at /10.5/sql/sql_connect.cc:1319
#23 0x00007fdade3aa6ba in start_thread (arg=0x7fdac4f51700) at pthread_create.c:333
#24 0x00007fdadd63b41d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

Comment by Elena Stepanova [ 2020-02-13 ]

It's one of those assertion failures which can happen in very different cases. If you have a test case without versioning, and it's not one of other open ones (e.g. MDEV-20763), then maybe it should be filed separately.

Comment by Aleksey Midenkov [ 2020-06-07 ]

Reproducible in 10.3:

--source include/have_innodb.inc
 
create table t1 (
  a int,
  row_start timestamp(6) as row start invisible,
  row_end timestamp(6) as row end invisible,
  period for system_time (row_start, row_end),
  v1 bigint unsigned as (a ^ row_start) unique,
  v2 bigint unsigned as (a ^ row_end) unique
) engine=innodb with system versioning;
 
insert into t1 (a) values (1), (2);
update ignore t1 set a= 3;
delete history from t1;
 
create or replace table t1 (
  a int,
  row_start bigint(20) unsigned as row start invisible,
  row_end bigint(20) unsigned as row end invisible,
  period for system_time (row_start, row_end),
  v1 bigint unsigned as (a ^ row_start) unique,
  v2 bigint unsigned as (a ^ row_end) unique
) engine=innodb with system versioning;
 
insert into t1 (a) values (1), (2);
update ignore t1 set a= 3;
delete history from t1;
 
# cleanup
drop table t1;

Comment by Eugene Kosov (Inactive) [ 2020-06-26 ]

Please, change formatting of a new code to a common MariaDB style.

The patch looks good to me.

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