Skip to content

Fix scheduler bugs on v1.x.x#248

Merged
Marenz merged 4 commits intofrequenz-floss:v1.x.xfrom
Marenz:pr246-v1
Mar 12, 2026
Merged

Fix scheduler bugs on v1.x.x#248
Marenz merged 4 commits intofrequenz-floss:v1.x.xfrom
Marenz:pr246-v1

Conversation

@Marenz
Copy link
Contributor

@Marenz Marenz commented Mar 12, 2026

Rebased follow-up of #246 for v1.x.x.

  • restores the scheduler heap after removing queued events
  • emits the missing stop notification when an update lands on the stop boundary
  • adds regression coverage for both scheduler issues
  • adapts the new scheduler tests to the time-machine 3 API used on v1.x.x

@github-actions github-actions bot added part:docs Affects the documentation part:tests Affects the unit, integration and performance (benchmarks) tests part:dispatcher Affects the high-level dispatcher interface labels Mar 12, 2026
Marenz added 4 commits March 12, 2026 11:06
list.pop(idx) removes an arbitrary element from the heap without
restoring the heap property. Add heapify() after the removal to fix
the invariant.

Change the return type from bool to QueueItem | None so callers can
inspect the removed item (needed for the follow-up fix).

Signed-off-by: Mathias L. Baumann <mathias.baumann@frequenz.com>
When a dispatch update arrives at exactly the stop boundary,
_remove_scheduled consumes the pending stop event from the queue.
_update_changed_running_state does not fire because old_dispatch.started
and dispatch.started are both False at this point. The actor would then
remain running indefinitely.

Fix: if _remove_scheduled returned a stop event (priority == 1) and the
dispatch is no longer started, send the running-state change explicitly.

Signed-off-by: Mathias L. Baumann <mathias.baumann@frequenz.com>
Signed-off-by: Mathias L. Baumann <mathias.baumann@frequenz.com>
Signed-off-by: Mathias L. Baumann <mathias.baumann@frequenz.com>
@Marenz Marenz marked this pull request as ready for review March 12, 2026 10:12
@Marenz Marenz requested a review from a team as a code owner March 12, 2026 10:12
@Marenz Marenz requested review from llucax and stefan-brus-frequenz and removed request for a team March 12, 2026 10:12
@Marenz
Copy link
Contributor Author

Marenz commented Mar 12, 2026

This is essentially the same as the already approved PR, just on the correct branch. Merging..

@Marenz Marenz merged commit 8e716a9 into frequenz-floss:v1.x.x Mar 12, 2026
6 checks passed
@Marenz Marenz deleted the pr246-v1 branch March 12, 2026 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

part:dispatcher Affects the high-level dispatcher interface part:docs Affects the documentation part:tests Affects the unit, integration and performance (benchmarks) tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant