Greetings,
We are experiencing something similar as the issue described in this post using Activiti version 5.17.0. Let me explain the scenario first.
We have a workflow with two java service tasks between two parallel gateways (opening and closing). The service tasks are configured as activiti:async="true" and activiti:exclusive="false", while the parallel gateways are configured with activiti:async="true". The rest of the task as configured as activiti:exclusive="true"
The service tasks look something like this (simplified - see code below) and it starts a new thread with executes a http request and waits for its reply. Once the http reply is received, it signals the service task, so that the workflow can continue. Service task does not wait for the thread to finish. Meaning there is no thread.join(). Both service tasks execute the exact same code shown below.
<code>
public class CopyTask extends TaskActivityBehavior {
private Expression NicknameFrom;
private Expression NicknameTo;
private Expression FolderAddress;
private Expression FileNamePattern;
@Override
public void execute(ActivityExecution execution) throws Exception {
/*keep the current execution information that will be used to signal it later on*/
String callbackId = execution.getId();
String processInstanceId = execution.getProcessInstanceId();
String currentActivitiId = execution.getCurrentActivityId();
/*do some preparation, and start the new thread. Function does not wait for the thread to finish. Meaning there is no thread.join()*/
}
@Override
public void signal(ActivityExecution execution, String signalName, Object signalData) throws Exception
{
leave(execution);
}
</code>
The thread that is executing the http request, creates a two variables that are passed to the signal function.
<code>
private void signalWaitState(HashMap<String, String> Result) {
ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
RuntimeService runtimeService = processEngine.getRuntimeService();
Map<String, Object> variableMap = new HashMap<String, Object>();
variableMap.put("Code", Result.get("Code"));
variableMap.put("Response", Result.get("Response"));
runtimeService.signal(this.executionId, variableMap);
System.out.println("Signalled execution id " + this.executionId + "(" + this.activityId + ")" + "(" + this.processInstanceId + ")");
}
</code>
The whole process executes normally and without any problem. But when Activiti tries to do the clean up of act_ru_variable, we get the following error:
<code>
### The error occurred while setting parameters
### SQL: delete from ACT_RU_EXECUTION where ID_ = ? and REV_ = ?
### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot delete or update a parent row: a foreign key constraint fails (`activiti`.`act_ru_variable`, CONSTRAINT `ACT_FK_VAR_EXE` FOREIGN KEY (`EXECUTION_ID_`) REFERENCES `ACT_RU_EXECUTION` (`ID_`))
</code>
Due to this error, the process is rollbacked to the closing parallel gateway, but it does not move forward to the next step. As a result, the process never ends.
Activiti engine and rest are configured to run in the same server and accessing the same MySQL database. Both are configured with these options:
<code>
<property name="jobExecutorActivate" value="false" />
<property name="asyncExecutorEnabled" value="true" />
<property name="asyncExecutorActivate" value="true" />
</code>
We ended up removing all the foreign key constrains on table act_ru_variable. Once removed, the process worked correctly.
So, we have some questions:
1) We read that this was fixed already, but we face this problem. Is there something we missed or need to configured?
2) What are the consequences of removing all the foreign key constrains on table act_ru_variable.
Let us know if you need additional information and many thanks in advance.
Keep on the good work on Activiti. It is a great tool.