-
Notifications
You must be signed in to change notification settings - Fork 582
Fix history prune scheduling #9677
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
base: master
Are you sure you want to change the base?
Conversation
…oid exceptions In HistoryPruner add checks before going into lock and doing pruning. In historyPruner make pruning task exclusive - don't schedule another before previous isn't finished.
Move CancelledToken out of generic type Specify channel options explicitly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the IBackgroundTaskScheduler API to return a boolean success indicator instead of void, renaming ScheduleTask to TryScheduleTask. The changes also include refactoring of HistoryPruner to add concurrency control, spelling corrections, and related test updates.
Key Changes:
- Changed
ScheduleTasktoTryScheduleTaskwithboolreturn value across the codebase to indicate scheduling success/failure - Refactored
HistoryPruner.SchedulePruneHistoryto useTask.Runand added_currentlyPruningflag for concurrency control - Optimized
BackgroundTaskSchedulerby removing lock and using lock-free operations withInterlocked
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| Nethermind.Consensus/Scheduler/IBackgroundTaskScheduler.cs | Updated interface signature to return bool |
| Nethermind.Consensus/Scheduler/BackgroundTaskScheduler.cs | Implemented TryScheduleTask, removed lock, improved documentation, moved CancelledToken to class level |
| Nethermind.Network/P2P/Utils/BackgroundTaskSchedulerWrapper.cs | Updated method calls to use TrySchedule* variants |
| Nethermind.Network/P2P/ProtocolHandlers/ProtocolHandlerBase.cs | Updated calls to wrapper methods |
| Nethermind.Network/P2P/Subprotocols/Eth/V62/Eth62ProtocolHandler.cs | Updated background task scheduling calls |
| Nethermind.History/HistoryPruner.cs | Added concurrency control, changed TryPruneHistory from Task to void, refactored logic, fixed typos |
| Nethermind.Consensus.Test/Scheduler/BackgroundTaskSchedulerTests.cs | Updated test calls to use TryScheduleTask |
| Nethermind.Network.Test/P2P/Subprotocols/Eth/V62/Eth62ProtocolHandlerTests.cs | Updated mock implementation to return bool |
| Nethermind.History.Test/HistoryPrunerTests.cs | Removed await from TryPruneHistory calls since it's now void |
| Nethermind.Core.Test/RunImmediatelyScheduler.cs | Updated test scheduler to return bool |
| { | ||
| bool lockTaken = false; | ||
| // take lock before updating delete pointer | ||
| // take lock before updating delete the pointer |
Copilot
AI
Nov 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected spelling: "delete the pointer" should be "delete pointer"
| // take lock before updating delete the pointer | |
| // take lock before updating delete pointer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove change
src/Nethermind/Nethermind.Consensus/Scheduler/BackgroundTaskScheduler.cs
Outdated
Show resolved
Hide resolved
src/Nethermind/Nethermind.Consensus/Scheduler/BackgroundTaskScheduler.cs
Outdated
Show resolved
Hide resolved
src/Nethermind/Nethermind.Consensus/Scheduler/BackgroundTaskScheduler.cs
Show resolved
Hide resolved
src/Nethermind/Nethermind.Consensus/Scheduler/BackgroundTaskScheduler.cs
Outdated
Show resolved
Hide resolved
src/Nethermind/Nethermind.Consensus/Scheduler/BackgroundTaskScheduler.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.
src/Nethermind/Nethermind.Consensus/Scheduler/BackgroundTaskScheduler.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@LukaszRozmej I've opened a new pull request, #9679, to work on those changes. Once the pull request is ready, I'll request review from you. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…heduler.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
| { | ||
| bool lockTaken = false; | ||
| // take lock before updating delete pointer | ||
| // take lock before updating delete the pointer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove change
Changes
BackgroundTaskScheduler.ScheduleTask->TryScheduleTaskand avoid exceptionsHistoryPruneradd checks before going into lock and doing pruning.HistoryPrunermake pruning task exclusive - don't schedule another before previous isn't finished.BackgroundTaskSchedulerCancelledTokenout of generic typeTypes of changes
What types of changes does your code introduce?
Testing
Requires testing
If yes, did you write tests?
Notes on testing
BackgroundTaskSchedulerwon't be throwing exceptions which can affect networking a bit?)