ORIGINAL COMPANY-CONTEXT PRACTICE
Reconcile edits from offline devices
Original practice scenario: Design a hypothetical notes application for an Apple-like device ecosystem. Two offline devices edit and delete the same note before reconnecting. What state must sync preserve?
Written for independent practice using company context; this is not a verified question from a company interview.
A REASONED APPROACH
Model answer.
Preserve operation identity and causal information instead of using wall-clock timestamps as unquestioned truth. Offline synchronization must distinguish a genuine deletion from an unseen edit.
Work through it
- Give notes and operations stable identifiers; retain a version vector or another explicit causal marker for changes acknowledged by each device.
- Define conflict behavior by field: merge independent edits where meaningful, expose concurrent incompatible changes, and retain deletion markers until safe collection.
- Make applying an operation idempotent, reconcile in different arrival orders, and test reconnects after long offline intervals or device restoration.
Tradeoffs to discuss
- Automatic merging reduces interruptions but can surprise users; visible conflict versions consume storage and require understandable recovery controls.
Common pitfalls
- A newly restored device must not resurrect a deletion merely because its local clock is ahead.
- Do not erase conflict evidence before all relevant replicas can learn the final state.