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

CHECK TABLE and REPAIR TABLE give "internal error 160" for a row that fits no partition

    XMLWordPrintable

Details

    Description

      Likely cause: old code in ha_partition::check_misplaced_rows(), not a recent change. MySQL 5.7, 8.0 and 9.1 give the same error. The testcase needs WITHOUT VALIDATION, which MDEV-22164 added in CS 11.4, so it does not run on older versions.

      --source include/have_partition.inc
      --source include/have_innodb.inc
      call mtr.add_suppression("was altered WITHOUT VALIDATION");
      CREATE TABLE t1 (a INT) ENGINE=InnoDB PARTITION BY LIST (a) (PARTITION p0 VALUES IN (1), PARTITION p1 VALUES IN (2));
      CREATE TABLE t2 (a INT) ENGINE=InnoDB;
      INSERT INTO t2 VALUES (1), (3);
      ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2 WITHOUT VALIDATION;
      --let $m= query_get_value(CHECK TABLE t1, Msg_text, 2)
      --let $bad= `SELECT '$m' LIKE '%internal error%'`
      if ($bad)
      {
        --die The row 3 fits no partition, and CHECK TABLE reports it as an internal error: $m
      }
      DROP TABLE t1, t2;

      Leads to:

      CS 13.1.2 87e62ca17270e163a6d41b3fc8d6f4d440f1bb88 (Optimized, Clang 22.1.8-20260622) Build 05/10/2026

      mysqltest: At line 12: The row 3 fits no partition, and CHECK TABLE reports it as an internal error: Unknown - internal error 160 during operation

      CHECK TABLE t1 gives Partition p0 returned error and Unknown - internal error 160 during operation, and REPAIR TABLE t1 gives the same. ALTER TABLE t1 REBUILD PARTITION p0 then removes the row 3 without a warning. MDEV-41598 shows the same for REORGANIZE PARTITION. A row that fits another partition is reported as "Found a misplaced row" and is moved by REPAIR TABLE. MyISAM, Aria and debug builds give the same result.

      From the code it seems that ha_partition::check_misplaced_rows() stops at the first error of get_partition_id(), which is HA_ERR_NO_PARTITION_FOUND (160) for this row, and returns it as it is.

      Attachments

        Issue Links

          Activity

            People

              ycp Yuchen Pei
              Roel Roel Van de Paar
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - Not Specified
                  Not Specified
                  Logged:
                  Time Spent - 0.5h
                  0.5h

                  Git Integration

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