controller: clean up open alerts when a spec is deleted#2847
Open
controller: clean up open alerts when a spec is deleted#2847
Conversation
e0949cb to
b9aaffd
Compare
When a task with active alerts is deleted, the alert resolution actions were never applied, leaving orphaned rows in `alert_history` with `resolved_at = NULL`. The `alertHistory` query then returned these phantom alerts for tasks that no longer exist. * Add `cleanup_open_alerts()` that sets `resolved_at` and deletes the associated notification tasks without sending resolution emails * Call it in `Outcome::apply` before the hard delete when `live_spec_deleted` is true * Add a one-time migration to resolve existing orphaned alerts and their notification tasks Fixes #2846
b9aaffd to
62096c4
Compare
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.
When a task with active alerts is deleted, the alert resolution actions were never applied, leaving orphaned rows in
alert_historywithresolved_at = NULL. ThealertHistoryquery then returned these phantom alerts for tasks that no longer exist.cleanup_open_alerts()that setsresolved_atand deletes the associated notification tasks without sending resolution emailsOutcome::applybefore the hard delete whenlive_spec_deletedis trueFixes #2846