Cannot insert duplicate key in object 'dbo.TeaCommerce_CustomOrderProperty'
Hi,
We are using Umbraco 6.1.6 and TC 2.3.2.
Sometimes we get the error during saving changes to DB for order. Our order contains about 10 custom properties and as result of save we get the following error:
Exception Details:
System.Data.SqlClient.SqlException (0x80131904): Violation of PRIMARY KEY constraint 'PK_TeaCommerce_CustomProperty'. Cannot insert duplicate key in object 'dbo.TeaCommerce_CustomOrderProperty'. The duplicate key value is (15737fe8-975a-496d-a9f8-dc78299667ca, state).
The statement has been terminated.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, 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(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at TeaCommerce.Api.Persistence.Database.Insert(String tableName, String primaryKeyName, Boolean autoIncrement, Object poco)
at TeaCommerce.Api.Persistence.Database.Insert(Object poco)
at TeaCommerce.Api.Persistence.Repositories.OrderRepository.Save(Order order)
at TeaCommerce.Api.Models.Order.Save()
As I mention, this error appears rarely and for different custom properties.
Yes, I sow it. But in our case alias name all time the same.
And as I mention, this issue appear not all time. So about 90 % of orders processed successfully, and only 10 % failed with this issue. So this issue appears unexpectedly.
I only have idea that this issue could happen when 2 or more threads tried to save the same order. But according to our code this shouldn't be possible.
Hmm that is weird. Somehow the object model must lose the DB id of the row and because of that it tries to insert it again. But we have not heard that this is something that happens on all solutions. We have never seen it in any of the ones we have build.
Cannot insert duplicate key in object 'dbo.TeaCommerce_CustomOrderProperty'
Hi,
We are using Umbraco 6.1.6 and TC 2.3.2.
Sometimes we get the error during saving changes to DB for order. Our order contains about 10 custom properties and as result of save we get the following error:
As I mention, this error appears rarely and for different custom properties.
Any ideas what is cause of this issue?
Hi Alexey,
Have you seen this thread.
https://our.umbraco.org/projects/website-utilities/tea-commerce/tea-commerce-support/45503-Error-when-changing-First-name-property-alias-or-Last-name-property-alias,
Perhaps it can help you to solve your issue.
/Dennis
Hi Dennis,
Yes, I sow it. But in our case alias name all time the same.
And as I mention, this issue appear not all time. So about 90 % of orders processed successfully, and only 10 % failed with this issue. So this issue appears unexpectedly.
I only have idea that this issue could happen when 2 or more threads tried to save the same order. But according to our code this shouldn't be possible.
Best regards. Alexey
Hi Alexey
Does it state which custom order line and value it tries to add to the DB? Maybe that can give you an idea of what happens.
Hi Anders,
Can you rephrase your comment. Not fully catch what you mean.
/Alexey
If the log/error tells which property alias and value that fails
Hello Anders,
Yes, we know value and alias. But all time we get different values and different properties aliases.
See example example of the same error but for other property:
As you can see we get same error but for other property after 2 weeks only.
/Alexey
Hmm that is weird. Somehow the object model must lose the DB id of the row and because of that it tries to insert it again. But we have not heard that this is something that happens on all solutions. We have never seen it in any of the ones we have build.
Hmm - so how to debug that? :)
Kind regards
Anders
is working on a reply...