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

Task AB#1310795: [LevelDB] Fixing an issue where a carriage return in the CURRENT file would consider our files as corrupted. #8

Merged
merged 1 commit into from
Dec 20, 2024

Conversation

@yabmek-msft yabmek-msft requested review from AlexTroyer, rohunMS and a team December 10, 2024 01:06
@@ -872,10 +872,17 @@ Status VersionSet::Recover(bool* save_manifest) {
if (!s.ok()) {
return s;
}
if (current.empty() || current[current.size() - 1] != '\n') {
const size_t size = current.size();
if (size == 0 || (current[size - 1] != '\n' && current[size - 1] != '\r')) {

Choose a reason for hiding this comment

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

Change looks fine as is but I wonder when do we have this condition (file ending with \r only not with the combination \r\n) ... wasn't this condition a side effect of not having the change below? (as in the first time we call recover it goes and clears the \n but not the \r and now the file is all weird).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Doesn't seem like the current.resize(current.size() - 1); causes this problem since current is just a string that gets reinitialized each time Recover is called. Removing the /n in current (for posix devices) on the first run shouldn't cause the next value of current after Recover is called again to be messed up since it's reinitialized with ReadFileToString. Seems like value of current is only adjusted for setting dscname. Not why file would be ending with \r, but this fix seems to have fixed whatever was causing it, but the original author of this commit was unable to remember the specifics.

Copy link
Collaborator

@rohunMS rohunMS left a comment

Choose a reason for hiding this comment

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

Approved for DoD.

@yabmek-msft yabmek-msft merged commit a985fcc into main Dec 20, 2024
16 checks passed
@yabmek-msft yabmek-msft deleted the ymekonnen/fixing_currentfile_corruption branch December 20, 2024 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants