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

MRR scan over partitioned InnoDB table produces "Out of memory" error

Details

    Description

      Run this testcase

      --source include/have_partition.inc
      --source include/have_innodb.inc
       
      create table ten(a int);
      insert into ten values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
       
      create table one_k(a int);
      insert into one_k select A.a + B.a* 10 + C.a * 100 from ten A, ten B, ten C;
       
      create table t1 (
        ID bigint(20) NOT NULL AUTO_INCREMENT,
        part_id int,
        key_col int,
        col2 int,
        key(key_col),
        PRIMARY KEY (ID,part_id)
      ) ENGINE=InnoDB
       PARTITION BY RANGE (part_id)
      (PARTITION p1 VALUES LESS THAN (3) ENGINE = InnoDB,
       PARTITION p2 VALUES LESS THAN (7) ENGINE = InnoDB,
       PARTITION p3 VALUES LESS THAN (10) ENGINE = InnoDB
      );
       
      insert into t1 select
        A.a+10*B.a,
        A.a,
        B.a,
        123456
      from ten A, ten B;
       
      set optimizer_switch='mrr=on';
      explain
      select * from t1 force index (key_col) where key_col < 10;
      select * from t1 force index (key_col) where key_col < 10;
       
      drop table ten,one_k,t1;
      

      And it will fail with:

      mysqltest: At line 35: query 'select * from t1 force index (key_col) where key_col < 10' failed: 1041: Out of memory.
      

      Attachments

        Issue Links

          Activity

            psergei Sergei Petrunia created issue -
            psergei Sergei Petrunia made changes -
            Field Original Value New Value
            Description
            {code:sql}
            --source include/have_partition.inc
            --source include/have_innodb.inc

            create table ten(a int);
            insert into ten values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);

            create table one_k(a int);
            insert into one_k select A.a + B.a* 10 + C.a * 100 from ten A, ten B, ten C;

            create table t1 (
              ID bigint(20) NOT NULL AUTO_INCREMENT,
              part_id int,
              key_col int,
              col2 int,
              key(key_col),
              PRIMARY KEY (ID,part_id)
            ) ENGINE=InnoDB
             PARTITION BY RANGE (part_id)
            (PARTITION p1 VALUES LESS THAN (3) ENGINE = InnoDB,
             PARTITION p2 VALUES LESS THAN (7) ENGINE = InnoDB,
             PARTITION p3 VALUES LESS THAN (10) ENGINE = InnoDB
            );

            insert into t1 select
              A.a+10*B.a,
              A.a,
              B.a,
              123456
            from ten A, ten B;

            set optimizer_switch='mrr=on';
            explain
            select * from t1 force index (key_col) where key_col < 10;
            select * from t1 force index (key_col) where key_col < 10;

            drop table ten,one_k,t1;
            {code}
            Run this testcase

            {code:sql}
            --source include/have_partition.inc
            --source include/have_innodb.inc

            create table ten(a int);
            insert into ten values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);

            create table one_k(a int);
            insert into one_k select A.a + B.a* 10 + C.a * 100 from ten A, ten B, ten C;

            create table t1 (
              ID bigint(20) NOT NULL AUTO_INCREMENT,
              part_id int,
              key_col int,
              col2 int,
              key(key_col),
              PRIMARY KEY (ID,part_id)
            ) ENGINE=InnoDB
             PARTITION BY RANGE (part_id)
            (PARTITION p1 VALUES LESS THAN (3) ENGINE = InnoDB,
             PARTITION p2 VALUES LESS THAN (7) ENGINE = InnoDB,
             PARTITION p3 VALUES LESS THAN (10) ENGINE = InnoDB
            );

            insert into t1 select
              A.a+10*B.a,
              A.a,
              B.a,
              123456
            from ten A, ten B;

            set optimizer_switch='mrr=on';
            explain
            select * from t1 force index (key_col) where key_col < 10;
            select * from t1 force index (key_col) where key_col < 10;

            drop table ten,one_k,t1;
            {code}

            And it will fail with:
            {code}
            mysqltest: At line 35: query 'select * from t1 force index (key_col) where key_col < 10' failed: 1041: Out of memory.
            {code}
            elenst Elena Stepanova made changes -
            Assignee Sergei Petrunia [ psergey ]
            elenst Elena Stepanova made changes -
            Fix Version/s 10.3 [ 22126 ]
            psergei Sergei Petrunia made changes -
            Fix Version/s 10.3.21 [ 24014 ]
            Fix Version/s 10.3 [ 22126 ]
            Resolution Fixed [ 1 ]
            Status Open [ 1 ] Closed [ 6 ]
            psergei Sergei Petrunia made changes -
            assen.totin Assen Totin (Inactive) made changes -
            Attachment mariadb-logo.png [ 49452 ]
            psergei Sergei Petrunia made changes -
            Fix Version/s 10.4.11 [ 24013 ]
            Fix Version/s 10.5.0 [ 23709 ]
            serg Sergei Golubchik made changes -
            Workflow MariaDB v3 [ 99709 ] MariaDB v4 [ 156756 ]
            mariadb-jira-automation Jira Automation (IT) made changes -
            Zendesk Related Tickets 164738

            People

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