Oversell-proof stock reservations under extreme concurrent contention: 100 units, 50,000 simultaneous "Buy Now" clicks, and exactly 100 must succeed.
Nobody has started this yet — be first.
Reserving exactly the last unit of stock is wrongly rejected
This project's entire reason for existing, stated plainly in its own README, is "100 units of stock, 50,000 simultaneous clicks, and EXACTLY 100 must succeed." With this bug, the 100th buyer -- the one asking for exactly the last unit of remaining stock -- gets a "sold out" rejection even though there is precisely enough stock to satisfy them. In a real flash sale that is a customer who did everything right and got turned away for no reason, a lost sale, and (if anyone compares "units sold" against "units in the warehouse" afterward) a support ticket asking why inventory does not match what was reported sold.
About this project
A production-grade inventory and reservation service whose entire reason for existing is preventing overselling under extreme concurrent contention. An append-only ledger () is the source of truth, double-entry-bookkeeping style, with a Postgres trigger physically forbidding any / on it; a materialized row gives O(1) reads and carries a constraint so can never even be committed out of balance. The reservation hot path is a pluggable with two implementations — one atomic conditional and one read-then-compare-and-swap optimistic loop reusing the sibling project's jittered-backoff retry executor — selected via and benchmarked head to head against 50,000 concurrent requests. A reaper reclaims expired holds safely across multiple replicas, idempotent commit/release logic makes retried payment webhooks a non-event, and a reconciliation tool re-sums the entire ledger from scratch to catch drift a naive balance check would miss.
REAPER_BATCH_SIZE is silently ignored
An operator tuning the TTL reaper under load (e.g. raising the batch size because expired reservations are piling up faster than the reaper clears them) sets `REAPER_BATCH_SIZE` in their deployment config and sees no change at all. There is no error, no warning -- the setting is silently discarded. This is exactly the kind of bug that costs an on-call engineer an hour of "I set it, why isn't it working?!" before anyone thinks to grep the source for the literal env var name.
stock_ledgerUPDATEDELETEsku_inventoryCHECKavailable + reserved + sold = totalClaimStrategyUPDATEreliableLOCK_STRATEGYSELECT ... FOR UPDATE SKIP LOCKEDSeventeen tickets are bugs deliberately injected into an otherwise-working codebase (an off-by-one on the exact-boundary claim, a sign flip that corrupts the optimistic strategy, a copy-pasted SQL branch that returns sold stock to available instead of marking it sold, two hard concurrency bugs from missing row-locking clauses); eight are enhancements that do not exist yet, each with a compile-only panicking stub so the codebase and the verification tests build before the real implementation is written. Every ticket has a dedicated Go test that goes green when the fix is correct — and several document exactly which of the project's own pre-existing tests they collaterally break in the meantime.
http://localhost:8081localhost:5434flash-saleeveryday-widgetcurl localhost:8081/healthzgo run ./cmd/loadtest -url http://localhost:8081 -sku flash-sale -concurrency 10000Work the tickets in tickets/docs/ (ordered easy → hard); each names one dedicated Go test in tickets/tests/:
export TEST_DATABASE_URL=postgresql://inventory:inventory@localhost:5432/inventory_test?sslmode=disable
go test ./tickets/tests/... -run TestTicket24 -v # a single ticket
./tickets/run_tickets.sh # all 25, clean pass/fail summary
Tickets that don't touch Postgres (02, 07, 17, 19) run fine without TEST_DATABASE_URL; the rest t.Skip cleanly, not fail, if it's unset.
How to run it locally, step by step.