Repository navigation
feat: delete automation run records older than their time-to-live - #2908
Merged
Merged
Conversation
Pruning old runs needs the same rule, so that it never deletes a failure before the monitor reported it. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
FLEXMEASURES_AUTOMATION_DBLOGS_TTL sets a time-to-live per automation type. Once an hour, flexmeasures jobs run-automations deletes older runs, with their attempts and jobs, keeping each automation's latest run, runs under a live claim and failures the monitor did not report yet. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Documentation build overview
32 files changed ·
|
Keep pruning on every run-automations tick, also when nothing is due, next to main's stale-skip and run reports. Follow the schedule_revision to revision rename in the pruning tests. Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
…sed v1.1.3 (#2908) Signed-off-by: Vibe Nuage Agent <vibe@mistral.ai>
Open
1 task done
Flix6x
added a commit
that referenced
this pull request
Dec 5, 2026
Resolve the conflict with #2908 in automation_monitoring.py: main moved the criterion for an unreported failure into unalerted_failure_criterion, which pruning uses too, to keep failures until the monitor reported them. The exclusion of direct runs moves into that criterion, so a failed or stuck direct run, which is never reported, is pruned like any other run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: F.N. Claessen <claessen@seita.nl>
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.
Description
The
automation_run,automation_run_attemptandautomation_run_jobtables grow with every run, most of all for ingestion automations that run every minute.This PR deletes old runs once an hour, as part of
flexmeasures jobs run-automations. For example, with the defaults, an ingestion run scheduled 15 days ago is deleted with its attempts and jobs, while the automation's latest run is kept however old it is.FLEXMEASURES_AUTOMATION_DBLOGS_TTL, per automation type, with a"default"for plugin types, likeFLEXMEASURES_AUTOMATION_MIN_INTERVAL.Nonekeeps runs forever, for one type or, as the whole setting, for all of them.or when they are a failed or stuck run of a monitored automation that
flexmeasures monitor automationshas not reported yet (the monitor's criterion, now shared).It deletes in batches of 1,000 and starts no new batch after 30 seconds; whatever is left waits for the next hour. A failed pruning prints a warning and does not fail the command.
documentation/changelog.rstDecisions worth a look:
Side effects:
total, and the counts per state) now cover only the runs kept.VACUUM FULLreclaims the space.Look & Feel
How to test
Or by hand: let a few automations run, age their runs with
UPDATE automation_run SET scheduled_at = scheduled_at - interval '100 days';, delete the Redis keyflexmeasures:automation-run-pruning, and runflexmeasures jobs run-automations.Old successful runs are deleted, unreported failures and each automation's latest run stay. After
flexmeasures monitor automations, the next pruning deletes the reported failures too.Further Improvements
Related Items
Closes #2872
Sign-off