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.

Google
Software Engineering Fundamentals
Software Engineer
Google
November 29, 2026
Software Engineer
Phone Screen
Software Engineering Fundamentals
Easy

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
optimistic concurrency
etag
If-Match
HTTP 412
REST API design
How to Approach This
  1. Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
  2. Choose data structures based on access patterns, not familiarity.
  3. Prefer immutable data and message passing over shared mutable state for concurrency.
  4. 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 Problems
Sample Answer
Requirements
  • get(event_id) returns (event, etag).
  • update(event_id, fields, if_match=None) applies the change only if if_match equals 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...


Submit Your Answer
Markdown supported