Friday 11 May 2018

Nodejs Race condition handling in Ecommerce Website.

Suppose there are two users A and B making a purchase in a E commerce website at a time.A sees the product quantity is more than 1, so in order to lock the product quantity ( temporarily reduct the product quantity to zero) He makes a call to mysql module and this results in waiting for a callback function !!During this time B sees the product quantity as 1,he too locks the product and the entire product quantity changes to -1;How to handle this case in Nodejs ? So that Only A completes the transaction sychronously and B gets a message that product is out of stock.

Submitted May 11, 2018 at 10:43PM by a_naidu

No comments:

Post a Comment