dblog-impl · Reference Implementation
DBLog: A Reference Implementation: Executable CDC and full-state snapshots in Java for MySQL and PostgreSQL
A Java 21 reference implementation of DBLog, by its creator Andreas Andreakis. DBLog is a Change-Data-Capture algorithm that copies the full state of a source database alongside live changes, without blocking writes or stalling change event propagation. Built from the published Netflix Technology Blog post (2019) and DBLog paper (2020).
Run lock-free incremental snapshots reconciled against live binlog and
pgoutput streams locally, with a paper-to-code audit map and the
Hydroscope TUI visualizer.
What this reference implementation includes
Everything needed to study, audit, and test the published watermark algorithm (Algorithm 1 in the paper) locally on real database engines, with no write-blocking table locks and explicit fail-closed guards.
- Core engine
Source-neutral watermark reconciler
Low and high watermark state machine (
WindowReconciler), chunked full-table dump orchestration, targeted primary-key repair, and restart-safe progress boundaries persisted in embedded H2. - Live adapters
MySQL and PostgreSQL replication
MySQL
binlog(tested on8.0,8.4,9.6) and PostgreSQLpgoutput(tested on14through18) with an explicit table-scoped commit-visibility check and Docker-backed end-to-end convergence tests. - Inspection and ops
Sinks, control plane, and Hydroscope
NDJSON stream and file output, typed H2 inspector, idempotent JDBC target apply, no-op sink, a local HTTP control plane for triggering dumps and repairs, and the optional Rust/ratatui Hydroscope visualizer.
Study and verification scope: Built for study, auditing, and
experimentation, not production CDC. dblog-impl implements the 2019/2020 DBLog
algorithm (chunked snapshots and targeted key repair for existing keys) and does not
implement the ABSENT / orphan-row repair extension. For production workloads
using DBLog-based incremental snapshots, use Debezium or
Apache Flink CDC.
How dblog-impl executes the watermark loop
Copying a table in bounded chunks while live changes stream from the transaction log
creates a race: a slower chunk read can overwrite a newer change event. DBLog resolves
that race deterministically by bracketing each chunk SELECT with two
metadata writes, a low watermark (LOW) and a
high watermark (HIGH), that land in the same transaction
log as the captured tables.
- Stream live changes. Consume committed transaction-log events and forward them to the sink.
- Pause and write
LOW. Pause log consumption and write a low-watermark row into the source metadata table. - Select a bounded chunk. Read the next primary-key range (for example
pk 41-43) into an in-memory buffer without emitting those rows yet (on PostgreSQL, after waiting for tracked table commits to become visible to the snapshot). - Write
HIGHand resume. Write the high-watermark row and resume reading the log from the pause position. - Let the log win. Keep live log events in log order. If any in-window
event targets the same table and primary key as a buffered chunk row, drop that buffered
row. By
HIGH, that key's last emitted state from the log is at least as new as the selected row. - Flush survivors. When
HIGHcloses the window, omit theLOWandHIGHwatermark markers and emit the reconciled window in logical order: in-window log events first, then surviving buffered rows in primary-key order. Indblog-impl, the runtime accumulates this window in memory, appends the reconciled batch to the sink atHIGH, and persists completed-chunk progress to H2 before acknowledging the source checkpoint.
LOW,
buffers pk=41, 42, 43, and writes HIGH. On resume,
UPDATE pk=42 on the same table lands inside the collision window and drops
buffered pk=42. When HIGH closes the window, in-window log
events and surviving rows 41 and 43 emit in logical order
(survivors in key order), and watermarks are omitted from the output stream.
Code map and quick start
Every step of Algorithm 1 is mapped to its implementing class, fail-closed guard, and
regression test in
docs/PAPER_MAP.md,
including explicit notes on paper deltas such as
PostgreSQL commit visibility.
Reading path
-
docs/PAPER_MAP.mdAlgorithm 1 step-by-step audit map, fail-closed guards, test locks, and paper deltas. -
WindowReconciler.javaLow and high watermark state machine, collision eviction, and ordered survivor flush. -
DefaultDumpWindowCoordinator.javaOpens bounded chunk windows and persists restart-safe progress boundaries. -
DefaultTargetedRepairCoordinator.javaOn-demand targeted primary-key repair through the same watermark machinery. -
RuntimeRequestPump.javaSingle-consumer loop interleaving live log capture with queued dump and repair requests.
Run locally (Java 21, Docker, Python 3.9+)
Start disposable MySQL and PostgreSQL fixtures, run an ALL_TABLES dump,
apply live writes, and verify convergence:
git clone https://github.com/aandreakis/dblog-impl.git
cd dblog-impl
python3 scripts/demo/mysql_to_postgres.py Verification suites from fast unit tests to the MySQL 8.0-9.6 and PostgreSQL 14-18 compatibility matrix (8 Docker images, 20+ min):
# fast unit tests (< 1 min)
./gradlew test
# live Docker convergence and repair scenarios
./gradlew e2eTestDocker
# MySQL 8.0-9.6 and PostgreSQL 14-18 (20+ min)
./gradlew compatibilityMatrix Sources and related reading
- An introduction to DBLog: How it enables incremental snapshots and sink repairs Conceptual guide to CDC fundamentals, watermark windows, Debezium and Flink CDC, and orphan-row repair.
- DBLog: A Watermark Based Change-Data-Capture Framework (arXiv:2010.12597) Andreas Andreakis and Ioannis Papapanagiotou, arXiv, 2020.
- DBLog: A Generic Change-Data-Capture Framework Andreas Andreakis and Ioannis Papapanagiotou, Netflix Technology Blog, 2019.
- I Vibe Coded My Old Netflix Project How this repository was built and tested from public material with coding agents.
- Hydroscope TUI Documentation Annotated guide to the bundled Rust/ratatui visualizer and replay scenarios.