Skip to content

Design a Reactive Database (Live Queries), stage 6 of 9: decide

Write the commit check

The committer receives a mutation's snapshot timestamp, its read set (index ranges) and its writes. It keeps the writes of recent commits in memory. Write the function that decides whether the mutation may commit.

System so far· 6 parts
12345678CLIENTWeb andmobile appsSERVICESync serversSERVICEFunction runnersDATABASEVersioned storeSERVICECommitterSERVICESubscriptiontracker

Select a component to see what it is responsible for and which state it owns.

  1. 1Web and mobile apps → Sync servers: Subscribe and mutate
  2. 2Sync servers → Function runners: Run a function
  3. 3Function runners → Versioned store: Read at a snapshot
  4. 4Function runners → Committer: Writes plus read set
  5. 5Committer → Versioned store: Append in timestamp order
  6. 6Versioned store → Subscription tracker: Committed writes, in order
  7. 7Subscription tracker → Sync servers: These subscriptions changed
  8. 8Sync servers → Web and mobile apps: New results
  • Request / response
  • Asynchronous
  • Server push

What you need to know

0 of 2 checks done
  1. Validation asks one question about a time window: did anything committed between my snapshot and now touch what I read?

    A single committer that assigns increasing timestamps in order makes that window well-defined, and lets the check and the append of the new commit happen as one step.

  2. Check

    A mutation's snapshot is timestamp 100. Which recent commits must it be checked against?