Stop jobs that are expired

Hello,
In my application, I have configured the asyncExecutorAsyncJobLockTimeInMillis to be 30 minutes. About 99% of the jobs that are executed are below 30 minutes, but there are still some that last longer. As I know, they become “expired” and are picked for execution again.
I have done several tests with jobs that are around 35 minutes. After the 35th minute, the job has been executed successfully. However it is started again and I receive Unexpected error: JobEntity [id=xxx] was updated by another transaction concurrently.

What I want to do is to force stop the execution of the job on the 30th minute and let the thread that picks expired jobs to execute it again immediately. Is it possible?

Hi Radoslav.

It is possible, but this functionality is not supported by the default job executor implementation. What I would recommend is to implement your own jobExecutor or job handler.

Regards
Martin

Hey Radoslav,

Doing what you are asking is not easy if you take multi node executions into consideration.

If job is running on Node 1, but Node 2 resets the job then the Job can’t be stopped by Node 2, since it doesn’t know anything about its execution.

Anyways, I would suggest that you revisit your long running jobs. If a job is running for so long it means that there is a transaction which is open for so long as well (and this is not good in my opinion).

Cheers,
Filip