I am occasionally receiving an error from SQL Server when the SAML component is inserting into the SAMLIdentifiers table. When setting the IDCache property in the Application_Start method in Global.asax, I am setting the DeleteExpiredPriorToAdd property of DatabaseIDCache to true.
The error is:
Violation of PRIMARYKEY constraint 'PK_SAMLIdentifiers'. Cannot insert duplicate key in object'dbo.SAMLIdentifiers'. The duplicate key value is(avMqNLrmP_MrPST1ESY1jHpPxIR). The statement has been terminated.
Stack trace: atSystem.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection,Action`1 wrapCloseInAction) atSystem.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObjectstateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommandcmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler,TdsParserStateObject stateObj, Boolean& dataReady) at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds,RunBehavior runBehavior, String resetOptionsString) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehaviorcmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async,Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehaviorcmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method,TaskCompletionSource`1 completion, Int32 timeout, Task& task, BooleanasyncWrite) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1completion, String methodName, Boolean sendToPipe, Int32 timeout, BooleanasyncWrite) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at ComponentSpace.SAML2.Data.DatabaseIDCache.Add(String id, DateTimeexpirationDateTime)
How can I solve this?
Thanks, Brian
|