You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(cron): deduplicate and protect scheduled executions (#601)
## Summary
- add task-level queue protection for scheduled cron executions
- deduplicate scheduled occurrences with a database-backed `(job_id,
scheduled_at)` claim
- add renewable run leases, heartbeat renewal, retry preservation, and
restart recovery
- claim occurrences before conversation preparation/creation
- keep schedule calculation on the theoretical occurrence grid
Closes#600
## Why
Conversation busy state alone cannot prevent duplicate callbacks from
creating two independent conversations. The occurrence claim must happen
at the task/database level before any conversation is materialized.
## Implementation
- add `queue_enabled` to cron jobs
- add `cron_job_runs` with a unique occurrence key and active-run index
- use `BEGIN IMMEDIATE` for atomic cross-process claims
- record duplicate, running, retrying, skipped, success, and error
outcomes
- use owner IDs and expiring leases for crash recovery
- preserve `scheduled_at` through retries and scheduler callbacks
- fence stale owners from updating job state after losing their lease
## Testing
- `RUSTUP_TOOLCHAIN=stable cargo fmt --all -- --check`
- `RUSTUP_TOOLCHAIN=stable cargo check -p aionui-cron -p aionui-db -p
aionui-app`
- `RUSTUP_TOOLCHAIN=stable cargo test -p aionui-cron -p aionui-db -p
aionui-api-types`
- `RUSTUP_TOOLCHAIN=stable cargo test -p aionui-app --test cron_e2e`
All checks pass on the latest upstream `main`.
## Related UI
The corresponding queue-protection UI and visual schedule builder are in
iOfficeAI/AionUi#3552.
---------
Co-authored-by: zk <>
0 commit comments