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

Assertion `((val << shift) & mask) == (val << shift)' failed in rec_set_bit_field_2

Details

    Description

      Note: Run the server with --innodb-page-size=64K. In MTR, run with

      --mysqld=--innodb-page-size=64K --mysqld=--innodb-buffer-pool-size=32M --mysqld=--sequence
      

      --source include/have_innodb.inc
       
      CREATE  TABLE t1 (a SMALLINT NOT NULL AUTO_INCREMENT, UNIQUE (a), KEY(a)) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
      INSERT INTO t1 (a) SELECT seq FROM seq_1_to_8191;
       
      # Cleanup
      DROP TABLE t1;
      

      10.3 2ae83aff

      mysqld: /data/src/10.3/storage/innobase/include/rem0rec.ic:218: void rec_set_bit_field_2(rec_t*, ulint, ulint, ulint, ulint): Assertion `((val << shift) & mask) == (val << shift)' failed.
      190520 15:00:39 [ERROR] mysqld got signal 6 ;
       
      #6  0x00007f4e58d86e67 in __assert_fail_base (fmt=<optimized out>, assertion=assertion@entry=0x55a27a190510 "((val << shift) & mask) == (val << shift)", file=file@entry=0x55a27a190490 "/data/src/10.3/storage/innobase/include/rem0rec.ic", line=line@entry=218, function=function@entry=0x55a27a193020 <rec_set_bit_field_2(unsigned char*, unsigned long, unsigned long, unsigned long, unsigned long)::__PRETTY_FUNCTION__> "void rec_set_bit_field_2(rec_t*, ulint, ulint, ulint, ulint)") at assert.c:92
      #7  0x00007f4e58d86f12 in __GI___assert_fail (assertion=0x55a27a190510 "((val << shift) & mask) == (val << shift)", file=0x55a27a190490 "/data/src/10.3/storage/innobase/include/rem0rec.ic", line=218, function=0x55a27a193020 <rec_set_bit_field_2(unsigned char*, unsigned long, unsigned long, unsigned long, unsigned long)::__PRETTY_FUNCTION__> "void rec_set_bit_field_2(rec_t*, ulint, ulint, ulint, ulint)") at assert.c:101
      #8  0x000055a279a0912d in rec_set_bit_field_2 (rec=0x7f4e4df5e06f "\237\377", val=8192, offs=4, mask=65528, shift=3) at /data/src/10.3/storage/innobase/include/rem0rec.ic:218
      #9  0x000055a279a09961 in rec_set_heap_no_new (rec=0x7f4e4df5e06f "\237\377", heap_no=8192) at /data/src/10.3/storage/innobase/include/rem0rec.ic:781
      #10 0x000055a279a0f989 in page_cur_insert_rec_low (current_rec=0x7f4e4df5e068 "\237\376", index=0x7f4e0400be78, rec=0x7f4e0408b4dd "\237\377", offsets=0x7f4e4c0dd240, mtr=0x7f4e4c0ddcb0) at /data/src/10.3/storage/innobase/page/page0cur.cc:1400
      #11 0x000055a279b886ae in page_cur_tuple_insert (cursor=0x7f4e4c0dd1a8, tuple=0x7f4e0400c208, index=0x7f4e0400be78, offsets=0x7f4e4c0dd148, heap=0x7f4e4c0dd110, n_ext=0, mtr=0x7f4e4c0ddcb0) at /data/src/10.3/storage/innobase/include/page0cur.ic:288
      #12 0x000055a279b9431c in btr_cur_optimistic_insert (flags=0, cursor=0x7f4e4c0dd1a0, offsets=0x7f4e4c0dd148, heap=0x7f4e4c0dd110, entry=0x7f4e0400c208, rec=0x7f4e4c0dd150, big_rec=0x7f4e4c0dd158, n_ext=0, thr=0x7f4e040a6ee0, mtr=0x7f4e4c0ddcb0) at /data/src/10.3/storage/innobase/btr/btr0cur.cc:3416
      #13 0x000055a279a70e22 in row_ins_sec_index_entry_low (flags=0, mode=2, index=0x7f4e0400be78, offsets_heap=0x7f4e0408b450, heap=0x7f4e0408b8e0, entry=0x7f4e0400c208, trx_id=0, thr=0x7f4e040a6ee0, dup_chk_only=false) at /data/src/10.3/storage/innobase/row/row0ins.cc:3165
      #14 0x000055a279a715b7 in row_ins_sec_index_entry (index=0x7f4e0400be78, entry=0x7f4e0400c208, thr=0x7f4e040a6ee0, dup_chk_only=false) at /data/src/10.3/storage/innobase/row/row0ins.cc:3353
      #15 0x000055a279a71789 in row_ins_index_entry (index=0x7f4e0400be78, entry=0x7f4e0400c208, thr=0x7f4e040a6ee0) at /data/src/10.3/storage/innobase/row/row0ins.cc:3401
      #16 0x000055a279a71d1e in row_ins_index_entry_step (node=0x7f4e040a6c88, thr=0x7f4e040a6ee0) at /data/src/10.3/storage/innobase/row/row0ins.cc:3549
      #17 0x000055a279a72161 in row_ins (node=0x7f4e040a6c88, thr=0x7f4e040a6ee0) at /data/src/10.3/storage/innobase/row/row0ins.cc:3692
      #18 0x000055a279a72964 in row_ins_step (thr=0x7f4e040a6ee0) at /data/src/10.3/storage/innobase/row/row0ins.cc:3937
      #19 0x000055a279a928be in row_insert_for_mysql (mysql_rec=0x7f4e0400c740 "\377\037", '\245' <repeats 14 times>, "`\307", prebuilt=0x7f4e040a6768, ins_mode=ROW_INS_NORMAL) at /data/src/10.3/storage/innobase/row/row0mysql.cc:1460
      #20 0x000055a2799379e7 in ha_innobase::write_row (this=0x7f4e0400a528, record=0x7f4e0400c740 "\377\037", '\245' <repeats 14 times>, "`\307") at /data/src/10.3/storage/innobase/handler/ha_innodb.cc:8073
      #21 0x000055a279731ef3 in handler::ha_write_row (this=0x7f4e0400a528, buf=0x7f4e0400c740 "\377\037", '\245' <repeats 14 times>, "`\307") at /data/src/10.3/sql/handler.cc:6420
      #22 0x000055a2793ecdbe in write_record (thd=0x7f4e04000b00, table=0x7f4e040a5b20, info=0x7f4e04014880) at /data/src/10.3/sql/sql_insert.cc:2030
      #23 0x000055a2793f20ee in select_insert::send_data (this=0x7f4e04014838, values=...) at /data/src/10.3/sql/sql_insert.cc:3874
      #24 0x000055a2794a01c3 in end_send (join=0x7f4e040148e8, join_tab=0x7f4e04015e28, end_of_records=false) at /data/src/10.3/sql/sql_select.cc:20582
      #25 0x000055a27949d9a9 in evaluate_join_record (join=0x7f4e040148e8, join_tab=0x7f4e04015a78, error=0) at /data/src/10.3/sql/sql_select.cc:19618
      #26 0x000055a27949d440 in sub_select (join=0x7f4e040148e8, join_tab=0x7f4e04015a78, end_of_records=false) at /data/src/10.3/sql/sql_select.cc:19437
      #27 0x000055a27949c790 in do_select (join=0x7f4e040148e8, procedure=0x0) at /data/src/10.3/sql/sql_select.cc:18938
      #28 0x000055a27947583d in JOIN::exec_inner (this=0x7f4e040148e8) at /data/src/10.3/sql/sql_select.cc:4042
      #29 0x000055a279474c80 in JOIN::exec (this=0x7f4e040148e8) at /data/src/10.3/sql/sql_select.cc:3836
      #30 0x000055a279475f21 in mysql_select (thd=0x7f4e04000b00, tables=0x7f4e04013200, wild_num=0, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=3489925888, result=0x7f4e04014838, unit=0x7f4e040049c8, select_lex=0x7f4e04005140) at /data/src/10.3/sql/sql_select.cc:4241
      #31 0x000055a279467e84 in handle_select (thd=0x7f4e04000b00, lex=0x7f4e04004900, result=0x7f4e04014838, setup_tables_done_option=1073741824) at /data/src/10.3/sql/sql_select.cc:373
      #32 0x000055a27942c119 in mysql_execute_command (thd=0x7f4e04000b00) at /data/src/10.3/sql/sql_parse.cc:4844
      #33 0x000055a279436968 in mysql_parse (thd=0x7f4e04000b00, rawbuf=0x7f4e04012808 "INSERT INTO t1 (a) SELECT seq FROM seq_1_to_8191", length=48, parser_state=0x7f4e4c0df5f0, is_com_multi=false, is_next_command=false) at /data/src/10.3/sql/sql_parse.cc:8098
      #34 0x000055a2794239aa in dispatch_command (command=COM_QUERY, thd=0x7f4e04000b00, packet=0x7f4e0415fdd1 "INSERT INTO t1 (a) SELECT seq FROM seq_1_to_8191", packet_length=48, is_com_multi=false, is_next_command=false) at /data/src/10.3/sql/sql_parse.cc:1858
      #35 0x000055a2794223cd in do_command (thd=0x7f4e04000b00) at /data/src/10.3/sql/sql_parse.cc:1403
      #36 0x000055a27958a50d in do_handle_one_connection (connect=0x55a27ba945a0) at /data/src/10.3/sql/sql_connect.cc:1402
      #37 0x000055a27958a284 in handle_one_connection (arg=0x55a27ba945a0) at /data/src/10.3/sql/sql_connect.cc:1308
      #38 0x000055a279e617c0 in pfs_spawn_thread (arg=0x55a27b945c40) at /data/src/10.3/storage/perfschema/pfs.cc:1862
      #39 0x00007f4e5a8fb4a4 in start_thread (arg=0x7f4e4c0e0700) at pthread_create.c:456
      #40 0x00007f4e58e43d0f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:97
      

      Reproducible on 10.1-10.4.
      Not reproducible with innodb-page-size=32K or 16K.
      No visible problem on a non-debug build.

      Attachments

        Issue Links

          Activity

            The assertion fails when heap_no exceeds the maximum allowed value 8191. There are two predefined records with heap numbers 0 (infimum) and 1 (supremum). So, at most 8190 user records may be inserted into a page.

            In this case, the record size for the secondary index is only 7 bytes, consisting of a 5-byte fixed-length header and 2 bytes of payload. Because we have UNIQUE KEY(a) that is treated as the primary key, the secondary KEY(a) will consist of only the column a. I did not realize that this actually makes the minimum record size as low as 7 bytes. I had previously thought that the minimum size for something that can exceed 256 user records per page would be at least 8 bytes.

            We are allocating the record at page offset 0xe06a, and the payload started at 0x7d. There are 57325 bytes or 8189 records in between. The sparse page directory (which from the end of the page) ends at 0xeff8. If the minimum size of the record were 8 bytes, we could insert way fewer than 8000 records in the page.

            This is a design problem of innodb_page_size=64k. I think that we must simply refuse the insert if the heap number would exceed 8191.

            marko Marko Mäkelä added a comment - The assertion fails when heap_no exceeds the maximum allowed value 8191. There are two predefined records with heap numbers 0 (infimum) and 1 (supremum). So, at most 8190 user records may be inserted into a page. In this case, the record size for the secondary index is only 7 bytes, consisting of a 5-byte fixed-length header and 2 bytes of payload. Because we have UNIQUE KEY(a) that is treated as the primary key, the secondary KEY(a) will consist of only the column a . I did not realize that this actually makes the minimum record size as low as 7 bytes. I had previously thought that the minimum size for something that can exceed 256 user records per page would be at least 8 bytes. We are allocating the record at page offset 0xe06a, and the payload started at 0x7d. There are 57325 bytes or 8189 records in between. The sparse page directory (which from the end of the page) ends at 0xeff8. If the minimum size of the record were 8 bytes, we could insert way fewer than 8000 records in the page. This is a design problem of innodb_page_size=64k . I think that we must simply refuse the insert if the heap number would exceed 8191.

            We will cause page splits to avoid exceeding the maximum heap number 8191.

            marko Marko Mäkelä added a comment - We will cause page splits to avoid exceeding the maximum heap number 8191.

            People

              marko Marko Mäkelä
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

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