Try our conversational search powered by Generative AI!

Race condition in cart creation

Fixed in

EPiServer.Commerce 9.15.0

(Or a related package)

Created

Mar 30, 2016

Updated

May 11, 2016

Area

Core

State

Closed, Fixed and tested


Description

When a cart gets created by calling Cart.GetCart (overload with string name, Guid customerId, MarketId marketId), a race condition occurs which can cause an exception.

If a second thread reads the cart list from cache before the first thread creates and caches a cart, the second thread tries to create another cart. This leads either to an exception (because of a DB constraint) or the creation of multiple carts, which leads to an exception the next time the cart is loaded (because the code assumes only one cart can exist (SingleOrDefault)).