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

unitialized handler::key_compare_result_on_equal in loose index scan of partition tables

    XMLWordPrintable

Details

    Description

      MDEV-34413 introduced a new overriding ha_partition::set_end_range, which causes handler::set_end_range to not be called which would set key_compare_result_on_equal, causing it to be uninitialized.

      In my local test, the following testcase testcase reliably produces different Handler_read_key counts between Debug and non-Debug builds. CI fails MSAN: https://buildbot.mariadb.org/#/builders/867/builds/5162

      --source include/have_partition.inc
      --source include/have_sequence.inc
      CREATE TABLE t1 (
       a INT,
       b INT,
       KEY ( a, b )
      ) PARTITION BY RANGE COLUMNS(a) (
       PARTITION `p1` VALUES LESS THAN (10),
       PARTITION `p2` VALUES LESS THAN (20),
       PARTITION `p3` VALUES LESS THAN (30),
       PARTITION `p4` VALUES LESS THAN (40),
       PARTITION `p5` VALUES LESS THAN MAXVALUE
      );
       
      insert into t1 select seq, seq from seq_1_to_50;
       
      FLUSH status;
      SELECT a, MIN(b) FROM t1 WHERE a > 18 and a < 21 GROUP BY a;
      show status like 'handler_read_%';
       
      DROP TABLE t1;
      

      One could place a breakpoint like so and print or display key_compare_result_on_equal which typically shows a random-looking value like -1094795586

      int handler::compare_key(key_range *range)
      {
        int cmp;
        if (!range || in_range_check_pushed_down)
          return 0;					// No max range
        cmp= key_cmp(range_key_part, range->key, range->length);
        if (!cmp)
          cmp= key_compare_result_on_equal; // <-- breakpoint
        return cmp;
      }
      

      Checked that it does not affect 11.8

      Attachments

        Issue Links

          Activity

            People

              psergei Sergei Petrunia
              ycp Yuchen Pei
              Votes:
              0 Vote for this issue
              Watchers:
              1 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.