Skip to content
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

fix(state-sync): clean up DBCol::StateParts when state snapshot is deleted #12199

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions core/store/src/adapter/trie_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ impl<'a> TrieStoreUpdateAdapter<'a> {
)
}

pub fn delete_state_parts(&mut self) {
self.store_update.delete_all(DBCol::StateParts)
}

pub fn delete_all_state(&mut self) {
self.store_update.delete_all(DBCol::State)
}
Expand Down
12 changes: 12 additions & 0 deletions core/store/src/trie/state_snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,18 @@ impl ShardTries {
}
}

// this will delete any state snapshot parts from db. Will retry 3 times
for _ in 0..3 {
let mut store_update = self.store_update();
store_update.delete_state_parts();
match store_update.commit() {
Ok(_) => break,
Err(err) => {
tracing::error!(target: "state_snapshot", ?err, "Failed to clear StatePart column in rocksdb");
}
}
}

metrics::HAS_STATE_SNAPSHOT.set(0);
}

Expand Down
Loading