-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
feat(workflow_engine): Split fast and slow condition evaluation #84275
Conversation
❌ 1 Tests Failed:
View the top 1 failed tests by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
33857a2
to
1a1c839
Compare
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.
logic changes lgtm but i'd like to clarify what we're actually enqueueing
if remaining_conditions: | ||
# If there are remaining conditions for the action filter to evaluate, | ||
# then return the list of conditions to enqueue | ||
enqueued_conditions.extend(remaining_conditions) |
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 had planned to enqueue the DataConditionGroup
, i think we can still do that here because the remaining_conditions
can only be slow conditions, or am i missing something about why it's better to enqueue the conditions themselves? or is this more generic in case remaining_conditions
might not only be slow conditions in the future?
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.
on second thought, probably need to rethink the enqueuing logic since i am planning to have the key be {workflow_id}:{group_id}:{dcg_id,...,dcg_id}
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.
yeah, i ended up changing the enqueue method a bit:
sentry/src/sentry/workflow_engine/processors/workflow.py
Lines 32 to 52 in 67d137e
def enqueue_workflow( | |
workflow: Workflow, | |
delayed_conditions: list[DataCondition], | |
event: GroupEvent, | |
source: WorkflowDataConditionGroupType, | |
) -> None: | |
project_id = event.group.project.id | |
buffer.backend.push_to_sorted_set(key=WORKFLOW_ENGINE_BUFFER_LIST_KEY, value=project_id) | |
condition_groups = ",".join( | |
str(condition.condition_group_id) for condition in delayed_conditions | |
) | |
value = json.dumps({"event_id": event.event_id, "occurrence_id": event.occurrence_id}) | |
buffer.backend.push_to_hash( | |
model=Workflow, | |
filters={"project": project_id}, | |
field=f"{workflow.id}:{event.group.id}:{condition_groups}:{source}", | |
value=value, | |
) |
Since each condition knows it's condition group, i just made the enqueue method signature a little more ergonomic
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.
yeah this works. will have to refactor my PR using this 😅
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.
out of curiosity, why's that? aren't you just reading from the buffer and that's all the format we chatted about this mornin'
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.
oh jk i need to learn to read
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 think i was misled that we are passing the conditions be enqueued when we're still actually enqueuing the
DataConditionGroup
, do we need to collect all the conditions in that case?
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.
eh, probably don't need them all, we could probably move that list coercion up and out of this method and just take a list of ids in the method signature, but can figure that out on the other PR :)
triggered_workflows.add(workflow) | ||
evaluation, remaining_conditions = workflow.evaluate_trigger_conditions(job) | ||
if remaining_conditions: | ||
workflows_to_enqueue.add(workflow) |
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 think we should enqueue the same thing in the buffer as in evaluate_workflow_action
filters, but i assume this is happening in a follow up PR
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.
Yep! rather than us trying to create a data structure here and then enqueue a bunch at the end, i ended up just enqueuing directly in the other PR. that made it so we don't need to have an additional query to match the workflows to the data condition groups when enqueuing them.
…filters, because the method takes a list of workflows
the complexity of delayed conditions.
… we don't evaluate up the stack - meaning if we have any slow conditions we can easily enqueue the condition, workflow, etc
…ll keep all the delayed processing / enqueuing of workflows into a single place.
1a1c839
to
df05a43
Compare
## Description This PR splits the fast / slow conditions when we evaluate the condition group. This method will use the condition group logic type to decide when to return slow conditions or if we can short circuit those conditions. Will Create a follow-up PR for enqueuing the slow conditions to the redis buffer (this was getting large) - Here's the draft of that PR, just need to add tests #84283
Description
This PR splits the fast / slow conditions when we evaluate the condition group. This method will use the condition group logic type to decide when to return slow conditions or if we can short circuit those conditions.
Will Create a follow-up PR for enqueuing the slow conditions to the redis buffer (this was getting large)