Bug 35948 - cleanup_database.pl should remove not only finished background jobs
Summary: cleanup_database.pl should remove not only finished background jobs
Status: In Discussion
Alias: None
Product: Koha
Classification: Unclassified
Component: Command-line Utilities (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: Fridolin Somers
QA Contact: Testopia
URL:
Keywords:
Depends on: 31969
Blocks:
  Show dependency treegraph
 
Reported: 2024-01-30 14:30 UTC by Fridolin Somers
Modified: 2024-02-27 08:11 UTC (History)
2 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 35948: cleanup_database.pl should remove not only finished background jobs (1.53 KB, patch)
2024-01-30 14:49 UTC, Fridolin Somers
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Fridolin Somers 2024-01-30 14:30:23 UTC
Bug 31969 changed cleanup_database.pl so it removes only finished background jobs.
But old background jobs with other statuses will never be removed.
I see no use to that
Comment 1 Fridolin Somers 2024-01-30 14:36:05 UTC
So we should use "enqueued_on" instead of "ended_on"
and no filter on status
Comment 2 Fridolin Somers 2024-01-30 14:49:22 UTC
Created attachment 161646 [details] [review]
Bug 35948: cleanup_database.pl should remove not only finished background jobs

Bug 31969 changed cleanup_database.pl so it removes only finished background jobs.
But old background jobs with other statuses will never be removed.

So we should use "enqueued_on" instead of "ended_on"
and no filter on status

Test plan :
1) Create a background job with for example a batch item modification
2) Simulate ancien job via SQL :
update background_jobs set status='failed',enqueued_on=DATE_SUB(NOW(),INTERVAL 10 DAY) where id=X
3) Run misc/cronjobs/cleanup_database.pl --jobs-days 9 --jobs-type all -v --confirm
4) Check the job is removed
Comment 3 Katrin Fischer 2024-01-30 16:58:09 UTC
Currently we have a lot of problems with jobs not finishing. Would this not only hide the problem? I feel it should be an option and not a change of behaviour.
Comment 4 Victor Grousset/tuxayo 2024-02-25 18:42:41 UTC
@Fridolin: see bug 35092

What are the other "final" statues that should be cleaned?
Certainly there should be "cancelled".

And on the long run, "failed" also.
Not sure about now because that might hide the current issues if --jobs-days is too small. But maybe it ok, I don't know.
Comment 5 Fridolin Somers 2024-02-26 14:47:24 UTC
Ah sure, cancelled is missing.

I set status to needs discussion ;)
Comment 6 Victor Grousset/tuxayo 2024-02-27 08:11:56 UTC
Anything else to cleanup besides cancelled and failed?