Flowable Task Completion Issue - UserTask should not be signalled before complete

Hi,

We are facing below issue details:

Prerequisite:
We are using flowable version 6.5.0 as a dependency in spring boot application.

Problem statement:
We are getting a issue “UserTask should not be signalled before complete" while completing a specific task.

Exception:

Caused by: org.flowable.common.engine.api.FlowableException: UserTask should not be signalled before complete
	at org.flowable.engine.impl.bpmn.behavior.UserTaskActivityBehavior.trigger(UserTaskActivityBehavior.java:271)
	at org.flowable.engine.impl.agenda.TriggerExecutionOperation.run(TriggerExecutionOperation.java:65)
	at org.flowable.engine.impl.interceptor.CommandInvoker.executeOperation(CommandInvoker.java:88)
	at org.flowable.engine.impl.interceptor.CommandInvoker.executeOperations(CommandInvoker.java:72)
	at org.flowable.engine.impl.interceptor.CommandInvoker.execute(CommandInvoker.java:56)
	at org.flowable.engine.impl.interceptor.BpmnOverrideContextInterceptor.execute(BpmnOverrideContextInterceptor.java:25)
	at org.flowable.common.engine.impl.interceptor.TransactionContextInterceptor.execute(TransactionContextInterceptor.java:53)
	at org.flowable.common.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:72)
	at org.flowable.common.spring.SpringTransactionInterceptor.lambda$execute$0(SpringTransactionInterceptor.java:56)
	at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133)
	at org.flowable.common.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:56)
	at org.flowable.common.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:30)
	at org.flowable.common.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:56)
	at org.flowable.common.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:51)
	at org.flowable.engine.impl.TaskServiceImpl.complete(TaskServiceImpl.java:213)

Upon investigation we found duplicate entries against same process instance id in table ACT_RU_TASK. Removing duplicate entries fixes the issue temporary and arises again.

It would be really helpful if we be provided for the root cause and permanent solution to this issue.
Here are few questions also which can help us understand this problem:

  1. How/when the records get inserted into the ACT_RU_TASK?
  2. How to avoid duplicate entries for the same process instance id?
  3. Based on what the records get deleted from ACT_RU_TASK?