core/rawdb: only complain loudly if truncating many items #21483
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When we originally implemented the freezer, it was disallowed to roll back items from it. In theory Geth will never do it itself during normal mode of operation, but in practice the user can call SetHead and Geth can roll back during fast sync. With the unified rollback handling, all these paths use the same code that printed the warning. This resulted in 2000 truncation warnings printed every time fast sync failed (2K headers rolled back).
This PR changes the behavior so that if only a single item is removed (SetHead will remove one-by-one since it needs to do additional maintenance after each), the log level is Debug, not Warn. If the freezer gets corrupted and a lot of data is removed we will still see the large truncation warnings.