The LockMonitorThread has a really huge bug.
It queries all jobs with overdue lock time:
Date threshold = new Date(System.currentTimeMillis() - maxLockTime - lockBufferTime);
List overdueJobs = jbpmContext.getJobSession().findJobsWithOverdueLockTime(threshold);
by this query:
<query name="JobSession.findJobsWithOverdueLockTime">
select job
from org.jbpm.job.Job as job
where job.lockTime > :threshold
</query>
This finds all jobs with a lock timer NEWER than the treshold, not OLDER as it should be. So the query must be:
<query name="JobSession.findJobsWithOverdueLockTime">
select job
from org.jbpm.job.Job as job
where job.lockTime < :threshold
</query>
So if a job runs exactly at the time the LockMonitorThread comes active, this leads to a StaleObjectException in the JobExecution. Since the LockMonitorThread runs only every minute, this is a pretty rare case. The more puzzling it was to find Surprising, that it wasn't recognized that long!
I commit the changed query to HEAD.
- duplicates
-
JBPM-2608 JobSession.findJobsWithOverdueLockTime returns incorrect list of overdue jobs for LockMonitorThread
- Resolved