Allow HistoryPruner to be callable via decorator#11098
Allow HistoryPruner to be callable via decorator#11098damian-orzechowski wants to merge 11 commits intomasterfrom
HistoryPruner to be callable via decorator#11098Conversation
|
@claude review |
|
Claude finished @damian-orzechowski's task in 1m 40s —— View job Code Review
Overall the PR is well-conceived and the tests are good. There are a few issues worth addressing before merge. Critical1. The method reads // Unsafe: no lock held, _hasLoadedDeletePointer / _deletePointer can race
if (_hasLoadedDeletePointer && _deletePointer < _minDeletableBlockNumber)
_deletePointer = _minDeletableBlockNumber;Similarly, Significant2. New public methods are not on The stated goal is to allow Medium3. Per the coding-style rules, all public APIs require documentation comments with 4. Log message range notation is misleading ( // Range is half-open: [minDeletable, syncPivot), but the log says "({_minDeletableBlockNumber}, ...)"
_logger.Warn($"... Should be in range ({_minDeletableBlockNumber}, {_blockTree.SyncPivot.BlockNumber}).");The parentheses imply exclusive on both ends, but the actual condition is 5. The previous code had no timeout; this PR sets a default of 2 seconds. On a slow node or large pruning pass, 2 seconds will cause the operation to be cancelled every time, effectively making history pruning a no-op. Consider a larger default (e.g. 30 or 60 seconds), or document clearly in the config description that the previous behaviour was no timeout and this changes it. 6. public bool TryScheduleTask<TReq>(..., string source = null)
// ^^^^^^ should be string?In a nullable-enabled project, Minor7. Consider throwing 8. Missing The existing |
….com/NethermindEth/nethermind into feature/configurable-history-prunner
|
@claude re-review |
|
Claude finished @damian-orzechowski's task in 1m 59s —— View job Re-Review
Good improvement from the first pass. Here's the updated status: Fixed Since Previous Review
Still Open1. The previous code had no timeout. This PR introduces a 2-second default. On a slow node, archive chain, or first pruning pass after a long gap, 2 seconds will cancel the operation every single time, making pruning a de-facto no-op that logs Consider a significantly larger default (30–60 s), or document the upgrade impact in the PR description. 2. // Current — nullable warning in a nullable-enabled project
public bool TryScheduleTask<TReq>(..., string source = null)
// Fix:
public bool TryScheduleTask<TReq>(..., string? source = null)New Observations (no action required)
Overall the PR is in good shape. The two remaining items are minor — the nullability warning is a one-character fix, and the timeout default is a judgment call worth documenting. Ready to merge once those are addressed. |
|
@claude - regarding:
|
|
Claude finished @damian-orzechowski's task in 49s —— View job Re-Review (follow-up)
Both clarifications are correct — closing both remaining items. Point 1 — Confirmed: Point 2 — Confirmed: neither All previously raised issues are now resolved. The PR is ready to merge. |
| [ConfigItem( | ||
| Description = "The minimum block number that may be deleted during pruning. Block 0 is never deleted. Override when the chain genesis is not block 0.", | ||
| DefaultValue = "1")] | ||
| long MinDeletableBlockNumber { get; set; } |
There was a problem hiding this comment.
Do we need it as separate config? Can we just use the same thing we use to determine which block is genesis?
|
|
||
| return Task.CompletedTask; | ||
| }, source: "HistoryPruner")) | ||
| }, timeout: pruningTimeout, source: "HistoryPruner")) |
There was a problem hiding this comment.
what happens on pruningTimeout? Maybe better to use custom time-outable CancellationTokenSource that will cancel gracefully?
| [ConfigItem( | ||
| Description = "Maximum time in seconds allowed for a single history pruning pass. Set to 0 to disable the timeout.", | ||
| DefaultValue = "2")] | ||
| uint PruningTimeoutSeconds { get; set; } |
Fixes Closes Resolves #
Extend
HistoryPrunerto be more configurable and change method to public to be callable if wrapped / decorated.Changes
SchedulePruneHistorypublicPruningTimeoutSecondsTypes of changes
What types of changes does your code introduce?
Testing
Requires testing
If yes, did you write tests?
Notes on testing
Documentation
Requires documentation update
Requires explanation in Release Notes
Remarks