New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Concurrent checkouts can cause stock to go below 0 when stock control is enabled. #403

TWarszawski opened this Issue Aug 17, 2016 · 0 comments


None yet
1 participant
Copy link

TWarszawski commented Aug 17, 2016

When two customers check out concurrently for the same product, both checkouts may succeed, and this causes the total amount of stock adjustments to be larger than the quantity in inventory.

Steps to reproduce:

  1. Start demo site, create two customers, create/pick test product.
  2. Both customers add the product to their baskets such that each basket individually is under the quantity in inventory and together they exceed this quantity. Perform a checkout concurrently, making sure both customers finish checkout (click the Place Order button) as close to the same time as possible.

We have reproduced this behavior on a single machine, by performing the above steps with one customer in one browser window and another customer in a second browser window with a short communication delay (100 ms) between the database and application. If connecting to the database using unix sockets, the following script can act as a proxy that delays packets:

Expected Result:
One of the two checkouts fails (this happens when performing the checkout serially).

Actual Result:
Both checkouts succeed, and the total stock adjustments for the product as seen in the admin site sum to less than 0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment