Violation of Primary Key constraint - error

Vote:
 
Hello all,

We've been running EpiServer website with EpiServer Mail for some time now. This morning we found out that our website wasn't answering. I checked Windows Event Viewer and found out that IIS had shut down our website.

"Application pool 'Solita' is being automatically disabled due to a series of failures in the process(es) serving that application pool."

Then I checked Application log in Event Viewer and found bunch of errors described below.

I googled around but found no answer. So I just started the IIS app pool and site was back on. Could someone explain what's going on around here and how we can fix this before IIS shuts down our website again?


BR,
Marko Parkkola


Exception: System.Data.SqlClient.SqlException

Message: Violation of PRIMARY KEY constraint 'PK_tblEPiServerMailAttributeValue'. Cannot insert duplicate key in object 'dbo.tblEPiServerMailAttributeValue'. The duplicate key value is (19, 10f3c226-9d95-410f-b6c5-97b6815fdd2d).
The statement has been terminated.

StackTrace: at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
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 EPiServer.Common.Data.DatabaseHandler.ExecuteNonQuery(Boolean inTransaction, String sp, CommandType commandType, Object[] args)
at EPiServer.Common.Data.DatabaseHandler.ExecuteNonQuery(Boolean inTransaction, String sp, Object[] args)
at EPiServer.Mail.Sources.Internal.Source.AddAttributeValue(Int32 attributeId, String attributeValue, Guid recipientId)
at EPiServer.Mail.Sources.Internal.Source.AddRecipient(Recipient recipient, RecipientContainer recipientContainer, Hashtable attributes)
at EPiServer.Mail.Sources.Internal.Source.ImportRecipientsFromText(RecipientContainer recipientContainer, Stream currentStream, Char separator)
at EPiServer.Mail.Core.Data.EPiServerMailFactory.ImportRecipients(String name, Stream stream, IRecipientStore store, ISite site)
at EPiServer.Mail.Core.Web.ManageRecipientsControl.ImportRecipients()
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

#62395
Oct 24, 2012 8:58
Vote:
 

Hello again.

I found the problem. Someone was trying to import email recipient list to the server and the text file contained invalid characters like tabulators.

So here's an improvement idea. Validate the incoming data and display clear message to the user what went wrong. Currently error goes to Windows Event Log and that's not really helpful because not everyone has access to the server and only few has necessary administrator rights to view the log.

 

-Marko

#62468
Oct 25, 2012 11:12
This thread is locked and should be used for reference only. Please use the Legacy add-ons forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.