mirror of
https://github.com/discourse/discourse.git
synced 2025-03-03 13:27:24 +08:00

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 commit 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.