-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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 reverse iterator in RocksDB #2398
Conversation
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.
It would be nice to have tests for reverse iteration with prefix. If can use examples from the mainnet, would be nice
@xgreenx I have added a test at rocksdb level and integration level. |
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.
Nice stuff. Thanks for spotting and fixing this!
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.
It seems that final solution doesn't match the description of the PR=D
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.
I think the current solution is more elegant. But it's still not clear to me why the old one was not working
Ohh, I see. We used |
@xgreenx Yes the description had one sentence that was outdated, I removed. |
The You are right all the tests are passing but the test on the playground on the mainnet data isn't working without |
I don't find a way to make one of the integration or unit test fails :/ |
So, did I get right that If you use the current fix but without |
@xgreenx yes. |
Linked Issues/PRs
Closes #2044
Description
Problem analysis
Our database columns use the prefix extractor configuration which allow rocksdb to make optimizations on storage based on prefix. However, this breaks the lexicographic order between prefixs and we need to pass a special option to the read iterator to bypass the "prefix sharding" (source: https://github.com/facebook/rocksdb/wiki/Prefix-Seek/3a5e28faf6c2d0ec1bdb99763043e1e3322007e9#how-to-ignore-prefix-bloom-filters-in-read).
Current solution
I took the same approach as before and started iteration from the next prefix using the bypass read option argument.
However I change the behavior to make only iterator to simplify and optimize the solution.
Better solution for the future
I think that breaking the "prefix sharding" from RocksDB to iterate can make the iterator way more costly.
There is a way to avoid it because we can iterate in reverse order inside a prefix (source: https://github.com/facebook/rocksdb/wiki/SeekForPrev) but we need to get the maximum value for a key in a given prefix to use it as a starting point of our iteration which is not possible to get in the current code because we don't have any information about the key.
Happy to here your thoughts @FuelLabs/client :)
EDIT: Not done : #2405
Checklist
Before requesting review