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

Check conflict at output level in CompactFiles #3926

Closed
wants to merge 2 commits into from

Conversation

ajkr
Copy link
Contributor

@ajkr ajkr commented May 31, 2018

CompactFiles checked whether the existing files conflicted with the chosen compaction. But it missed checking whether future files would conflict, i.e., when another compaction was simultaneously writing new files to the same range at the same output level.

Test Plan:

  • exposed the bug in a test case, verified it works after this fix

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.

@@ -852,6 +852,11 @@ Status CompactionPicker::SanitizeCompactionInputFilesForAllLevels(
}
}
}
if (RangeOverlapWithCompaction(smallestkey, largestkey, output_level)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

oops this is inside the loop, it should be able to go outside

@facebook-github-bot
Copy link
Contributor

@ajkr has updated the pull request. View: changes, changes since last import

@ajkr ajkr requested a review from siying May 31, 2018 23:20
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.

@ajkr
Copy link
Contributor Author

ajkr commented Jun 5, 2018

ping

@ajkr ajkr requested a review from anand1976 June 5, 2018 16:24
@@ -853,6 +853,11 @@ Status CompactionPicker::SanitizeCompactionInputFilesForAllLevels(
}
}
}
if (RangeOverlapWithCompaction(smallestkey, largestkey, output_level)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

How is it possible that there is no overlap of input files with running compactions, but there is overlap at output level?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a weird edge case, where the input files' key range is in a gap between files that are pending compaction to the same output level. The pending compaction merges the input files and can produce output files that cover the gap.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the clarification. In this edge case, we might end up with files in the output with overlapping key ranges. So checking for range overlap with pending compactions would detect that and not start the manual compaction.

@@ -853,6 +853,11 @@ Status CompactionPicker::SanitizeCompactionInputFilesForAllLevels(
}
}
}
if (RangeOverlapWithCompaction(smallestkey, largestkey, output_level)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the clarification. In this edge case, we might end up with files in the output with overlapping key ranges. So checking for range overlap with pending compactions would detect that and not start the manual compaction.

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 is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

huachaohuang added a commit to tikv/rocksdb that referenced this pull request Jun 7, 2018
* fix CompactFiles inclusion of older L0 files

Summary:
if we're moving any L0 files down, we need to include older L0 files since they may contain older versions of the keys being moved down.
Closes facebook#2845

Differential Revision: D5773800

Pulled By: ajkr

fbshipit-source-id: 9f0770a8eaaeea4c87df2e7a2a1d65bf9d7f4f7e

* fix hanging after CompactFiles with L0 overlap

Summary:
Bug report: https://www.facebook.com/groups/rocksdb.dev/permalink/1389452781153232/

Non-empty `level0_compactions_in_progress_` was aborting `CompactFiles` after incrementing `bg_compaction_scheduled_`, and in that case we never decremented it. This blocked future compactions and prevented DB close as we wait for scheduled compactions to finish/abort during close.

I eliminated `CompactFiles`'s dependency on `level0_compactions_in_progress_`. Since it takes a contiguous span of L0 files -- through the last L0 file if any L1+ files are included -- it's fine to run in parallel with other compactions involving L0. We make the same assumption in intra-L0 compaction.
Closes facebook#2849

Differential Revision: D5780440

Pulled By: ajkr

fbshipit-source-id: 15b15d3faf5a699aed4b82a58352d4a7bb23e027

* Check conflict at output level in CompactFiles (facebook#3926)

Summary:
CompactFiles checked whether the existing files conflicted with the chosen compaction. But it missed checking whether future files would conflict, i.e., when another compaction was simultaneously writing new files to the same range at the same output level.
Closes facebook#3926

Differential Revision: D8218996

Pulled By: ajkr

fbshipit-source-id: 21cb00a6fed4c8c62d3ed2ff810962e6bdc2fdfb
petermattis added a commit to petermattis/cockroach that referenced this pull request Jun 15, 2018
RocksDB was violating an invariant that no 2 sstables in a level
overlap. It isn't quite clear what the upshot of this violation is. At
the very least it would cause the overlapping tables to be compacted
together. It seems possible that it could lead to missing writes, but I
haven't been able to verify that.

Fixes cockroachdb#26693

Release note: None
petermattis added a commit to petermattis/cockroach that referenced this pull request Jun 15, 2018
RocksDB was violating an invariant that no 2 sstables in a level
overlap. It isn't quite clear what the upshot of this violation is. At
the very least it would cause the overlapping tables to be compacted
together. It seems possible that it could lead to missing writes, but I
haven't been able to verify that.

Fixes cockroachdb#26693

Release note: None
craig bot pushed a commit to cockroachdb/cockroach that referenced this pull request Jun 15, 2018
26755: release-2.0: Bump RocksDB pointer to grab facebook/rocksdb#3926 r=benesch,a-robinson a=petermattis

RocksDB was violating an invariant that no 2 sstables in a level
overlap. It isn't quite clear what the upshot of this violation is. At
the very least it would cause the overlapping tables to be compacted
together. It seems possible that it could lead to missing writes, but I
haven't been able to verify that.

Fixes #26693

Release note: None

Co-authored-by: Peter Mattis <[email protected]>
craig bot pushed a commit to cockroachdb/cockroach that referenced this pull request Jun 15, 2018
26753: storage: Add extra event to allocator rebalancing r=a-robinson a=a-robinson

Helps make the output of simulated allocator runs less confusing, since
otherwise it's not clear why we're considering removal from the range
and why the replicas being considered for removal includes one that
isn't even a real member of the range.

Release note: None

Would have made looking at the simulated allocator output from https://forum.cockroachlabs.com/t/how-to-enable-leaseholder-load-balancing/1732/3 a little more pleasant.

26754: Bump RocksDB pointer to grab facebook/rocksdb#3926 r=benesch,a-robinson a=petermattis

RocksDB was violating an invariant that no 2 sstables in a level
overlap. It isn't quite clear what the upshot of this violation is. At
the very least it would cause the overlapping tables to be compacted
together. It seems possible that it could lead to missing writes, but I
haven't been able to verify that.

Fixes #26693

Release note: None

Co-authored-by: Alex Robinson <[email protected]>
Co-authored-by: Peter Mattis <[email protected]>
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.

3 participants