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

Delta Migration: Handle delta lake's automatic log clean and VACUUM #6880

Merged
merged 12 commits into from
Mar 1, 2023

Conversation

JonasJ-ap
Copy link
Contributor

Issue Fixed

This PR fixes #6781 .

The automatic log clean whenever a new checkpoint is created and the manual data file clean by VACUUM sometimes lead to inconsistency between the first constructable delta lake version and the earliest delta lake version in the table. The inconsistency will cause file not found errors during the migration.

This PR fix the issue by forcing the snapshot delta lake action to start from the first constructable delta lake version instead of the earliest version.

Test

Added Integration tests to mock the file clean scenario.

Copy link
Contributor

@jackye1995 jackye1995 left a comment

Choose a reason for hiding this comment

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

thanks for the fix, overall looks good to me, just nit for test

@jackye1995
Copy link
Contributor

This seems needed as a fix for Delta conversion to work properly, because most users run VACUUM against the table. Mark it as required for 1.2 release

@jackye1995 jackye1995 added this to the Iceberg 1.2.0 milestone Feb 23, 2023
appendFiles.commit();

return constructableStartVersion;
} catch (NotFoundException | IllegalArgumentException | DeltaStandaloneException e) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Just want to confirm we don't need to explicitly handle IOException here for when the file isn't found, we'll get a NotFoundException?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for pointing this out. The HadoopFileIO re-throw FileNotFoundExceptiion as NotFoundException and general IOException as RuntimeIOException.

private FileStatus lazyStat() {
if (stat == null) {
try {
this.stat = fs.getFileStatus(path);
} catch (FileNotFoundException e) {
throw new NotFoundException(e, "File does not exist: %s", path);
} catch (IOException e) {
throw new RuntimeIOException(e, "Failed to get status for file: %s", path);
}
}
return stat;
}

In this case, I think we only need to handle the NotFoundException since VACUUM may delete the data file. I've added a code block in buildDataFileFromAction to explicitly check file existence and throw NotFoundException if necessary.

Please let me know if you have any other concern here.

@JonasJ-ap
Copy link
Contributor Author

Thanks @jackye1995, @amogh-jahagirdar for reviewing this. I added the file existence check and refactored the integration tests based on your suggestions. @amogh-jahagirdar May I ask if you could review this PR again? Thank you in advance for your help!

Copy link
Contributor

@jackye1995 jackye1995 left a comment

Choose a reason for hiding this comment

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

looks good to me!

@jackye1995
Copy link
Contributor

Merging, thanks for the fix @JonasJ-ap , and thanks for the review @yyanyy and @amogh-jahagirdar !

@jackye1995 jackye1995 merged commit 141f4d4 into apache:master Mar 1, 2023
krvikash pushed a commit to krvikash/iceberg that referenced this pull request Mar 16, 2023
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.

Fix migration of Delta table that has performed VACUUM
4 participants