The Auction That Closed Instantly — Java Bug Hunt
Inspired by the unit-mismatch outages that hit marketplaces: one side of a comparison speaks seconds, the other milliseconds, and suddenly every auction on…
- Language: Java
- Layer: Backend
- Difficulty: Easy
- Concepts: Time, Units
- Modelled on: eBay-class markets
- Visible tests: an auction with time left is open; the closing instant closes it
- Reward: 50 XP for a complete fix
Incident
- Severity: SEV-1 (priority: Critical)
- Ticket: BUG-SNIPE
- Reported by: marketplace
- Time to fix: 10 minutes, the target for an easy incident
Failing checks on the shipped build
- an auction with time left is open — 1s before close: expected condition to hold
How to work this incident
- Read the report: write down the expected behaviour and the actual one in a sentence each.
- Reproduce it: run the visible tests and find the failing check that matches the report.
- Read the logs and the failing checks for the first value that is wrong — the earliest wrong value is nearer the cause than the loudest error.
- Follow the request through the handler, the validation and the service it calls; find the first step whose output disagrees with the report.
- Fix the cause rather than the symptom, run the visible tests again, and submit against the hidden ones — then write the root cause down.
Briefing
Inspired by the unit-mismatch outages that hit marketplaces: one side of a comparison speaks seconds, the other milliseconds, and suddenly every auction on the site is "already ended".
AuctionClock.java mixes the two.
Bug report
BUG-SNIPE · Priority: Critical · Reported by: marketplace
isClosed(closeAtSeconds, nowMillis) — auctions close AT the closing instant:
- 1 second before -> open
- exactly at close -> closed
- 1 second after -> closed
Observed: every auction reports closed the moment it is listed, because epoch milliseconds are ~1000x larger than epoch seconds.
Logs
[auction] listed at 1700000000s, closeAt=1700086400s, now=1700000000123ms -> CLOSEDThe code as shipped
AuctionClock.java (editable)
class AuctionClock {
static boolean isClosed(long closeAtSeconds, long nowMillis) {
return nowMillis >= closeAtSeconds;
}
}Open the hunt to start the incident clock, edit the files, run the visible tests and submit against the hidden ones, then write the root cause down. More Java bug hunts.