Nobody has started this yet — be first.
Business impact
sku_inventory.version exists so the optimistic-locking strategy (and any future tooling that reasons about "has this row changed since I last looked?") can detect concurrent writers. If a routine restock silently resets it back to 1, any external system caching "the version I last saw was N" now sees a version lower than one it already observed -- undermining the entire assumption that version only ever climbs. This kind of bug tends to stay invisible for a long time (nothing crashes) and then causes deeply confusing behavior in whatever eventually relies on version being monotonic.
Problem
Every restock of an already-existing SKU resets sku_inventory.version back to 1, instead of incrementing it.
Current behavior
Restock's INSERT ... ON CONFLICT DO UPDATE clause sets version = EXCLUDED.version, but EXCLUDED.version is always the literal 1 from the INSERT's own VALUES list.
Expected behavior
version should increase by exactly 1 on every write to the row -- restocks included, the same as reservations, commits, releases, and expiries already do.
Steps to reproduce
go test ./tickets/tests/... -run TestTicket10 -vWhy this matters
Restock's INSERT ... ON CONFLICT DO UPDATE clause sets version = EXCLUDED.version -- but EXCLUDED.version is always the literal 1 from the INSERT's own VALUES list (used only for the very first creation), not a computed "current version + 1". Every subsequent restock of the same row re-applies that same literal 1.
Suggested approach
Compare the version assignment in Restock's ON CONFLICT clause against how every other write to sku_inventory in this codebase increments version (grep -n "version = sku_inventory.version" pkg/inventory will find several).
Acceptance criteria
Verification
TEST_DATABASE_URL=postgresql://... go test ./tickets/tests/... -run TestTicket10 -v
Hints (0/2)
Try it without hints first — the reading is the exercise.
Working on this ticket
Work on a branch named for the ticket — that's what you'll submit.
Branch off your fork
Sign in to create it automatically, or do it yourself:
$git checkout -b fix/restock-version-resetFix it and commit
Meet every acceptance criterion, and add a test that would have caught this.
Push the branch
$git push -u origin fix/restock-version-resetSubmit it below
Paste your fork URL and the branch name, with a short write-up of the root cause.
Questions
Ask about anything unclear in the ticket — the maintainer and anyone who has solved it can answer. Please don't post full solutions.
Sign in to ask a question or reply.
Sign inSKIP LOCKEDhttp://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.
Level 1
Fix a bug
Read existing behaviour, correct it.