-
-
Notifications
You must be signed in to change notification settings - Fork 825
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scheduled Jobs - Define and track "last_run_end" #29587
Conversation
🤖 Thank you for contributing to CiviCRM! ❤️ We will need to test and review this PR. 👷 Introduction for new contributors...
Quick links for reviewers...
|
This does seem like a pretty good idea, and the patch includes some good/non-obvious bits. (I haven't run tho.) |
@mattwire Error:
|
For the rest of the patch, I did some Should allow a brief pause in case others have comments. Flagging |
Reading through the code, this looks good and I agree it will be useful. |
I think people have had some time now to get their heads around this merging |
Overview
Currently if a job throws an exception it's caught and logged in JobLog. But if it fails for another reason (eg. 500 error, Out of Memory) it silently crashes and stops all jobs from running because it tries to run again and crashes every time you run cron.
Before
No easy was to identify that a job started but did not finish. You can analyse the civicrm_job_log table but as you won't find a "job completed" log entry it requires some interesting queries to identify this situation (because you have to try to match the lack of a record with an existing "job start" record of which there will be many...
After
If a job completes (whether successful or by exception) it will record a last_run_end date in the job table.
This could be used to improve system status messages but also the queuing and prioritising of scheduled jobs. For example a simple sort on last_run_date is not empty would prevent a single bad job from stopping execution of all other jobs.
Technical Details
Add a new field to the table. Add job to scheduled job runner to clear and populate the field.
Comments
We don't implement any logic in this PR to use the field for analysis or to prioritise the job queue. This could be done in a future PR.