A task named “IDRefresh”. It is the default identity refresh task but with “Allow Concurrency” enabled.
Each thread started by the plugin will be allocated an identity unique to that thread.
Each thread will launch IDRefresh with parameter to refresh that thread’s identity.
But I found that often some of the IDRefresh task will get stuck. They will forever be pending until I clean them up with iiq console (with the terminateOrphans please command).
How can I troubleshoot this? I want to stop them from getting stuck but I have no idea what they are getting stuck on.
These will be very verbose and add lots of information to your logs, so make sure they are turned off after debugging. This should narrow down which methods are getting stuck.
But searching through the log, I couldn’t find anything worthy of notice from Identitizer and IdentityRefreshExecutor. Instead, I found SQL exceptions:
2021-09-03 15:00:29,147 WARN QuartzScheduler_Worker-2 org.hibernate.util.JDBCExceptionReporter:100 - SQL Error: 2627, SQLState: 23000
2021-09-03 15:00:29,147 ERROR QuartzScheduler_Worker-2 org.hibernate.util.JDBCExceptionReporter:101 - Violation of UNIQUE KEY constraint 'UQ__spt_task__72E12F1B85E4BF00'. Cannot insert duplicate key in object 'identityiq.spt_task_result'. The duplicate key value is (IntegrationTest-IDRefresh).
2021-09-03 15:00:29,147 ERROR QuartzScheduler_Worker-2 sailpoint.api.TaskManager:2009 - Unable to close TaskResult: IntegrationTest-IDRefresh
2021-09-03 15:00:29,147 ERROR QuartzScheduler_Worker-2 sailpoint.api.TaskManager:2010 - sailpoint.tools.GeneralException: could not update: [sailpoint.object.TaskResult#8a42e2777baa7375017baa7564e40052]
2021-09-03 15:00:29,163 WARN QuartzScheduler_Worker-2 org.hibernate.util.JDBCExceptionReporter:100 - SQL Error: 2627, SQLState: 23000
2021-09-03 15:00:29,163 ERROR QuartzScheduler_Worker-2 org.hibernate.util.JDBCExceptionReporter:101 - Violation of UNIQUE KEY constraint 'UQ__spt_task__72E12F1B85E4BF00'. Cannot insert duplicate key in object 'identityiq.spt_task_result'. The duplicate key value is (IntegrationTest-IDRefresh).
2021-09-03 15:00:29,163 ERROR QuartzScheduler_Worker-2 sailpoint.scheduler.JobAdapter:138 - The 11742f33ce774939a310801073492955 task failed to execute
sailpoint.tools.GeneralException: could not update: [sailpoint.object.TaskResult#8a42e2777baa7375017baa7564e40052]
at sailpoint.persistence.HibernatePersistenceManager.commitTransaction(HibernatePersistenceManager.java:497)
at sailpoint.persistence.ClassPersistenceManager.commitTransaction(ClassPersistenceManager.java:207)
at sailpoint.server.InternalContext.commitTransaction(InternalContext.java:520)
at sailpoint.api.Terminator.innerDelete(Terminator.java:323)
at sailpoint.api.Terminator.visitTaskSchedule(Terminator.java:2607)
at sailpoint.object.TaskSchedule.visit(TaskSchedule.java:844)
at sailpoint.object.Visitor.visit(Visitor.java:26)
at sailpoint.api.Terminator.deleteObject(Terminator.java:256)
at sailpoint.scheduler.JobAdapter.execute(JobAdapter.java:133)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
Caused by: org.hibernate.exception.ConstraintViolationException: could not update: [sailpoint.object.TaskResult#8a42e2777baa7375017baa7564e40052]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:96)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2596)
at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2478)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2805)
at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:114)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:268)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:260)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:180)
at sailpoint.persistence.PatchedDefaultFlushEventListener.performExecutions(PatchedDefaultFlushEventListener.java:39)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1206)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:375)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:137)
at sailpoint.persistence.HibernatePersistenceManager.commitTransaction(HibernatePersistenceManager.java:483)
... 10 more
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Violation of UNIQUE KEY constraint 'UQ__spt_task__72E12F1B85E4BF00'. Cannot insert duplicate key in object 'identityiq.spt_task_result'. The duplicate key value is (IntegrationTest-IDRefresh).
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:256)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1621)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:592)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:522)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7194)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:2930)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:248)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:223)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeUpdate(SQLServerPreparedStatement.java:471)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)
at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:46)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2574)
... 22 more
The task result ID reported in the log matches the one my plugin found to be stuck.
My plugin launches the task with the runWithResult API:
TaskManager manager = new TaskManager(context);
TaskResult tr = manager.runWithResult(task, parameters);
And then I monitors the TaskResult by repeatedly searching for TaskResult with its ID and checking its status:
do {
TaskResult r = context.getObjectById(TaskResult.class, id);
if (r != null) {
CompletionStatus status = r.getCompletionStatus();
context.decache(r);
// Check status here, break when completed
}
Thread.sleep(5000);
} while (!timeout);
Is it perhaps due to a delicate timing issue, my code checking the status blocks the task from updating it?
The SQL exception being thrown is stating that you already have a TaskResult with the name ‘IntegrationTest-IDRefresh’ . What does your TaskDefinition look like (XML) and what does the Map ‘parameters’ contain?