I'm using Activiti 5.22.0, and I occasionally encounter the following exception when trying to complete a task:
### Error updating database. Cause: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "act_hi_detail_pkey"
Detail: Key (id_)=(5096) already exists.
### The error may involve org.activiti.engine.impl.persistence.entity.HistoricDetailEntity.insertHistoricDetailVariableInstanceUpdate-Inline
### The error occurred while setting parameters
### SQL: insert into ACT_HI_DETAIL (ID_, TYPE_, PROC_INST_ID_, EXECUTION_ID_, ACT_INST_ID_, TASK_ID_, NAME_, REV_, VAR_TYPE_, TIME_, BYTEARRAY_ID_, DOUBLE_, LONG_ , TEXT_, TEXT2_) values ( ?, 'VariableUpdate', ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )
### Cause: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "act_hi_detail_pkey"
I cannot reproduce this consistently, and the issue resolves on reinitialization of Activiti (a restart of the application server), because another block of 2500 IDs is retrieved. I am guessing that for some reason the value retrieved from org.activiti.engine.impl.db.DbIdGenerator is in conflict with an ID that already exists in the act_hi_detail table.
Any ideas what is causing this issue, or what can be done to prevent it from happening? Has this issue been fixed in more recent versions?