Magento2: Concurrent checkouts can lead to negative stock

Created on 27 Aug 2016  Â·  9Comments  Â·  Source: magento/magento2

Description:

When two customers check out concurrently for the same product and the total quantity being ordered is greater than the quantity available, the stock can become negative.

Preconditions

  1. Ubuntu 14.04
  2. Xampp 5.6.19
  3. Magento CE 2.1.0 with sample data.

    Steps to reproduce

  1. Start site, create two customers, create/pick test product and allocate some stock.
  2. Both customers add the product to their carts such that each cart individually is under (and not equal to) the available stock, but combined they exceed the available stock.
  3. 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 by simulating one customer in one browser window and another customer in a second browser window.

Expected result

  1. One of the two checkouts fails to complete.

Actual result

  1. Both checkouts succeed and the quantity for the product is negative in the admin console.
Checkout Clear Description Confirmed Format is valid Ready for Work Reproduced on 2.1.x Reproduced on 2.2.x Reproduced on 2.3.x bug report

All 9 comments

Does any one have solution? We set one product to sale and after that we have quantity of product=-14. We use 18 instances of frontend;

anyone have the solution for this issue? I think its critical issues.

me too with CE 2.1.5 - 2.1.7

Internal ticket was created for this issue - MAGETWO-69701

This solution https://belvg.com/blog/magento-2-oversell-fix.html are working for us

@TWarszawski, thank you for your report.
We've created internal ticket(s) MAGETWO-69701 to track progress on the issue.

The bug still exists in 2.1.9

Any update on this?

Hi @TWarszawski , current issue was fixed in 2.2-develop branch (commit: f726dacecc92e76d79f1b6319e7813633375cc89)

Was this page helpful?
0 / 5 - 0 ratings