cancel
Showing results for 
Search instead for 
Did you mean: 

[Activiti 5.10] JobExecutor executes already acquired and running job again

jmonte83
Champ in-the-making
Champ in-the-making
Hi everyone,

Let me first clarify our Activiti environment setup:

We are currently using version 5.10 of Activiti.

We have the Activiti engine integrated in our artifact which also includes processes and corresponding Java classes. The JobExecutor uses the implementation org.activiti.engine.impl.jobexecutor.DefaultJobExecutor which is configured with settings:

jobExecutor.setCorePoolSize(1);
jobExecutor.setMaxPoolSize(1);

The JobExecutor is manually started after the Spring Context has been successfully initialized.

This artifact is deployed on two servers. Both Activiti engines work on the same database.

For analysis purposes, I have set up a separate activiti_engine.log file where log messages from package org.activiti.engine are written to.

We have the following scenario:

A job for a process instance/ execution is acquired by the JobExecutor and is then executed. The execution starts at an async service task, traverses two exclusive gateways, then executes a sync service task and finally ends up in an end node. For some unknown reason, the execution of the sync service task lasts 17 seconds. Normally, the execution of the mentioned sync service task lasts around 3 seconds.

5 seconds after the first acquisition of the job mentioned above, the same job is again acquired by the JobExecutor and then executed. All process elements mentioned above are again traversed.

The same job is therefore executed twice by the same Job Executor.

As far as I understand, a job is (by default) locked by the JobExecutor for 5 minutes. Also the unique id of the JobExecutor is set for a job when it is aquired. Does this locking only prevent that another JobExecutor can acquire this job concurrently or should it also prevent that the same JobExecutor acquires/ executes a job twice during this 5 minutes?

Is the described behavior the expected/ normal way Activiti works? I would expect that Activiti ensures that a job that is acquired by a JobExecutor is only executed once.

Is the problem only caused by the slow execution of the sync service task? Do long-running job executions generally represent a problem for Activiti?

Thanks a lot.

Best regards,
Monte.
1 REPLY 1

trademak
Star Contributor
Star Contributor
Hi,

No this should definitely not happen. Can it be that there's an error while executing the job? Because then Activiti will retry the job automatically. Did you look if the retry count was changed? Activiti locks the job so it can't be executed twice without a reason.

Best regards,