Allow Scheduler to automatically clean up preserved jobs every N jobs or seconds #465
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.
This will be enabled by default in GoodJob 3.0.
The general idea is a garbage collector doing a sweep on a set interval: both number of jobs executed, and a time-based interval. The time-based interval is currently reliant on a job being executed i.e. the trigger for the time-based interval is a job being executed (there is not a separate cron-like process)
Adds two new configuration options:
cleanup_interval_jobs
(integer) Number of jobs a Scheduler will execute before cleaning up preserved jobs. Defaults tonil
. Can also be set with the environment variableGOOD_JOB_CLEANUP_INTERVAL_JOBS
.cleanup_interval_seconds
(integer) Number of seconds a Scheduler will wait before cleaning up preserved jobs. Defaults tonil
. Can also be set with the environment variableGOOD_JOB_CLEANUP_INTERVAL_SECONDS
.Uses the existing (but awkwardly named)
cleanup_preserved_jobs_before_seconds_ago
configuration option.Closes #412