Databases, Transactions & Durable Storage

ML data, feature state and checkpoints depend on relational correctness and crash semantics. This section connects queries to physical work and acknowledged writes to recoverable state.

Section 4 of 7 · 9 units · about 38 hours

0/9

By the end you can Recover a checksummed append-only store after crashes at every publish boundary, reproduce and prevent one transaction anomaly, and explain one query-plan change with measured logical and physical work.

Units

Build it

Mini project · about 14 to 20 hours

Durable service state and PostgreSQL catalog with transaction evidence

Make the service slice durable with a checksummed log, rebuildable index, crash recovery and versioned compaction, and keep tenant metadata in PostgreSQL 18. Produce the dossier SQL evidence for constraints, plans, transactions and visibility.

  1. 1Store every write as a checksummed frame acknowledged only after fsync, refuse further writes after an fsync failure, and test every short-write and truncation boundary against an acknowledged-prefix oracle, rejecting corruption.
  2. 2Rebuild a key-to-offset index with range support and check it against a replayed oracle, derive the ordered-index page cost against the hash rebuild, and model a pinned buffer pool with its no-victim and failed-writeback cases, choosing the layout for point and scan reads.
  3. 3Compact by publishing a manifest with lab/publish.py that names the live generation, recover to one complete generation after a crash at each step, retain tombstones until safe, version records compatibly across all writer and reader combinations, and count logical bytes by kind.
  4. 4Model tenants, credentials, segments and usage in PostgreSQL with keys and constraints doing the validation, and rewrite one join with its filter moved, proving bag equivalence both ways, with each rejection tested.
  5. 5Export the as-served usage rows at a cutoff inside a read-only REPEATABLE READ transaction, cover nulls, ties and exact-cutoff rows with backfill stability, and store the query, cutoff and digest.
  6. 6Compare EXPLAIN output before and after one index change with sizes and settings recorded and boundary results equal, force write skew across two SERIALIZABLE transactions with restart and recheck, and trace tuple visibility while separating lock waits from latches.
What you hand in
  • kv/store.py with checksummed log, rebuilt index, manifest compaction and versioned records, plus crash and compatibility tests.
  • The acknowledged-prefix report across every injected boundary with recovered prefixes and retained corruption cases.
  • The catalog, export, plan and transaction evidence with digests, equivalence proofs and visibility traces.
  • The buffer pool model with its failure tests and the layout choice for the store reads.
How to check it
  • Self-grade with the rubric below
How it's graded

Durability and recovery

Pass: No write is acknowledged before fsync, failures stop writes, and the oracle passes at every boundary with corruption rejected.

Great: The report states which failures the tests cover and which real faults lie outside them.

Index, versions and compaction

Pass: The rebuilt index matches the oracle, all version combinations pass, and recovery opens one complete generation with tombstones held.

Great: An early tombstone drop is kept as a regression, and byte counters separate the kinds of work.

SQL and transactions

Pass: Constraints reject bad rows, the rewrite proves equivalent, the export verifies after backfill, and the skew test restarts cleanly.

Great: Plans are explained from rows and buffers, and visibility evidence separates waits from latches.

Resources

  • CMU 15-445/645 - database and storage coreCarnegie Mellon Database Group

    Use Fall 2025 Lectures 1-9, 11-18 and 20-22 with their notes: relational model, SQL, storage, buffer pools, layouts, indexes, execution, planning, concurrency, MVCC, logging and recovery. Complete the matching SQL, Storage, Indexes and Filters, Transactions and Recovery homeworks before considering a BusTub project.

  • PostgreSQL - EXPLAIN and transaction isolation labPostgreSQL Global Development Group

    Create one normalized schema, joins, an aggregation and a window query. Compare EXPLAIN ANALYZE before and after one justified index. In two sessions, reproduce one documented isolation anomaly and prevent it with a stated database or application invariant.

  • Operating Systems: Three Easy Pieces - persistence and integrityRemzi and Andrea Arpaci-Dusseau

    Use Chapters 36, 39-45 to trace devices, filesystem structures, journaling, log-structured storage, flash and integrity. Apply the crash sequence to your own append-only store rather than repeating the SYS-1 file experiment.

  • CMU 15-445 - one reduced BusTub project sliceCarnegie Mellon Database Group

    If a C++ database implementation is the chosen depth lane, complete Project 1 Buffer Pool Manager or Project 2 Database Index, not both during the first pass. Follow the course publication rules and keep code private. The blank-file append-only store remains the core checkpoint.

  • Designing Data-Intensive Applications, 2nd edition - storage and transactionsMartin Kleppmann and Chris Riccomini

    Read only the sections on data models and query languages, storage and retrieval, encoding and evolution, and transactions that answer a live design question from the CMU route. Write one comparison table covering layout, index, isolation and recovery trade-offs.

  • Point-in-time joinsFeast

    Read Point-in-time joins and Retrieving features as of the event time. Separate event-time eligibility from actual feature availability; implement the predicates in SQL, not a Feast installation.

  • CMU Lecture 19: Timestamp Ordering Concurrency ControlCarnegie Mellon Database Group

    Section 1 only, p. 1: timestamp order as a chosen serialization order. The section pool omits Lecture 19; this fills the timestamp-ordering vocabulary gap without assigning all of OCC.

  • SQLite Write-Ahead LoggingSQLite

    Sections 1 and 3 only: rollback journaling remains the default and WAL is an opt-in mode. Correct the dated SQLite statement in CMU Lecture 21; inspect the bundled engine without running concurrent WAL writers.