Duplicate key error in bg logs when auto start process is triggered with multiple BG's
search cancel

Duplicate key error in bg logs when auto start process is triggered with multiple BG's

book

Article ID: 381695

calendar_today

Updated On:

Products

Clarity PPM SaaS

Issue/Introduction

There is a possibility of a race condition when multiple BGs are running in Postgres environment when attempting to trigger many process instances at the same time.

STEPS TO REPRODUCE:
1. Set-up a PG DB based Clarity environment.
2. Install Demo Data.
3. Set-up 2 BG's for this environment. You can use "service clone bg", "service add deploy bg2", "service start bg2".
4. Create a Sub object of Project as "Test Sub Object".
5. Create a String attribute on Test Sub Object as "Description Update".
6. Create an Auto Start Process which triggers on both "Create and Update". Select the option "Don't start a Process if one is already running".
7. Set the Primary Object as "Test Sub Object" and Linked Object as "Project".
8. In the Start step of the Process create a system action. Select the object as "Test Sub Object" and action as "Set Description Update" and value as "Test Validation".
9. Validate the process and activate it.
10. navigate to Home -> Projects -> take a project -> properties -> Test sub Object List.
11. Create an instance.
12. Once the instance is create modify the name of the object instance 2-3 times.

Expected Results: Because there is no actual condition, we expect that the process is triggered multiple times.
Actual Results: Process is triggered multiple times, but the bg-ca.log is flooded with 'Unique constraint' errors.

Resolution

DE154185, Fixed in 16.3.0

Additional Information

Caused by: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "bpm_em_event_process_lock_n1"
  Detail: Key (event_id, process_version_id)=(73887220, 5233708) already exists.
    at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2725)
    at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2412)
    at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:371)
    at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:502)
    at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:419)
    at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:194)
    at org.postgresql.jdbc.PgPreparedStatement.execute(PgPreparedStatement.java:180)
    at jdk.internal.reflect.GeneratedMethodAccessor17.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:569)
    at org.apache.tomcat.jdbc.pool.StatementFacade$StatementProxy.invoke(StatementFacade.java:118)
    at jdk.proxy2/jdk.proxy2.$Proxy8.execute(Unknown Source)
    at com.niku.union.persistence.PersistenceController.processSql(PersistenceController.java:3804)
    at com.niku.union.persistence.PersistenceController.processStatement(PersistenceController.java:927)
    at com.niku.union.persistence.PersistenceController.processStatements(PersistenceController.java:825)
    at com.niku.union.persistence.PersistenceController.doProcessRequest(PersistenceController.java:627)
    at com.niku.union.persistence.PersistenceController.processRequest(PersistenceController.java:344)
    at com.niku.bpm.engine.persistence.EnginePersistenceUtils.execute(EnginePersistenceUtils.java:3691)
    at com.niku.bpm.engine.persistence.EnginePersistenceUtils.execute(EnginePersistenceUtils.java:3643)
    at com.niku.bpm.engine.persistence.EnginePersistenceUtils.lockEventProcess(EnginePersistenceUtils.java:1968)
    at com.niku.bpm.eventmgr.ObjectEventHandler.lockEvent(ObjectEventHandler.java:330)
    at com.niku.bpm.eventmgr.ObjectEventHandler.processEventToAutoStartProcesses(ObjectEventHandler.java:244)
    ... 6 more
 [Event Handler pool-3-thread-11] persistence.PersistenceController (clarity:some_user@some_company.com:session_id:none) () Error happened with error code:25P02