Skip to content

ref(rules): Fix get_condition_groups#72662

Merged
ceorourke merged 5 commits into
masterfrom
ceorourke/delayed-rule-processor-fix-rules-groups
Jun 13, 2024
Merged

ref(rules): Fix get_condition_groups#72662
ceorourke merged 5 commits into
masterfrom
ceorourke/delayed-rule-processor-fix-rules-groups

Conversation

@ceorourke

Copy link
Copy Markdown
Member

Fix get_condition_groups to not combine groups from multiple rules - this was causing the wrong rule to be fired for a given group.

I also renamed get_rule_to_slow_conditions to get_rules_to_slow_conditions since it's more accurate.

@ceorourke ceorourke requested a review from a team as a code owner June 12, 2024 22:50
@sentry

sentry Bot commented Jun 12, 2024

Copy link
Copy Markdown
Contributor

🔍 Existing Issues For Review

Your pull request is modifying functions with the following pre-existing issues:

📄 File: src/sentry/rules/processing/delayed_processing.py

Function Unhandled Issue
apply_delayed ValueError: invalid literal for int() with base 10: '1.0' sentry.rules.processing.delayed_p...
Event Count: 1

Did you find this useful? React with a 👍 or 👎

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Jun 12, 2024
@ceorourke ceorourke requested a review from wedamija June 12, 2024 22:51

@wedamija wedamija left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, I removed the fix and ran the tests and verified they failed without the fix

Comment on lines +352 to 354
assert len(rule_fire_histories) == 2
assert (self.rule1.id, self.group1.id) in rule_fire_histories
assert (self.rule1.id, group5.id) in rule_fire_histories
assert (rule5.id, group5.id) in rule_fire_histories

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why doesn't this fire anymore? It should still match this rule I think?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There were 3 like this that failed after the fix - group5 wasn't enqueued with self.rule1 so I don't think it should have actually fired.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, that makes sense. Damn, so we actually had a test that might have caught this earlier

Comment on lines +352 to 354
assert len(rule_fire_histories) == 2
assert (self.rule1.id, self.group1.id) in rule_fire_histories
assert (self.rule1.id, group5.id) in rule_fire_histories
assert (rule5.id, group5.id) in rule_fire_histories

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, that makes sense. Damn, so we actually had a test that might have caught this earlier

@codecov

codecov Bot commented Jun 13, 2024

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.06%. Comparing base (8d255a2) to head (f6bd4d8).
Report is 20 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #72662   +/-   ##
=======================================
  Coverage   78.05%   78.06%           
=======================================
  Files        6597     6597           
  Lines      294016   294055   +39     
  Branches    50716    50720    +4     
=======================================
+ Hits       229508   229565   +57     
+ Misses      58246    58229   -17     
+ Partials     6262     6261    -1     
Files Coverage Δ
src/sentry/rules/processing/delayed_processing.py 86.03% <100.00%> (ø)

... and 20 files with indirect coverage changes

else:
condition_groups[unique_condition] = DataAndGroups(
condition_data, rules_to_groups[rule.id]
condition_data, set(rules_to_groups[rule.id])

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For anyone reading, just pointing out that this is the fix - we copy the set here to avoid polluting the data

@saponifi3d saponifi3d left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉 nice! lgtm!

@ceorourke ceorourke merged commit c6e975c into master Jun 13, 2024
@ceorourke ceorourke deleted the ceorourke/delayed-rule-processor-fix-rules-groups branch June 13, 2024 16:35
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants