
hi. i create cool stuff. eng @use_zypp
heaven
Joined May 2024
- Tweets2.8K
- Following1.3K
- Followers1.6K
- Likes3.3K
Replying to @josh_scriptz @Udoka_AM
sooo... the two requests can arrive at the same millisecond, but the db row lock would make them go one at a timee. the fiirst one sees [stock=1] and takes it, second one re-checks [stock > 0], sees 0 items left and gets ‘sold out’
so basically no middle layer is needed because the db already does that.
Replying to @Udoka_AM
i feel there should be a middle layer that resolves simultaneous requests. if there was one, it would have hit and sent back an error... but if none of them settles, then none of them gets the item.
hmmm.. omo 🙃
okay, what if we never get to "1 item left in stock", at least to the users. whenever we get to one remaining, we return it as none left in stock, so there is no possibility of overlapping requests.
could even help if someone in the company needs the product 😂

