-
Notifications
You must be signed in to change notification settings - Fork 616
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
feat(resharding): flat storage resharding mvp #12164
base: master
Are you sure you want to change the base?
Changes from all commits
51f9f44
eb421de
c1a71a6
9234160
c39b476
f977326
d6823d3
0195907
c7a6875
4c7e9b2
79730a4
ad83e0b
ae82453
e735755
fc38090
75c42b5
3848c40
306c502
b9f11d4
7fe014e
d02fc52
cf8ec95
f45cc9e
3c188c5
ac6d642
9269c37
7ad602e
d0b3125
df869fc
e1f3b5d
6d4188c
d6b5ab3
c52b947
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
//! `CatchingUp`: moves flat storage head forward, so it may reach chain final head. | ||
//! `Ready`: flat storage is created and it is up-to-date. | ||
|
||
use crate::flat_storage_resharder::FlatStorageResharder; | ||
use crate::types::RuntimeAdapter; | ||
use crate::{ChainStore, ChainStoreAccess}; | ||
use assert_matches::assert_matches; | ||
|
@@ -388,6 +389,12 @@ impl FlatStorageShardCreator { | |
FlatStorageStatus::Disabled => { | ||
panic!("initiated flat storage creation for shard {shard_id} while it is disabled"); | ||
} | ||
// If the flat storage is undergoing resharding it means it was previously created successfully, | ||
// but resharding itself hasn't been finished. | ||
// This case is a no-op because the flat storage resharder has already been created in `create_flat_storage_for_current_epoch`. | ||
FlatStorageStatus::Resharding(_) => { | ||
return Ok(true); | ||
} | ||
}; | ||
Ok(false) | ||
} | ||
|
@@ -403,10 +410,13 @@ pub struct FlatStorageCreator { | |
impl FlatStorageCreator { | ||
/// For each of tracked shards, either creates flat storage if it is already stored on DB, | ||
/// or starts migration to flat storage which updates DB in background and creates flat storage afterwards. | ||
/// | ||
/// Also resumes any resharding operation which was already in progress. | ||
pub fn new( | ||
epoch_manager: Arc<dyn EpochManagerAdapter>, | ||
runtime: Arc<dyn RuntimeAdapter>, | ||
chain_store: &ChainStore, | ||
flat_storage_resharder: &FlatStorageResharder, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't completely understand why is flat_storage_resharder a part of FlatStorageCreator? The FlatStorageCreator is created at the time of calling new() in client. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Basically the
In normal flow the resharding of flat storage would be initiated by the resharding manager, but that part is not done yet |
||
num_threads: usize, | ||
) -> Result<Option<Self>, Error> { | ||
let flat_storage_manager = runtime.get_flat_storage_manager(); | ||
|
@@ -420,6 +430,7 @@ impl FlatStorageCreator { | |
&epoch_manager, | ||
&flat_storage_manager, | ||
&runtime, | ||
&flat_storage_resharder, | ||
)?; | ||
|
||
// Create flat storage for the shards in the next epoch. This only | ||
|
@@ -447,6 +458,7 @@ impl FlatStorageCreator { | |
epoch_manager: &Arc<dyn EpochManagerAdapter>, | ||
flat_storage_manager: &FlatStorageManager, | ||
runtime: &Arc<dyn RuntimeAdapter>, | ||
_flat_storage_resharder: &FlatStorageResharder, | ||
) -> Result<HashMap<ShardUId, FlatStorageShardCreator>, Error> { | ||
let epoch_id = &chain_head.epoch_id; | ||
tracing::debug!(target: "store", ?epoch_id, "creating flat storage for the current epoch"); | ||
|
@@ -473,6 +485,10 @@ impl FlatStorageCreator { | |
); | ||
} | ||
FlatStorageStatus::Disabled => {} | ||
FlatStorageStatus::Resharding(_status) => { | ||
// TODO(Trisfald): call resume | ||
// flat_storage_resharder.resume(shard_uid, &status, ...)?; | ||
Comment on lines
+489
to
+490
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this a todo for this PR or later? I'm fine with later but I just saw that the resume method is already implemented so might as well call it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is meant for a second PR, I'll need to see how to link everything together |
||
} | ||
} | ||
} | ||
|
||
|
@@ -502,7 +518,8 @@ impl FlatStorageCreator { | |
} | ||
FlatStorageStatus::Empty | ||
| FlatStorageStatus::Creation(_) | ||
| FlatStorageStatus::Disabled => { | ||
| FlatStorageStatus::Disabled | ||
| FlatStorageStatus::Resharding(_) => { | ||
// The flat storage for children shards will be created | ||
// separately in the resharding process. | ||
} | ||
|
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.
nit: The formatting seems a bit off, I use an vs code extension called "rewrap" it has some on the fly and on demand formatting (shortcut).