Catch up on missed automation runs#2292
Draft
Flix6x wants to merge 1 commit into
Draft
Conversation
Track the last processed minute in Redis (automation-runner:last-tick). If previous invocations of `flexmeasures jobs run-automations` missed some minutes (e.g. due to host downtime or overload), the next invocation also matches automations against the missed minutes, bounded by a new --max-catchup option (60 minutes by default; 0 disables). An automation due in several missed minutes still runs only once per invocation, as its timing parameters are resolved against the current time, so queueing multiple identical jobs would be wasteful. The per-(automation, minute) Redis guard keys still protect against concurrent invocations, also over overlapping catch-up windows. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Rbix8k1JfeUWNXEmHEZVpX
Documentation build overview
17 files changed ·
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
flexmeasures jobs run-automationswas stateless: if the host's cron missed a minute (downtime, overload), automations due in that minute were silently skipped forever.Solution
automation-runner:last-tick, set after each invocation completes). On each invocation, it processes every minute from just after the last tick through the current minute.--max-catchupoption (in minutes, default 60) bounds how far back the runner looks;0disables catching up. Without a recorded last tick (first run), only the current minute is processed.Changes
flexmeasures/data/services/automations.py: newget_due_automations_in_window(start, end)returning each due automation once, with its due minutes (DST-safe minute iteration);get_due_automationsnow delegates to it.flexmeasures/cli/jobs.py: catch-up window computation,--max-catchupoption, last-tick bookkeeping, updated help text.commands.rstone-liner, CLI changelog bullet.--max-catchupbounding (incl.0disabling catch-up), and first-run behavior.🤖 Generated with Claude Code
https://claude.ai/code/session_01Rbix8k1JfeUWNXEmHEZVpX