[MDEV-30597] Assertion `flag == 1' failed in row_build_index_entry_low Created: 2023-02-07  Updated: 2023-03-13  Resolved: 2023-02-14

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - InnoDB, 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.11.2, 10.4.29, 10.5.20, 10.6.13, 10.8.8, 10.9.6, 10.10.4

Type: Bug Priority: Major
Reporter: Matthias Leich Assignee: Thirunarayanan Balathandayuthapani
Resolution: Fixed Votes: 1
Labels: None


 Description   

origin/bb-10.6-release 6d3e8a1cbdd18e63b0bec27b7986d261ca5af37b 2023-02-02T18:19:36+02:00
 
CREATE TABLE t1 (
col1 INT PRIMARY KEY,
col_text TEXT,
col_text_g TEXT GENERATED ALWAYS AS (SUBSTR(col_text,1,499))
) ENGINE = InnoDB ROW_FORMAT = Compact;
INSERT INTO t1 (col1) VALUES (1) ;
DELETE FROM t1 WHERE col1 = 1;
ALTER TABLE t1 ADD UNIQUE INDEX (col_text_g(9));
BEGIN;
INSERT INTO t1 (col1) VALUES (1);
ROLLBACK;
harvests
mariadbd: /data/Server/bb-10.6-releaseC/storage/innobase/row/row0row.cc:274: dtuple_t* row_build_index_entry_low(const dtuple_t*, const row_ext_t*, const dict_index_t*, mem_heap_t*, ulint): Assertion `flag == 1' failed.
(rr) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007f20cd540859 in __GI_abort () at abort.c:79
#2  0x00007f20cd540729 in __assert_fail_base (fmt=0x7f20cd6d6588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x561c9acc7aa0 "flag == 1", 
    file=0x561c9acc8348 "/data/Server/bb-10.6-releaseC/storage/innobase/row/row0row.cc", line=274, function=<optimized out>) at assert.c:92
#3  0x00007f20cd551f36 in __GI___assert_fail (assertion=assertion@entry=0x561c9acc7aa0 "flag == 1", file=file@entry=0x561c9acc8348 "/data/Server/bb-10.6-releaseC/storage/innobase/row/row0row.cc", 
    line=line@entry=274, function=function@entry=0x561c9acc7860 "dtuple_t* row_build_index_entry_low(const dtuple_t*, const row_ext_t*, const dict_index_t*, mem_heap_t*, ulint)") at assert.c:101
#4  0x0000561c99d2a6a0 in row_build_index_entry_low (row=row@entry=0x6190000bb108, ext=ext@entry=0x0, index=index@entry=0x616000961008, heap=heap@entry=0x6190000bae80, flag=flag@entry=0)
    at /data/Server/bb-10.6-releaseC/storage/innobase/row/row0row.cc:274
#5  0x0000561c99da9dd3 in row_build_index_entry (heap=0x6190000bae80, index=0x616000961008, ext=0x0, row=0x6190000bb108) at /data/Server/bb-10.6-releaseC/storage/innobase/include/row0row.inl:126
#6  row_vers_old_has_index_entry (also_curr=also_curr@entry=false, rec=<optimized out>, mtr=mtr@entry=0x7f20c1e960c0, index=index@entry=0x616000961008, ientry=ientry@entry=0x6190000b9b08, 
    roll_ptr=roll_ptr@entry=0, trx_id=<optimized out>) at /data/Server/bb-10.6-releaseC/storage/innobase/row/row0vers.cc:1087
#7  0x0000561c9a248df7 in row_undo_mod_del_mark_or_remove_sec_low (node=node@entry=0x61a000056b08, thr=thr@entry=0x6160009742c0, index=index@entry=0x616000961008, entry=entry@entry=0x6190000b9b08, 
    mode=<optimized out>, mode@entry=BTR_MODIFY_LEAF) at /data/Server/bb-10.6-releaseC/storage/innobase/include/btr0pcur.h:413
#8  0x0000561c9a2499f9 in row_undo_mod_del_mark_or_remove_sec (node=node@entry=0x61a000056b08, thr=thr@entry=0x6160009742c0, index=index@entry=0x616000961008, entry=entry@entry=0x6190000b9b08)
    at /data/Server/bb-10.6-releaseC/storage/innobase/row/row0umod.cc:631
#9  0x0000561c9a24afc0 in row_undo_mod_upd_del_sec (node=node@entry=0x61a000056b08, thr=thr@entry=0x6160009742c0) at /data/Server/bb-10.6-releaseC/storage/innobase/row/row0umod.cc:875
#10 0x0000561c9a24bf84 in row_undo_mod (node=node@entry=0x61a000056b08, thr=thr@entry=0x6160009742c0) at /data/Server/bb-10.6-releaseC/storage/innobase/row/row0umod.cc:1241
#11 0x0000561c99d6c0f7 in row_undo (node=node@entry=0x61a000056b08, thr=thr@entry=0x6160009742c0) at /data/Server/bb-10.6-releaseC/storage/innobase/row/row0undo.cc:405
#12 0x0000561c99d7137e in row_undo_step (thr=thr@entry=0x6160009742c0) at /data/Server/bb-10.6-releaseC/storage/innobase/row/row0undo.cc:452
#13 0x0000561c99bd19cd in que_thr_step (thr=0x6160009742c0) at /data/Server/bb-10.6-releaseC/storage/innobase/que/que0que.cc:595
#14 que_run_threads_low (thr=thr@entry=0x6160009742c0) at /data/Server/bb-10.6-releaseC/storage/innobase/que/que0que.cc:653
#15 0x0000561c99bd1d4b in que_run_threads (thr=0x6160009742c0) at /data/Server/bb-10.6-releaseC/storage/innobase/que/que0que.cc:673
#16 0x0000561c99e31837 in trx_t::rollback_low (this=this@entry=0x7f20c9831340, savept=savept@entry=0x0) at /data/Server/bb-10.6-releaseC/storage/innobase/trx/trx0roll.cc:125
#17 0x0000561c99e2bf3b in trx_rollback_for_mysql_low (trx=trx@entry=0x7f20c9831340) at /data/Server/bb-10.6-releaseC/storage/innobase/trx/trx0roll.cc:196
#18 0x0000561c99e2c4f5 in trx_rollback_for_mysql (trx=trx@entry=0x7f20c9831340) at /data/Server/bb-10.6-releaseC/storage/innobase/trx/trx0roll.cc:231
#19 0x0000561c998b27bf in innobase_rollback (hton=<optimized out>, thd=0x62b0000af218, rollback_trx=<optimized out>) at /data/Server/bb-10.6-releaseC/storage/innobase/handler/ha_innodb.cc:4696
#20 0x0000561c98ef5233 in ha_rollback_trans (thd=thd@entry=0x62b0000af218, all=all@entry=true) at /data/Server/bb-10.6-releaseC/sql/handler.cc:2199
#21 0x0000561c98aed479 in trans_rollback (thd=thd@entry=0x62b0000af218) at /data/Server/bb-10.6-releaseC/sql/transaction.cc:372
#22 0x0000561c98688cfe in mysql_execute_command (thd=thd@entry=0x62b0000af218, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /data/Server/bb-10.6-releaseC/sql/sql_parse.cc:5662
#23 0x0000561c98641720 in mysql_parse (thd=thd@entry=0x62b0000af218, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x7f20c1e98130)
    at /data/Server/bb-10.6-releaseC/sql/sql_parse.cc:8021
#24 0x0000561c986700bf in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x62b0000af218, packet=packet@entry=0x629000258219 "ROLLBACK", packet_length=packet_length@entry=8, 
    blocking=blocking@entry=true) at /data/Server/bb-10.6-releaseC/sql/sql_class.h:1385
#25 0x0000561c98676da6 in do_command (thd=0x62b0000af218, blocking=blocking@entry=true) at /data/Server/bb-10.6-releaseC/sql/sql_parse.cc:1409
#26 0x0000561c98aae281 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x608000002338, put_in_cache=put_in_cache@entry=true) at /data/Server/bb-10.6-releaseC/sql/sql_connect.cc:1416
#27 0x0000561c98aaedca in handle_one_connection (arg=0x608000002338) at /data/Server/bb-10.6-releaseC/sql/sql_connect.cc:1318
#28 0x00007f20cda68609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#29 0x00007f20cd63d293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
(rr)



 Comments   
Comment by Marko Mäkelä [ 2023-02-10 ]

The fix looks reasonable to me, but I would like to see a deterministic test case for this bug. I think that we need something like this right after the CREATE TABLE:

connect stop_purge,localhost,root;
START TRANSACTION WITH CONSISTENT SNAPSHOT;
connection default;

And right before the ROLLBACK:

disconnect stop_purge;

Comment by Roel Van de Paar [ 2023-03-11 ]

I also ran into this assert. Sporadic. These are 10.6+ only. Two testcases:

CREATE TABLE t (c INT,c2 CHAR(1),c3 DECIMAL(0,0) GENERATED ALWAYS AS (c + 1) VIRTUAL,PRIMARY KEY(c)) ENGINE=InnoDB;
INSERT INTO t (c,c2) VALUES (0,0);
UPDATE t SET c=c - 2;
UPDATE t SET c=c + 1;
ALTER TABLE t ADD INDEX c3 (c3);
INSERT INTO t (c) VALUES (2),(3),(4);
UPDATE t SET c=c * 2;

And

CREATE TABLE t (c INT,c2 CHAR(1),c3 INT GENERATED ALWAYS AS (c + 1) VIRTUAL,PRIMARY KEY(c)) ENGINE=InnoDB;
INSERT INTO t (c,c2) VALUES (0,0);
UPDATE t SET c=c - 2;
UPDATE t SET c=c + 1;
ALTER TABLE t ADD INDEX c3 (c3);
INSERT INTO t (c) VALUES (0),(0),(0);

11.0.1 f2dc4d4c10ac36a73b5c1eb765352d3aee808d66 (Debug)

mariadbd: /test/11.0_dbg/storage/innobase/row/row0row.cc:266: dtuple_t* row_build_index_entry_low(const dtuple_t*, const row_ext_t*, const dict_index_t*, mem_heap_t*, ulint): Assertion `flag == 1' failed.

11.0.1 f2dc4d4c10ac36a73b5c1eb765352d3aee808d66 (Debug)

Core was generated by `/test/MD180223-mariadb-11.0.1-linux-x86_64-dbg/bin/mariadbd --no-defaults --cor'.
Program terminated with signal SIGABRT, Aborted.
#0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=22555253159488)
    at ./nptl/pthread_kill.c:44
[Current thread is 1 (Thread 0x14838dda3640 (LWP 1107309))]
(gdb) bt
#0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=22555253159488) at ./nptl/pthread_kill.c:44
#1  __pthread_kill_internal (signo=6, threadid=22555253159488) at ./nptl/pthread_kill.c:78
#2  __GI___pthread_kill (threadid=22555253159488, signo=signo@entry=6) at ./nptl/pthread_kill.c:89
#3  0x00001483c8c7d476 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#4  0x00001483c8c637f3 in __GI_abort () at ./stdlib/abort.c:79
#5  0x00001483c8c6371b in __assert_fail_base (fmt=0x1483c8e18150 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x5629d5f4f25c "flag == 1", file=0x5629d5f4f2b8 "/test/11.0_dbg/storage/innobase/row/row0row.cc", line=266, function=<optimized out>) at ./assert/assert.c:92
#6  0x00001483c8c74e96 in __GI___assert_fail (assertion=0x5629d5f4f25c "flag == 1", file=0x5629d5f4f2b8 "/test/11.0_dbg/storage/innobase/row/row0row.cc", line=266, function=0x5629d5f4fe40 "dtuple_t* row_build_index_entry_low(const dtuple_t*, const row_ext_t*, const dict_index_t*, mem_heap_t*, ulint)") at ./assert/assert.c:101
#7  0x00005629d5920555 in row_build_index_entry_low (row=row@entry=0x14831c027d18, ext=ext@entry=0x0, index=index@entry=0x14831c073440, heap=heap@entry=0x14831c027ad0, flag=flag@entry=0) at /test/11.0_dbg/storage/innobase/row/row0row.cc:266
#8  0x00005629d59501e6 in row_build_index_entry (heap=0x14831c027ad0, index=0x14831c073440, ext=0x0, row=0x14831c027d18) at /test/11.0_dbg/storage/innobase/include/row0row.inl:126
#9  row_vers_old_has_index_entry (also_curr=also_curr@entry=false, rec=<optimized out>, mtr=mtr@entry=0x14838dda0fa0, index=index@entry=0x14831c073440, ientry=ientry@entry=0x14831c0276c0, roll_ptr=roll_ptr@entry=0, trx_id=0) at /test/11.0_dbg/storage/innobase/row/row0vers.cc:1102
#10 0x00005629d5ae4fc2 in row_undo_mod_del_mark_or_remove_sec_low (node=node@entry=0x14831c027130, thr=thr@entry=0x14831c074010, index=index@entry=0x14831c073440, entry=entry@entry=0x14831c0276c0, mode=<optimized out>, mode@entry=BTR_MODIFY_LEAF) at /test/11.0_dbg/storage/innobase/include/btr0pcur.h:413
#11 0x00005629d5ae5609 in row_undo_mod_del_mark_or_remove_sec (node=node@entry=0x14831c027130, thr=thr@entry=0x14831c074010, index=index@entry=0x14831c073440, entry=entry@entry=0x14831c0276c0) at /test/11.0_dbg/storage/innobase/row/row0umod.cc:619
#12 0x00005629d5ae6bc1 in row_undo_mod_upd_del_sec (thr=0x14831c074010, node=0x14831c027130) at /test/11.0_dbg/storage/innobase/row/row0umod.cc:850
#13 row_undo_mod (node=node@entry=0x14831c027130, thr=thr@entry=0x14831c074010) at /test/11.0_dbg/storage/innobase/row/row0umod.cc:1216
#14 0x00005629d593a789 in row_undo (thr=0x14831c074010, node=0x14831c027130) at /test/11.0_dbg/storage/innobase/row/row0undo.cc:405
#15 row_undo_step (thr=thr@entry=0x14831c074010) at /test/11.0_dbg/storage/innobase/row/row0undo.cc:452
#16 0x00005629d5896ffa in que_thr_step (thr=0x14831c074010) at /test/11.0_dbg/storage/innobase/que/que0que.cc:595
#17 que_run_threads_low (thr=0x14831c074010) at /test/11.0_dbg/storage/innobase/que/que0que.cc:653
#18 que_run_threads (thr=0x14831c074010) at /test/11.0_dbg/storage/innobase/que/que0que.cc:673
#19 0x00005629d597bd50 in trx_t::rollback_low (this=this@entry=0x1483c03fdb80, savept=savept@entry=0x0) at /test/11.0_dbg/storage/innobase/trx/trx0roll.cc:124
#20 0x00005629d5979c7e in trx_rollback_for_mysql_low (trx=0x1483c03fdb80) at /test/11.0_dbg/storage/innobase/trx/trx0roll.cc:195
#21 trx_rollback_for_mysql (trx=trx@entry=0x1483c03fdb80) at /test/11.0_dbg/storage/innobase/trx/trx0roll.cc:230
#22 0x00005629d579d314 in innobase_rollback (hton=<optimized out>, thd=0x14831c000d58, rollback_trx=<optimized out>) at /test/11.0_dbg/storage/innobase/handler/ha_innodb.cc:4579
#23 0x00005629d54cc5fd in ha_rollback_trans (thd=thd@entry=0x14831c000d58, all=all@entry=false) at /test/11.0_dbg/sql/handler.cc:2237
#24 0x00005629d536ba61 in trans_rollback_stmt (thd=thd@entry=0x14831c000d58) at /test/11.0_dbg/sql/transaction.cc:535
#25 0x00005629d5201482 in mysql_execute_command (thd=thd@entry=0x14831c000d58, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /test/11.0_dbg/sql/sql_parse.cc:6056
#26 0x00005629d52027cf in mysql_parse (thd=thd@entry=0x14831c000d58, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x14838dda22c0) at /test/11.0_dbg/sql/sql_parse.cc:8002
#27 0x00005629d5204963 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x14831c000d58, packet=packet@entry=0x14831c00ae19 "UPDATE t SET c=c * 2", packet_length=packet_length@entry=20, blocking=blocking@entry=true) at /test/11.0_dbg/sql/sql_class.h:242
#28 0x00005629d52067bc in do_command (thd=0x14831c000d58, blocking=blocking@entry=true) at /test/11.0_dbg/sql/sql_parse.cc:1407
#29 0x00005629d53576e2 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x5629d7b48fe8, put_in_cache=put_in_cache@entry=true) at /test/11.0_dbg/sql/sql_connect.cc:1416
#30 0x00005629d5357941 in handle_one_connection (arg=0x5629d7b48fe8) at /test/11.0_dbg/sql/sql_connect.cc:1318
#31 0x00001483c8ccfb43 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
#32 0x00001483c8d61a00 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81

Bug confirmed present in:
MariaDB: 10.6.13 (dbg), 10.7.8 (dbg), 10.8.8 (dbg), 10.9.6 (dbg), 10.10.4 (dbg), 10.11.2 (dbg), 11.0.1 (dbg)

Comment by Thirunarayanan Balathandayuthapani [ 2023-03-13 ]

Roel Thanks for noticing the issue. still 10.6+ doesn't have the patch of MDEV-30597. So it is expected to fail there.
But I cherry-picked the patch in 10.6 and verified both the cases. Both're fixed by the patch.

Comment by Roel Van de Paar [ 2023-03-13 ]

thiru Yes. Thank you for confirming both are fixed by the patch.

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