-
Notifications
You must be signed in to change notification settings - Fork 223
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
Streamline kvdb API and upgrade rocksdb to 0.19 #661
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.
I'm aboard to update these deps but it looks like the API for rocksdb::DBIterator has changed to Result<Option<_>>
which needs to fixed in order to compile
Yup, submitted a PR too quickly, but in the process of fixing this realized how to remove |
eeebcee
to
2ff8f23
Compare
The compilation fix is in 2957b4e An alternative would be to change the I don't have a strong preference between these two. |
6a6694e
to
d8b659f
Compare
Could also consider changing kvdb trait. |
Can you rebase now that #662 is merged for easier reviewing? |
Thanks for this. I was not sure whether to make more breaking changes or keep as is: #661 (comment), but I think having an iterator API that swallows errors might be a bad design and it's better to let the use bail out ASAP if needed (I imagine that'd be the default). Will make those changes to kvdb to streamline the API as well. |
yes this https://github.com/paritytech/polkadot/blob/0879bdbcd93ae96602d42e1c2f9fd54c752eace5/node/subsystem-util/src/database.rs#L147 was me being lazy to change the trait, seeing that rocksdb deps also return result, changing trait sounds right to me. |
d8b659f
to
62535e1
Compare
I don't blame you here. As you can see I was hesitant to make these breaking changes here myself. We need to improve our release and upgrade process so people are less afraid of making breaking changes. Updated the PR, please take a look. |
@@ -144,8 +146,8 @@ pub trait KeyValueDB: Sync + Send + parity_util_mem::MallocSizeOf { | |||
} | |||
|
|||
/// Check for the existence of a value by prefix. | |||
fn has_prefix(&self, col: u32, prefix: &[u8]) -> bool { | |||
self.get_by_prefix(col, prefix).is_some() | |||
fn has_prefix(&self, col: u32, prefix: &[u8]) -> io::Result<bool> { |
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.
Not sure whether folks care about whether the key was not found or an error occurred.... i.e, you could convert both Option::None and Result:Error to false
Further it also possible use get_by_prefix
if one wants to know the cause..
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.
True, but it was also inconsistent with has_key
method. I believe we should try to report the IO error to the user as soon as it happens and not swallow it in the lib. It might make it less ergonomic, but with ?
shouldn't be much of a problem.
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.
nicely done, looks good to me I had a couple optional minor comments...
The rocksdb upgrade seems non-breaking, but it uses
tikv-jemalloc-sys
transitively which links to the native libraryjemalloc
.It's about time we release a new version of each crate anyway.
Depends on: #662.