Hasty Briefsbeta

The Write Last, Read First Rule

12 days ago
  • #database
  • #consistency
  • #transactions
  • TigerBeetle is a financial transactions database designed for correctness, focusing on double-entry bookkeeping with accounts and transfers.
  • The system separates master data (stored in Postgres) from transaction data (stored in TigerBeetle) to scale independently and meet different security and compliance needs.
  • Transactions in TigerBeetle are atomic, but composing transactions across systems (Postgres and TigerBeetle) requires coordination to maintain consistency.
  • The system must uphold safety properties like consistency (every account in Postgres has a corresponding account in TigerBeetle and vice versa) and traceability (every account in TigerBeetle with a positive balance corresponds to an account in Postgres).
  • TigerBeetle is designated as the system of record, meaning it determines the existence of an account, while Postgres is the system of reference.
  • The 'Write Last, Read First' principle ensures consistency: write to the system of reference first, then the system of record; read from the system of record first.
  • Operations must be idempotent to handle disruptions and ensure eventual completion, leveraging frameworks like Resonate's Distributed Async Await.
  • The application layer interprets subsystem responses (Postgres and TigerBeetle) to enforce application-level semantics and detect violations like ordering conflicts or data inconsistencies.
  • Correctness is achieved through careful design, durable executions, intentional ordering, and idempotent operations, even in the absence of transactions.