Developer forum

Forum » Development » DBConcurrencyException: Concurrency violation

DBConcurrencyException: Concurrency violation

Tomas Gomez
Reply

Hi,

We get this exception sometimes, on the home page after restarting the solution. The exception is triggered only once, as it doesn't appear after refreshing or going to another page.

What if the reason for this exception? Any clue?

 

Regards,
Tomas

รง

 

 


Replies

 
Tomas Gomez
Reply

There are other posts with similar questions on:

  • https://doc.dynamicweb.com/forum/development/development/system-data-dbconcurrencyexception-concurrency-violation-in-payment-provider
  • https://doc.dynamicweb.com/forum/development/development/concurrency-violation-exception-in-ecommerce
 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Hi Tomas

Your dump is missing.

Thanks, Nicolai

 
Tomas Gomez
Reply

Sorry, I send it as an attachment

concurrency_exception.png
 
Tomas Gomez
Reply

Hi again, 

the error is still there, does somebody got a clue about the reason?

This is the log error:

2021-02-17 11:00:08.925: Concurrency violation: the UpdateCommand affected 0 of the expected 1 records.
System.Data.DBConcurrencyException: Concurrency violation: the UpdateCommand affected 0 of the expected 1 records.
at System.Data.Common.DbDataAdapter.UpdatedRowStatusErrors(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)
at System.Data.Common.DbDataAdapter.UpdatedRowStatus(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)
at System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows, DataTableMapping tableMapping)
at System.Data.Common.DbDataAdapter.UpdateFromDataTable(DataTable dataTable, DataTableMapping tableMapping)
at System.Data.Common.DbDataAdapter.Update(DataSet dataSet, String srcTable)
at Dynamicweb.Ecommerce.Orders.OrderRepository.Save(Order order)
at Dynamicweb.Ecommerce.Orders.OrderService.Save(Order order, Boolean saveOldVersion)
at Dynamicweb.Ecommerce.Frontend.Cart.CartService.SaveCart(Order cart, User user, OrderContext orderContext)
at Dynamicweb.Ecommerce.Common.Context.SetCart(Order cart, User user, OrderContext orderContext)
at Dynamicweb.Ecommerce.Frontend.Cart.CartService.LoadCart(User user, OrderContext orderContext)
at Dynamicweb.Ecommerce.Common.Context.GetCart(OrderContext orderContext)
at Dynamicweb.Ecommerce.Frontend.Cart.CartCatch.CatchCart(Int32 pageId, PageView pageView)
at Dynamicweb.Ecommerce.Frontend.EcomPageLoadNotificationSubscriber.LoadedPage(PageView pageview)
at Dynamicweb.Extensibility.Notifications.NotificationManager.Notify(String notification, NotificationArgs eventArgs)
at Dynamicweb.Frontend.PageView.Load()
at Dynamicweb.Frontend.DynamicwebHttpHandler.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
2021-02-17 11:00:08.956: Request headers: [   "Connection",   "Content-Length",   "Accept",   "Accept-Encoding",   "Accept-Language",   "Cookie",   "Host",   "User-Agent",   "sec-ch-ua",   "sec-ch-ua-mobile",   "upgrade-insecure-requests",   "sec-fetch-site",   "sec-fetch-mode",   "sec-fetch-user",   "sec-fetch-dest",   "X-Original-URL" ]
2021-02-17 11:00:08.956: Request item keys: [   "Order.Field.Collection.SELECT *  FROM EcomOrderField ORDER BY OrderFieldSort",   "eCommerce.Price.CachedPrices",   "owin.Environment",   {},   "EcomCart:CustomCartContext",   "Dynamicweb.Analytics.VisitorCookie",   "MS_HttpRequestMessage",   "AspSession",   "PermissionContextStack",   "Dynamicweb.OMC.VisitContext",   "QubbosLiveIntegrationAddInWebServiceURI",   "AspSessionIDManagerInitializeRequestCalled",   "Price.Collection.SELECT EcomPrices.* FROM EcomPrices WHERE PriceProductID=\u0027PROD7742\u0027 ORDER BY PriceID",   "alternateUrlKey",   "ExecutionTableMapper",   "Price.Collection.SELECT EcomPrices.* FROM EcomPrices WHERE PriceProductID=\u0027PROD3472\u0027 ORDER BY PriceID",   "DWPAGEVIEW",   "Dynamicweb.Environment.Web",   "Dynamicweb.Tracking.Tracker" ]
2021-02-17 11:00:08.956: Request form: []

 

 

concurrency_violation.png
 
Anders Ebdrup
Anders Ebdrup
Reply

We see the same issue as Tomas

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi guys,

I can confirm we see the same thing sometimes.

In our case, we have isolated one of the cases to an update on an order (usually because of a delayed payment confirmation).

But we have also seen it from time to time (on various versions) even in development instances where the payment is out of the equation.

It looks like it is not an isolated case but it seems pretty hard to reproduce it consistently.

 

Adrian

 
Anders Ebdrup
Anders Ebdrup
Reply

When a user is starting up on the shop we also see errors like this (stack trace is from 9.10):

 

[InvalidOperationException: Collection was modified; enumeration operation may not execute.]
   System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource) +56
   System.Collections.Generic.Enumerator.MoveNextRare() +14657978
   Dynamicweb.Ecommerce.Orders.OrderService.ClearCachedPrices(Order order) +147
   Dynamicweb.Ecommerce.Orders.OrderLineCollection.Add(OrderLine orderLine) +53
   Dynamicweb.Ecommerce.Orders.Order.get_OrderLines() +263
   Dynamicweb.Ecommerce.Orders.OrderService.ClearCachedPrices(Order order) +40
   Dynamicweb.Ecommerce.Frontend.Cart.CartService.SaveCart(Order cart, User user, OrderContext orderContext) +43
   Dynamicweb.Ecommerce.Common.Context.SetCart(Order cart, User user, OrderContext orderContext) +114
   Dynamicweb.Ecommerce.Frontend.Cart.CartService.LoadCart(User user, OrderContext orderContext) +678
   Dynamicweb.Ecommerce.Common.Context.GetCart(OrderContext orderContext) +53
   Dynamicweb.Ecommerce.Frontend.Cart.CartCatch.CatchCart(Int32 pageId, PageView pageView) +550
   Dynamicweb.Ecommerce.Frontend.EcomPageLoadNotificationSubscriber.LoadedPage(PageView pageview) +407
   Dynamicweb.Extensibility.Notifications.NotificationManager.Notify(String notification, NotificationArgs eventArgs) +866
   Dynamicweb.Frontend.PageView.Load() +2633
   Dynamicweb.AspNet.DynamicwebHttpHandler.ProcessRequest(HttpContext context) +50
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +790
   System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +195
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +88
 
Scott Forsyth Dynamicweb Employee
Scott Forsyth
Reply

We're getting it too, for sites with a single currency. We've had this on a few sites and I thought that they went away with upgrades, but the site below just reported it on 9.9.3.

 
Unnsteinn Garðarsson
Unnsteinn Garðarsson
Reply

We have a site using 9.9.8 and we have the same error, it has been reported from a few customers when they open the webshop, but it is resolved with a reload. AFAIK it has been happening from time to time for a while now, at least half a year, probably longer.

 
Allan Iversen
Allan Iversen
Reply

Any update on this? - we too get these on our customer solutions from time to time.

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Hi Allan

Yes - we are working on a solution and is close to testing stage. This is a really difficult one for us, because it affects the order of how orders are calculated and passed to and from live integration and other risky stuff. But we have a solution that we think will take care of all these scenarios and also fix this problem. The testing of this will be thorough because of the risk, and might also take a bit of time.

BR Nicolai

 
Allan Iversen
Allan Iversen
Reply

Sounds great - we wait for this.

 
Tomas Gomez
Reply

Hi,

We updated to DW 9.10.13 and the error is still there. Have to mention that, as far as now, it happens no so often as with previous version DW 9.9.6

Regards,
Tomas

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Can you provide a screendump or full stracktrace?

What kind of custom code do you have that calls order.save?

 
Tomas Gomez
Reply

Hi Nicolai,

Thanks for the prtompt reply.

Last time happened to a colleague, just starting a new window at the home page. The info and content of the error is:

User Name: System
Url: /
Description: Concurrency violation: the UpdateCommand affected 0 of the expected 1 records.
Created: Wed, 15 Sep 2021 09:19 (UTC+02:00)
Machine name: DW-D014
Exception type: DBConcurrencyException

2021-09-15 09:19:42.741: Concurrency violation: the UpdateCommand affected 0 of the expected 1 records.
System.Data.DBConcurrencyException: Concurrency violation: the UpdateCommand affected 0 of the expected 1 records.
at System.Data.Common.DbDataAdapter.UpdatedRowStatusErrors(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)
at System.Data.Common.DbDataAdapter.UpdatedRowStatus(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)
at System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows, DataTableMapping tableMapping)
at System.Data.Common.DbDataAdapter.UpdateFromDataTable(DataTable dataTable, DataTableMapping tableMapping)
at System.Data.Common.DbDataAdapter.Update(DataSet dataSet, String srcTable)
at Dynamicweb.Ecommerce.Orders.OrderRepository.Save(Order order)
at Dynamicweb.Ecommerce.Orders.OrderService.Save(Order order, Boolean saveOldVersion)
at Dynamicweb.Ecommerce.Frontend.Cart.CartService.SaveCart(Order cart, User user, OrderContext orderContext)
at Dynamicweb.Ecommerce.Common.Context.SetCart(Order cart, User user, OrderContext orderContext)
at Dynamicweb.Ecommerce.Frontend.Cart.CartService.LoadCart(User user, OrderContext orderContext)
at Dynamicweb.Ecommerce.Common.Context.GetCart(OrderContext orderContext)
at Dynamicweb.Ecommerce.Frontend.Cart.CartCatch.CatchCart(Int32 pageId, PageView pageView)
at Dynamicweb.Ecommerce.Frontend.EcomPageLoadNotificationSubscriber.LoadedPage(PageView pageview)
at Dynamicweb.Extensibility.Notifications.NotificationManager.Notify(String notification, NotificationArgs eventArgs)
at Dynamicweb.Frontend.PageView.Load()
at Dynamicweb.AspNet.DynamicwebHttpHandler.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
2021-09-15 09:19:42.803: Request headers: [   "Connection",   "Accept",   "Accept-Encoding",   "Accept-Language",   "Cookie",   "Host",   "User-Agent",   "sec-ch-ua",   "sec-ch-ua-mobile",   "sec-ch-ua-platform",   "upgrade-insecure-requests",   "sec-fetch-site",   "sec-fetch-mode",   "sec-fetch-user",   "sec-fetch-dest" ]
2021-09-15 09:19:42.803: Request item keys: [   "DynamicwebLiveIntegrationIsIntegrationActive",   "owin.Environment",   "EcomCart:CustomCartContext",   {},   "AspSession",   "PermissionContextStack",   "QubbosLiveIntegrationAddInWebServiceURI",   "AspSessionIDManagerInitializeRequestCalled",   "alternateUrlKey",   "ExecutionTableMapper",   "DWPAGEVIEW",   "Dynamicweb.Environment.Web",   "MS_HttpRequestMessage",   "Dynamicweb.Tracking.Tracker" ]
2021-09-15 09:19:42.803: Request form: []

The ruote and the last line "Request headers" slightly changes in other errors, for instance:

2021-09-13 09:23:47.289: Request headers: [   "Connection",   "Accept",   "Accept-Encoding",   "Accept-Language",   "Cookie",   "Host",   "Referer",   "User-Agent",   "sec-ch-ua",   "sec-ch-ua-mobile",   "upgrade-insecure-requests",   "sec-fetch-site",   "sec-fetch-mode",   "sec-fetch-user",   "sec-fetch-dest" ]
2021-09-13 09:23:47.289: Request item keys: [   "Order.Field.Collection.SELECT *  FROM EcomOrderField ORDER BY OrderFieldSort",   "owin.Environment",   "EcomCart:CustomCartContext",   "MS_HttpRequestMessage",   "AspSession",   "PermissionContextStack",   "QubbosLiveIntegrationAddInWebServiceURI",   "AspSessionIDManagerInitializeRequestCalled",   "alternateUrlKey",   "ExecutionTableMapper",   "DWPAGEVIEW",   {},   "Dynamicweb.Environment.Web",   "DynamicwebLiveIntegrationIsIntegrationActive",   "Dynamicweb.Tracking.Tracker" ]

2021-09-13 01:43:59.337: Request headers: [   "Connection",   "Accept",   "Accept-Encoding",   "Accept-Language",   "Cookie",   "Host",   "User-Agent",   "Upgrade-Insecure-Requests",   "Sec-Fetch-Site",   "Sec-Fetch-Mode",   "Sec-Fetch-User",   "Sec-Fetch-Dest" ]
2021-09-13 01:43:59.337: Request item keys: [   "DynamicwebLiveIntegrationIsIntegrationActive",   "owin.Environment",   "EcomCart:CustomCartContext",   "MS_HttpRequestMessage",   "AspSession",   "PermissionContextStack",   "QubbosLiveIntegrationAddInWebServiceURI",   "AspSessionIDManagerInitializeRequestCalled",   "alternateUrlKey",   "ExecutionTableMapper",   "DWPAGEVIEW",   {},   "Dynamicweb.Environment.Web",   "Dynamicweb.Tracking.Tracker" ]
2021-09-13 01:43:59.337: Request form: []

 

As well, I attach an image with errors at monitoring

Regards,
Tomas

 

concurrency_violation.png
 
Tomas Gomez
Reply

Hi Nicolai,

Is that trace useful to search for the error?

Our custom code save the orders from several places, but it doen't appear any of tem in the trace (they usually appear when there is an error in our code)

Regards,
Tomas

 

You must be logged in to post in the forum