Time Slicing job fails due to duplicate records being inserted

book

Article ID: 23178

calendar_today

Updated On:

Products

Clarity PPM On Premise Clarity PPM SaaS

Issue/Introduction

The Time Slicing job is failing with errors in the logs. You have tried to restart BG services but the same repeated error can be seen in the BG logs. Here are examples:

MSSQL ERROR:

   Error message: [CA Clarity][SQLServer JDBC Driver][SQLServer]Cannot insert duplicate key row in object 'dbo.PRJ_BLB_SLICES' with unique index 'PRJ_BLB_SLICES_U2'.
    SQL error code: 3621
    Error message: [CA Clarity][SQLServer JDBC Driver][SQLServer]The statement has been terminated.
    ....
    Using input:
    {sliceDate=2015-02-01T00:00:00, sliceID=11438446, role_id=5005473, startDate=2015-02-01T00:00:00, objectID=5003935, resource_id=5005473, unit=0, finishDate=2015-03-01T00:00:00, requestID=6, slice=159.6, investment_id=5006074}

ORACLE ERROR:

Caused by: java.sql.SQLIntegrityConstraintViolationException: [CA Clarity][Oracle JDBC Driver][Oracle]ORA-00001: unique constraint (CLARITY.PRJ_BLB_SLICES_W_AVL_U1) violated 
ORA-06512: at line 1 
ORA-06512: at "CLARITY.PRJ_BLB_SLICE_MERGE_SP", line 128 
ORA-06512: at line 1

The table name and constraint can vary, depending on the data being inserted. Examples include:

  • PRJ_BLB_SLICES_U1
  • PRJ_BLB_SLICES_U2
  • PRJ_BLB_SLICES_W_AVL
  • PRJ_BLB_SLICES_W_ALC_U2
  • PRJ_BLB_SLICES_D_ETC_U1
  • PRJ_BLB_SLICES_M_ALC_U1
  • PRJ_BLB_SLICES_W_ETC_U1

Cause

The constraint error occurs because the Time Slicing job is attempting to add a record that is already there.
This issue can occur if contention appears in the database and the database session is not handled.

The BG logs will need to be obtained and reviewed to obtain the slice data table and its corresponding records necessary to construct SQL backup and delete statements to resolve the issue.

Environment

Clarity Time Slicing

Resolution

Step 1 - Pause Time Slicing Job

Step 2 - Delete and regenerate the slice data on the table (DBA)

DBA team assistance is required for running queries below. 

  1. Review the BG logs to obtain the table name.
  2. Run the following queries to validate the slice id and table name.
    • Query 1
      select id, request_name, table_name from PRJ_BLB_SLICEREQUESTS where table_name = '[TABLE_IN_BG_LOG]'

      • Check how many records need to be deleted, in order to regenerate the data.
      • NOTE: Actual data will be regenerated, therefore no data is being deleted.
    • Query 2

      select slice_request_id, count(*) from

      [Table_name]

      where slice_request_id in

      (x)

      group by slice_request_id

  3. Make a backup of the table with the slices.

  4. Run the below query:

    delete from [TABLE_NAME]
    where slice_request_id in (x);
    commit;

  5. Reset the dates to force a reslice

    update PRJ_BLB_SLICEREQUESTS 
    set expiration_date = null, 
    request_completed_date = null 
    where id in
    (x);
    commit;

Step 4 - Restart all BG services (Optional - Restart is not usually needed)

A restart is usually not needed unless there was an issue with the Job scheduler

Step 5 - Run an immediate instance of the Time Slicing job

If the same error occurs, please contact the Support team for further assistance.

Additional Information

If the above isn't the cause of your issue, see also: