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

ALTER TABLE IMPORT TABLESPACE fails with Data structure corruption

    XMLWordPrintable

Details

    Description

      Attached is the MTR test that demonstrates the bug. Also a patch with a proposed fix.

      The problem is that during ALTER TABLE IMPORT TABLESPACE two things happen:

      • Regardless of whether the tablespace is encrypted, the current LSN (8 bytes) gets written at FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION
      • Then if the page is encrypted the first 4 bytes at that offset are being interpreted as key_version while the remainder as the CRC32 checksum. If the key_version is non-zero, CRC32 check of the page is performed (fil0import.cc:3599) . So if the LSN >= 1 << 32 we perform the check, which will most likely fail as we are comparing the lowest 4 bytes of the LSN against the computed CRC-32 checksum of the page thus resulting in the error message to the client.

      I believe the right thing to do is to not write the LSN at FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION for encrypted pages. At least it fixes the problem at hand.

      Attachments

        1. t2.opt
          0.1 kB
        2. t2.patch
          1 kB
        3. t2.test
          2 kB

        Issue Links

          Activity

            People

              marko Marko Mäkelä
              spachev Sasha Pachev
              Votes:
              1 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.