-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
fix(aci milestone 3): clean up orphaned objects from workflow engine #90796
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(aci milestone 3): clean up orphaned objects from workflow engine #90796
Conversation
# is a schema change, it's completely safe to run the operation after the code has deployed. | ||
# Once deployed, run these manually via: https://develop.sentry.dev/database-migrations/#migration-deployment | ||
|
||
is_post_deployment = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Marked post-deploy, but it probably doesn't have to be.
This PR has a migration; here is the generated SQL for for --
-- Raw Python operation
--
-- THIS OPERATION CANNOT BE WRITTEN AS SQL |
tests/sentry/workflow_engine/migrations/test_0054_clean_up_orphaned_metric_alert_objects.py
Show resolved
Hide resolved
Codecov ReportAttention: Patch coverage is ✅ All tests successful. No failed tests found.
Additional details and impacted files@@ Coverage Diff @@
## master #90796 +/- ##
========================================
Coverage 87.80% 87.81%
========================================
Files 10283 10285 +2
Lines 583510 583651 +141
Branches 22569 22569
========================================
+ Hits 512338 512510 +172
+ Misses 70742 70711 -31
Partials 430 430 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How many rows are going to be affected here?
with transaction.atomic(router.db_for_write(Action)): | ||
orphaned_actions.delete() | ||
orphaned_dcgs.delete() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typically we prefer to not run large batch deletions like this, since it could potentially run for a long time and will time out. Usually we prefer to take the slower route of just iterating through the rows individually and deleting.
@wedamija ~700 data condition groups and ~250 actions. I can change it to iterate and delete. |
with transaction.atomic(router.db_for_write(Action)): | ||
for action in orphaned_actions: | ||
action.delete() | ||
for dcg in orphaned_dcgs: | ||
dcg.delete() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd also recommend not wrapping this entire operation in a transaction, because all involved rows will be locked for the whole transaction. Maybe it doesn't matter too much since they're orphaned, but better to be safe.
If you want to make sure the rows related to each other are in a transaction that's fine, but you'll just need to associate them and have a smaller transaction for each set of related rows. I think it's probably safe enough to just skip it though.
) | ||
|
||
|
||
class TestCleanUpOrphanedMetricAlertObjects(TestMigrations): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's comment this out now that it has proved this runs fine, just to make sure ci doesn't end up breaking.
Suspect IssuesThis pull request was deployed and Sentry observed the following issues:
Did you find this useful? React with a 👍 or 👎 |
After running this cleanup, we will fix an issue where some trigger actions had multiple entries in the AARTA table, which preventing users from editing alerts with this error.