Skip to content
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

FIX: Prevent race condition in recurring automations #26828

Merged
merged 2 commits into from May 1, 2024

Conversation

OsamaSayegh
Copy link
Member

Recurring automations are triggered by a scheduled job that runs every minute and checks for due automations, runs them and then marks as them as completed (by deleting the PendingAutomation record). However, the job is currently subject to a race condition where a recurring automation can be executed more than once at its due date if it takes more than a minute to finish.

This PR adds a mutex around the code that triggers the recurring automation so that no concurrent executions can happen for a single automation.

Meta topic: https://meta.discourse.org/t/daily-summary-9pm-utc/291850/119?u=osama.

Copy link
Contributor

@martin-brennan martin-brennan left a comment

Choose a reason for hiding this comment

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

Is there a test we can add for this, maybe using freeze_time? You can move forward time using it so > 1 minute has passed.

@OsamaSayegh OsamaSayegh merged commit 8ed6843 into main May 1, 2024
16 checks passed
@OsamaSayegh OsamaSayegh deleted the fix/prevent-concurrent-automation-runs branch May 1, 2024 06:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants