[MDEV-22714] Assertion `index->table->is_instant()' failed upon multi-update on table with WITHOUT OVERLAPS Created: 2020-05-26  Updated: 2023-07-27  Resolved: 2020-11-02

Status: Closed
Project: MariaDB Server
Component/s: Versioned Tables
Affects Version/s: 10.5
Fix Version/s: 10.5.7

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

Issue Links:
Issue split
split to MDEV-23801 Assertion `index->table->instant' fai... Closed
Relates
relates to MDEV-22667 Multi-delete on table with unique blo... Confirmed
relates to MDEV-31784 [draft]Assertion `index->table->is_in... Open

 Description   

MyISAM version

CREATE TABLE t1 (a INT) ENGINE=MyISAM;
INSERT INTO t1 VALUES (0),(NULL),(0);
 
CREATE TABLE t2 (f INT, s DATE, e DATE, PERIOD FOR p(s,e), UNIQUE(f, p WITHOUT OVERLAPS)) ENGINE=MyISAM;
INSERT INTO t2 VALUES (NULL,'2026-02-12','2036-09-16'), (NULL,'2025-03-09','2032-12-05');
 
UPDATE IGNORE t1 JOIN t2 SET f = a;
 
# Cleanup
DROP TABLE t1, t2;

10.5 8569dac1

mysqltest: At line 9: query 'UPDATE IGNORE t1 JOIN t2 SET f = a' failed: 126: Index for table './test/t2.MYI' is corrupt; try to repair it

Aria version

CREATE TABLE t1 (a INT) ENGINE=Aria;
INSERT INTO t1 VALUES (0),(NULL),(0);
 
CREATE TABLE t2 (f INT, s DATE, e DATE, PERIOD FOR p(s,e), UNIQUE(f, p WITHOUT OVERLAPS)) ENGINE=Aria;
INSERT INTO t2 VALUES (NULL,'2026-02-12','2036-09-16'), (NULL,'2025-03-09','2032-12-05');
 
UPDATE IGNORE t1 JOIN t2 SET f = a;
 
# Cleanup
DROP TABLE t1, t2;

mysqltest: At line 9: query 'UPDATE IGNORE t1 JOIN t2 SET f = a' failed: 1032: Can't find record in 't2'

InnoDB version

--source include/have_innodb.inc
 
CREATE TABLE t1 (a INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (0),(NULL),(0);
 
CREATE TABLE t2 (f INT, s DATE, e DATE, PERIOD FOR p(s,e), UNIQUE(f, p WITHOUT OVERLAPS)) ENGINE=InnoDB;
INSERT INTO t2 VALUES (NULL,'2026-02-12','2036-09-16'), (NULL,'2025-03-09','2032-12-05');
 
UPDATE IGNORE t1 JOIN t2 SET f = a;
 
# Cleanup
DROP TABLE t1, t2;

10.5 8569dac1 debug

mariadbd: /data/src/10.5/storage/innobase/btr/btr0cur.cc:4137: void btr_cur_upd_rec_in_place(rec_t*, const dict_index_t*, const rec_offs*, const upd_t*, buf_block_t*, mtr_t*): Assertion `index->table->is_instant()' failed.
200526 13:07:59 [ERROR] mysqld got signal 6 ;
 
#7  0x00007fc046fd7f12 in __GI___assert_fail (assertion=0x55fb9884f972 "index->table->is_instant()", file=0x55fb9884dbf8 "/data/src/10.5/storage/innobase/btr/btr0cur.cc", line=4137, function=0x55fb98854f00 <btr_cur_upd_rec_in_place(unsigned char*, dict_index_t const*, unsigned short const*, upd_t const*, buf_block_t*, mtr_t*)::__PRETTY_FUNCTION__> "void btr_cur_upd_rec_in_place(rec_t*, const dict_index_t*, const rec_offs*, const upd_t*, buf_block_t*, mtr_t*)") at assert.c:101
#8  0x000055fb9813e5f3 in btr_cur_upd_rec_in_place (rec=0x7fc02c92409d "", index=0x7fc00005bca8, offsets=0x7fc038f54c60, update=0x7fc00005f2d0, block=0x7fc02c02aee0, mtr=0x7fc038f54ec0) at /data/src/10.5/storage/innobase/btr/btr0cur.cc:4137
#9  0x000055fb9813f933 in btr_cur_update_in_place (flags=2, cursor=0x7fc000062328, offsets=0x7fc038f54c60, update=0x7fc00005f2d0, cmpl_info=0, thr=0x7fc0000624c8, trx_id=50, mtr=0x7fc038f54ec0) at /data/src/10.5/storage/innobase/btr/btr0cur.cc:4317
#10 0x000055fb98141403 in btr_cur_optimistic_update (flags=2, cursor=0x7fc000062328, offsets=0x7fc038f54b70, heap=0x7fc038f54c10, update=0x7fc00005f2d0, cmpl_info=0, thr=0x7fc0000624c8, trx_id=50, mtr=0x7fc038f54ec0) at /data/src/10.5/storage/innobase/btr/btr0cur.cc:4561
#11 0x000055fb98076a22 in row_upd_clust_rec (flags=0, node=0x7fc00005f1a8, index=0x7fc00005bca8, offsets=0x7fc038f54c60, offsets_heap=0x7fc038f54c10, thr=0x7fc0000624c8, mtr=0x7fc038f54ec0) at /data/src/10.5/storage/innobase/row/row0upd.cc:2566
#12 0x000055fb98077cb9 in row_upd_clust_step (node=0x7fc00005f1a8, thr=0x7fc0000624c8) at /data/src/10.5/storage/innobase/row/row0upd.cc:2930
#13 0x000055fb98078039 in row_upd (node=0x7fc00005f1a8, thr=0x7fc0000624c8) at /data/src/10.5/storage/innobase/row/row0upd.cc:2995
#14 0x000055fb980785ff in row_upd_step (thr=0x7fc0000624c8) at /data/src/10.5/storage/innobase/row/row0upd.cc:3139
#15 0x000055fb980196f8 in row_update_for_mysql (prebuilt=0x7fc00005e6d8) at /data/src/10.5/storage/innobase/row/row0mysql.cc:1888
#16 0x000055fb97e63f05 in ha_innobase::update_row (this=0x7fc0000570b0, old_row=0x7fc00005a038 "\375", new_row=0x7fc00005a028 "\377") at /data/src/10.5/storage/innobase/handler/ha_innodb.cc:8504
#17 0x000055fb97a18405 in handler::ha_update_row (this=0x7fc0000570b0, old_data=0x7fc00005a038 "\375", new_data=0x7fc00005a028 "\377") at /data/src/10.5/sql/handler.cc:7037
#18 0x000055fb977d6dc1 in multi_update::send_data (this=0x7fc0000152d0, not_used_values=...) at /data/src/10.5/sql/sql_update.cc:2530
#19 0x000055fb9774b6b9 in select_result_sink::send_data_with_check (this=0x7fc0000152d0, items=..., u=0x7fc000004b30, sent=4) at /data/src/10.5/sql/sql_class.h:5279
#20 0x000055fb977325fa in end_send (join=0x7fc0000153a8, join_tab=0x7fc000018468, end_of_records=false) at /data/src/10.5/sql/sql_select.cc:21807
#21 0x000055fb9772fc8e in evaluate_join_record (join=0x7fc0000153a8, join_tab=0x7fc0000180c0, error=0) at /data/src/10.5/sql/sql_select.cc:20838
#22 0x000055fb9772f710 in sub_select (join=0x7fc0000153a8, join_tab=0x7fc0000180c0, end_of_records=false) at /data/src/10.5/sql/sql_select.cc:20654
#23 0x000055fb9772fc8e in evaluate_join_record (join=0x7fc0000153a8, join_tab=0x7fc000017d18, error=0) at /data/src/10.5/sql/sql_select.cc:20838
#24 0x000055fb9772f710 in sub_select (join=0x7fc0000153a8, join_tab=0x7fc000017d18, end_of_records=false) at /data/src/10.5/sql/sql_select.cc:20654
#25 0x000055fb9772e9ae in do_select (join=0x7fc0000153a8, procedure=0x0) at /data/src/10.5/sql/sql_select.cc:20149
#26 0x000055fb97702741 in JOIN::exec_inner (this=0x7fc0000153a8) at /data/src/10.5/sql/sql_select.cc:4464
#27 0x000055fb9770186d in JOIN::exec (this=0x7fc0000153a8) at /data/src/10.5/sql/sql_select.cc:4245
#28 0x000055fb97702f9e in mysql_select (thd=0x7fc000000b18, tables=0x7fc000013a48, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2200096997504, result=0x7fc0000152d0, unit=0x7fc000004b30, select_lex=0x7fc000005330) at /data/src/10.5/sql/sql_select.cc:4669
#29 0x000055fb977d4bef in mysql_multi_update (thd=0x7fc000000b18, table_list=0x7fc000013a48, fields=0x7fc000005480, values=0x7fc0000059f8, conds=0x0, options=0, handle_duplicates=DUP_ERROR, ignore=true, unit=0x7fc000004b30, select_lex=0x7fc000005330, result=0x7fc038f56050) at /data/src/10.5/sql/sql_update.cc:1929
#30 0x000055fb976b110a in mysql_execute_command (thd=0x7fc000000b18) at /data/src/10.5/sql/sql_parse.cc:4477
#31 0x000055fb976bcf89 in mysql_parse (thd=0x7fc000000b18, rawbuf=0x7fc000013950 "UPDATE IGNORE t1 JOIN t2 SET f = a", length=34, parser_state=0x7fc038f56520, is_com_multi=false, is_next_command=false) at /data/src/10.5/sql/sql_parse.cc:7991
#32 0x000055fb976a9335 in dispatch_command (command=COM_QUERY, thd=0x7fc000000b18, packet=0x7fc000171499 "UPDATE IGNORE t1 JOIN t2 SET f = a", packet_length=34, is_com_multi=false, is_next_command=false) at /data/src/10.5/sql/sql_parse.cc:1875
#33 0x000055fb976a7a6d in do_command (thd=0x7fc000000b18) at /data/src/10.5/sql/sql_parse.cc:1356
#34 0x000055fb9784b531 in do_handle_one_connection (connect=0x55fb9adaac78, put_in_cache=true) at /data/src/10.5/sql/sql_connect.cc:1411
#35 0x000055fb9784b299 in handle_one_connection (arg=0x55fb9adaac78) at /data/src/10.5/sql/sql_connect.cc:1313
#36 0x000055fb97d81da2 in pfs_spawn_thread (arg=0x55fb9adaa8a8) at /data/src/10.5/storage/perfschema/pfs.cc:2201
#37 0x00007fc048f604a4 in start_thread (arg=0x7fc038f57700) at pthread_create.c:456
#38 0x00007fc047094d0f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:97

Corruption errors are reproducible on debug and release alike.
InnoDB failure seems to only affect debug builds.



 Comments   
Comment by Elena Stepanova [ 2020-05-26 ]

Possibly the test case can be modified not to use WITHOUT OVERLAPS, but I didn't succeed at it.

Comment by Roel Van de Paar [ 2020-09-09 ]

I am seeing the same assert, same btr area, on a different testcase. I cannot get the testcase to repeat at the command prompt, however I have been able to reduce is using the C-API/pquery to the following;

# mysqld options that were in use during reduction: --sql_mode=ONLY_FULL_GROUP_BY --performance-schema --performance-schema-instrument='%=on' --default-tmp-storage-engine=MyISAM --innodb_file_per_table=1 --innodb_flush_method=O_DIRECT
USE test;
CREATE TABLE t1(a BIGINT UNSIGNED) ENGINE=InnoDB;
set global innodb_limit_optimistic_insert_debug = 2;
INSERT INTO t1 VALUES(12979);
ALTER TABLE t1 algorithm=inplace, ADD f DECIMAL(5,2);
insert into t1 values (5175,'abcdefghijklmnopqrstuvwxyz');
DELETE FROM t1;
SELECT HEX(a), HEX(@a:=CONVERT(a USING utf8mb4)), HEX(CONVERT(@a USING utf16le)) FROM t1; ;

10.4.15 eae968f62d285de97ed607c87bc131cd863d5d03

mysqld: /test/10.4_dbg/storage/innobase/btr/btr0pcur.cc:154: void btr_pcur_store_position(btr_pcur_t*, mtr_t*): Assertion `index->table->instant' failed.

10.4.15 eae968f62d285de97ed607c87bc131cd863d5d03

Core was generated by `/test/MD110820-mariadb-10.4.15-linux-x86_64-dbg/bin/mysqld --no-defaults --max_'.
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 0x14d82c06d700 (LWP 1089182))]
(gdb) bt
#0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=6) at ../sysdeps/unix/sysv/linux/pthread_kill.c:57
#1  0x000055943ec758a6 in my_write_core (sig=sig@entry=6) at /test/10.4_dbg/mysys/stacktrace.c:482
#2  0x000055943e3f1cdc in handle_fatal_signal (sig=6) at /test/10.4_dbg/sql/signal_handler.cc:343
#3  <signal handler called>
#4  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#5  0x000014d834a778b1 in __GI_abort () at abort.c:79
#6  0x000014d834a6742a in __assert_fail_base (fmt=0x14d834beea38 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x55943ef93086 "index->table->instant", file=file@entry=0x55943efe8838 "/test/10.4_dbg/storage/innobase/btr/btr0pcur.cc", line=line@entry=154, function=function@entry=0x55943efe9e00 <btr_pcur_store_position(btr_pcur_t*, mtr_t*)::__PRETTY_FUNCTION__> "void btr_pcur_store_position(btr_pcur_t*, mtr_t*)") at assert.c:92
#7  0x000014d834a674a2 in __GI___assert_fail (assertion=assertion@entry=0x55943ef93086 "index->table->instant", file=file@entry=0x55943efe8838 "/test/10.4_dbg/storage/innobase/btr/btr0pcur.cc", line=line@entry=154, function=function@entry=0x55943efe9e00 <btr_pcur_store_position(btr_pcur_t*, mtr_t*)::__PRETTY_FUNCTION__> "void btr_pcur_store_position(btr_pcur_t*, mtr_t*)") at assert.c:101
#8  0x000055943e8d646f in btr_pcur_store_position (cursor=cursor@entry=0x14d7c43ae988, mtr=mtr@entry=0x14d82c069430) at /test/10.4_dbg/storage/innobase/btr/btr0pcur.cc:154
#9  0x000055943e7eccf3 in row_search_mvcc (buf=buf@entry=0x14d7c4433650 "\377", mode=mode@entry=PAGE_CUR_G, prebuilt=0x14d7c43ae7c0, match_mode=match_mode@entry=0, direction=direction@entry=0) at /test/10.4_dbg/storage/innobase/row/row0sel.cc:5632
#10 0x000055943e6304f4 in ha_innobase::index_read (this=this@entry=0x14d7c4432358, buf=buf@entry=0x14d7c4433650 "\377", key_ptr=key_ptr@entry=0x0, key_len=key_len@entry=0, find_flag=find_flag@entry=HA_READ_AFTER_KEY) at /test/10.4_dbg/storage/innobase/handler/ha_innodb.cc:9214
#11 0x000055943e630772 in ha_innobase::index_first (this=this@entry=0x14d7c4432358, buf=buf@entry=0x14d7c4433650 "\377") at /test/10.4_dbg/storage/innobase/handler/ha_innodb.cc:9588
#12 0x000055943e6307f3 in ha_innobase::rnd_next (this=0x14d7c4432358, buf=0x14d7c4433650 "\377") at /test/10.4_dbg/storage/innobase/handler/ha_innodb.cc:9681
#13 0x000055943e3f95d7 in handler::ha_rnd_next (this=0x14d7c4432358, buf=0x14d7c4433650 "\377") at /test/10.4_dbg/sql/handler.cc:2862
#14 0x000055943e58f634 in rr_sequential (info=0x14d7c4015768) at /test/10.4_dbg/sql/records.cc:485
#15 0x000055943e19f94a in READ_RECORD::read_record (this=0x14d7c4015768) at /test/10.4_dbg/sql/records.h:70
#16 join_init_read_record (tab=0x14d7c40156a0) at /test/10.4_dbg/sql/sql_select.cc:21342
#17 0x000055943e189eeb in sub_select (join=0x14d7c40142c0, join_tab=0x14d7c40156a0, end_of_records=<optimized out>) at /test/10.4_dbg/sql/sql_select.cc:20397
#18 0x000055943e1bba70 in do_select (procedure=0x0, join=0x14d7c40142c0) at /test/10.4_dbg/sql/sql_select.cc:19938
#19 JOIN::exec_inner (this=this@entry=0x14d7c40142c0) at /test/10.4_dbg/sql/sql_select.cc:4473
#20 0x000055943e1bc04d in JOIN::exec (this=this@entry=0x14d7c40142c0) at /test/10.4_dbg/sql/sql_select.cc:4255
#21 0x000055943e1ba3f3 in mysql_select (thd=thd@entry=0x14d7c4000d50, tables=<optimized out>, wild_num=0, fields=@0x14d7c4012398: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x14d7c4012908, last = 0x14d7c4013240, elements = 3}, <No data fields>}, conds=0x0, og_num=<optimized out>, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2148803328, result=0x14d7c4014298, unit=0x14d7c4004c78, select_lex=0x14d7c4012250) at /test/10.4_dbg/sql/sql_select.cc:4687
#22 0x000055943e1ba71e in handle_select (thd=thd@entry=0x14d7c4000d50, lex=lex@entry=0x14d7c4004bb8, result=result@entry=0x14d7c4014298, setup_tables_done_option=setup_tables_done_option@entry=0) at /test/10.4_dbg/sql/sql_select.cc:410
#23 0x000055943e1333c6 in execute_sqlcom_select (thd=thd@entry=0x14d7c4000d50, all_tables=0x14d7c40132e8) at /test/10.4_dbg/sql/sql_parse.cc:6355
#24 0x000055943e13e79a in mysql_execute_command (thd=thd@entry=0x14d7c4000d50) at /test/10.4_dbg/sql/sql_parse.cc:3889
#25 0x000055943e149090 in mysql_parse (thd=thd@entry=0x14d7c4000d50, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x14d82c06c470, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.4_dbg/sql/sql_parse.cc:7896
#26 0x000055943e14b920 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x14d7c4000d50, packet=packet@entry=0x14d7c401a4b1 "", packet_length=packet_length@entry=90, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.4_dbg/sql/sql_parse.cc:1834
#27 0x000055943e14f35b in do_command (thd=0x14d7c4000d50) at /test/10.4_dbg/sql/sql_parse.cc:1352
#28 0x000055943e27b8b6 in do_handle_one_connection (connect=connect@entry=0x55944187a4f0) at /test/10.4_dbg/sql/sql_connect.cc:1412
#29 0x000055943e27b9d6 in handle_one_connection (arg=arg@entry=0x55944187a4f0) at /test/10.4_dbg/sql/sql_connect.cc:1316
#30 0x000055943eb88898 in pfs_spawn_thread (arg=0x5594417874f0) at /test/10.4_dbg/storage/perfschema/pfs.cc:1869
#31 0x000014d8359de6db in start_thread (arg=0x14d82c06d700) at pthread_create.c:463
#32 0x000014d834b58a3f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

This in turn may be connected to the other `innodb_limit_optimistic_insert_debug` bugs out there.

Comment by Roel Van de Paar [ 2020-09-09 ]

marko Perhaps the latter is an altogether different bug afterall?

Comment by Nikita Malyavin [ 2020-09-14 ]

WITHOUT OVERLAPS is present since 10.5

Comment by Nikita Malyavin [ 2020-09-23 ]

Roel The bug you experienced is most likely a different one, so better report it separately for innodb team

Comment by Roel Van de Paar [ 2020-09-24 ]

nikitamalyavin Thank you. Split that last one to MDEV-23801. Thanks

Comment by Oleksandr Byelkin [ 2020-10-12 ]

1) fix version shoud be fixed
2) saving/restoring of state should be moved around disturbing ha_index_read to keep current protocol intact.

Comment by Oleksandr Byelkin [ 2020-10-23 ]

the last version OK to push

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