mosquito-cr / mosquito

A background task runner for crystal applications supporting periodic (CRON) and manually queued jobs
MIT License
227 stars 24 forks source link

Fixes distributed periodic jobs #119

Closed robacarp closed 1 year ago

robacarp commented 1 year ago

I overlooked a small but important detail about how periodic jobs are enqueued in #108. The "last run" timestamp was stored in-process, which was fine when the coordinator was manually selected by config parameter. The bug is, when the distributed lock is enabled, all active workers will enqueue each periodic job each time the interval is up.

The fix is to store the periodic job last_run timestamp in a metadata block.