We're using new relic to monitor our app and we're getting this error rather frequently, and I'm having a difficult time tracking it down:
System.Data.SqlClient.SqlException: Violation of PRIMARY KEY constraint 'PK_ASPStateTempSess_267ABA7A'. Cannot insert duplicate key in object 'dbo.ASPStateTempSessions'. The statement has been terminated.
It seems like an easy fix if we could find the root cause, just check that the primary key does not exist before inserting, but this seems like default functionality that I don't know if we have the ability to modify. The are no specific lines of code mentioned, so I really don't know where to begin. I've done a bunch of searching on here and on google but can't find this exact problem. The app is running on 2 load balanced servers and I've checked that the web.configs are the same, with a common aspstate database. Here's the stack trace if it helps:
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean\ breakConnection)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception,\ Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject\ stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand\ cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler,\ TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds,\ RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior,\ RunBehavior runBehavior, Boolean returnStream, Boolean async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior,\ RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult\ result, String methodName, Boolean sendToPipe)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at System.Web.SessionState.SqlSessionStateStore.CreateUninitializedItem(HttpContext\ context, String id, Int32 timeout)
Does anyone have any experience with something like this or can maybe point me in another direction of other things to look at?