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 wrong value passed in compaction filter in BlobDB #10391

Conversation

sherriiiliu
Copy link
Contributor

@sherriiiliu sherriiiliu commented Jul 20, 2022

Summary:

New blobdb has a bug in compaction filter, where blob_value_ is not reset for next iterated key. This will cause blob_value_ not empty and previous value read from blob is passed into the filter function for next key, even if its value is not in blob. Fixed by reseting regardless of key type.

Test Case:
Add FilterByValueLength test case in DBBlobCompactionTest

@sherriiiliu
Copy link
Contributor Author

sherriiiliu commented Jul 28, 2022

@ltamasi @riversand963 could you please help review this bug fix? Thanks

@@ -214,6 +214,7 @@ bool CompactionIterator::InvokeFilterIfNeeded(bool* need_skip,
CompactionFilter::Decision filter = CompactionFilter::Decision::kUndetermined;
compaction_filter_value_.clear();
compaction_filter_skip_until_.Clear();
blob_value_.Reset();
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks so much for reporting and for the PR @sherriiiliu !

This issue is somewhat similar to what I'm addressing in #10490 w/r/t the DB iterator. I'm wondering if we could reset blob_value_ in e.g. CompactionIterator::Next() instead of here? It would have the same benefit as in the DB iterator, namely we would release any cache handles as soon as possible. (Also note that GC uses blob_value_ as well, so it might be non-empty for non-compaction filter related reasons.)

Copy link
Contributor Author

@sherriiiliu sherriiiliu Aug 9, 2022

Choose a reason for hiding this comment

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

Thanks @ltamasi for your suggestion. I have changed blob_value_ reset to be in the beginning of CompactionIterator::NextFromInput() while loop

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 again for the fix @sherriiiliu !

@facebook-github-bot
Copy link
Contributor

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

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