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

Compaction with timestamp: input boundaries #6645

Closed

Conversation

riversand963
Copy link
Contributor

@riversand963 riversand963 commented Apr 3, 2020

Towards making compaction logic compatible with user timestamp.
When computing boundaries and overlapping ranges for inputs of compaction, We need to compare SSTs by user key without timestamp.

Test plan (devserver):

make check

Several individual tests:

./version_set_test --gtest_filter=VersionStorageInfoTimestampTest.GetOverlappingInputs
./db_with_timestamp_compaction_test
./db_with_timestamp_basic_test

@riversand963 riversand963 added the WIP Work in progress label Apr 3, 2020
@riversand963 riversand963 changed the title [WIP] Ts compatible compaction [WIP] Timestamp compatible compaction Apr 3, 2020
@riversand963 riversand963 changed the title [WIP] Timestamp compatible compaction Timestamp compatible compaction Apr 10, 2020
@riversand963 riversand963 removed the WIP Work in progress label Apr 10, 2020
@riversand963 riversand963 changed the title Timestamp compatible compaction Timestamp compatible compaction - input boundary computation Apr 10, 2020
@riversand963 riversand963 changed the title Timestamp compatible compaction - input boundary computation Timestamp compatible compaction: input boundaries Apr 10, 2020
@riversand963 riversand963 changed the title Timestamp compatible compaction: input boundaries Compaction with timestamp: input boundaries Apr 10, 2020
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.

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.

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.

@facebook-github-bot
Copy link
Contributor

@riversand963 has updated the pull request. Re-import the pull request

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
Copy link
Contributor Author

cc @hliu18

@facebook-github-bot
Copy link
Contributor

@riversand963 has updated the pull request. Re-import the pull request

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.

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 patch @riversand963 ! Looks good, just some minor comments (please see below). Also, one general question: I suppose we'll need changes in other places like e.g. CompactionPicker, CompactionIterator, FileIndexer etc.; will those be handled in a separate PR?

db/db_with_timestamp_compaction_test.cc Outdated Show resolved Hide resolved
db/db_with_timestamp_compaction_test.cc Outdated Show resolved Hide resolved
}
ASSERT_OK(Flush());
// Wait for compaction to finish
ASSERT_OK(dbfull()->TEST_WaitForCompact());
Copy link
Contributor

Choose a reason for hiding this comment

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

So we're relying on automatic compactions here, right? I'm wondering if it would be better if we called CompactRange with for the range consisting only of key 99 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 think they will go through the same code path in LevelCompactionBuilder, thus should be the same.

test_util/testutil.cc Outdated Show resolved Hide resolved
test_util/testutil.cc Show resolved Hide resolved
test_util/testutil.cc Outdated Show resolved Hide resolved
test_util/testutil.cc Show resolved Hide resolved
test_util/testutil.cc Outdated Show resolved Hide resolved
Summary:
During compaction, timestamp should also be taken into accound when computing
overlapping ranges. If not, point lookup and range scan will return incorrect
results.

Test Plan:
make check
@facebook-github-bot
Copy link
Contributor

@riversand963 has updated the pull request. Re-import the pull request

@riversand963
Copy link
Contributor Author

Thanks for the patch @riversand963 ! Looks good, just some minor comments (please see below). Also, one general question: I suppose we'll need changes in other places like e.g. CompactionPicker, CompactionIterator, FileIndexer etc.; will those be handled in a separate PR?

Thanks @ltamasi for the detailed review.
Current implementation of user timestamp is such that user key + timestamp is treated by RocksDB compaction and other internals as a whole. Therefore, the same user key with different timestamps will be treated as different "user" keys by compaction logic. This PR makes sure that correct files must be picked for compaction. Once this is done, most of the original logic should work.
There are cases in which things can be tricky, and I decide to leave them for future PRs.

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.

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.

LGTM, thanks @riversand963 !

@riversand963 riversand963 deleted the ts-compatible-compaction branch April 10, 2020 23:10
@facebook-github-bot
Copy link
Contributor

@riversand963 merged this pull request in 0c05624.

facebook-github-bot pushed a commit that referenced this pull request Jun 12, 2021
Summary:
The subcompaction boundary picking logic does not currently guarantee
that all user keys that differ only by timestamp get processed by the same
subcompaction. This can cause issues with the `CompactionIterator` state
machine: for instance, one subcompaction that processes a subset of such KVs
might drop a tombstone based on the KVs it sees, while in reality the
tombstone might not have been eligible to be optimized out.
(See also #6645, which adjusted the way compaction inputs are picked for the
same reason.)

Pull Request resolved: #8393

Test Plan: Ran `make check` and the crash test script with timestamps enabled.

Reviewed By: jay-zhuang

Differential Revision: D29071635

Pulled By: ltamasi

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