-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
Expose deleted keys through iteration. #1084
Conversation
I can see your pain-point, the fact that a seek/next might not return quickly enough (because it has to iterate through a large number of deletes). You proposed two solutions:
Does anybody else have any other proposals of solving this problem? |
Thanks @joinwinds @joinwinds, I don't think we need a dedicated function like key_is_deleted(), can we reuse GetProperty() or status() to expose that the iterator is exposing a deleted key. |
this definitely sounds reasonable to me. what will your application d when it encounters Status::Incomplete()? |
@IslamAbdelRahman Good point about the virtual function. My change had to touch many unrelated test files just for the interface change. It would be a good option to expose the deletion status through status(). Regarding the Status::Incomplete() proposal, the burden on the application to handle this situation seems equivalent to exposing the deletion status for every key. In the example code snippet below, I think the code may look the same with both Status::Deleted() and Status::Incomplete() (Unless there are other situations where Incomplete() is more appropriate? Incomplete() is definitely a more generic name than deleted())
|
Agreed |
…l keys Summary: Operations like Seek/Next/Prev sometimes take too long to complete when there are many internal keys to be skipped. Adding an option, max_skippable_internal_keys -- which could be used to set a threshold for the maximum number of keys that can be skipped, will help to address these cases where it is much better to fail a request (as incomplete) than to wait for a considerable time for the request to complete. This feature -- to fail an iterator seek request as incomplete, is disabled by default when max_skippable_internal_keys = 0. It is enabled only when max_skippable_internal_keys > 0. This feature is based on the discussion mentioned in the PR #1084. Closes #2000 Differential Revision: D4753223 Pulled By: sagar0 fbshipit-source-id: 1c973f7
When there are too many deleted keys, we are seeing that Seek/Next are taking too long to return. That is resulting in our threads to lock up for a potentially unbounded amount of time. There are techniques to mitigate this problem as documented in https://github.com/facebook/rocksdb/wiki/Delete-A-Range-Of-Keys, but we wanted a predictable upper bound on the time an iteration can take before returning.
I am proposing a change where rocksdb will expose deleted keys through iteration. In this case, it is up to the user code to continuously call Next() until they find a non-deleted valid key. This will give our code the opportunity to periodically check the time and yield the thread if needed.
Before implementing, I also considered an alternative approach of passing a timeout to Seek/Next calls but that would have made the interface/implementation much more complicated.
PTAL. If this change looks acceptable, I will look into implementing some tests in the next round.