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

Update MultiGet to provide consistent CF view for kPersistedTier #13433

Closed
wants to merge 2 commits into from

Conversation

cbi42
Copy link
Member

@cbi42 cbi42 commented Mar 3, 2025

Summary: when reading with ReadOptions::read_tier = kPersistedTier and with a snapshot, MultiGet allows the case where some CF is read before a flush and some CF is read after the flush. This is not desirable, especially when atomic_flush is enabled and users use MultiGet to do some consistency checks on the data in SST files. This PR updates the code path for SuperVersion acquisition to get a consistent view across when kPersistedTier is used.

Test plan: a new unit test that could be flaky without this change.

@facebook-github-bot
Copy link
Contributor

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

@cbi42 cbi42 requested a review from jaykorean March 3, 2025 21:17
@jaykorean jaykorean requested a review from anand1976 March 3, 2025 22:05
Copy link
Contributor

@jaykorean jaykorean left a comment

Choose a reason for hiding this comment

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

Nice fix! Just one nit comment.

@@ -2753,29 +2753,30 @@ Status DBImpl::MultiCFSnapshot(const ReadOptions& read_options,
// sure.
constexpr int num_retries = 3;
for (int i = 0; i < num_retries; ++i) {
last_try = (i == num_retries - 1);
acquire_mutex = ((i == num_retries - 1) && !read_options.snapshot) ||
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I'd change the order.

acquire_mutex =  read_options.read_tier == kPersistedTier || ((i == num_retries - 1) && !read_options.snapshot);

Also consider updating the comment above that if read_tier is kPersistentTier we won't bother do the two first try without lock and just acquire the mutex and get the SV.

Copy link
Member Author

Choose a reason for hiding this comment

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

I added some comment. read_options.read_tier == kPersistedTier is usually false so I ordered it last.

@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

@cbi42 merged this pull request in 7e272d2.

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