The Last-Item Race Condition: Why Two Customers Both 'Win' the Same Order
Two requests hit your checkout API at the same millisecond for the last unit in stock. Both succeed. You just oversold. Here's the race condition, and three real fixes: SELECT FOR UPDATE, optimistic locking, and atomic Redis DECR.