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

Table corruption after insert into a non-InnoDB table with DESC index

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Blocker
    • Resolution: Fixed
    • N/A
    • 10.8.1
    • Server
    • None

    Description

      CREATE TABLE t1 (
        a bigint default 0,
        b bigint default 0,
        c binary(128) NOT NULL,
        d datetime default '0000-00-00 00:00:00',
        KEY (c DESC,b,d,a)
      ) ENGINE=Aria;
       
      INSERT INTO t1 (c) VALUES
        ('xx'),('bb'),('tt'),('pp'),('mm'),('yy'),('rr'),('bb'),('yy'),('gg'),
        ('dd'),('fx'),('wi'),('ix'),('ox'),('mu'),('ux'),('pm'),('mx'),('xu'),
        ('ul'),('lp'),('px'),('lp'),('xx'),('pq'),('qs'),('se'),('ee'),('xx'),
        ('rv'),('ff'),('vj'),('jy'),('yn'),('nc'),('nx'),('hj'),('ji'),('ik'),
        ('kk'),('ww'),('xx'),('yd'),('dw'),('wk'),('kr'),('dd'),('rj'),('jf'),
        ('bx'),('fc'),('cp'),('pm'),('mw'),('wy'),('yl'),('li'),('ic'),('he'),
        ('ci'),('il'),('lz'),('zd'),('gz'),('xd'),('ze'),('dm'),('ms'),('xd'),
        ('sw'),('we'),('nb'),('tx'),('vr'),('xw'),('aa'),('ah'),('hd'),('jl'),
        ('lf'),('fw'),('wx'),('xh'),('hr'),('zx'),('vw'),('rm'),('mx'),('xt'),
        ('tp'),('ps'),('sh'),('ga'),('df'),('as'),('gz'),('xd'),('yy'),('xr');
       
      CHECK TABLE t1 EXTENDED;
      

      preview-10.8-MDEV-13756-desc-indexes d6fa6e0a

      CHECK TABLE t1 EXTENDED;
      Table	Op	Msg_type	Msg_text
      test.t1	check	error	Record at:            1:0  Can't find key for index:  1
      test.t1	check	error	Corrupt
      

      If we further execute, for example,

      SELECT COUNT(*) FROM t1 WHERE c LIKE 's%';
      COUNT(*)
      0
      

      the result is wrong, the expected result is 3.

      Or, if we execute

      SELECT c FROM t1;
      

      it hangs.

      All the above is true for both Aria and MyISAM.
      InnoDB looks okay.

      Additionally, with Aria and a slightly different test case (same as above, but the DESC part of a key is a prefix):

      CREATE TABLE t1 (
        a bigint default 0,
        b bigint default 0,
        c binary(128) NOT NULL,
        d datetime default '0000-00-00 00:00:00',
        KEY (c(64) DESC,b,d,a)
      ) ENGINE=Aria;
       
      INSERT INTO t1 (c) VALUES
        ('xx'),('bb'),('tt'),('pp'),('mm'),('yy'),('rr'),('bb'),('yy'),('gg'),
        ('dd'),('fx'),('wi'),('ix'),('ox'),('mu'),('ux'),('pm'),('mx'),('xu'),
        ('ul'),('lp'),('px'),('lp'),('xx'),('pq'),('qs'),('se'),('ee'),('xx'),
        ('rv'),('ff'),('vj'),('jy'),('yn'),('nc'),('nx'),('hj'),('ji'),('ik'),
        ('kk'),('ww'),('xx'),('yd'),('dw'),('wk'),('kr'),('dd'),('rj'),('jf'),
        ('bx'),('fc'),('cp'),('pm'),('mw'),('wy'),('yl'),('li'),('ic'),('he'),
        ('ci'),('il'),('lz'),('zd'),('gz'),('xd'),('ze'),('dm'),('ms'),('xd'),
        ('sw'),('we'),('nb'),('tx'),('vr'),('xw'),('aa'),('ah'),('hd'),('jl'),
        ('lf'),('fw'),('wx'),('xh'),('hr'),('zx'),('vw'),('rm'),('mx'),('xt'),
        ('tp'),('ps'),('sh'),('ga'),('df'),('as'),('gz'),('xd'),('yy'),('xr');
      

      --error 0,1032
      SELECT COUNT(*) FROM t1 WHERE c LIKE 's%';
      SELECT c FROM t1;
      

      The first SELECT causes ER_KEY_NOT_FOUND, and if we proceed to the next one, it fails on the assertion:

      mariadbd: /data/src/preview-10.8-MDEV-13756-desc-indexes/storage/maria/ma_pagecache.c:3814: uchar *pagecache_read(PAGECACHE *, PAGECACHE_FILE *, pgcache_page_no_t, uint, uchar *, enum pagecache_page_type, enum pagecache_page_lock, PAGECACHE_BLOCK_LINK **): Assertion `block->type == PAGECACHE_EMPTY_PAGE || block->type == type || type == PAGECACHE_LSN_PAGE || type == PAGECACHE_READ_UNKNOWN_PAGE || block->type == PAGECACHE_READ_UNKNOWN_PAGE' failed.
      211217 22:22:06 [ERROR] mysqld got signal 6 ;
       
      #7  0x00007fc72b46df36 in __GI___assert_fail (assertion=0x3d69140 <str> "block->type == PAGECACHE_EMPTY_PAGE || block->type == type || type == PAGECACHE_LSN_PAGE || type == PAGECACHE_READ_UNKNOWN_PAGE || block->type == PAGECACHE_READ_UNKNOWN_PAGE", file=0x3d67820 <str> "/data/src/preview-10.8-MDEV-13756-desc-indexes/storage/maria/ma_pagecache.c", line=3814, function=0x3d68e80 <__PRETTY_FUNCTION__.pagecache_read> "uchar *pagecache_read(PAGECACHE *, PAGECACHE_FILE *, pgcache_page_no_t, uint, uchar *, enum pagecache_page_type, enum pagecache_page_lock, PAGECACHE_BLOCK_LINK **)") at assert.c:101
      #8  0x00000000021be733 in pagecache_read (pagecache=0x6574f88 <maria_pagecache_var>, file=0x62100009d120, pageno=0, level=0, buff=0x62900028f288 '\276' <repeats 200 times>..., type=PAGECACHE_PLAIN_PAGE, lock=PAGECACHE_LOCK_LEFT_UNLOCKED, page_link=0x7fc7220ff240) at /data/src/preview-10.8-MDEV-13756-desc-indexes/storage/maria/ma_pagecache.c:3810
      #9  0x00000000022cd022 in _ma_scan_block_record (info=0x62900026c288, record=0x61a000081138 "\377", record_pos=0, skip_deleted=1 '\001') at /data/src/preview-10.8-MDEV-13756-desc-indexes/storage/maria/ma_blockrec.c:5591
      #10 0x0000000002292137 in maria_scan (info=0x62900026c288, record=0x61a000081138 "\377") at /data/src/preview-10.8-MDEV-13756-desc-indexes/storage/maria/ma_scan.c:54
      #11 0x000000000212cc0b in ha_maria::rnd_next (this=0x61d0001d7528, buf=0x61a000081138 "\377") at /data/src/preview-10.8-MDEV-13756-desc-indexes/storage/maria/ha_maria.cc:2564
      #12 0x00000000019c2793 in handler::ha_rnd_next (this=0x61d0001d7528, buf=0x61a000081138 "\377") at /data/src/preview-10.8-MDEV-13756-desc-indexes/sql/handler.cc:3393
      #13 0x0000000000a0a4e3 in rr_sequential (info=0x6290000e8d38) at /data/src/preview-10.8-MDEV-13756-desc-indexes/sql/records.cc:519
      #14 0x00000000009bc609 in READ_RECORD::read_record (this=0x6290000e8d38) at /data/src/preview-10.8-MDEV-13756-desc-indexes/sql/records.h:81
      #15 0x0000000000fc6cb6 in join_init_read_record (tab=0x6290000e8c70) at /data/src/preview-10.8-MDEV-13756-desc-indexes/sql/sql_select.cc:22065
      #16 0x0000000000f42f30 in sub_select (join=0x6290000e7998, join_tab=0x6290000e8c70, end_of_records=false) at /data/src/preview-10.8-MDEV-13756-desc-indexes/sql/sql_select.cc:21067
      #17 0x0000000000fd45d4 in do_select (join=0x6290000e7998, procedure=0x0) at /data/src/preview-10.8-MDEV-13756-desc-indexes/sql/sql_select.cc:20617
      #18 0x0000000000fd09bd in JOIN::exec_inner (this=0x6290000e7998) at /data/src/preview-10.8-MDEV-13756-desc-indexes/sql/sql_select.cc:4735
      #19 0x0000000000fccd87 in JOIN::exec (this=0x6290000e7998) at /data/src/preview-10.8-MDEV-13756-desc-indexes/sql/sql_select.cc:4513
      #20 0x0000000000f45959 in mysql_select (thd=0x62b00007e288, tables=0x6290000e6958, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x6290000e7968, unit=0x62b000082690, select_lex=0x6290000e6338) at /data/src/preview-10.8-MDEV-13756-desc-indexes/sql/sql_select.cc:4993
      #21 0x0000000000f4443b in handle_select (thd=0x62b00007e288, lex=0x62b0000825b8, result=0x6290000e7968, setup_tables_done_option=0) at /data/src/preview-10.8-MDEV-13756-desc-indexes/sql/sql_select.cc:545
      #22 0x0000000000e155ae in execute_sqlcom_select (thd=0x62b00007e288, all_tables=0x6290000e6958) at /data/src/preview-10.8-MDEV-13756-desc-indexes/sql/sql_parse.cc:6253
      #23 0x0000000000df9125 in mysql_execute_command (thd=0x62b00007e288, is_called_from_prepared_stmt=false) at /data/src/preview-10.8-MDEV-13756-desc-indexes/sql/sql_parse.cc:3944
      #24 0x0000000000de008b in mysql_parse (thd=0x62b00007e288, rawbuf=0x6290000e62a8 "SELECT c FROM t1", length=16, parser_state=0x7fc722107bb0) at /data/src/preview-10.8-MDEV-13756-desc-indexes/sql/sql_parse.cc:8028
      #25 0x0000000000dd8dcc in dispatch_command (command=COM_QUERY, thd=0x62b00007e288, packet=0x62900025d289 "", packet_length=16, blocking=true) at /data/src/preview-10.8-MDEV-13756-desc-indexes/sql/sql_parse.cc:1894
      #26 0x0000000000de2da6 in do_command (thd=0x62b00007e288, blocking=true) at /data/src/preview-10.8-MDEV-13756-desc-indexes/sql/sql_parse.cc:1402
      #27 0x000000000140e6f6 in do_handle_one_connection (connect=0x61100000a5c8, put_in_cache=true) at /data/src/preview-10.8-MDEV-13756-desc-indexes/sql/sql_connect.cc:1418
      #28 0x000000000140dd24 in handle_one_connection (arg=0x61100000a488) at /data/src/preview-10.8-MDEV-13756-desc-indexes/sql/sql_connect.cc:1312
      #29 0x00000000024eddf8 in pfs_spawn_thread (arg=0x618000005908) at /data/src/preview-10.8-MDEV-13756-desc-indexes/storage/perfschema/pfs.cc:2201
      #30 0x00007fc72b842609 in start_thread (arg=<optimized out>) at pthread_create.c:477
      #31 0x00007fc72b559293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
      

      Attachments

        Issue Links

          Activity

            People

              serg Sergei Golubchik
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              2 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.