Sold Out, Sold Again

Medium

· Database

Incident

SEV-1

BUG-OVERSELL

Priority: Critical (refund storm) · reported by ticketing

Time to fix: 20 min

Failing checks on the shipped build

  • the second oversized request is rejected

    only 2 seats remained: expected [true,false] but got [true,true]

  • requests that fit all pass

    expected 0 but got 7

How to work this incident

  1. Read the report: write down the expected behaviour and the actual one in a sentence each.
  2. Reproduce it: run the visible tests and find the failing check that matches the report.
  3. 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.
  4. Follow the data through the query or the repository code; compare the rows it returns with the rows the report expects.
  5. Fix the cause rather than the symptom, run the visible tests again, and submit against the hidden ones — then write the root cause down.

Inspired by

Ticketmaster-class sales

Inspired by every on-sale meltdown where more tickets sell than exist. The batch processor reads the inventory count once, then validates the entire queue against that stale snapshot — every request "fits".

reservations.js must re-check against the live count for each request.

Code map

// Processes a queue of reservation requests against the inventory.
exports.processQueue = function (store, requests) {
  var available = store.count;
  var decisions = [];
  for (var i = 0; i < requests.length; i++) {
    if (available >= requests[i]) {
      store.count = available - requests[i];
      decisions.push(true);
    } else {
      decisions.push(false);
    }
  }
  return decisions;
};

Sign in to edit the file, run the tests and submit a fix

A free account — no card, no trial clock. You come straight back here.

Sold Out, Sold Again — JavaScript Bug Hunt

Inspired by every on-sale meltdown where more tickets sell than exist.

  • Language: JavaScript
  • Layer: Database
  • Difficulty: Medium
  • Concepts: Inventory, Check-Then-Act
  • Modelled on: Ticketmaster-class sales
  • Visible tests: the second oversized request is rejected; requests that fit all pass
  • Reward: 50 XP for a complete fix

Incident

  • Severity: SEV-1 (priority: Critical (refund storm))
  • Ticket: BUG-OVERSELL
  • Reported by: ticketing
  • Time to fix: 20 minutes, the target for a medium incident

Failing checks on the shipped build

  • the second oversized request is rejected — only 2 seats remained: expected [true,false] but got [true,true]
  • requests that fit all pass — expected 0 but got 7

How to work this incident

  1. Read the report: write down the expected behaviour and the actual one in a sentence each.
  2. Reproduce it: run the visible tests and find the failing check that matches the report.
  3. 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.
  4. Follow the data through the query or the repository code; compare the rows it returns with the rows the report expects.
  5. 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 every on-sale meltdown where more tickets sell than exist. The batch processor reads the inventory count once, then validates the entire queue against that stale snapshot — every request "fits".

reservations.js must re-check against the live count for each request.

Bug report

BUG-OVERSELL · Priority: Critical (refund storm) · Reported by: ticketing

processQueue(store, requests):

  • for each requested qty: if store.count >= qty, deduct and record true; otherwise record false
  • returns the array of decisions; store.count must end correct

Observed: 5 seats, queue [3, 3] -> both approved, 6 of 5 sold.

Logs

[gate] event 8112: capacity 5, tickets issued 6

The code as shipped

src/tickets/reservations.js (editable)

// Processes a queue of reservation requests against the inventory.
exports.processQueue = function (store, requests) {
  var available = store.count;
  var decisions = [];
  for (var i = 0; i < requests.length; i++) {
    if (available >= requests[i]) {
      store.count = available - requests[i];
      decisions.push(true);
    } else {
      decisions.push(false);
    }
  }
  return decisions;
};

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 JavaScript bug hunts.