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

InnoDB fails to restore tablespace first page from doublewrite buffer when page is empty

    XMLWordPrintable

Details

    Description

      InnoDB fails to find the space id to restore the page from doublewrite
      buffer. It is not easy to find the space id from consecutive pages when
      we don't have page size information (fsp_flags also 0)

      Patch to repeat the failure:

      diff --git a/mysql-test/suite/innodb/t/doublewrite.test b/mysql-test/suite/innodb/t/doublewrite.test
      index 89e6577b434..7eedfc7e636 100644
      --- a/mysql-test/suite/innodb/t/doublewrite.test
      +++ b/mysql-test/suite/innodb/t/doublewrite.test
      @@ -65,8 +65,9 @@ my $page_size = $ENV{INNODB_PAGE_SIZE};
       my $page;
       do "$ENV{MTR_SUITE_DIR}/../innodb/include/crc32.pl";
       open(FILE, "+<", $fname) or die;
      -sysseek(FILE, ($page_size/2), 0);
      -syswrite(FILE, chr(0) x ($page_size/2));
      +#sysseek(FILE, ($page_size/2), 0);
      +#syswrite(FILE, chr(0) x ($page_size/2));
      +syswrite(FILE, chr(0) x $page_size);
       sysseek(FILE, 3*$page_size, 0);
       sysread(FILE, $page, $page_size)==$page_size||die "Unable to read $name\n";
       sysseek(FILE, 3*$page_size, 0)||die "Unable to seek $fname\n";
      

      error message in log file:

      2023-12-07 22:32:59 0 [Note] InnoDB: Starting crash recovery from checkpoint LSN=49621,49621
      2023-12-07 22:32:59 0 [Note] InnoDB: Header page consists of zero bytes in datafile: ./test/t1.ibd, Space ID:0, Flags: 0
      2023-12-07 22:32:59 0 [Note] InnoDB: Page size:1024. Pages to analyze:64
      2023-12-07 22:32:59 0 [Note] InnoDB: Page size: 1024. Possible space_id count:0
      2023-12-07 22:32:59 0 [Note] InnoDB: Page size:2048. Pages to analyze:64
      2023-12-07 22:32:59 0 [Note] InnoDB: Page size: 2048. Possible space_id count:0
      2023-12-07 22:32:59 0 [Note] InnoDB: Page size:4096. Pages to analyze:40
      2023-12-07 22:32:59 0 [Note] InnoDB: Page size: 4096. Possible space_id count:0
      2023-12-07 22:32:59 0 [Note] InnoDB: Page size:8192. Pages to analyze:20
      2023-12-07 22:32:59 0 [Note] InnoDB: Page size: 8192. Possible space_id count:0
      2023-12-07 22:32:59 0 [Note] InnoDB: Page size:16384. Pages to analyze:10
      2023-12-07 22:32:59 0 [Note] InnoDB: Page size: 16384. Possible space_id count:0
      2023-12-07 22:32:59 0 [Note] InnoDB: Page size:32768. Pages to analyze:5
      2023-12-07 22:32:59 0 [Note] InnoDB: Page size: 32768. Possible space_id count:0
      2023-12-07 22:32:59 0 [Note] InnoDB: Page size:65536. Pages to analyze:2
      2023-12-07 22:32:59 0 [Note] InnoDB: Page size: 65536. Possible space_id count:0
      2023-12-07 22:32:59 0 [ERROR] InnoDB: Datafile './test/t1.ibd' is corrupted. Cannot determine the space ID from the first 64 pages.
      2023-12-07 22:32:59 0 [ERROR] InnoDB: Tablespace 5 was not found at ./test/t1.ibd.
      2023-12-07 22:32:59 0 [ERROR] InnoDB: Set innodb_force_recovery=1 to ignore this and to permanently lose all changes to the tablespace.
      

      Solution:

      Find the 0th pages in doublewrite buffer
      Extract the space id and flags from page0
      Use flags to find page_size information and read consecutive pages to match space id
      If all pages are matching with doublewrite buffer page0 then write into the datafile.

      Attachments

        Issue Links

          Activity

            People

              thiru Thirunarayanan Balathandayuthapani
              thiru Thirunarayanan Balathandayuthapani
              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.