The interview problem

Practice prompt

Two administrators edit the same resource from old browser tabs. Design optimistic concurrency that preserves both users' awareness instead of silently overwriting changes.

Original practice, not a reported company interview. Scenarios and numbers are illustrative. Interview date: not applicable. Sources retrieved October 1, 2026.

1. Scope and worked approach

Assume a resource has an opaque strong version validator. Return it with reads and require the matching precondition on updates. The storage operation compares and changes the version atomically. On conflict, return current state or a way to fetch it; the client shows a field-level merge when safe and asks for a decision otherwise. Authorization remains independent of the version check.

2. Trace the design or derivation

Read representation and version
  → edit
  → submit precondition
  → commit or return conflict

The compare and mutation must occur in one storage transaction or equivalent conditional primitive. Checking the version in application code and writing later leaves a race. Return enough conflict metadata for the client to preserve its draft, but do not expose fields the caller no longer has permission to read.

3. Calculate the example

Both editors read version 7 with limit 100. A sets it to 120 and commits version 8. B's attempt to set 80 with version 7 must fail the precondition. Automatically retrying B against version 8 would still lose A's intent; a retry requires a new user or operation-level merge decision.

4. Failure cases and trade-offs

Comparing a version in application memory before a separate write leaves a race. Omitting preconditions on one legacy endpoint bypasses the invariant. PATCH is not automatically conflict-free: two patches can touch the same logical field. Pessimistic locks reduce conflicts but add abandoned-lock handling and user waiting.

5. Validation, follow-ups and self-review

Submit simultaneous edits, identical retry bodies and stale authorized clients. Verify only one stale-base edit succeeds and the UI preserves unsaved text. Follow-up: can independent fields merge automatically? Reward atomic preconditions, retained intent and a defined conflict experience.

Sources and related practice

Technical reference: httpwg.org — HTTP validators, ranges, preconditions and representation semantics; customer workflows are original examples.

Source publication/update: June 2022. Retrieved October 1, 2026. The workflow, calculations and review exercises are original; this reference is not evidence that a company asked this question.

Continue with Design an offline-capable collaborative document editor; Handle conflicting customer edits without silent loss.

Continue your preparation

Choose a connected learning path or browse more System design questions. Read our editorial method and attribution policy.