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

InnoDB: index records in a wrong order upon CHECK with DESC index

Details

    Description

      --source include/have_innodb.inc
       
      CREATE TABLE t (pk INT PRIMARY KEY, a VARCHAR(1), KEY (a DESC)) ENGINE=InnoDB;
      INSERT INTO t VALUES (1,NULL),(2,'x');
      CHECK TABLE t EXTENDED;
       
      DROP TABLE t;
      

      main 3761a7fec8a273c06d52f89bccf11e50cbe5a89d

      CHECK TABLE t EXTENDED;
      Table	Op	Msg_type	Msg_text
      test.t	check	Warning	InnoDB: The B-tree of index a is corrupted.
      test.t	check	error	Corrupt
      DROP TABLE t;
      bug.flag1a                               [ fail ]  Found warnings/errors in server log file!
              Test ended at 2025-01-14 22:10:02
      line
      2025-01-14 22:10:01 4 [ERROR] InnoDB: index records in a wrong order in `a` of table `test`.`t`: TUPLE (info_bits=0, 2 fields): {NULL,[4]    (0x80000001)}, COMPACT RECORD(info_bits=0, 2 fields): {[1]x(0x78),[4]    (0x80000002)}
      2025-01-14 22:10:01 4 [ERROR] InnoDB: Flagged corruption of `a` in table `test`.`t` in CHECK TABLE-check index
      

      The failure started happening after this commit in main:

      commit 3761a7fec8a273c06d52f89bccf11e50cbe5a89d (HEAD, origin/main, origin/HEAD, main)
      Author: Marko Mäkelä
      Date:   Fri Jan 10 16:40:55 2025 +0200
       
          MDEV-35312 page_cur_search_with_match() could avoid rec_get_offsets()
      

      Attachments

        Issue Links

          Activity

            The error affects the comparison between NULL and a non NULL value for ROW_FORMAT≠REDUNDANT:

            diff --git a/storage/innobase/page/page0cur.cc b/storage/innobase/page/page0cur.cc
            index 00e29caeeb7..d1d11b50de8 100644
            --- a/storage/innobase/page/page0cur.cc
            +++ b/storage/innobase/page/page0cur.cc
            @@ -606,7 +606,7 @@ static int page_cur_dtuple_cmp(const dtuple_t &dtuple, const rec_t *rec,
                     {
                       if (i < cur_field || dtuple.fields[i].len == UNIV_SQL_NULL)
                         continue;
            -          ret= 1;
            +          ret= field->descending ? -1 : 1;
                       break;
                     }
                   }
            

            marko Marko Mäkelä added a comment - The error affects the comparison between NULL and a non NULL value for ROW_FORMAT≠REDUNDANT : diff --git a/storage/innobase/page/page0cur.cc b/storage/innobase/page/page0cur.cc index 00e29caeeb7..d1d11b50de8 100644 --- a/storage/innobase/page/page0cur.cc +++ b/storage/innobase/page/page0cur.cc @@ -606,7 +606,7 @@ static int page_cur_dtuple_cmp(const dtuple_t &dtuple, const rec_t *rec, { if (i < cur_field || dtuple.fields[i].len == UNIV_SQL_NULL) continue; - ret= 1; + ret= field->descending ? -1 : 1; break; } }

            Approved.

            vlad.lesin Vladislav Lesin added a comment - Approved.

            People

              marko Marko Mäkelä
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              3 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.