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

[pruner] remove open iterator between await points #11808

Merged
merged 1 commit into from
May 8, 2023
Merged
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
16 changes: 6 additions & 10 deletions crates/sui-core/src/authority/authority_store_pruner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,23 +169,19 @@ impl AuthorityStorePruner {
"Starting object pruning. Current epoch: {}. Latest pruned checkpoint: {}",
current_epoch, checkpoint_number
);
let iter = checkpoint_store
.certified_checkpoints
.iter()
.skip_to(&(checkpoint_number + 1))?
.map(|(k, ckpt)| (k, ckpt.into_inner()));

#[allow(clippy::explicit_counter_loop)]
for (_, checkpoint) in iter {
checkpoint_number = *checkpoint.sequence_number();

loop {
let Some(ckpt) = checkpoint_store.certified_checkpoints.get(&(checkpoint_number + 1))? else {break;};
let checkpoint = ckpt.into_inner();
// Skipping because checkpoint's epoch or checkpoint number is too new.
// We have to respect the highest executed checkpoint watermark because there might be
// parts of the system that still require access to old object versions (i.e. state accumulator)
if (current_epoch < checkpoint.epoch() + config.num_epochs_to_retain)
|| (checkpoint_number > highest_executed_checkpoint)
|| (*checkpoint.sequence_number() > highest_executed_checkpoint)
{
break;
}
checkpoint_number = *checkpoint.sequence_number();
checkpoints_in_batch += 1;
if network_total_transactions == checkpoint.network_total_transactions {
continue;
Expand Down
3 changes: 2 additions & 1 deletion crates/typed-store/src/rocks/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ use serde::{de::DeserializeOwned, Serialize};
pub struct Iter<'a, K, V> {
cf_name: String,
db_iter: RocksDBRawIter<'a>,
_phantom: PhantomData<(K, V)>,
// *const here is an equivalent to `impl !Send for Iter` (which is not a stable feature at the moment)
_phantom: PhantomData<*const (K, V)>,
direction: Direction,
is_initialized: bool,
_timer: Option<HistogramTimer>,
Expand Down