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
Keep Cache and Env alive with Rc #497
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.
Looking good to me! 👍
I'm not one hundred percent sure, but I'm afraid that yes. I need to check the RocksDB code more thoroughly, though. |
src/db_options.rs
Outdated
} | ||
|
||
#[derive(Default)] | ||
pub struct BlockBasedOptionsMustOutliveDB { |
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.
Does it really need to be public rather than pub(crate)
? If so then I'd rename it to BlockBasedCache
or something because it seems weird name as for public API.
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 could be private!
I'm saving also the |
@acrrd resolve please conflicts. Thanks. |
Done,thanks. |
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.
LGTM
Fix #462.
Checkpoint
to ensure that it does not outlive theDB
Cache
andEnv
in anRc
and keep a copy of that in the database to ensure that they are not dropped before the database is.This add two auxiliary structs where to keep
Cache
andEnv
that are set usingset_row_cache
inOptions
orset_block_cache
,set_block_compressed
inBlockBasedOptions
. When aDB
is open this structs are cloned and kept in the database to ensure the lifetime requirements are met.This approach allow us to have an unchanged api (with the exception of
Checkpoint
life time) but the compiler will not help us if we forget to keep track of something. Implementing this with lifetime will require to have four lifetimes parameters in (at least),Options
,BlockBasedOptioins
,DB
, andColumnFamilyDescriptor
.Do we need to keep track of
Cache
andEnv
that are in theOptions
insideColumnFamilyDescriptor
when we open a database through them?