Here's the oversell bug that bothers me most. A customer support ticket says two people were promised the last unit of the same product. You open the database and look at the stock row: OnHand = 1, Reserved = 1, Available = 0. Perfectly consistent. No negative number, no constraint violation, no exception in the logs. Everything looks right, and you still sold one unit twice.
In this post I'll focus on that one part of the problem: why the stock row looks healthy after an oversell, which number you should check instead, and how to make the race happen on every test run instead of once a month in production. The fixes come at the end, in outline. Everything here comes from a small EF Core 10 proof project I call StockGuard, running on SQLite with .NET SDK 10.0.401. It builds with zero warnings and its 17 xUnit tests pass.
If you need a complete multi-warehouse app rather than a proof project, the Inventory Management System (.NET 9) has it, and Tech Skill Builder has complete, tested
Discussion
Jump in and comment!
Get the ball rolling with your comment!