Asset Update Accepts a Future Revision
Level 2 · node · Concurrency · Optimistic locking revision equality error
Scenario
A fictional equipment inventory service uses revision-based optimistic locking because multiple operators can edit the same asset note. Updates must include the revision last read by the operator and should succeed only if it exactly matches the stored revision. The current implementation rejects stale revisions but accepts revisions higher than the current value, allowing an invalid edit.
Requirements
Update the note and increment the revision only when expectedRevision is an integer exactly equal to the stored revision. Reject older, future, or missing revisions without changing the note or revision.
Acceptance criteria
- An edit matching the current revision succeeds.
- An edit with an older revision is rejected.
- An edit with a future revision is rejected.
- An edit without a revision is rejected.