-
Notifications
You must be signed in to change notification settings - Fork 911
upgrade redb file format to v3 #7917
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
base: unstable
Are you sure you want to change the base?
Conversation
pub fn downgrade_from_v29<T: BeaconChainTypes>( | ||
_d: Arc<HotColdDB<T::EthSpec, T::HotStore, T::ColdStore>>, | ||
) -> Result<Vec<KeyValueStoreOp>, Error> { | ||
Err(Error::MigrationError("Cannot downgrade from v29: Redb file format upgrade is irreversible".to_string())) |
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 downgrade should only fail if redb is enabled and the database backend is redb
In all other cases it should just be a no-op
Just wanted to document here that redb https://docs.rs/redb/2.6.2/src/redb/db.rs.html#1202-1220 So once we push this change, new redb databases will be using the correct v3 format as well |
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.
Thanks for sticking through with this! This looks really good, mostly just have some things to remove
pub fn upgrade_to_v29<T: BeaconChainTypes>( | ||
db: Arc<HotColdDB<T::EthSpec, T::HotStore, T::ColdStore>>, | ||
) -> Result<Vec<KeyValueStoreOp>, Error> { | ||
if db.is_redb() { |
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.
this was nice for testing, but we no longer need this, you can just call upgrade
} | ||
#[cfg(feature = "redb")] | ||
BeaconNodeBackend::Redb(redb) => { | ||
info!("Running Redb v29 migration"); |
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.
Lets update to this log to "Updating Redb file format to v3"
match self { | ||
#[cfg(feature = "leveldb")] | ||
BeaconNodeBackend::LevelDb(_) => { | ||
info!("LevelDB upgrade: no migration needed"); |
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.
Lets update this log to "LevelDB, no upgrade required" and downgrade this log to debug
#[cfg(feature = "redb")] | ||
let _database_backend = DatabaseBackend::Redb; | ||
#[cfg(feature = "leveldb")] | ||
let database_backend = DatabaseBackend::LevelDb; | ||
|
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.
sorry, this must be something I pushed up, we can remove this
@@ -82,6 +84,8 @@ pub struct HotColdDB<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> { | |||
historic_state_cache: Mutex<HistoricStateCache<E>>, | |||
/// Chain spec. | |||
pub spec: Arc<ChainSpec>, | |||
/// Database backend type | |||
pub database_backend: Option<DatabaseBackend>, |
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.
remove this as well
@@ -1,3 +1,5 @@ | |||
#[cfg(feature = "redb")] | |||
use crate::config::DatabaseBackend; |
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.
can be removed
@@ -242,6 +246,7 @@ impl<E: EthSpec> HotColdDB<E, MemoryStore<E>, MemoryStore<E>> { | |||
config, | |||
hierarchy, | |||
spec, | |||
database_backend: None, |
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.
can be removed
@@ -294,6 +304,7 @@ impl<E: EthSpec> HotColdDB<E, BeaconNodeBackend<E>, BeaconNodeBackend<E>> { | |||
config, | |||
hierarchy, | |||
spec, | |||
database_backend: Some(database_backend), |
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.
can remove as well
lighthouse/Cargo.toml
Outdated
@@ -12,7 +12,7 @@ rust-version = "1.88.0" | |||
normal = ["target_check"] | |||
|
|||
[features] | |||
default = ["slasher-lmdb", "beacon-node-leveldb"] | |||
default = ["slasher-lmdb", "beacon-node-redb"] |
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.
set default back to leveldb (sorry I think I pushed up this change)
#[cfg(feature = "redb")] | ||
BeaconNodeBackend::Redb(redb) => { | ||
info!("Updating Redb file format to v3"); | ||
redb.upgrade()?; |
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.
note thta upgrade
returns true is successful and false if its already in the v3 format
https://docs.rs/redb/2.6.2/redb/struct.Database.html#method.upgrade
In all other failure cases it will raise an error
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!
@michaelsproul whenever you have a chance, would be great to get your review as well. Thanks!
Some required checks have failed. Could you please take a look @owanikin? 🙏 |
@owanikin we have a small ci failure, can you run |
Issue Addressed
#7911
Proposed Changes
v29
for Redb file-format upgrade.migration_schema_v29.rs
with:redb
feature.schema_change.rs
.