Reject Stale Writes to Calendar Events With ETags
Last updated: November 29, 2026
Quick Overview
Implement optimistic concurrency for a Calendar event update method: each event carries an etag, and an update with a stale etag must fail with a precondition error instead of overwriting someone else's change.
0
0
0 solved
Implement optimistic concurrency for a Calendar event update method: each event carries an etag, and an update with a stale etag must fail with a precondition error instead of overwriting someone else's change.
Calendar events are edited from phones, the web and shared assistants at the same time, so Google APIs expose etags and If-Match. This easy screen question checks that you know the read-modify-write race and the HTTP status codes that go with it.
What the Interviewer Expects
- Describe the lost update race between two editors
- Generate a new etag on every successful write
- Compare the client etag before applying the write
- Return 412 Precondition Failed on mismatch and 404 on missing
- Allow unconditional writes when no etag is sent, if the API chooses to
Key Topics to Cover
How to Approach This
- Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
- Choose data structures based on access patterns, not familiarity.
- Prefer immutable data and message passing over shared mutable state for concurrency.
- Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
- Should the etag be a version counter or a content hash?
- How does If-None-Match help with caching reads?
- How do you avoid the check and write racing each other?
- What should the client do after a 412?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice System Design ProblemsSample Answer
Requirements
get(event_id)returns(event, etag).update(event_id, fields, if_match=None)applies the change only ifif_matchequals the current etag, then returns the new etag.- Mismatch raises a 412...
High-Level Design
Two assistants both read an event at version 7, both change different fields, and both save; without a precondition the second save silently erases the first. With etags the second save carries versio...