-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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 bug when prefix_same_as_start = true and keys not in domain #5923
base: main
Are you sure you want to change the base?
Conversation
Summary: Prefix extractor needs to be invoked for a key only when it is in domain. However, when prefix_same_as_start = true, this assumption is broken. The fix is to add InDomain() check before any Transform() call when prefix_same_as_start = true. Test Plan: Add a unit test to cover prefix_same_as_start = true with seek keys and keys on DB not in domain.
assert(prefix_extractor_ != nullptr); | ||
assert(!prefix_same_as_start_ || prefix_extractor_ != nullptr); | ||
if (valid_ && prefix_same_as_start_ && | ||
prefix_extractor_->InDomain(saved_key_.GetUserKey())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If valid_
, can prefix_extractor_->InDomain(saved_key_.GetUserKey())
be false?
If |
ro.prefix_same_as_start = true; | ||
std::unique_ptr<Iterator> iter(NewIterator(ro)); | ||
|
||
// Behavior of prefix_same_as_start = ture with seek key not in domain |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this is one of the cases I was thinking about where we could consider making the iterator invalid.
Also, there's a typo ("true").
ASSERT_FALSE(iter->Valid()); | ||
ASSERT_OK(iter->status()); | ||
|
||
// Behavior of prefix_same_as_start = ture + SeekForPrev() is not defined |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here; also, it's SeekToFirst
/SeekToLast
, not SeekForPrev
. (We could also consider actually adding a test for say, SeekForPrev("e")
.)
Hi @siying! Thank you for your pull request. We require contributors to sign our Contributor License Agreement, and yours needs attention. You currently have a record in our system, but the CLA is no longer valid, and will need to be resubmitted. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
hi, Any updates in this issue ? we have used PrefixExtractor, but not all keys meet the InDomain of PrefixExtractor. When we enable total_ order_ seek, but prefix_same_as_ start still on, follow the comments in ReadOptions, prefix_same_as_ start=true && total_ order_ seek=true, prefixScan is not effective. However, when the Iterator is actually used, the process will be aborted because the traversal does not meet the InDomain constraint~ |
Summary: Prefix extractor needs to be invoked for a key only when it is in domain. However, when prefix_same_as_start = true, this assumption is broken. The fix is to add InDomain() check before any Transform() call when prefix_same_as_start = true.
Test Plan: Add a unit test to cover prefix_same_as_start = true with seek keys and keys on DB not in domain.