Skip to content

feat(seer): Allow one active cron or manual run per automation - #132218

Draft
trevor-e wants to merge 10 commits into
claude/project-thread-m5jbynfrom
claude/project-thread-m5jbyn-exclusive-runs
Draft

trevor-e wants to merge 10 commits into
claude/project-thread-m5jbynfrom
claude/project-thread-m5jbyn-exclusive-runs

Conversation

@trevor-e

@trevor-e trevor-e commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Stacked on #132182.

Allows at most one queued or running cron or manual run per automation, with a partial unique index on (workflow_config). Event-triggered runs are left out, so parallel breaches still run. Also adds a partial index on date_added for active runs, for a future stuck-run sweeper.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@trevor-e trevor-e self-assigned this Nov 23, 2026
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Nov 23, 2026
@sentry

sentry Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Sentry Snapshot Testing

Name Added Removed Changed Renamed Unchanged Skipped Status
sentry-frontend
sentry-frontend
0 0 0 0 1062 0 ✅ Unchanged

⚙️ sentry-frontend Snapshot Settings

@cursor cursor Bot 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.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 4e58168. Configure here.

status__in=ACTIVE_WORKFLOW_RUN_STATUSES,
),
name="seer_nightshiftrun_one_active_exclusive_run",
),

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.

Exclusive-run constraint never applies: source is never set

Medium Severity

The new unique constraint only covers rows where source is cron or manual, but nothing writes source. SeerWorkflowRunLifecycle.create takes no source argument and sets only status=QUEUED. The other creation paths set neither field. Every run row has source NULL, so the constraint never applies and nothing stops two active cron or manual runs on the same automation.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 4e58168. Configure here.

@github-actions

Copy link
Copy Markdown
Contributor

This PR has a migration; here is the generated SQL for src/sentry/seer/migrations/0050_workflow_run_active_constraints.py

for 0050_workflow_run_active_constraints in seer

--
-- Create index seer_run_active_added_idx on field(s) date_added of model seerworkflowrun
--
CREATE INDEX CONCURRENTLY "seer_run_active_added_idx" ON "seer_nightshiftrun" ("date_added") WHERE "status" IN ('queued', 'running');
--
-- Create constraint seer_nightshiftrun_one_active_exclusive_run on model seerworkflowrun
--
CREATE UNIQUE INDEX CONCURRENTLY "seer_nightshiftrun_one_active_exclusive_run" ON "seer_nightshiftrun" ("workflow_config_id") WHERE ("source" IN ('cron', 'manual') AND "status" IN ('queued', 'running'));

This branch was successfully deployed

1 active (outdated) deployment
Preview — 6118b26d Deployed Nov 23, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants