From bcd81fba2aad6d4a8d30a8e9d45e340381337a20 Mon Sep 17 00:00:00 2001 From: Cathy Teng Date: Mon, 24 Nov 2025 13:47:44 -0800 Subject: [PATCH 1/4] log missing WorkflowActionGroupStatus after bulk create --- src/sentry/workflow_engine/processors/action.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/sentry/workflow_engine/processors/action.py b/src/sentry/workflow_engine/processors/action.py index 82386e72f46906..c3d939edaa00b8 100644 --- a/src/sentry/workflow_engine/processors/action.py +++ b/src/sentry/workflow_engine/processors/action.py @@ -119,11 +119,21 @@ def update_workflow_action_group_statuses( id__in=statuses_to_update, date_updated__lt=now ).update(date_updated=now) - WorkflowActionGroupStatus.objects.bulk_create( + created_statuses = WorkflowActionGroupStatus.objects.bulk_create( missing_statuses, batch_size=1000, ignore_conflicts=True, ) + if len(missing_statuses) != len(created_statuses): + # pairs that weren't created + created_pairs = {(status.workflow_id, status.action_id) for status in created_statuses} + missing_pairs = { + (status.workflow_id, status.action_id) for status in missing_statuses + } - created_pairs + logger.warning( + "Failed to create WorkflowActionGroupStatus objects", + extra={"missing_pairs": missing_pairs}, + ) def get_unique_active_actions( From e558c98ac1b01c4dcb5140452e21cf925b716b06 Mon Sep 17 00:00:00 2001 From: Cathy Teng Date: Mon, 24 Nov 2025 14:14:10 -0800 Subject: [PATCH 2/4] use status.id to check if it was actually created --- src/sentry/workflow_engine/processors/action.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/sentry/workflow_engine/processors/action.py b/src/sentry/workflow_engine/processors/action.py index c3d939edaa00b8..9c41f4de434886 100644 --- a/src/sentry/workflow_engine/processors/action.py +++ b/src/sentry/workflow_engine/processors/action.py @@ -126,7 +126,11 @@ def update_workflow_action_group_statuses( ) if len(missing_statuses) != len(created_statuses): # pairs that weren't created - created_pairs = {(status.workflow_id, status.action_id) for status in created_statuses} + created_pairs = { + (status.workflow_id, status.action_id) + for status in created_statuses + if status.id is not None + } missing_pairs = { (status.workflow_id, status.action_id) for status in missing_statuses } - created_pairs From 25156113e8f891eec70092b056bf0c3345f1484d Mon Sep 17 00:00:00 2001 From: Cathy Teng Date: Mon, 24 Nov 2025 14:17:19 -0800 Subject: [PATCH 3/4] make the log nicer --- .../workflow_engine/processors/action.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/sentry/workflow_engine/processors/action.py b/src/sentry/workflow_engine/processors/action.py index 9c41f4de434886..d9424f988ea3a7 100644 --- a/src/sentry/workflow_engine/processors/action.py +++ b/src/sentry/workflow_engine/processors/action.py @@ -119,24 +119,18 @@ def update_workflow_action_group_statuses( id__in=statuses_to_update, date_updated__lt=now ).update(date_updated=now) - created_statuses = WorkflowActionGroupStatus.objects.bulk_create( + all_statuses = WorkflowActionGroupStatus.objects.bulk_create( missing_statuses, batch_size=1000, ignore_conflicts=True, ) - if len(missing_statuses) != len(created_statuses): - # pairs that weren't created - created_pairs = { - (status.workflow_id, status.action_id) - for status in created_statuses - if status.id is not None - } - missing_pairs = { - (status.workflow_id, status.action_id) for status in missing_statuses - } - created_pairs + missing_statuses = [ + (status.workflow_id, status.action_id) for status in all_statuses if status.id is None + ] + if missing_statuses: logger.warning( "Failed to create WorkflowActionGroupStatus objects", - extra={"missing_pairs": missing_pairs}, + extra={"missing_statuses": missing_statuses}, ) From 455d764a307575ac4b44c7abdeaf41608c8b7a94 Mon Sep 17 00:00:00 2001 From: Cathy Teng Date: Mon, 24 Nov 2025 14:31:22 -0800 Subject: [PATCH 4/4] rename var for typing --- src/sentry/workflow_engine/processors/action.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sentry/workflow_engine/processors/action.py b/src/sentry/workflow_engine/processors/action.py index d9424f988ea3a7..3580d600831948 100644 --- a/src/sentry/workflow_engine/processors/action.py +++ b/src/sentry/workflow_engine/processors/action.py @@ -124,13 +124,13 @@ def update_workflow_action_group_statuses( batch_size=1000, ignore_conflicts=True, ) - missing_statuses = [ + missing_status_pairs = [ (status.workflow_id, status.action_id) for status in all_statuses if status.id is None ] - if missing_statuses: + if missing_status_pairs: logger.warning( "Failed to create WorkflowActionGroupStatus objects", - extra={"missing_statuses": missing_statuses}, + extra={"missing_status_pairs": missing_status_pairs}, )