-
Notifications
You must be signed in to change notification settings - Fork 745
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
Backfill blob storage fix #5119
Merged
michaelsproul
merged 5 commits into
sigp:unstable
from
realbigsean:backfill-blob-storage-fix
Jan 23, 2024
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ad218ed
store blobs in the correct db in backfill
realbigsean 5cc8243
add database migration
realbigsean d616560
add migration file
realbigsean d5d89f9
remove log info suggesting deneb isn't schedule
realbigsean 4aa98ae
add batching in blob migration
realbigsean File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
beacon_node/beacon_chain/src/schema_change/migration_schema_v19.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
use crate::beacon_chain::BeaconChainTypes; | ||
use slog::{debug, info, Logger}; | ||
use std::sync::Arc; | ||
use store::{get_key_for_col, DBColumn, Error, HotColdDB, KeyValueStore, KeyValueStoreOp}; | ||
|
||
pub fn upgrade_to_v19<T: BeaconChainTypes>( | ||
db: Arc<HotColdDB<T::EthSpec, T::HotStore, T::ColdStore>>, | ||
log: Logger, | ||
) -> Result<Vec<KeyValueStoreOp>, Error> { | ||
let mut hot_delete_ops = vec![]; | ||
let mut blob_keys = vec![]; | ||
let column = DBColumn::BeaconBlob; | ||
|
||
debug!(log, "Migrating from v18 to v19"); | ||
// Iterate throught the blobs on disk. | ||
for res in db.hot_db.iter_column_keys::<Vec<u8>>(column) { | ||
let key = res?; | ||
let key_col = get_key_for_col(column.as_str(), &key); | ||
hot_delete_ops.push(KeyValueStoreOp::DeleteKey(key_col)); | ||
blob_keys.push(key); | ||
} | ||
let num_blobs = blob_keys.len(); | ||
debug!(log, "Collected {} blob lists to migrate", num_blobs); | ||
|
||
for key in blob_keys { | ||
let next_blob = db.hot_db.get_bytes(column.as_str(), &key)?; | ||
if let Some(next_blob) = next_blob { | ||
let key_col = get_key_for_col(column.as_str(), &key); | ||
db.blobs_db | ||
.do_atomically(vec![KeyValueStoreOp::PutKeyValue(key_col, next_blob)])?; | ||
} | ||
} | ||
debug!(log, "Wrote {} blobs to the blobs db", num_blobs); | ||
|
||
// Delete all the blobs | ||
info!( | ||
log, | ||
"Upgrading to v19 schema"; | ||
"info" => "ready for Deneb once it is scheduled" | ||
michaelsproul marked this conversation as resolved.
Show resolved
Hide resolved
|
||
); | ||
Ok(hot_delete_ops) | ||
} | ||
|
||
pub fn downgrade_from_v19<T: BeaconChainTypes>( | ||
_db: Arc<HotColdDB<T::EthSpec, T::HotStore, T::ColdStore>>, | ||
log: Logger, | ||
) -> Result<Vec<KeyValueStoreOp>, Error> { | ||
// No-op | ||
info!( | ||
log, | ||
"Downgrading to v18 schema"; | ||
); | ||
|
||
Ok(vec![]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Why do we need the downgrade if it's no-op?
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 was thinking so we could support 19 -> 17 for example