-
Notifications
You must be signed in to change notification settings - Fork 514
PS-11202 [8.0]: Fix abrupt server termination when reading page tracking files fails #5988
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
Open
jakub-nowakowski-percona
wants to merge
1
commit into
percona:8.0
Choose a base branch
from
jakub-nowakowski-percona:PS-11202-8.0-corrupted-page-tracking-info-crash
base: 8.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+206
−32
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| # | ||
| # Enable page tracking | ||
| # | ||
| INSTALL COMPONENT 'file://component_mysqlbackup'; | ||
| SELECT mysqlbackup_page_track_set(1); | ||
| mysqlbackup_page_track_set(1) | ||
| # | ||
| # | ||
| # Generate data to create page tracking archive files | ||
| # | ||
| CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT) ENGINE=InnoDB; | ||
| UPDATE t1 SET b = REPEAT('y', 1000); | ||
| # | ||
| # Verify page tracking works before corruption | ||
| # | ||
| SELECT mysqlbackup_page_track_get_changed_page_count(mysqlbackup_page_track_get_start_lsn(), mysqlbackup_page_track_get_start_lsn() + 1); | ||
| mysqlbackup_page_track_get_changed_page_count(mysqlbackup_page_track_get_start_lsn(), mysqlbackup_page_track_get_start_lsn() + 1) | ||
| # | ||
| # | ||
| # Shutdown the server | ||
| # | ||
| # | ||
| # Corrupt page tracking archive files | ||
| # | ||
| Page tracking archive files corrupted successfully. | ||
| # | ||
| # Restart the server — should succeed despite corrupted archive files | ||
| # | ||
| # restart | ||
| # | ||
| # Verify page tracking query does not crash after corruption | ||
| # | ||
| SELECT mysqlbackup_page_track_get_changed_page_count(mysqlbackup_page_track_get_start_lsn(), mysqlbackup_page_track_get_start_lsn() + 1); | ||
| mysqlbackup_page_track_get_changed_page_count(mysqlbackup_page_track_get_start_lsn(), mysqlbackup_page_track_get_start_lsn() + 1) | ||
| # | ||
| # | ||
| # Cleanup | ||
| # | ||
| DROP TABLE t1; | ||
| UNINSTALL COMPONENT 'file://component_mysqlbackup'; |
118 changes: 118 additions & 0 deletions
118
mysql-test/suite/innodb/t/page_tracking_corruption.test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,118 @@ | ||
| # Test that the server starts despite corrupted page tracking archive files. | ||
| # | ||
| # When ib_page_* files in #ib_archive are corrupted (e.g. truncated), | ||
| # the server should detect the problem, log a warning, and continue | ||
| # starting up rather than crashing. | ||
| # | ||
| --source include/not_valgrind.inc | ||
|
|
||
| --disable_query_log | ||
| call mtr.add_suppression("Page Archiver's doublewrite buffer initialisation failed"); | ||
| call mtr.add_suppression("Page archiver system's recovery failed"); | ||
| call mtr.add_suppression("Operating system error number .* in a file operation"); | ||
| call mtr.add_suppression("Error number .* means"); | ||
| call mtr.add_suppression("'rmdir' returned OS error"); | ||
| call mtr.add_suppression("bytes should have been read. Only .* bytes read"); | ||
| call mtr.add_suppression("Retry attempts for reading partial data failed"); | ||
| --enable_query_log | ||
|
|
||
| let MYSQLD_DATADIR = `SELECT @@datadir`; | ||
|
|
||
| --echo # | ||
| --echo # Enable page tracking | ||
| --echo # | ||
| INSTALL COMPONENT 'file://component_mysqlbackup'; | ||
| --replace_column 1 # | ||
| SELECT mysqlbackup_page_track_set(1); | ||
|
|
||
| --echo # | ||
| --echo # Generate data to create page tracking archive files | ||
| --echo # | ||
| CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT) ENGINE=InnoDB; | ||
|
|
||
| --disable_query_log | ||
| --let $i = 100 | ||
| while ($i) | ||
| { | ||
| INSERT INTO t1 (b) VALUES (REPEAT('x', 1000)); | ||
| --dec $i | ||
| } | ||
| --enable_query_log | ||
|
|
||
| UPDATE t1 SET b = REPEAT('y', 1000); | ||
|
|
||
| --echo # | ||
| --echo # Verify page tracking works before corruption | ||
| --echo # | ||
| --replace_column 1 # | ||
| SELECT mysqlbackup_page_track_get_changed_page_count(mysqlbackup_page_track_get_start_lsn(), mysqlbackup_page_track_get_start_lsn() + 1); | ||
|
|
||
| --echo # | ||
| --echo # Shutdown the server | ||
| --echo # | ||
| --source include/shutdown_mysqld.inc | ||
|
|
||
| --echo # | ||
| --echo # Corrupt page tracking archive files | ||
| --echo # | ||
|
|
||
| perl; | ||
| use File::Find; | ||
| use strict; | ||
| use warnings; | ||
|
|
||
| my $datadir = $ENV{'MYSQLD_DATADIR'}; | ||
| chomp $datadir if defined $datadir; | ||
| die "MYSQLD_DATADIR not set\n" unless defined $datadir && length $datadir; | ||
|
|
||
| $datadir .= '/' unless $datadir =~ m{/$}; | ||
| my $archive_dir = "${datadir}#ib_archive"; | ||
|
|
||
| die "Archive directory $archive_dir not found.\n" unless -d $archive_dir; | ||
|
|
||
| my $corrupted = 0; | ||
|
|
||
| find(sub { | ||
| # Truncate the doublewrite buffer so it cannot restore corrupted blocks. | ||
| if (/^dblwr_\d+$/ && -f $File::Find::name) { | ||
| truncate($File::Find::name, 0) or die "Cannot truncate $File::Find::name: $!\n"; | ||
| } | ||
|
|
||
| return unless /^ib_page_\d+$/; | ||
| my $path = $File::Find::name; | ||
| my $size = -s $path; | ||
| return unless defined $size && $size > 16384; | ||
|
|
||
| # Truncate just past the first block (the reset block). This preserves | ||
| # the valid reset entries that reference data blocks further in the file, | ||
| # but removes those data blocks. During recovery, fetch_reset_lsn() will | ||
| # try to read a referenced data block past the end of the file and hit | ||
| # the assertion (debug) or fatal read error (release). | ||
| # The size must be > ARCH_PAGE_BLK_SIZE (16384) so that | ||
| # cleanup_if_required() does not delete the file. | ||
| truncate($path, 16385) or die "Cannot truncate $path: $!\n"; | ||
|
|
||
| $corrupted++; | ||
| }, $archive_dir); | ||
|
|
||
| die "No ib_page_* files found under $archive_dir.\n" if $corrupted == 0; | ||
|
|
||
| print "Page tracking archive files corrupted successfully.\n"; | ||
| EOF | ||
|
|
||
| --echo # | ||
| --echo # Restart the server — should succeed despite corrupted archive files | ||
| --echo # | ||
| --source include/start_mysqld.inc | ||
|
|
||
| --echo # | ||
| --echo # Verify page tracking query does not crash after corruption | ||
| --echo # | ||
| --replace_column 1 # | ||
| SELECT mysqlbackup_page_track_get_changed_page_count(mysqlbackup_page_track_get_start_lsn(), mysqlbackup_page_track_get_start_lsn() + 1); | ||
|
|
||
| --echo # | ||
| --echo # Cleanup | ||
| --echo # | ||
| DROP TABLE t1; | ||
| UNINSTALL COMPONENT 'file://component_mysqlbackup'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
modified by mistake?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's due to clang-format. I can't stop it from changing that.