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

Cancel tombstone skipping during bottommost compaction #7356

Conversation

riversand963
Copy link
Contributor

During bottommost compaction, RocksDB cannot simply drop a tombstone if
this tombstone is not in the earliest snapshot. The current behavior is: RocksDB
skips other internal keys (of the same user key) in the same snapshot range. In
the meantime, RocksDB should check for the shutting_down flag. Otherwise, it
is possible for a bottommost compaction that has already started running to take
a long time to finish, even if the application has tried to cancel all background jobs.

Test plan:
make check

Copy link
Contributor

@ltamasi ltamasi 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 @riversand963 ! LGTM with a couple of questions/minor comments.

@@ -565,11 +563,16 @@ void CompactionIterator::NextFromInput() {
// Handle the case where we have a delete key at the bottom most level
// We can skip outputting the key iff there are no subsequent puts for this
// key
assert(compaction_->KeyNotExistsBeyondOutputLevel(ikey_.user_key,
Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably also assert(compaction_); here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I ended up doing assert(!compaction_ || compaction_->KeyNot.....).


for (int i = 0; i < kNumL0Files / 4; ++i) {
ASSERT_OK(Put("a", "value"));
ASSERT_OK(Put("c", "value"));
Copy link
Contributor

Choose a reason for hiding this comment

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

Based on i < kNumL0Files / 4, I'm assuming the loop body is supposed to generate four files, is that correct? Maybe a Flush call is missing from here?


CompactRangeOptions cro;
Status s = db_->CompactRange(cro, nullptr, nullptr);
ASSERT_TRUE(s.IsShutdownInProgress());
Copy link
Contributor

@ltamasi ltamasi Sep 10, 2020

Choose a reason for hiding this comment

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

I'm wondering if we can somehow make sure that in this test that the new logic kicked in? (I believe you would get the same behavior with the old code as well once we'd churned through the tombstones.) Maybe instead of changing the condition of the while above, we could put a check with a sync point in the while loop's body, e.g. if (IsShuttingDown()) { TEST_SYNC_POINT(...); break; }?

@riversand963 riversand963 force-pushed the cancel-compact-skip-bottom-tombstones branch from a36b377 to c15c029 Compare September 11, 2020 00:46
@riversand963
Copy link
Contributor Author

Oh, thanks @ltamasi for the review....I just deleted the unit test because I think it was testing something not very interesting at the cost of introducing additional test sync points which make it more tedious for future code-refactoring...

@pdillinger
Copy link
Contributor

Update HISTORY.md?

@riversand963 riversand963 force-pushed the cancel-compact-skip-bottom-tombstones branch from c15c029 to fec0773 Compare September 11, 2020 23:13
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.

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

@riversand963 riversand963 deleted the cancel-compact-skip-bottom-tombstones branch September 12, 2020 01:23
@facebook-github-bot
Copy link
Contributor

@riversand963 merged this pull request in 205e577.

codingrhythm pushed a commit to SafetyCulture/rocksdb that referenced this pull request Mar 5, 2021
Summary:
During bottommost compaction, RocksDB cannot simply drop a tombstone if
this tombstone is not in the earliest snapshot. The current behavior is: RocksDB
skips other internal keys (of the same user key) in the same snapshot range. In
the meantime, RocksDB should check for the `shutting_down` flag. Otherwise, it
is possible for a bottommost compaction that has already started running to take
a long time to finish, even if the application has tried to cancel all background jobs.

Pull Request resolved: facebook#7356

Test Plan: make check

Reviewed By: ltamasi

Differential Revision: D23663241

Pulled By: riversand963

fbshipit-source-id: 25f8e9b51bc3bfa3353cdf87557800f9d90ee0b5
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