LESSON 07 · Consistency and deletion

Repair derived state when rules change

Treat timeline entries as disposable pointers and recheck access at the final read boundary.

SYSTEM VIEW

The feed path

Diagram view
Time—
5120 in inbox—
5120 shown—

Watch a block at 10:05 stop a post still sitting in Ana’s inbox, long before cleanup removes it.

  1. The author publishes post 5120, and at 10:00 the Fanout workers write its ID into Ana’s inbox. The entry is a derived pointer, not the post and not permission: the Feed service still looks the post up when Ana reads.

    Post
    5120
    Inbox entry
    a pointer, not access

    What changed

    • Post 5120 published
    • 5120 in Ana’s inbox
  2. At 10:05 the author blocks Ana. The Follow graph, the canonical record of follows and blocks, changes at once to version 8. Ana’s inbox still holds post 5120’s ID: derived entries lag behind a rule change.

    Follow graph
    v8: author blocks Ana
    Ana’s inbox
    still holds 5120

    What changed

    • Block, graph v8
    • 5120 still in the inbox
  3. At 10:06 Ana refreshes. Her inbox still lists 5120 among 20 candidates, and the Access check reads the current Follow graph before returning anything. It finds the block and drops 5120, and Ana gets 19 posts.

    Candidates
    20, 5120 among them
    Dropped
    5120: author blocks Ana
    Returned
    19 posts

    What changed

    • Refresh at 10:06
    • 5120 dropped by the check
    • 19 posts to Ana
  4. At 10:20 the Cleanup job removes post 5120’s ID from Ana’s inbox. That saves later reads some work, but it isn’t the privacy boundary: if access waited for cleanup, Ana would have had 14 more minutes after her 10:06 refresh.

    Refresh
    10:06
    Cleanup
    10:20
    If cleanup guarded
    14 more minutes

    What changed

    • Cleanup job
    • 5120 from Ana’s inbox
  5. Deletion can need faster suppression than publishing. The author deletes post 5120, and the Post store keeps a tombstone. A delayed Fanout retry checks first, finds the tombstone and skips the insert; its job’s graph v7, older than v8, marks it stale too.

    Post 5120
    deleted, tombstone kept
    Retry built on
    graph v7, now v8

    What changed

    • Cleanup job
    • Post store
    • Tombstone for 5120
    • Stale retry skipped
  6. The boundary costs a batched permission lookup on every page. The Access check reads rules for 20 candidates from the Follow graph and the Post store, one batch each. A cache of those rules needs a short expiry, or it recreates the lag.

    Per page
    1 batch per store
    Cached rules
    short expiry

    What changed

    • 1 batch to the Follow graph
    • 1 batch to the Post store
    • Cached rules expire fast
  7. Some copies are beyond the read check: a post may already be on a device or in a CDN cache, and no server policy can erase a screenshot. Document the revocation window and media purge, and give Delete a retention and audit policy.

    On a device
    out of reach
    CDN media
    purge in a window
    Delete
    retention + audit

    What changed

    • Inboxes
    • CDN
    • Revocation window for media
    • Retention and audit policy

Space plays · ← → step · Home resets

THE IDEA

How it works

A user may unfollow, mute, block, change a post’s audience, or delete it after fanout. Existing inbox entries and caches can lag. The read service must enforce the current authorization policy against canonical relationship and post state before returning content. Background invalidation removes stale pointers and reduces future work, but it is not the privacy boundary.

Walk through one block. At 10:00 fanout places a post ID in Ana’s inbox. At 10:05 the author blocks Ana. At 10:06 Ana refreshes; the ID is still there, but the read check finds the block and drops the post. At 10:20 a cleanup job removes the entry. If access relied on cleanup, Ana would have had 14 more minutes of access.

Set distinct guarantees: post creation can appear eventually in a follower’s feed; deletion or a privacy change may require much faster suppression. Tombstones, durable markers that a post was deleted, prevent it from reappearing when a delayed worker retries. Versioned audience or relationship data helps workers detect work produced under an older rule. The cost is a batched permission lookup on every page, and any cache of those permissions needs a short expiry or it recreates the same lag.

A post may already be on a device or in a CDN cache. Document the practical revocation window and purge mechanism for media; no server-side cache policy can erase a screenshot or a client’s previously downloaded bytes. “Delete” needs a product-specific retention and audit policy as well as an API behavior.

DECISION POINT

A private post was fanned out, then the author removes a follower while a queue is delayed. What must hold at read time?

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

Keep in mind

  • Feed cache entries never override current access rules.
  • Creation and revocation may need different consistency targets.
CHECK YOUR UNDERSTANDING

Put it into practice.

1 OF 3
RecallQUESTION 01

Where should final authorization be enforced?

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

Next lesson

0 of 3 checkpoints answered correctly to complete this lesson.