Support Article
Getting insert errors (duplicate keys)
Summary
User observed insert errors in DB, as part of performance testing of the application.
Error Messages
822 [ PegaRULES-Batch-2] [ STANDARD] [ PegaRULES:06.02] (ion.context.GlobalContextCache) ERROR - Exception in writeRuleSetListHashToDB inserting a row to the pr_sys_ruleset_index table
com.pega.pegarules.pub.database.IntegrityConstraintViolationException: Database-General 1 23000 ORA-00001: unique constraint (PRPC_APP.PR_SYS_RULESET_INDEX_PK) violated From: (B4912FCE919869C81EB12FFE6D47D7082)
SQL: insert into pr_sys_ruleset_index (PXCREATEDATETIME , PXCREATEOPNAME , PXCREATESYSTEMID , PXINSNAME , PXOBJCLASS , PYRULESETVERSION , PZRULESETINDEX , PZRULESETLISTHASH , PZRULESETNAME , PZRULESETVERSIONMAJOR , PZRULESETVERSIONMINOR , PZRULESETVERSIONPATCH , pzInsKey) values (? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ?)
SQL Inserts: <816> <> <1b132bb2ec1a7ebb3dc87de795f22f00> <3A355F0015AD3211BFB7787C6511D36D!PEGA-PROCESSCOMMANDER> <06-02> <1> <3a355f0015ad3211bfb7787c6511d36d> <6> <2> <-1>
Caused by SQL Problems.
Problem #1, SQLState 23000, Error code 1: java.sql.SQLIntegrityConstraintViolationException: ORA-00001: unique constraint (PRPC_APP.PR_SYS_RULESET_INDEX_PK) violated
at com.pega.pegarules.data.internal.access.ExceptionInformation.createExceptionDueToDBFailure(ExceptionInformation.java:165)
at com.pega.pegarules.data.internal.access.DatabaseImpl$SaverImpl.saveAllOrNone(DatabaseImpl.java:4997)
at com.pega.pegarules.session.internal.authorization.context.GlobalContextCache.writeRuleSetListHashToDB(GlobalContextCache.java:950)
at com.pega.pegarules.session.internal.authorization.context.CustomApplicationContext.alterRuleSetList(CustomApplicationContext.java:565)
at com.pega.pegarules.session.internal.authorization.Authorization.alterRuleSetList(Authorization.java:940)
at com.pega.pegarules.session.internal.authorization.Authorization.alterRuleSetList(Authorization.java:932)
at com.pega.pegarules.session.internal.async.BatchRequestorTask.run(BatchRequestorTask.java:665)
at com.pega.pegarules.session.internal.PRSessionProviderImpl.doWithRequestorLocked(PRSessionProviderImpl.java:1000)
at com.pega.pegarules.session.internal.PRSessionProviderImpl.doWithRequestorLocked(PRSessionProviderImpl.java:709)
at com.pega.pegarules.session.internal.async.BatchRequestorTask.run(BatchRequestorTask.java:548)
at com.pega.jsr166backport.java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:991)
at com.pega.jsr166backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:532)
at java.lang.Thread.run(Unknown Source)
Caused by: java.sql.SQLIntegrityConstraintViolationException: ORA-00001: unique constraint (PRPC_APP.PR_SYS_RULESET_INDEX_PK) violated
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:445)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396)
at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:879)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:450)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:192)
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:531)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:207)
at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:1044)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1329)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3584)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3665)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeUpdate(OraclePreparedStatementWrapper.java:1352)
at com.pega.pegarules.data.internal.access.DatabasePreparedStatementImpl.executeUpdate(DatabasePreparedStatementImpl.java:467)
at com.pega.pegarules.data.internal.access.DatabaseImpl$SaverImpl.saveInstance(DatabaseImpl.java:5043)
at com.pega.pegarules.data.internal.access.DatabaseImpl$SaverImpl.saveAllOrNone(DatabaseImpl.java:4986)
Steps to Reproduce
Perform Load testing using one operator Id with multiple threads at the same time.
Root Cause
The root cause of this issue is with the using one operator id with multiple threads and trying to login and logout into the application at the same time.
Resolution
Here’s the explanation for the reported behavior:
The error table entries are inserted when users log in and log out of the application. As multiple threads use the same operator Id simultaneously, the Constraint Violation exception occurs.
Published February 27, 2016 - Updated April 6, 2021
Have a question? Get answers now.
Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.