Transactional “Reserve Inventory” with SELECT … FOR UPDATE

12505
0

Inventory systems are concurrency systems. Lock the row, verify available quantity, then write the reservation in the same transaction. It’s the simplest correct starting point.