Stock reservation (inventory locking)
Holding a product for a few minutes while a customer pays, so nobody else can buy it.
How do I avoid selling the same product twice in my online store?
When a product is one of a kind or only a few units are left, two people can try to buy it at almost the same moment. A stock reservation sets it aside on the server the instant someone starts paying, and releases it again if the payment doesn't go through in time.
It's called atomic when the database does the check and the hold in a single, indivisible step, with the record locked for an instant. If two attempts arrive together, one waits for the other, and the second one finds the stock already at zero.
Why it matters to your business
Selling the same thing twice means refunding money and apologizing to a customer who'd already made up their mind. In a store with one-of-a-kind products or limited stock, that collision can happen any day two customers want the same thing.
How we use this at Damorus
At URG Technology, almost everything is a one-of-a-kind unit, and the first version let two buyers through at once and built up phantom stock, computers held forever by abandoned payments. The fix was an atomic reservation in PostgreSQL, a rule that blocks holding more than what exists, automatic release every two minutes, and cross-cancellation between Mercado Pago and Bre-B. Whoever loses the race sees "Someone was faster!", a button pointing to similar computers, and a 5% coupon by email.
Need this on your project?
I want my free mockup →