cancel
Showing results for 
Search instead for 
Did you mean: 

Exception on insert into act_hi_detail

jamespatten
Champ in-the-making
Champ in-the-making

Hi,

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?

Thanks

2 REPLIES 2

bassam_al-saror
Star Collaborator
Star Collaborator

I don't think that DbIdGenerator is the issue but you can try switching to UUID instead see Activiti User Guide 

upforsin
Star Collaborator
Star Collaborator

Recently we faced this issue on Alfresco Community 6.1.x. The problem is about the incorrect ID generator (newly generated ID is already in the database).

To fix this issue you have to change next.dbid value in the database.

image

Step-by-step:

1) Check maximum id value 

id_ select max(to_number(id_,'999999999')) from public.act_hi_detail

2) Update value_ in the act_ge_property table - must be greater than maximum id return by the previous SQL statement

3) Restart Alfresco

howkymike
Alfresco Developer