We've 1 book left in the inventory. and two people are trying to get the same book ( say person x and person y ). Person x has added book to the cart and about to make payment and person y has also added book to the cart. How would you solve this concurrency problem ?
Asked
Active
Viewed 143 times
1 Answers
1
Based on your description, Looks like you are allowing users to add last item to cart that mean there is no hold on item while its in cart, Now you can add check during check out, checking for item availability like database constraint that stock can not be less than 0 in this case your database transaction will fail and would return error. You can reply back with message saying item out of stock.

kr.pradeep
- 115
- 8