I got a screen (block) in which users make requests for a specific product and I validate the number of items available in the database at the moment of the request, before they commit, which is suposed to reduce the existence ot the item requested.
The problem I'm facing is... if several users are making the request at the same time they all get the existence available before a complete request has been done by a user. So when another user makes the request, the existence in the datase is unreal for that particular user.
I think of validating the existence of the product again before commiting the request to the database, and display a message to the user that the existence has chaged since the he first logged in. I don't know if that is a good solution. I need your expiience in this type of situation.
How can I control the existence of an item while several users are making requests at the same time?
I just need the basic idea so I can continue with the code.I think the problem is independent on language I am using.