DBLOG · INTERACTIVE

DBLog: Flow and Sound

DBLog is a Change-Data-Capture design originated at Netflix and adopted by Debezium and Apache Flink CDC for live incremental snapshots. It captures existing table rows and repairs drifted sinks inside a live change stream without blocking writes at the source while change events keep flowing.

Turn sound on to hear writes diverge, wait in a commit log and merge with live table reads as you watch.

01Dual Writes: Silent Divergence

Services often keep state in more than one database. Alongside a primary PostgreSQL or MySQL table, teams maintain search indexes, caches or analytical stores.

The simplest way to update two stores is a classic dual write: the application commits to the Primary DB first and sends a second call to Search only after that commit succeeds. Because no transaction spans both stores, a transient failure or dropped call on Search loses the second write with no durable record. An empty ring followed by silence.

FIG 01 Sequential Dual Writes (24 px/s commit drift)
Animated timeline showing application requests committing to Primary DB first and only then sending a second write to Search, where periodic Search hiccups sever the secondary write and leave permanent silent divergence.

02Commit Log: Observable Lag

Change-Data-Capture replaces those two calls with one to the primary database. Relational databases already record committed changes in an ordered transaction log (such as PostgreSQL WAL via logical decoding or MySQL binlog). A CDC reader tails that log and projects changes downstream in commit order.

Moving secondary writes off the request path turns a downstream hiccup from silent loss into observable, replayable lag while the log retains those entries. The gold cursor holds its offset while commits keep landing ahead of it, stretching a visible lag span and a low harmonic swell that resolves in strict order on recovery.

FIG 02 Change-Data-Capture & FIFO Catch-Up
Animated timeline showing single commits stamping onto an ordered Commit Log while a downstream consumer cursor pauses during a transient outage, opening an observable lag span before catching up smoothly in commit order.

03DBLog [lo, hi]: State in Motion

Pure log tailing only moves forward and commit logs have finite retention. Populating a new empty sink or repairing drifted rows requires reading the current state of a database table while live writes keep mutating those same keys. An uncoordinated SELECT races with the log and can overwrite fresher changes.

DBLog avoids that race by bracketing each small chunk read between two watermark writes on the source database:

  1. Write lo watermark to the source DB: Briefly pause reading the log and update a dedicated single-row watermark table with a unique lo value, stamping an opening barline into the commit log.
  2. SELECT one bounded chunk into memory: Read a small batch of rows (either the next table chunk or specific keys via WHERE pk IN (...)) into a transient in-memory map indexed by primary key. Nothing is emitted yet.
  3. Write hi watermark and resume streaming: Update the watermark table with a hi value and resume tailing the log, forwarding every live event downstream in order.
  4. Reconcile in flight (log wins): If any log event inside [lo, hi] touches a key held in the chunk map, discard that buffered SELECT row because the commit log already carries that key's state in stream order.
  5. Release survivors at hi: When hi arrives on the log, emit the surviving buffered rows together into the output stream and clear memory back to zero.

DBLog buffers only one bounded chunk of rows in memory at a time rather than a copy of your table. Hover or tap k1…k12 below to trigger live writes inside the moving window.

FIG 03 Watermark Reconciliation & Live Writes
Hover or tap k1–k12 to trigger writes RAM buffer: 0 rows
Interactive timeline of DBLog’s [lo, hi] watermark window across keys k1 through k12, showing staggered SELECT notes, live commits, upward dissolution of superseded buffered rows and survivor emission at hi.