1

Closed

System.Data.Entity.Infrastructure.DbUpdateException because of duplicate Notifications (PK cosntraint violated)

description

When adding the "SqlPublisherConfiguration", we get the following error:
2015-01-21 10:29:46,525 [15] ERROR Wolfpack [(null)] - IncidentId:f5929b03-be65-495b-9a5c-5d052f1e1802; Encountered 'ApplicationException' during 'WebService Call: http://web02.intercom.at:802/api/notification/notify'; Message:=System.ApplicationException: Step failure ---> System.Data.Entity.Infrastructure.DbUpdateException: An error occurred while updating the entries. See the inner exception for details. ---> System.Data.Entity.Core.UpdateException: An error occurred while updating the entries. See the inner exception for details. ---> System.Data.SqlClient.SqlException: Verletzung der PRIMARY KEY-Einschränkung 'PK_dbo.NotificationEvents'. Ein doppelter Schlüssel kann in das dbo.NotificationEvents-Objekt nicht eingefügt werden. Der doppelte Schlüsselwert ist (005a8cd6-4959-4ffd-beff-d777f721038b).

Die Anweisung wurde beendet.

bei System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction)

bei System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)

bei System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)

bei System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)

bei System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds)

bei System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource
1 completion, Int32 timeout, Task& task, Boolean asyncWrite)

bei System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite)

bei System.Data.SqlClient.SqlCommand.ExecuteNonQuery()

bei System.Data.Entity.Infrastructure.Interception.InternalDispatcher
1.Dispatch[TTarget,TInterceptionContext,TResult](TTarget target, Func3 operation, TInterceptionContext interceptionContext, Action3 executing, Action3 executed)

bei System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.NonQuery(DbCommand command, DbCommandInterceptionContext interceptionContext)

bei System.Data.Entity.Core.Mapping.Update.Internal.DynamicUpdateCommand.Execute(Dictionary
2 identifierValues, List1 generatedValues)

bei System.Data.Entity.Core.Mapping.Update.Internal.UpdateTranslator.Update()

--- Ende der internen Ausnahmestapelüberwachung ---

bei System.Data.Entity.Core.Mapping.Update.Internal.UpdateTranslator.Update()


bei System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func
1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)
bei System.Data.Entity.Core.Objects.ObjectContext.SaveChangesToStore(SaveOptions options, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction)

bei System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func1 operation)

bei System.Data.Entity.Core.Objects.ObjectContext.SaveChangesInternal(SaveOptions options, Boolean executeInExistingTransaction)

bei System.Data.Entity.Internal.InternalContext.SaveChanges()

--- Ende der internen Ausnahmestapelüberwachung ---

bei System.Data.Entity.Internal.InternalContext.SaveChanges()

bei Wolfpack.Core.Repositories.Sql.SqlDbContext.SaveChanges() in c:\Projects\Wolfpack\Releases\v3.0.26\Source\Wolfpack.Core\Repositories\Sql\SqlDbContext.cs:Zeile 21.

bei Wolfpack.Core.Repositories.Sql.SqlRepository.Add(NotificationEvent notification) in c:\Projects\Wolfpack\Releases\v3.0.26\Source\Wolfpack.Core\Repositories\Sql\SqlRepository.cs:Zeile 49.

bei Wolfpack.Core.Publishers.Sql.SqlPublisher.Consume(NotificationEvent message) in c:\Projects\Wolfpack\Releases\v3.0.26\Source\Wolfpack.Core\Publishers\Sql\SqlPublisher.cs:Zeile 28.

bei Magnum.Extensions.ExtensionsToEnumerable.Each[T](IEnumerable
1 collection, Action1 callback)

bei Wolfpack.Core.MagnumMessenger.Wolfpack.Core.Interfaces.IMessenger.Publish(NotificationEvent message) in c:\Projects\Wolfpack\Releases\v3.0.26\Source\Wolfpack.Core\Messenger.cs:Zeile 88.

bei Wolfpack.Core.Messenger.Publish(NotificationEvent message) in c:\Projects\Wolfpack\Releases\v3.0.26\Source\Wolfpack.Core\Messenger.cs:Zeile 45.

bei Wolfpack.Core.WebServices.Strategies.Steps.RepublishMessageStep.Execute(WebServiceReceiverContext context) in c:\Projects\Wolfpack\Releases\v3.0.26\Source\Wolfpack.Core.WebServices\Strategies\Steps\RepublishMessageStep.cs:Zeile 10.

bei Wolfpack.Core.Pipeline.DefaultPipeline
1.Execute(T context) in c:\Projects\Wolfpack\Releases\v3.0.26\Source\Wolfpack.Core\Pipeline\DefaultPipeline.cs:Zeile 37.

--- Ende der internen Ausnahmestapelüberwachung ---

bei Wolfpack.Core.WebServices.Strategies.WebServiceReceiverStrategy.Execute(NotificationEvent notification) in c:\Projects\Wolfpack\Releases\v3.0.26\Source\Wolfpack.Core.WebServices\Strategies\WebServiceReceiverStrategy.cs:Zeile 35.

bei Wolfpack.Core.WebServices.Modules.NotificationModule.<.ctor>b__1(Object request) in c:\Projects\Wolfpack\Releases\v3.0.26\Source\Wolfpack.Core.WebServices\Modules\NotificationModule.cs:Zeile 33.

bei CallSite.Target(Closure , CallSite , Func`2 , Object )

bei Nancy.Routing.Route.<>c__DisplayClass4.<Wrap>b__3(Object parameters, CancellationToken context)

this basically means that a notification is added to our SQLRepository, albeit it already exists.
The error lies in the "CheckForDuplicateStep" which only checks for duplicates in a single repository. However it has to take all existing repositories into account! (fix coming soon)
Closed Feb 17, 2015 at 11:54 AM by gentledepp

comments

jimbobdog wrote Jan 27, 2015 at 9:13 AM

Ok, sure that makes sense and thanks in advance for any fix!

Regards,
James