LESSON 02 · Metadata and objects

Separate names from bytes

Keep folders and revisions queryable while durable object storage holds content.

SYSTEM VIEW

The file path

Diagram view
Readers see—
Blocks verified—

Watch revision 8 of a file go in pending, gain its blocks, and become current only once all three check out.

  1. Metadata DB holds each file’s row: its ID, owner, folder, name, current revision, status, size and access rules. Object storage holds the immutable blocks a file is split into. A manifest lists a revision’s ordered block keys and checksums, so a download can rebuild it.

    Current
    rev 7
    Manifest
    block keys, checksums

    What changed

    • File rows and manifests in Metadata DB
    • Immutable blocks in Object storage
  2. The Laptop renames a 2 GB file. The File API updates one row in Metadata DB, and Object storage moves no bytes: a stable file ID keeps the file’s identity and history through the rename.

    File
    2 GB
    Rows updated
    1
    Bytes moved
    0

    What changed

    • Name changed in 1 row
    • File ID unchanged
    • 0 bytes moved
  3. The Laptop saves revision 8, which has three blocks. Before any bytes move, the File API inserts revision 8 into Metadata DB as pending, with its manifest of three block keys and checksums. Readers still see revision 7.

    Rev 8
    3 blocks
    Status
    pending

    What changed

    • Rev 8, pending
    • Manifest of 3 block keys
    • Readers still on rev 7
  4. The Laptop uploads revision 8’s three blocks straight to Object storage. Metadata DB and Object storage can’t share one transaction, so these bytes land before the File API has checked them: revision 8 is still pending, and readers still see revision 7.

    Uploaded
    3 blocks
    Rev 8
    still pending

    What changed

    • 3 blocks in Object storage
    • Rev 8 still pending
  5. The File API checks that all three blocks exist with the right checksums. Only then does one Metadata DB transaction set the current revision to 8 and append a change-log entry, so readers see revision 8.

    Checked
    3 of 3 blocks
    One commit
    current = 8 + log entry

    What changed

    • 3 of 3 checksums match
    • Current revision: 7 → 8
    • Change-log entry, same transaction
  6. Replay it with a crash. The three blocks land in Object storage, then the File API crashes before it verifies or commits. Metadata DB still says current revision 7 with revision 8 pending, so readers keep revision 7 and nothing half-published shows.

    Blocks stored
    3, unverified
    Current
    rev 7

    What changed

    • File API crashes before commit
    • Current revision stays 7
    • Rev 8 stays pending
  7. The cost of two stores is cleanup: abandoned uploads leave blocks no manifest references. The Reconciler matches pending revisions in Metadata DB against Object storage, then publishes or cleans up; nothing is deleted before that. A very small service can keep small files in the database instead.

    Orphans
    blocks no manifest lists
    Before deleting
    reconcile

    What changed

    • Reconciler
    • File API back up
    • Pending rev 8 checked, not deleted

Space plays · ← → step · Home resets

THE IDEA

How it works

Store file identity, owner, parent folder, name, current revision, status, size, and access rules in a metadata database. Immutable content blocks, the pieces a file is split into, live in object storage such as S3. A revision manifest lists ordered block keys and checksums so a download can rebuild that version. Stable file IDs let a rename preserve identity and history: renaming a 2 GB file updates one row and moves no bytes. Dropbox draws a similar line, keeping file blocks in its Magic Pocket store and metadata in separate databases.

Metadata and object storage cannot share a simple database transaction, so order the steps. Suppose revision 8 of a file has three blocks. The API inserts revision 8 as pending with its manifest. The client uploads the three objects. The API confirms each one exists with the right checksum, then in one database transaction sets the current revision to 8 and appends a change-log entry. If the API crashes before that commit, readers still see revision 7.

A transactional outbox can deliver notifications after commit: it is a table written in the same transaction, which a separate process reads and publishes from. The cost of two stores is cleanup. Abandoned uploads leave orphaned objects that no manifest references, so reconcile orphaned objects and pending records before deleting anything. A very small service can reasonably keep small files in the database and skip this split until size forces it.

DECISION POINT

The object arrived, but the API crashed before marking the revision ready. What should readers see?

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

Keep in mind

  • Metadata describes and authorizes files; object storage holds bytes.
  • Publish only after required content is verified.
CHECK YOUR UNDERSTANDING

Put it into practice.

1 OF 2
RecallQUESTION 01

Where does an ordered list of blocks for a revision belong?

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.