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

Server crashes in get_store_key / create_ref_for_key / get_best_combination

    XMLWordPrintable

    Details

    • Sprint:
      10.2.6-3, 5.5.58

      Description

      Initially reported on #maria IRC channel.

      Test case

      --source include/have_innodb.inc
       
      CREATE TABLE `stats_disk_usage` (
        `id` varchar(16) NOT NULL,
        `date_scanned` date NOT NULL,
        `instances_id` varchar(16) NOT NULL,
        `stat_type` varchar(16) NOT NULL,
        `kilobytes` bigint(20) unsigned NOT NULL,
        `date_created` datetime NOT NULL,
        `date_changed` datetime DEFAULT NULL,
        PRIMARY KEY (`id`),
        UNIQUE KEY `date_scanned_instance_idx` (`date_scanned`,`instances_id`,`stat_type`),
        KEY `date_scanned_idx` (`date_scanned`),
        KEY `instances_id_stat_type_idx` (`instances_id`,`stat_type`),
        KEY `kilobytes_idx` (`kilobytes`),
        KEY `date_created_idx` (`date_created`),
        KEY `date_changed_idx` (`date_changed`),
        KEY `date_type_size_idx` (`date_scanned`,`stat_type`,`kilobytes`)
      ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
       
      CREATE TABLE `stats_disk_usage_monthly` (
        `id` varchar(16) NOT NULL,
        `date_scanned` date NOT NULL,
        `date_month` date NOT NULL,
        `instances_id` varchar(16) NOT NULL,
        `stat_type` varchar(16) NOT NULL,
        `kilobytes` bigint(20) unsigned NOT NULL,
        `date_created` datetime NOT NULL,
        `date_changed` datetime DEFAULT NULL,
        PRIMARY KEY (`id`),
        UNIQUE KEY `date_month_instance_idx` (`date_month`,`instances_id`,`stat_type`),
        KEY `date_scanned_idx` (`date_scanned`),
        KEY `date_month_idx` (`date_month`),
        KEY `instances_id_stat_type_idx` (`instances_id`,`stat_type`),
        KEY `kilobytes_idx` (`kilobytes`),
        KEY `date_created_idx` (`date_created`),
        KEY `date_changed_idx` (`date_changed`),
        KEY `date_type_size_idx` (`date_scanned`,`stat_type`,`kilobytes`)
      ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
       
       INSERT into stats_disk_usage_monthly
       (id, date_scanned, date_month, instances_id, stat_type,
        kilobytes, date_created, date_changed)
       
       SELECT CONCAT(LEFT( id, LENGTH(id)-1 ), 'm'), max(date_scanned), '2016-12-01', instances_id, stat_type,
       kilobytes AS total_quantity, '2016-12-13 12:11:26', NULL
       
       FROM stats_disk_usage AS orig
       WHERE orig.date_scanned >= '2016-12-01' AND orig.date_scanned <= '2016-12-31'
       AND   orig.stat_type='files'
       GROUP BY orig.instances_id
       
       ON DUPLICATE KEY UPDATE
       stats_disk_usage_monthly.kilobytes =
       (
         SELECT kilobytes FROM stats_disk_usage AS target
         WHERE target.date_scanned >= '2016-12-01' AND target.date_scanned <= '2016-12-31'
         AND   target.instances_id = orig.instances_id
         AND   target.stat_type='files'
         ORDER BY target.date_scanned DESC
         LIMIT 1
       ),
       stats_disk_usage_monthly.date_changed='2016-12-13 12:11:26';
       
      

      5.5 03dabfa84d6bc9a8197c8d9fbe80f2a7f6a5b6ac

      #3  <signal handler called>
      #4  0x0000000000000000 in ?? ()
      #5  0x0000000000647450 in get_store_key (thd=0x7f6181360060, keyuse=0x7f6179091460, used_tables=0, key_part=0x7f6179078618, key_buff=0x7f617919e988 "", maybe_null=0) at /data/src/5.5/sql/sql_select.cc:8222
      #6  0x0000000000647100 in create_ref_for_key (join=0x7f6179109620, j=0x7f617919e668, org_keyuse=0x7f6179091460, allow_full_scan=true, used_tables=4611686018427387905) at /data/src/5.5/sql/sql_select.cc:8153
      #7  0x0000000000646031 in get_best_combination (join=0x7f6179109620) at /data/src/5.5/sql/sql_select.cc:7819
      #8  0x000000000063c70d in make_join_statistics (join=0x7f6179109620, tables_list=..., conds=0x7f61790f14d8, keyuse_array=0x7f6179109938) at /data/src/5.5/sql/sql_select.cc:3832
      #9  0x0000000000633402 in JOIN::optimize (this=0x7f6179109620) at /data/src/5.5/sql/sql_select.cc:1229
      #10 0x00000000005f8ebb in st_select_lex::optimize_unflattened_subqueries (this=0x7f6181363a70, const_only=false) at /data/src/5.5/sql/sql_lex.cc:3549
      #11 0x0000000000744ad4 in JOIN::optimize_unflattened_subqueries (this=0x7f61791084f0) at /data/src/5.5/sql/opt_subselect.cc:4984
      #12 0x0000000000634ea7 in JOIN::optimize (this=0x7f61791084f0) at /data/src/5.5/sql/sql_select.cc:1665
      #13 0x0000000000639d87 in mysql_select (thd=0x7f6181360060, rref_pointer_array=0x7f6181363ce0, tables=0x7f617918b858, wild_num=0, fields=..., conds=0x7f617918c500, og_num=1, order=0x0, group=0x7f617918cab0, having=0x0, proc_param=0x0, select_options=3489925888, result=0x7f6179108458, unit=0x7f6181363390, select_lex=0x7f6181363a70) at /data/src/5.5/sql/sql_select.cc:3080
      #14 0x0000000000630702 in handle_select (thd=0x7f6181360060, lex=0x7f61813632e0, result=0x7f6179108458, setup_tables_done_option=1073741824) at /data/src/5.5/sql/sql_select.cc:319
      #15 0x0000000000604f52 in mysql_execute_command (thd=0x7f6181360060) at /data/src/5.5/sql/sql_parse.cc:3060
      #16 0x000000000060c834 in mysql_parse (thd=0x7f6181360060, rawbuf=0x7f6179191078 "INSERT into stats_disk_usage_monthly\n(id, date_scanned, date_month, instances_id, stat_type,\nkilobytes, date_created, date_changed)\nSELECT CONCAT(LEFT( id, LENGTH(id)-1 ), 'm'), max(date_scanned), '20"..., length=840, parser_state=0x7f6189bfe650) at /data/src/5.5/sql/sql_parse.cc:5934
      #17 0x0000000000600549 in dispatch_command (command=COM_QUERY, thd=0x7f6181360060, packet=0x7f6181206061 "INSERT into stats_disk_usage_monthly\n(id, date_scanned, date_month, instances_id, stat_type,\nkilobytes, date_created, date_changed)\nSELECT CONCAT(LEFT( id, LENGTH(id)-1 ), 'm'), max(date_scanned), '20"..., packet_length=840) at /data/src/5.5/sql/sql_parse.cc:1079
      #18 0x00000000005ff703 in do_command (thd=0x7f6181360060) at /data/src/5.5/sql/sql_parse.cc:793
      #19 0x000000000070190f in do_handle_one_connection (thd_arg=0x7f6181360060) at /data/src/5.5/sql/sql_connect.cc:1270
      #20 0x000000000070169c in handle_one_connection (arg=0x7f6181360060) at /data/src/5.5/sql/sql_connect.cc:1186
      #21 0x000000000094409f in pfs_spawn_thread (arg=0x7f61813ffe80) at /data/src/5.5/storage/perfschema/pfs.cc:1015
      #22 0x00007f61898450a4 in start_thread (arg=0x7f6189bff700) at pthread_create.c:309
      #23 0x00007f6187c6b87d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111
      

      Does not crash with MyISAM.
      Does not crash on MySQL 5.5.
      MySQL 5.6/5.7 produce the error:

      1054: Unknown column 'orig.instances_id' in 'where clause'
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              igor Igor Babaev
              Reporter:
              elenst Elena Stepanova
              Votes:
              1 Vote for this issue
              Watchers:
              7 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.