LESSON 04 · Device convergence

Sync through a change log

Treat notifications as wake-up signals and a durable cursor as recovery state.

SYSTEM VIEW

The file path

Diagram view
Laptop cursor—
After cursor—

Watch a laptop catch up on a phone’s two edits by reading the change log after its saved cursor.

  1. Each committed change adds one event to the change log in Metadata DB: the file, its revision and the operation, numbered in order. The Laptop saves a cursor, the position of its last applied event: 5,120.

    Event
    file, rev, operation
    Laptop cursor
    5,120

    What changed

    • Change log through 5,120
    • Laptop cursor at 5,120
  2. The Phone commits two edits to file f8. Each commit appends one event to the change log: 5,121 for revision 4, then 5,122 for revision 5. Two events now lie after the Laptop’s cursor.

    New events
    5,121 and 5,122

    What changed

    • 5,121: f8, rev 4, edit
    • 5,122: f8, rev 5, edit
  3. The Notifier sends the Laptop a hint over its held connection: changes are waiting. Push, long polling or a WebSocket can carry it, but hints can be duplicated or missed, so the Laptop also polls now and then and always pulls from the log.

    What changed

    • Hint to the Laptop
    • No file data in the hint
  4. The Laptop asks the File API for changes after its cursor, 5,120. The File API reads 5,121 and 5,122 from the log and returns them as one page. The Laptop fetches their metadata and only the missing blocks, and rebuilds f8.

    What changed

    • One page: 5,121 and 5,122
    • f8 rebuilt at rev 5
    • Cursor not saved yet
  5. The Laptop crashes after applying both events but before saving its cursor. A device advances its cursor only after its local state is durable, so the saved position still says 5,120, with two events after it.

    Saved cursor
    5,120

    What changed

    • Laptop crashes before saving
    • Saved cursor still 5,120
  6. The Laptop restarts and asks again for changes after 5,120. It applies 5,121 and 5,122 a second time with the same result, then saves its cursor at 5,122. Applying an event twice must be harmless.

    What changed

    • 5,121 and 5,122 applied again
    • Laptop cursor 5,122
  7. The change log keeps 30 days. Had the Laptop been away 90 days, its cursor would have expired: it loads a consistent snapshot, then resumes from the snapshot’s boundary. Longer retention spares more devices a snapshot but takes more storage.

    Log keeps
    30 days
    If away
    90 days

    What changed

    • If away 90 days: cursor expired
    • Snapshot, then later changes

Space plays · ← → step · Home resets

THE IDEA

How it works

Each committed change adds an ordered event for its account or namespace: file ID, revision, operation, and sequence. A device saves a cursor, the position of its last applied event. On reconnect it requests paginated changes after that cursor, applies them, and advances the cursor only after local state is durable. An expired cursor requires a consistent snapshot followed by later changes. Shared-file updates must enter each authorized recipient’s change view; revocation removes the file from that view without exposing new content.

Consider a laptop with cursor 5,120. A phone commits two edits, events 5,121 and 5,122. The laptop gets a hint, requests changes after 5,120, applies both, and saves 5,122. If it crashes before saving, it asks again from 5,120, so applying an event twice must be harmless.

Push, long polling (a request the server holds open until something changes), or WebSocket can alert an online device. Signals may be duplicated or missed, so clients pull the authoritative change log and also poll now and then. The receiving device fetches metadata, downloads only missing blocks, and rebuilds the revision. Access revocation must stop protected downloads even when an old object key is known. Dropbox’s list_folder endpoints and Google Drive’s changes API both hand clients a cursor or page token in this style. The cost is log retention: longer history spares more devices a full snapshot but takes more storage.

DECISION POINT

A laptop is offline for a week and misses thousands of pushes. How does it catch up?

Write a sentence or two to unlock the guidance. Committing first is what makes it stick.

Keep in mind

  • Durable cursors recover missed changes after offline periods.
  • Notifications prompt a pull; they are not the complete file state.
CHECK YOUR UNDERSTANDING

Put it into practice.

1 OF 2
RecallQUESTION 01

What should a returning device request to recover missed events?

Choose an answer. You’ll see the explanation once you get it right.

Next lesson

0 of 2 checkpoints answered correctly to complete this lesson.