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

A bug when using a prefix_extractor with a comparator. #12855

Closed
wqshr12345 opened this issue Jul 11, 2024 · 3 comments
Closed

A bug when using a prefix_extractor with a comparator. #12855

wqshr12345 opened this issue Jul 11, 2024 · 3 comments
Assignees
Labels
bug Confirmed RocksDB bugs

Comments

@wqshr12345
Copy link
Contributor

Note: Please use Issues only for bug reports. For questions, discussions, feature requests, etc. post to dev group: https://groups.google.com/forum/#!forum/rocksdb or https://www.facebook.com/groups/rocksdb.dev

I noticed in the comments about prefix_extractor in options.h, it is mentioned:
image

This means — all keys with the same prefix must be in a contiguous group by comparator order.
In the LevelIterator::Seek(), I noticed the following logic:
image

The meaning of this code is that during PrefixSeek, it can be pre-determined whether it is necessary to actually enter the next file for seeking based on the prefix value of the first key in the next file.
In fact,it is based on the assumption that "all keys with the same prefix must be in a contiguous group by comparator order".
However, I believe using user_comparator_.CompareWithoutTimestamp() is an incorrect usage. To compare "same prefix", it is more appropriate to use Slice's own Compare. The user comparator is not responsible for comparing prefixes.

@cbi42 cbi42 added the bug Confirmed RocksDB bugs label Jul 13, 2024
@cbi42
Copy link
Member

cbi42 commented Jul 13, 2024

Hi - using Slice's own compare makes sense. Would you like to contribute a fix?

@wqshr12345
Copy link
Contributor Author

@cbi42 Yes,I'd like to create a pr to fix it.

@wqshr12345
Copy link
Contributor Author

@cbi42 I have create a pr #12862 to fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Confirmed RocksDB bugs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants