Optimistic Concurrency Control for Concurrent Page Bio Edits

Last updated: November 29, 2026

Quick Overview

Two admins of the same Facebook Page edit its About section at the same time. Implement versioned writes so a stale edit is rejected instead of silently overwriting, plus a retry helper for safe automatic merges.

Meta
Software Engineering Fundamentals
Software Engineer
Meta
November 29, 2026
Software Engineer
Technical Screen
Software Engineering Fundamentals
Easy

0

0

0 solved


Two admins of the same Facebook Page edit its About section at the same time. Implement versioned writes so a stale edit is rejected instead of silently overwriting, plus a retry helper for safe automatic merges.

Lost updates are a classic databases-and-transactions bug, and Page settings with multiple admins are a concrete Meta setting where they happen. This screen question checks whether you know the version-column pattern, what the actual SQL looks like, and when to retry automatically versus asking the human.

What the Interviewer Expects
  • Explains the lost update anomaly with a concrete interleaving
  • Adds a version column and makes the write conditional on it
  • Shows the UPDATE ... WHERE version = ? statement and checks affected rows
  • Retries only pure mutations and surfaces conflicts on human edits
  • Compares with pessimistic locking (SELECT ... FOR UPDATE) and when each fits
Key Topics to Cover
optimistic concurrency control
lost updates
version columns
compare-and-set
transactions
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
  • When would you choose pessimistic locking instead?
  • How would you present a conflict to the second admin in the UI?
  • How would you merge field-level changes so editing the phone number does not conflict with editing the bio?
  • Does this work across a cache layer in front of the database?
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
  • read(page_id) returns fields and a version.
  • write(page_id, fields, expected_version) succeeds only if the version is unchanged, then increments it; otherwise raises VersionConflict.
  • `updat...
High-Level Design

Without protection: admin A reads bio v1, admin B reads v1, A saves, B saves, and A's change vanishes with no error. With a version column the save becomes `UPDATE pages SET bio = ?, version = version...


Submit Your Answer
Markdown supported