Data Engineering · Module 07
Change data capture and replication
- Lessons
- 9
- Free
- 0
- Reading
- ~3 h
Your progress
0 / 9 lessons done
Sign in to trackLessons
- Change data capture: reading the database’s change logMost data teams start by querying a replica for changed rows, and most outgrow it when someone asks about a value that was overwritten, or a row that was deleted. Change data capture is how the warehouse sees every change, and it brings a new job: keeping a reader on the production database healthy.
- Debezium and CDC connectors in practiceMost teams that stream database changes run Debezium or a tool built the same way. The configuration takes an hour; the operational risk, a slot that quietly fills the production database’s disk, is what wakes people up at night.
- Case: Shopify’s CDC from a sharded monolithMost teams move to change data capture after an incremental load has quietly missed deletes or edits. Shopify’s account shows the full path at large scale, including the problems it hadn’t solved yet, so you can plan for them before your own pipeline goes live.
- Initial snapshots: loading history before changesEvery CDC pipeline starts with rows that were written before anyone was listening. Loading them is the longest and riskiest step of a CDC launch, and the step most often redone after an outage.
- Deletes, updates and schema changes in CDCA CDC pipeline is only as correct as its handling of the awkward cases: rows that disappear, updates that don’t say what changed, and tables that gain columns while the stream runs. These are where copies quietly drift from the source.
- Ordering and duplicates in CDC pipelinesEvery CDC pipeline repeats changes after a crash, and many deliver changes out of the order a consumer reads them. A consumer that trusts arrival order counts orders twice or moves an order back to an old status, with no error anywhere.
- Landing CDC data in a warehouse or lakehouseEvery CDC pipeline ends in a table someone queries. If the change events land without a merge, or with a careless one, reports count each order several times or show rows that no longer exist, and nothing fails.
- Application events or CDC: choosing a sourceSooner or later an app team offers to publish its own events so the data team can stop reading its tables. Saying yes or no well means knowing what each source can lose, and most data platforms end up running both.
- Design: syncing a production database to analyticsCopying a production database into the warehouse is one of the most common jobs a data platform has. Each piece is simple; the design is in making the pieces agree, switching readers over without a gap, and noticing within minutes when the copy stops moving.
Practise with
No tools or paper guides for this module yet.
Terms this module teaches 19
Open glossaryApplication event
A message a service writes on purpose to say what happened in the business, with fields its owning team chooses, rather than a copy of a changed database row.
Binary log (binlog)
MySQL’s log of every committed change, in commit order, read by replicas and by change data capture tools.
Change event
A record of one committed insert, update or delete of one row, with the row’s values and where in the database’s log the change came from.
Change event envelope
The standard structure of a CDC change event: the row before and after the change, the operation, where the change came from, and when it was processed.
Claim check pattern
Storing a large payload outside a message system and sending a small message that points to it.
Current-state table
A table with one row per key holding that key’s latest values, built by applying change events in order.
Debezium
An open-source tool that reads a database’s change log and publishes each committed insert, update and delete as an event, usually to Kafka.
Heartbeat table
A one-row table on a source database that is updated on a schedule and captured like any other table, so its age at the end of a pipeline shows how far behind the whole pipeline is.
Incremental snapshot
A snapshot that reads a table in small chunks by primary key while the change stream keeps running, dropping any chunk row the stream changed during the read.
Initial snapshot
The first read of every existing row by a CDC connector, taken as of one log position so the change stream can continue from exactly that point.
Kafka Streams
A Java library, part of Apache Kafka, for building applications that read topics, process records and write the results to other topics.
Log compaction
A Kafka topic setting (cleanup.policy=compact) that keeps at least the latest record for each key in a partition, instead of deleting records by age.
Outbox Event Router
A Debezium transform that turns inserts into an outbox table into events on a topic chosen from a column, keyed by the aggregate id, and drops the table’s deletes.
Publication (PostgreSQL)
A named list of tables whose changes a PostgreSQL logical replication stream includes.
Replica identity
A PostgreSQL table setting that decides which old column values are written to the log for updates and deletes: by default only the primary key, with FULL every column.
Signal table
A small table in the source database that a Debezium connector watches for commands, such as starting a snapshot, and writes window marks into.
Snowflake stream
A Snowflake object that records an offset on a table and returns the rows changed since it; the offset moves only when a DML statement that reads the stream commits.
Table registry
A list, kept in code, of the tables a pipeline handles, with each table’s keys, columns and locations, from which the pipeline generates the same steps for every table.
TOAST
PostgreSQL’s way of storing large column values outside the main row, compressed or split into chunks.