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.
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.
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:
- Write
lowatermark to the source DB: Briefly pause reading the log and update a dedicated single-row watermark table with a uniquelovalue, stamping an opening barline into the commit log. SELECTone bounded chunk into memory: Read a small batch of rows (either the next table chunk or specific keys viaWHERE pk IN (...)) into a transient in-memory map indexed by primary key. Nothing is emitted yet.- Write
hiwatermark and resume streaming: Update the watermark table with ahivalue and resume tailing the log, forwarding every live event downstream in order. - Reconcile in flight (log wins): If any log event inside
[lo, hi]touches a key held in the chunk map, discard that bufferedSELECTrow because the commit log already carries that key's state in stream order. - Release survivors at
hi: Whenhiarrives 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.