Last run time in ScheduledJobRunner


I was checking a case where a Service Job failed to run because of a server failure (container got killed while job was running), which first kept back the execution of a new JobRun until the expireLockTime had passed.
The next execution clears the lock, but it keeps the lastRunTime at the time the lock was created. This has the effect that the serviceJob is not run within the assigned time slot, so in our case as the job is run daily, it would be run again the next day, effectively skipping one day that goes by without any new execution attempt.
When there is a failure while executing a JobRun, the lastRunTime is set back to the value it had before, so that value should represent the last successful run time. So, following this, the behavior when expiring the lock should be to reset the lastRunTime to the time of the last successful execution, or null if there is no successful execution. Is this correct?

1 Like

This sounds right. It sounds like a good candidate for a PR.

Thanks Michael, there is a PR in place with this fix: When expiring lock, set lastRunTime to startTime of last successful jobRun (or null) by jenshp · Pull Request #633 · moqui/moqui-framework · GitHub