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

Prunes non-empty shard #7104

Closed
emhane opened this issue Mar 11, 2024 · 0 comments · Fixed by #7105
Closed

Prunes non-empty shard #7104

emhane opened this issue Mar 11, 2024 · 0 comments · Fixed by #7105
Labels
A-pruning Related to pruning or full node C-bug An unexpected or incorrect behavior

Comments

@emhane
Copy link
Member

emhane commented Mar 11, 2024

Describe the feature

Passing the check blocks.len() as usize != new_blocks.len() means that if new_blocks is empty, then blocks is non-empty. Hence, shards are being deleted that contain blocks that are higher than the target block. The target block is used to filter out blocks to give new_blocks vector.

// If there were blocks less than or equal to the target one
// (so the shard has changed), update the shard.
if blocks.len() as usize != new_blocks.len() {
// If there are no more blocks in this shard, we need to remove it, as empty
// shards are not allowed.
if new_blocks.is_empty() {
if key.as_ref().highest_block_number == u64::MAX {
let prev_row = cursor.prev()?;
match prev_row {
// If current shard is the last shard for the sharded key that
// has previous shards, replace it with the previous shard.
Some((prev_key, prev_value)) if key_matches(&prev_key, &key) => {
cursor.delete_current()?;
deleted += 1;
// Upsert will replace the last shard for this sharded key with
// the previous value.
cursor.upsert(key.clone(), prev_value)?;
}
// If there's no previous shard for this sharded key,
// just delete last shard completely.
_ => {
// If we successfully moved the cursor to a previous row,
// jump to the original last shard.
if prev_row.is_some() {
cursor.next()?;
}
// Delete shard.
cursor.delete_current()?;
deleted += 1;
}
}
}
// If current shard is not the last shard for this sharded key,
// just delete it.
else {
cursor.delete_current()?;
deleted += 1;
}
} else {
cursor.upsert(key.clone(), BlockNumberList::new_pre_sorted(new_blocks))?;
}
}

let new_blocks =
blocks.iter().skip_while(|block| *block <= to_block).collect::<Vec<_>>();

Additional context

No response

@emhane emhane added C-bug An unexpected or incorrect behavior A-pruning Related to pruning or full node labels Mar 11, 2024
This was referenced Mar 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-pruning Related to pruning or full node C-bug An unexpected or incorrect behavior
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant