Skip to content

Commit f6aeecb

Browse files
committed
fix(aci): Retry process_delayed_workflows timeouts
1 parent 2096754 commit f6aeecb

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/sentry/workflow_engine/processors/delayed_workflow.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
)
6666
from sentry.workflow_engine.processors.workflow_fire_history import create_workflow_fire_histories
6767
from sentry.workflow_engine.tasks.actions import build_trigger_action_task_params, trigger_action
68+
from sentry.workflow_engine.tasks.utils import retry_timeouts
6869
from sentry.workflow_engine.types import DataConditionHandler, WorkflowEventData
6970
from sentry.workflow_engine.utils import log_context
7071

@@ -760,6 +761,7 @@ def repr_keys[T, V](d: dict[T, V]) -> dict[str, V]:
760761
),
761762
)
762763
@retry
764+
@retry_timeouts
763765
@log_context.root()
764766
def process_delayed_workflows(
765767
project_id: int, batch_key: str | None = None, *args: Any, **kwargs: Any

src/sentry/workflow_engine/tasks/utils.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
from functools import wraps
2+
3+
import sentry_sdk
14
from google.api_core.exceptions import DeadlineExceeded, RetryError, ServiceUnavailable
25

36
from sentry import nodestore
@@ -6,6 +9,8 @@
69
from sentry.issues.issue_occurrence import IssueOccurrence
710
from sentry.models.environment import Environment
811
from sentry.models.group import Group
12+
from sentry.taskworker.retry import retry_task
13+
from sentry.taskworker.workerchild import ProcessingDeadlineExceeded
914
from sentry.types.activity import ActivityType
1015
from sentry.utils.retries import ConditionalRetryPolicy, exponential_delay
1116
from sentry.workflow_engine.types import WorkflowEventData
@@ -82,3 +87,20 @@ def build_workflow_event_data_from_event(
8287
has_escalated=has_escalated,
8388
workflow_env=workflow_env,
8489
)
90+
91+
92+
def retry_timeouts(func):
93+
"""
94+
Schedule a task retry if the function raises ProcessingDeadlineExceeded.
95+
This exists because the standard retry decorator doesn't allow BaseExceptions.
96+
"""
97+
98+
@wraps(func)
99+
def wrapper(*args, **kwargs):
100+
try:
101+
return func(*args, **kwargs)
102+
except ProcessingDeadlineExceeded:
103+
sentry_sdk.capture_exception(level="info")
104+
retry_task()
105+
106+
return wrapper

0 commit comments

Comments
 (0)