Skip to content

Fix background scheduler branch completion#12033

Draft
flcl42 wants to merge 1 commit into
masterfrom
fix/background-task-scheduler-branch-completion
Draft

Fix background scheduler branch completion#12033
flcl42 wants to merge 1 commit into
masterfrom
fix/background-task-scheduler-branch-completion

Conversation

@flcl42

@flcl42 flcl42 commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Changes

  • Added a branch-level BlocksProcessed event to IBranchProcessor and emit it from BranchProcessor in a finally path after branch cleanup.
  • Updated BackgroundTaskScheduler to pause background tasks for the full non-sync branch-processing interval instead of resuming on the first per-block BlockProcessed event.
  • Serialized block-processing CTS replacement, token reads, and disposal behind the scheduler's block-processing lock.
  • Updated wrappers, test stubs, and the scheduler benchmark stub to forward or raise the branch-completion event.
  • Added regression coverage for the failure modes below.

Problems fixed

  • For multi-block branches, the scheduler previously resumed queued background work after the first BlockProcessed event even though later blocks in the same branch could still be processing.
  • If branch processing raised BlocksProcessing and then exited before a matching BlockProcessed, the scheduler could keep a cancelled block-processing CTS and leave queued or future work paused/cancelled until another successful block happened to reset it.
  • The scheduler no longer depends on BlocksProcessingEventArgs object identity for completion, so branch completion raised with fresh event args still restores normal scheduling.

Types of changes

What types of changes does your code introduce?

  • Bugfix (a non-breaking change that fixes an issue)
  • New feature (a non-breaking change that adds functionality)
  • Breaking change (a change that causes existing functionality not to work as expected)
  • Optimization
  • Refactoring
  • Documentation update
  • Build-related changes
  • Other: Description

Testing

Requires testing

  • Yes
  • No

If yes, did you write tests?

  • Yes
  • No

Notes on testing

  • Focused scheduler tests pass.
  • BalRecorder branch-processor tests pass.
  • Full solution analyzer-shaped release build passes with zero warnings and zero errors.
  • Diff whitespace check passes.

Documentation

Requires documentation update

  • Yes
  • No

Requires explanation in Release Notes

  • Yes
  • No

Remarks

Draft PR for review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant