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

Fix unexpected compaction error for compact files #8024

Closed
wants to merge 3 commits into from

Conversation

Connor1996
Copy link
Contributor

@Connor1996 Connor1996 commented Mar 4, 2021

Summary:
When doing CompactFiles on the files of multiple levels(num_level > 2) with L0 is included, the compaction would fail like this.
image

The reason is that in VerifyCompactionFileConsistency it checks the levels between the L0 and base level should be empty, but it regards the compaction triggered by CompactFiles as an L0 -> base level compaction wrongly.

The condition is committed several years ago, whereas it isn't correct anymore.

 if (vstorage->compaction_style_ == kCompactionStyleLevel &&
        c->start_level() == 0 && c->num_input_levels() > 2U)

So this PR just deletes the incorrect check.

Test Plan:
make check

Signed-off-by: Connor1996 <zbk602423539@gmail.com>
@yiwu-arbug
Copy link
Contributor

@ajkr Is there anyone can take a look and merge the PR? Thanks.

CI failure looks irrelevant.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@ajkr has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link
Contributor

@ajkr ajkr left a comment

Choose a reason for hiding this comment

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

Agreed the check is incorrect and can be removed.

num_input_levels == output_level - start_level + 1

My reading of the code suggests this is still true today. Is it not? That condition can be true and the check can still be incorrect since that condition doesn't imply anything about whether the input levels are empty.

@yiwu-arbug
Copy link
Contributor

Agreed the check is incorrect and can be removed.

num_input_levels == output_level - start_level + 1

My reading of the code suggests this is still true today. Is it not? That condition can be true and the check can still be incorrect since that condition doesn't imply anything about whether the input levels are empty.

The issue is not about level compaction, but about when we issue CompactFiles to compact some files across multiple levels, where the check is incorrect.

@Connor1996
Copy link
Contributor Author

@ajkr the test fails but seems unrelated. Could you help to take a look?

@Connor1996
Copy link
Contributor Author

Agreed the check is incorrect and can be removed.

num_input_levels == output_level - start_level + 1

My reading of the code suggests this is still true today. Is it not? That condition can be true and the check can still be incorrect since that condition doesn't imply anything about whether the input levels are empty.

num_input_levels == output_level - start_level + 1 is not true today. As I understood, num_input_levels should be the number of levels involved in compaction input.

@ajkr
Copy link
Contributor

ajkr commented Mar 23, 2021

As I understood, num_input_levels should be the number of levels involved in compaction input.

I thought the below code fills in entries for all the levels not explicitly provided, which would be L1-L4 in your example. num_input_levels comes from the size of that vector.

for (int level = first_non_empty_level; level <= last_non_empty_level;
++level) {
matched_input_files[level].level = level;
input_files->emplace_back(std::move(matched_input_files[level]));
}

Anyways, this isn't a blocking issue - I am just waiting on somebody to accept the internal PR to land it.

@Connor1996
Copy link
Contributor Author

As I understood, num_input_levels should be the number of levels involved in compaction input.

I thought the below code fills in entries for all the levels not explicitly provided, which would be L1-L4 in your example. num_input_levels comes from the size of that vector.

for (int level = first_non_empty_level; level <= last_non_empty_level;
++level) {
matched_input_files[level].level = level;
input_files->emplace_back(std::move(matched_input_files[level]));
}

Anyways, this isn't a blocking issue - I am just waiting on somebody to accept the internal PR to land it.

Oh, I see.

@facebook-github-bot
Copy link
Contributor

@Connor1996 has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@ajkr has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@ajkr merged this pull request in f06b761.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants