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

[Executino] Chunk data pack pruning config fix #7112

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
7 changes: 4 additions & 3 deletions engine/execution/pruner/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ func LoopPruneExecutionDataFromRootToLatestSealed(
return fmt.Errorf("failed to get next and latest to prune: %w", err)
}

// report the target pruned height and pruned height
metrics.ExecutionTargetChunkDataPackPrunedHeight(latestToPrune)
metrics.ExecutionLastChunkDataPackPrunedHeight(nextToPrune - 1)

commitDuration := 2 * time.Millisecond // with default batch size 1200, the avg commit duration is 2ms
batchCount, totalDuration := EstimateBatchProcessing(
nextToPrune, latestToPrune,
Expand All @@ -77,9 +81,6 @@ func LoopPruneExecutionDataFromRootToLatestSealed(
time.Now().Add(config.SleepAfterEachIteration).Add(totalDuration).UTC(),
)

// report the target pruned height
metrics.ExecutionTargetChunkDataPackPrunedHeight(latestToPrune)

select {
case <-ctx.Done():
return nil
Expand Down
5 changes: 4 additions & 1 deletion module/block_iterator/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,11 @@ func (n *PersistentIteratorState) NextRange() (rg module.IteratorRange, hasNext
return module.IteratorRange{}, false, nil
}

// latest could be less than next, if the pruning-threshold was increased, which means
// we would like to keep more data than before.
// in this case, we should not iterate any block.
if latest < next {
return module.IteratorRange{}, false, fmt.Errorf("latest block is less than next block: %d < %d", latest, next)
return module.IteratorRange{}, false, nil
}

// iterate from next to latest (inclusive)
Expand Down
9 changes: 9 additions & 0 deletions module/block_iterator/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,14 @@ func TestProgress(t *testing.T) {
rg, hasNext, err = progress.NextRange()
require.NoError(t, err)
require.False(t, hasNext)

// now initialize again with a different latest that which cause latest < next
// verify there will be no block to iterate
initializer = store.NewConsumerProgress(pebbleimpl.ToDB(db), "test")
progress, err = NewPersistentIteratorState(initializer, root, getLatest)
require.NoError(t, err)
_, hasNext, err = progress.NextRange()
require.NoError(t, err)
require.False(t, hasNext) // has no block to iterate
})
}
Loading