-
Notifications
You must be signed in to change notification settings - Fork 678
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
refactor: Clean flat state via range #9109
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.
overall looks good, well done!
core/store/src/flat/manager.rs
Outdated
shard_uid: ShardUId, | ||
shard_layout: ShardLayout, | ||
) -> Result<(), StorageError> { | ||
pub fn remove_flat_storage_for_shard(&self, shard_uid: ShardUId) -> Result<(), StorageError> { | ||
let mut flat_storages = self.0.flat_storages.lock().expect(POISONED_LOCK_ERR); | ||
|
||
match flat_storages.remove(&shard_uid) { |
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.
let refactor this to avoid nasty None => {}
case:
if let Some(flat_store) = flat_storages.remove(&shard_uid) {
...
}
@@ -307,24 +307,20 @@ impl FlatStorage { | |||
// TODO (#7327): call it just after we stopped tracking a shard. | |||
// TODO (#7327): remove FlatStateChanges. Consider custom serialization of keys to remove them by | |||
// prefix. | |||
// TODO (#7327): support range deletions which are much faster than naive deletions. For that, we |
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.
also remove the following comments above, that is no longer relevant:
// Removes all items belonging to the shard one by one.
// Note that it does not work for resharding.
// TODO (#7327): remove FlatStateChanges.
core/store/src/flat/storage.rs
Outdated
guard.shard_uid, | ||
&[DBCol::FlatState], | ||
); | ||
let removed_items = guard.store.iter(DBCol::FlatState).count(); |
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 is potentially expensive operation and the result is only used for logging, let's drop that part
core/store/src/flat/store_helper.rs
Outdated
@@ -57,11 +57,16 @@ pub fn remove_delta(store_update: &mut StoreUpdate, shard_uid: ShardUId, block_h | |||
store_update.delete(DBCol::FlatStateDeltaMetadata, &key); | |||
} | |||
|
|||
pub fn remove_all_deltas(store_update: &mut StoreUpdate, shard_uid: ShardUId) { | |||
pub fn remove_range_by_shard_uid( |
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 is potentially dangerous public API since it accepts any DBCol
while not all of those are prefixed by shard_uid
.
I suggest to keep that as a private helper function and expose 2 public functions:
pub(crate) fn remove_all_flat_state_values(store_update: &mut StoreUpdate, shard_uid: ShardUId) -> Result<..> {
remove_range_by_shard_uid(store_update, shard_uid, &DBCol::FlatState)
}
pub(crate) fn remove_all_deltas(store_update: &mut StoreUpdate, shard_uid: ShardUId) ...
also I suggest changing parameter cols: &[DBCol]
to col: &DBCol
and just calling it twice in remove_all_deltas
for changes and metadata.
Use range deletion in `clean_state` when removing values from `FlatState` column. Addresses #8332
Use range deletion in `clean_state` when removing values from `FlatState` column. Addresses #8332
Use range deletion in
clean_state
when removing values fromFlatState
column. Addresses #8332