-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
MDEV-40728 Recovery wrongly fails if FILE_CREATE is followed by FILE_RENAME #5531
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
dr-m
wants to merge
1
commit into
10.11
Choose a base branch
from
circular-MDEV-40728
base: 10.11
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.
+34
−27
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
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
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.
Merging
case FIL_LOAD_ID_CHANGEDintocase FIL_LOAD_NOT_FOUNDdoes more thansimplify:
The two statuses mean opposite things:
NOT_FOUND is "no file, the name is free to claim",
ID_CHANGED is "the file is there and its page 0 belongs to a different tablespace".
Let's say space id is 7 is deferred with create_lsn set, we parse FILE_RENAME 7-> t2.ibd
t2.ibd on disk has space id 9 in page 0. In this case, this patch sets deferred file name to t2.ibd (to space id 7). reinit_all() binds space 7 to t2.ibd and writes space 7 pages to space 9 silently.
Can we have separate case like we used to do before the patch ? By doing this, we don't need fil_load_status s variable at all.
In mtr_t::commit_file(), we also flush the redo log before doing file operation.
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.
The reason why I merged the paths is that the
FILE_RENAMEhandling needs to be executed also in case we gotFIL_LOAD_ID_CHANGED. The scenario could be similar to the one in the #5530 functionfil_delete_apply(). That is, theFILE_CREATEwill be followed by aFILE_RENAMEthat would replace a file that unexpectedly exists in the data directory.Apart from
innodb_log_archive=ONrecovery, this could be the case when a file has been copied to the data directory in order to prepare forALTER TABLE…IMPORT TABLESPACE. Such copying could happen shortly before or after the server was killed. The existence of such a file would result in the following recovery failure message:Note: This message does not mention the newly created file at all.
If we retain this adjustment, the recovery would fail a little later with a more specific message:
(In #5530 this failure may be prevented for
innodb_log_archive=ONrecovery by replaying theFILE_DELETEon the oldt1.ibdfile.)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.
This error is being called in
recv_rename_files(). If the tablespace exist in deferred space (d) that means fil_space_t::get(id) will throw nullptr.Scenario:
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.
I think that I must create an
ib_logfile0corresponding to thedata.tar.xzthat is attached to MDEV-40728. Then we can test how recovery will actually perform on this data directory.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.
Please refer to this comment in MDEV-40728 on how to test this. If I revert the changes to this
switchstatement (retaining only thereset_create:removal), the filet1.ibdwill be recovered incorrectly, with the old contents (tablespace ID 147, not 171). Recovery reports no error:If I try to access the table from SQL, an error will be reported:
This erroneous recovery would be a serious regression.