HomeChallengesRepsProblemsLeaderboardTake a challenge

The Lost Update

Two people opened the same order. Both pressed save. One of those edits is gone and there is no error, no log, and nothing to find later. Refuse the second write instead.

Intermediate20 min on the clock5 graded checks · 100 pointsThe Write Side
Graded by running your code against real cases.

What you build

  • updateIfUnchanged(rows, id, patch, expectedVersion) — write only if the version still matches
  • A stale version is a conflict: change nothing, say so
  • The version increments on a real write, and only then
  • An id that does not exist is missing, not a conflict
  • retryWith(...) — re-read, resolve, and write against the current version

Done means

The second save is refused rather than silently winning, and a retry succeeds.

How it is graded

Published in full, before you start — every point is one of these and there is nothing else. Each one runs your code; it is not a search for keywords.

  1. A matching version writes and bumps+20The lost update
  2. A stale version changes nothing+30The lost update
  3. A refused write does not bump the version+15The lost update
  4. An unknown id is missing, not a conflict+10Failing in a shape callers can read
  5. retryWith resolves and succeeds+25The lost update

What it teaches

The rest of The Write Side