liveBook · Manning

Source of truth

As explained in Crack Any Codebase with AI

A source of truth is the authoritative system or representation from which the accepted value of data is determined.

A source of truth is the authoritative system from which accepted data values are determined. Assigning that role prevents independently maintained stores from drifting through failed dual writes. section 9.5

Postgres as the authority

Cal.com treats Postgres as the sole source of truth and Redis as disposable cache data. When Redis is stale or missing, the application reads more slowly from Postgres rather than returning an incorrect value, avoiding an outbox or CDC pipeline. section 9.5

Use the pattern to sharpen architectural investigation:

  • Identify which store owns accepted data and which stores merely cache, index, or replicate it. section 9.5
  • Trace the fallback when a derived store is stale, missing, or unavailable. section 9.5
  • Name the consistency promise when concurrent writers race, rather than inferring it from defaults and locks. section 9.5
Table 9.5 What each consistency model promises when two writers race
Model
What it promises
Examples
What it buys
What it costs
Linearizable
Every read sees the most recent write, system-wide
Single-primary Postgres/MySQL writes, etcd, Spanner
One global order; the easiest model to reason about
Coordination on every write; the slowest and least available under partition
Sequential/serializable
All clients see operations in the same order, not necessarily real-time
SERIALIZABLE isolation, FoundationDB
Safe concurrent transactions without manual locking
Aborts and retries under contention
Read-your-writes
You always see your own writes; others may lag
Sticky sessions to primary, "read from primary after write"
A user never loses their own edit
Doesn't help two different users racing
Bounded staleness
Reads lag the truth by at most X seconds
DynamoDB strong-vs-eventual toggle, Cosmos DB tunable
Tunable freshness-vs-cost dial per query
You must pick the bound, and pick wrong somewhere
Eventual
All replicas converge given no new writes
DynamoDB default reads, Cassandra ONE, DNS
Highest availability and throughput
Stale reads, lost-update and conflict-resolution headaches

Compare consistency models by their guarantees, examples, benefits, and coordination costs. section 9.5

How Crack Any Codebase with AI covers it

How deep it goes
Explains dual-write failure, fallback reads, and concurrent-write guarantees, while deferring implementation redesigns such as CDC or event sourcing.
Examples
Uses Cal.com with Postgres as authority, Redis as disposable cache, and fallback reads for stale or missing entries.
What you can do after
Diagnose/debug with it by locating authoritative data, identifying derived stores, and testing their failure and concurrency behavior.
How it connects
Connects caching, databases, dual writes, change data capture, event sourcing, and consistency models.

Also explained in

Compare how 13 books explain source of truth →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Crack Any Codebase with AI. The section links point to the parts of the book it draws on.