Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Rasmus Fjord 675 posts 1566 karma points c-trib
    Jan 31, 2019 @ 13:00
    Rasmus Fjord
    0

    Cannot insert duplicate key in object

    Hey :)

    We have a webshop running TC 3.2.4 were we sometime see a wierd error.

    The error is here :

        2019-01-31 13:53:16,297 [P12732/D3/T8] ERROR BlueHors.Models.Shop.ShopContext - Violation of PRIMARY KEY constraint 'PK_TeaCommerce_OrderLinePrice_1'. Cannot insert duplicate key in object 'dbo.TeaCommerce_OrderLinePrice'. The duplicate key value is (3481, 3).
    The statement has been terminated.
    System.Data.SqlClient.SqlException (0x80131904): Violation of PRIMARY KEY constraint 'PK_TeaCommerce_OrderLinePrice_1'. Cannot insert duplicate key in object 'dbo.TeaCommerce_OrderLinePrice'. The duplicate key value is (3481, 3).
    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, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted)
       at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
       at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
       at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
       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.SaveOrderLines(Database database, Guid orderId, OrderLineCollection orderLines, Nullable`1 parentOrderLineId)
       at TeaCommerce.Api.Persistence.Repositories.OrderRepository.Save(Order order)
       at TeaCommerce.Api.Models.Order.Save()
       at TeaCommerce.Api.Web.SessionController.SetCurrentVatGroupId(Int64 storeId, Int64 vatGroupId)
       at TeaCommerce.Api.Web.TeaCommerceHelper.SetCurrentVatGroup(Int64 storeId, Int64 vatGroupId)
       at ShopContext.UpdateShopContext() in myproject\ShopContext.cs:line 108
    

    If we look at shopcontext.cs line 108 we actually just set a vat group: TC.SetCurrentVatGroup(SkyConstants.ShopId, vatGroupId);

    And its not a constant bug, it just on browsing, or if we search for a product through lucene. I dont know if it has something to do with it, but it might be when we hit something alot of times quickly, like a search api.

    Any ideas? Im really hitting bottom on this one and cant seem to figure out why.

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Jan 31, 2019 @ 13:25
    Matt Brailsford
    0

    Hey Rasmus,

    That's an interesting one. What database tech are you using? SQL Server? SQL Azure?

  • Rasmus Fjord 675 posts 1566 karma points c-trib
    Jan 31, 2019 @ 13:28
    Rasmus Fjord
    0

    Yeah its an odd one, and we see on multiple places of the solution, I was thinking if it was part of some sql pooling or something that made it come out.

    Its on a 100 DTU Azure SQL. Not doing anything special in the connection string, so all basic umbraco setup.

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Jan 31, 2019 @ 13:32
    Matt Brailsford
    0

    Hmm, the only thing I know of currently is that TC uses it's own implementation of PetaPoco which doesn't have transient fault handling like the Umbraco Core does, but if that was the issue, I'd expect requests to be failing rather than running multiple times.

  • Rasmus Fjord 675 posts 1566 karma points c-trib
    Feb 01, 2019 @ 08:19
    Rasmus Fjord
    0

    Hmm yeah that is wierd :/

    Is their a way we can come this any closer? Im guessing the code where the error is thrown is comming from the closed source part of TC.

    WIll it be an option to send you a zip of the project? and how to force it "down"?

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Feb 01, 2019 @ 09:24
    Matt Brailsford
    0

    Sure, we can certainly try.

    Drop us an email at [email protected] with a copy of your project (please make sure it doesn't contain any customer data) and instructions for getting setup / replicating the issue and we can see what we can figure out.

Please Sign in or register to post replies

Write your reply to:

Draft