In our project we are maintaining the stock levels for products. I am facing an issue in a specific scenario and its mentioned below -
I have set a Product A stock to 3 and now two different users, lets say User A and User B, have added 2 qty of Product A in their cart. Since stock is not reserved yet so both can add qty 2 to their cart, when both users simultaneously proceed to payment page and as a result stock level reaches to -1 (negative) order gets placed successfully for both the users.
ideally as soon as its reserved by one of the users it should not allow other to proceed with qty 2 .
Can anyone please suggest or advise me on this issue ? How can I prevent this situation ?
I am unable to replicate this issue on my local but its rarely occurring on Production.
Thanks in advance.