bensheldon / good_job

Multithreaded, Postgres-based, Active Job backend for Ruby on Rails.

Home Page:https://goodjob-demo.herokuapp.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Discrepancy in README about preserve_job_records?

marckohlbrugge opened this issue · comments

preserve_job_records is enabled by default:

- `preserve_job_records` (boolean) keeps job records in your database even after jobs are completed. (Default: `true`)

but here it says "By default, GoodJob automatically destroys job records":

good_job/README.md

Lines 221 to 222 in 3933005

By default, GoodJob automatically destroys job records when the job is performed
and this command is not required to be used.

Am I misunderstanding, or are those two conflicting statements?

It seems that by default jobs are preserved for 14 days, but only if you run good_job cleanup_preserved_jobs will it actually clear out these older jobs. If that's the case, then I think the README should be clearer about the need for running good_job cleanup_preserved_jobs.

Also, a pre-existing GoodJob::CleanupPreservedJobsJob we can use with the cron feature would be handy for this.

You're right that sentence doesn't give the full picture. A more accurate statement would be something like.

"By default, GoodJob retains finished job records for 14 days and then automatically deletes them."

The setting that is used immediately after a job finishes to determine what to do is:

  • preserve_job_records

And then the settings related to how the jobs are automatically cleaned up are:

  • cleanup_discarded_jobs
  • cleanup_preserved_jobs_before_seconds_ago (I'm still looking for a better name for this)
  • cleanup_interval_jobs
  • cleanup_interval_seconds

Looking at the Readme, it probably looks like jobs need to be manually cleaned up because it documents the manual action of the CLI before getting to the configuration values (and I think the manual action did exist before the automatic part was added) and this section:

https://github.com/bensheldon/good_job?tab=readme-ov-file#monitor-and-preserve-worked-jobs

I see! Thanks for the clarification.

It might be worth giving this feature a self-explanatory name such as "auto cleanup". Just some (AI-generated) ideas:

  • preserve_job_recordsretain_job_records_on_completion : Keeps job records in your database even after jobs are completed.
  • cleanup_discarded_jobs → auto_cleanup_discarded_jobs: Automatically deletes discarded job records consistently, controlled by auto_cleanup_interval_jobs and auto_cleanup_interval_seconds.
  • cleanup_preserved_jobs_before_seconds_ago → auto_cleanup_retention_period: Specifies the duration for which a job record should be retained before being automatically cleaned up.
  • cleanup_interval_jobs → auto_cleanup_interval_jobs: Determines the interval (count of jobs done) after which the cleanup operation is initiated.
  • cleanup_interval_seconds → auto_cleanup_interval_seconds: Determines the timeframe (in seconds) after which the cleanup operation is initiated.