fix(scheduler): skip cron runs while an automation is active - #283
Draft
trungminhdo4-glitch wants to merge 2 commits into
Draft
fix(scheduler): skip cron runs while an automation is active#283trungminhdo4-glitch wants to merge 2 commits into
trungminhdo4-glitch wants to merge 2 commits into
Conversation
Author
|
HUMAN: (Owner-authorized; posted by my agent on my behalf.) I am supervising this contribution, and it remains a draft by design. Before I decide it is ready for review, I want the concurrency contract to remain explicit: one batch query for due automations; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PENDINGorRUNNINGrunWhy
A cron automation can currently schedule another run while its previous run is
still pending or running. Long-running automations can therefore stack multiple
concurrent sandboxes.
Concurrency contract
The guard is evaluated inside the scheduler transaction that already locks the
automation row with
FOR UPDATE SKIP LOCKEDon PostgreSQL.This PR intentionally applies the guard only to cron scheduling. Manual and
event-triggered dispatch behavior remains unchanged, and no database uniqueness
constraint is introduced, leaving room for an explicit per-automation override
later.
SQLite remains covered under the repository's existing single-process
assumption.
Behavior
Blocking statuses:
PENDINGRUNNINGNon-blocking statuses:
COMPLETEDFAILEDCANCELLEDSKIPPEDWhen a run is skipped:
last_polled_atis still updatedlast_triggered_atis unchangedTests
The functional behavior was tested with in-memory SQLite. PostgreSQL
multi-worker behavior was not exercised against a live PostgreSQL instance; the
serialization property follows the scheduler's existing automation-row lock.
Fixes #218
Disclosure: This contribution was prepared with AI assistance and independently
reviewed and tested locally before publication.