Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-29992

Index corruption with multi-part key and nopad collation

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • 10.5, 10.6, 10.11, 11.1(EOL), 11.2, 11.4, 10.4(EOL), 10.8(EOL), 10.9(EOL), 10.10(EOL), 11.0(EOL), 11.3(EOL)
    • 10.5, 10.6, 10.11, 11.2, 11.4
    • Server
    • None

    Description

      --source include/have_innodb.inc
       
      CREATE TABLE t (id INT PRIMARY KEY, b VARCHAR(8), c CHAR(4), UNIQUE(b DESC,c)) COLLATE utf8_nopad_bin;
      INSERT INTO t VALUES (1,UNHEX('00010203'),'a'),(2,'','b'),(3,UNHEX('00020201'),'c');
      REPLACE INTO t SELECT id, b, c FROM t;
       
      # Cleanup
      DROP TABLE t;
      

      With MyISAM for the table engine:

      10.8 d6d8a499

      query 'REPLACE INTO t SELECT id, b, c FROM t' failed: HA_ERR_CRASHED (126): Index for table './test/t.MYI' is corrupt; try to repair it
      

      With Aria:

      query 'REPLACE INTO t SELECT id, b, c FROM t' failed: HA_ERR_CRASHED (126): Got error '126 "Index is corrupted"' for './test/t.MAI'
      

      With InnoDB:

      2022-11-09 21:23:43 4 [ERROR] InnoDB: Record in index `b` of table `test`.`t` was not found on update: TUPLE (info_bits=0, 3 fields): {[0](0x),[4]b   (0x62202020),[4]    (0x80000002)} at: COMPACT RECORD(info_bits=0, 1 fields): {[8]infimum (0x696E66696D756D00)}
      mariadbd: /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/storage/innobase/row/row0upd.cc:1930: dberr_t row_upd_sec_index_entry(upd_node_t*, que_thr_t*): Assertion `0' failed.
      221109 21:23:43 [ERROR] mysqld got signal 6 ;
       
      #7  0x00007f43e9aee662 in __GI___assert_fail (assertion=0x55e26c78d1e0 "0", file=0x55e26c794700 "/home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/storage/innobase/row/row0upd.cc", line=1930, function=0x55e26c796340 "dberr_t row_upd_sec_index_entry(upd_node_t*, que_thr_t*)") at assert.c:101
      #8  0x000055e26b27066d in row_upd_sec_index_entry (node=0x620000014c38, thr=0x6240000f01a0) at /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/storage/innobase/row/row0upd.cc:1930
      #9  0x000055e26b271632 in row_upd_sec_step (node=0x620000014c38, thr=0x6240000f01a0) at /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/storage/innobase/row/row0upd.cc:2055
      #10 0x000055e26b27671b in row_upd (node=0x620000014c38, thr=0x6240000f01a0) at /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/storage/innobase/row/row0upd.cc:2779
      #11 0x000055e26b277200 in row_upd_step (thr=0x6240000f01a0) at /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/storage/innobase/row/row0upd.cc:2894
      #12 0x000055e26b1cca32 in row_update_for_mysql (prebuilt=0x620000014120) at /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/storage/innobase/row/row0mysql.cc:1690
      #13 0x000055e26ae1f357 in ha_innobase::delete_row (this=0x61d0002d5ab8, record=0x6190000ee7f8 "\274\002") at /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/storage/innobase/handler/ha_innodb.cc:8707
      #14 0x000055e26a4b6727 in handler::ha_delete_row (this=0x61d0002d5ab8, buf=0x6190000ee7f8 "\274\002") at /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/sql/handler.cc:7698
      #15 0x000055e269b20f6d in write_record (thd=0x62b00017a218, table=0x6190000ee298, info=0x62900010b388, sink=0x0) at /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/sql/sql_insert.cc:2141
      #16 0x000055e269b32444 in select_insert::send_data (this=0x62900010b338, values=...) at /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/sql/sql_insert.cc:4170
      #17 0x000055e269db34fd in select_result_sink::send_data_with_check (this=0x62900010b338, items=..., u=0x62b00017e630, sent=2) at /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/sql/sql_class.h:5689
      #18 0x000055e269d6f5c1 in end_send (join=0x62900010b400, join_tab=0x6290002da998, end_of_records=false) at /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/sql/sql_select.cc:22574
      #19 0x000055e269d67763 in evaluate_join_record (join=0x62900010b400, join_tab=0x6290002da5e8, error=0) at /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/sql/sql_select.cc:21568
      #20 0x000055e269da4e2f in AGGR_OP::end_send (this=0x62900010ce00) at /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/sql/sql_select.cc:29799
      #21 0x000055e269d64e71 in sub_select_postjoin_aggr (join=0x62900010b400, join_tab=0x6290002da5e8, end_of_records=true) at /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/sql/sql_select.cc:21046
      #22 0x000055e269d657c5 in sub_select (join=0x62900010b400, join_tab=0x6290002da238, end_of_records=true) at /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/sql/sql_select.cc:21281
      #23 0x000055e269d6418a in do_select (join=0x62900010b400, procedure=0x0) at /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/sql/sql_select.cc:20883
      #24 0x000055e269cf1367 in JOIN::exec_inner (this=0x62900010b400) at /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/sql/sql_select.cc:4791
      #25 0x000055e269cee87b in JOIN::exec (this=0x62900010b400) at /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/sql/sql_select.cc:4569
      #26 0x000055e269cf2c9c in mysql_select (thd=0x62b00017a218, tables=0x62900010a328, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2202244745984, result=0x62900010b338, unit=0x62b00017e630, select_lex=0x629000109a78) at /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/sql/sql_select.cc:5049
      #27 0x000055e269cc325b in handle_select (thd=0x62b00017a218, lex=0x62b00017e558, result=0x62900010b338, setup_tables_done_option=1073741824) at /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/sql/sql_select.cc:552
      #28 0x000055e269be2055 in mysql_execute_command (thd=0x62b00017a218, is_called_from_prepared_stmt=false) at /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/sql/sql_parse.cc:4709
      #29 0x000055e269bf8b05 in mysql_parse (thd=0x62b00017a218, rawbuf=0x629000109238 "REPLACE INTO t SELECT id, b, c FROM t", length=37, parser_state=0x7f43da699990) at /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/sql/sql_parse.cc:8014
      #30 0x000055e269bcf4ab in dispatch_command (command=COM_QUERY, thd=0x62b00017a218, packet=0x62900028f219 "REPLACE INTO t SELECT id, b, c FROM t", packet_length=37, blocking=true) at /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/sql/sql_parse.cc:1894
      #31 0x000055e269bcc27e in do_command (thd=0x62b00017a218, blocking=true) at /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/sql/sql_parse.cc:1407
      #32 0x000055e26a0656f6 in do_handle_one_connection (connect=0x6080000032b8, put_in_cache=true) at /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/sql/sql_connect.cc:1416
      #33 0x000055e26a06508c in handle_one_connection (arg=0x608000003238) at /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/sql/sql_connect.cc:1318
      #34 0x000055e26ac2ffdc in pfs_spawn_thread (arg=0x617000007418) at /home/jenkins/workspace/sandbox-elenst/Nightly-Build-CS/src/storage/perfschema/pfs.cc:2201
      #35 0x00007f43e9fccea7 in start_thread (arg=<optimized out>) at pthread_create.c:477
      #36 0x00007f43e9bb9aef in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
      

      The test case above uses DESC key, so it's only applicable to 10.8+ after MDEV-26938.
      Here is another test case (originally from MDEV-33231) which reproduces at least the InnoDB failure on all existing versions. Given the similarities with the test case above, I assume it's the same issue.

      --source include/have_innodb.inc
       
      CREATE TABLE t (a INT, b VARCHAR(16) NOT NULL, KEY(b(8),a)) ENGINE=InnoDB COLLATE utf8_nopad_bin;
      INSERT INTO t (b,a) VALUES
        (UNHEX('222C'),1),(UNHEX('0001'),8),(UNHEX('3030'),3),
        (UNHEX('2F63'),3),(UNHEX('0010'),4),(UNHEX('5552'),9);
      UPDATE IGNORE t SET b = NULL;
       
      # Cleanup
      DROP TABLE t;
      

      10.4 c9b0c006e0491c9f7a1dae07090db3cdb87da446

      2024-03-03 15:20:05 9 [ERROR] InnoDB: Record in index `b` of table `test`.`t` was not found on update: TUPLE (info_bits=0, 3 fields): {[2]  (0x0010),[4]    (0x80000004),[6]      (0x000000000204)} at: COMPACT RECORD(info_bits=0, 3 fields): {[0](0x),[4]    (0x80000003),[6]      (0x000000000203)}
      mysqld: /data/bld/10.4-asan/storage/innobase/row/row0upd.cc:2455: dberr_t row_upd_sec_index_entry(upd_node_t*, que_thr_t*): Assertion `0' failed.
      240303 15:20:05 [ERROR] mysqld got signal 6 ;
       
      #9  0x00007f3f8b853e32 in __GI___assert_fail (assertion=0x5653f570cb00 "0", file=0x5653f57137c0 "/data/bld/10.4-asan/storage/innobase/row/row0upd.cc", line=2455, function=0x5653f57157e0 "dberr_t row_upd_sec_index_entry(upd_node_t*, que_thr_t*)") at ./assert/assert.c:101
      #10 0x00005653f44b39f0 in row_upd_sec_index_entry (node=0x62000003dc40, thr=0x6240001c2188) at /data/bld/10.4-asan/storage/innobase/row/row0upd.cc:2455
      #11 0x00005653f44b49c7 in row_upd_sec_step (node=0x62000003dc40, thr=0x6240001c2188) at /data/bld/10.4-asan/storage/innobase/row/row0upd.cc:2598
      #12 0x00005653f44ba12c in row_upd (node=0x62000003dc40, thr=0x6240001c2188) at /data/bld/10.4-asan/storage/innobase/row/row0upd.cc:3384
      #13 0x00005653f44bac5b in row_upd_step (thr=0x6240001c2188) at /data/bld/10.4-asan/storage/innobase/row/row0upd.cc:3499
      #14 0x00005653f43f9f55 in row_update_for_mysql (prebuilt=0x62000003d108) at /data/bld/10.4-asan/storage/innobase/row/row0mysql.cc:1802
      #15 0x00005653f408886d in ha_innobase::update_row (this=0x61d000247ca8, old_row=0x6190000d9df0 "\376\004", new_row=0x6190000d9db8 "\376\004") at /data/bld/10.4-asan/storage/innobase/handler/ha_innodb.cc:8954
      #16 0x00005653f36fdea1 in handler::ha_update_row (this=0x61d000247ca8, old_data=0x6190000d9df0 "\376\004", new_data=0x6190000d9db8 "\376\004") at /data/bld/10.4-asan/sql/handler.cc:6935
      #17 0x00005653f31f88a1 in mysql_update (thd=0x62b00009a208, table_list=0x62b0000a1338, fields=..., values=..., conds=0x0, order_num=0, order=0x0, limit=18446744073709551611, ignore=true, found_return=0x7f3f75890200, updated_return=0x7f3f75890220) at /data/bld/10.4-asan/sql/sql_update.cc:1087
      #18 0x00005653f2f22688 in mysql_execute_command (thd=0x62b00009a208) at /data/bld/10.4-asan/sql/sql_parse.cc:4453
      #19 0x00005653f2f3bc75 in mysql_parse (thd=0x62b00009a208, rawbuf=0x62b0000a1228 "UPDATE IGNORE t SET b = NULL", length=28, parser_state=0x7f3f75891c60, is_com_multi=false, is_next_command=false) at /data/bld/10.4-asan/sql/sql_parse.cc:8088
      #20 0x00005653f2f11894 in dispatch_command (command=COM_QUERY, thd=0x62b00009a208, packet=0x62900028f209 "UPDATE IGNORE t SET b = NULL", packet_length=28, is_com_multi=false, is_next_command=false) at /data/bld/10.4-asan/sql/sql_parse.cc:1857
      #21 0x00005653f2f0e403 in do_command (thd=0x62b00009a208) at /data/bld/10.4-asan/sql/sql_parse.cc:1378
      #22 0x00005653f331591d in do_handle_one_connection (connect=0x608000000ba8) at /data/bld/10.4-asan/sql/sql_connect.cc:1419
      #23 0x00005653f3315234 in handle_one_connection (arg=0x608000000ba8) at /data/bld/10.4-asan/sql/sql_connect.cc:1323
      #24 0x00005653f3f7b776 in pfs_spawn_thread (arg=0x615000006208) at /data/bld/10.4-asan/storage/perfschema/pfs.cc:1869
      #25 0x00007f3f8b8a8044 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
      #26 0x00007f3f8b92861c in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
      

      Attachments

        Issue Links

          Activity

            People

              bar Alexander Barkov
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.