Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MDEV-34898 Doublewrite recovery of innodb_checksum_algorithm=full_crc32 encrypted pages does not work #3691

Open
wants to merge 1 commit into
base: 10.6
Choose a base branch
from

Conversation

Thirunarayanan
Copy link
Member

  • The Jira issue number for this PR is: MDEV-34989

Description

  • InnoDB fails to recover the full crc32 encrypted page from doublewrite buffer. The reason is that buf_dblwr_t::recover() fails to identify the space id from the page because the page has been encrypted from FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION bytes.

Fix:

buf_dblwr_t::recover(): preserve any pages whose space_id does not match a known tablespace. These could be encrypted pages of tablespaces that had been created with
innodb_checksum_algorithm=full_crc32.

buf_page_t::read_complete(): If the page looks corrupted and the tablespace is encrypted and in full_crc32 format, try to restore the page from doublewrite buffer.

recv_dblwr_t::recover_encrypted_page(): Find the page which has the same page number and try to decrypt the page using space->crypt_data. After decryption, compare the space id. Write the recovered page back to the file.

How can this PR be tested?

./mtr encryption.doublewrite_debug

Basing the PR against the correct MariaDB version

  • This is a new feature or a refactoring, and the PR is based against the main branch.
  • This is a bug fix, and the PR is based against the earliest maintained branch in which the bug can be reproduced.

PR quality check

  • I checked the CODING_STANDARDS.md file and my PR conforms to this where appropriate.
  • For any trivial modifications to the PR, I am ok with the reviewer making the changes themselves.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

mysql-test/suite/encryption/t/debug_key_management.test Outdated Show resolved Hide resolved
storage/innobase/log/log0recv.cc Outdated Show resolved Hide resolved
storage/innobase/log/log0recv.cc Outdated Show resolved Hide resolved
storage/innobase/log/log0recv.cc Outdated Show resolved Hide resolved
storage/innobase/srv/srv0start.cc Show resolved Hide resolved
storage/innobase/buf/buf0buf.cc Outdated Show resolved Hide resolved
storage/innobase/buf/buf0buf.cc Outdated Show resolved Hide resolved
storage/innobase/log/log0recv.cc Outdated Show resolved Hide resolved
storage/innobase/buf/buf0dblwr.cc Outdated Show resolved Hide resolved
storage/innobase/include/log0recv.h Outdated Show resolved Hide resolved
Comment on lines +56 to +93
my $fname= "$ENV{'MYSQLD_DATADIR'}test/t2.ibd";
open(FILE, "+<", $fname) or die;
FILE->autoflush(1);
binmode FILE;
seek(FILE, 3 * $ENV{'INNODB_PAGE_SIZE'}, SEEK_SET);
print FILE chr(0) x ($ENV{'INNODB_PAGE_SIZE'});
close FILE;
EOF

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked that FIL_PAGE_LSN is not encrypted on the page. Therefore, we should be able to corrupt just that (for example, write chr(255) x 8, which will be newer than end of the log) and recompute the checksum. I think that it would be more interesting than this "totally corrupted" page.

Can you please also do a test variant that corrupts this page in the doublewrite buffer, with an LSN that is before the checkpoint? That should lead to InnoDB crash recovery failing. Better make it two attempts: also with an LSN that is after the end of the log.

storage/innobase/buf/buf0dblwr.cc Outdated Show resolved Hide resolved
storage/innobase/srv/srv0start.cc Show resolved Hide resolved
storage/innobase/srv/srv0start.cc Show resolved Hide resolved
storage/innobase/log/log0recv.cc Outdated Show resolved Hide resolved
storage/innobase/log/log0recv.cc Outdated Show resolved Hide resolved
…32 encrypted pages does not work

- InnoDB fails to recover the full crc32 encrypted page from
doublewrite buffer. The reason is that buf_dblwr_t::recover()
fails to identify the space id from the page because the page has
been encrypted from FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION bytes.

Fix:
===
buf_dblwr_t::recover(): preserve any pages whose space_id
does not match a known tablespace. These could be encrypted pages
of tablespaces that had been created with
innodb_checksum_algorithm=full_crc32.

buf_page_t::read_complete(): If the page looks corrupted and the
tablespace is encrypted and in full_crc32 format, try to
restore the page from doublewrite buffer.

recv_dblwr_t::recover_encrypted_page(): Find the page which
has the same page number and try to decrypt the page using
space->crypt_data. After decryption, compare the space id.
Write the recovered page back to the file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants