End-to-End Real-Time CDC → Kafka → Flink → Iceberg Pipeline
Assemble a production-shaped CDC path from databases through Kafka and Flink into Iceberg tables.
In plain words
Snapshot plus exact binlog/LSN handoff. Next, keyed Kafka event versions and contracts. Finally, Iceberg transaction, offset alignment, audit and replay.
Think of it like…
CDC writes the bank ledger, Kafka is a numbered armored tube, Flink is a checkpointed processing room, and Iceberg publishes a complete new inventory edition rather than exposing half-filled boxes.
Where you’ve seen it
Debezium emits (lsn,txid,table,pk,before,after) to a keyed topic; Flink emits to Iceberg keyed by pk, commits table files on checkpoint, and resumes Kafka offsets/state together when the checkpoint/catalog transaction is recoverable.
Words you’ll hear
- CDC
- A database-to-log event feed that captures source mutations with transaction order and source identity.
- Flink
- A stateful processor that transforms CDC streams and coordinates checkpoints with compatible sink commits.
- Iceberg
- A snapshot-based table target whose data/delete files are atomically referenced for analytical consumers.
- Operational boundary
- A bootstrap gap loses changes, Debezium restart can retain slots, Kafka EOS does not span Iceberg, and a Flink checkpoint after an external table commit can cause duplicate MERGEs unless the sink transaction key is aligned. Coordinate a low-watermark snapshot/CDC handoff, monitor connector slot and Kafka lag, use Flink Iceberg's two-phase commits, dedupe stable source primary keys/version, pin catalog compatibility, and rehearse checkpoint rollback plus late schema events.
Visual diagram
Theory & deep dive
CDC: the working mechanism
An end-to-end CDC path snapshots a source, streams committed log changes through Kafka, enriches/windows them in Flink, and commits idempotent row changes into an Iceberg snapshot with checkpoints and replay controls.
Snapshot plus exact binlog/LSN handoff. Keyed Kafka event versions and contracts, then Flink event-time/enrichment with checkpoints; this exposes the state governed by Iceberg.
Debezium emits (lsn,txid,table,pk,before,after) to a keyed topic; Flink emits to Iceberg keyed by pk, commits table files on checkpoint, and resumes Kafka offsets/state together when the checkpoint/catalog transaction is recoverable.
End-to-End Real-Time CDC → Kafka → Flink → Iceberg Pipeline: failure mode and production response
A bootstrap gap loses changes, Debezium restart can retain slots, Kafka EOS does not span Iceberg, and a Flink checkpoint after an external table commit can cause duplicate MERGEs unless the sink transaction key is aligned.
Coordinate a low-watermark snapshot/CDC handoff, monitor connector slot and Kafka lag, use Flink Iceberg's two-phase commits, dedupe stable source primary keys/version, pin catalog compatibility, and rehearse checkpoint rollback plus late schema events. Track End-to-end lag as "source commit or LSN time to Iceberg snapshot", and make Source slot retention visible to the dataset owner.
How it works, step by step
Step 1 of 41. Bootstrap CDC
Snapshot plus exact binlog/LSN handoff. An end-to-end CDC path snapshots a source, streams committed log changes through Kafka, enriches/windows them in Flink, and commits idempotent row changes into an Iceberg snapshot with checkpoints and replay controls.
- End-to-end lag
- source commit or LSN time to Iceberg snapshot
- Flink
- A stateful processor that transforms CDC streams and coordinates checkpoints with compatible sink commits.
When to use it & trade-offs
What it is
An end-to-end CDC path snapshots a source, streams committed log changes through Kafka, enriches/windows them in Flink, and commits idempotent row changes into an Iceberg snapshot with checkpoints and replay controls. Debezium emits (lsn,txid,table,pk,before,after) to a keyed topic; Flink emits to Iceberg keyed by pk, commits table files on checkpoint, and resumes Kafka offsets/state together when the checkpoint/catalog transaction is recoverable.
Why it matters: A bootstrap gap loses changes, Debezium restart can retain slots, Kafka EOS does not span Iceberg, and a Flink checkpoint after an external table commit can cause duplicate MERGEs unless the sink transaction key is aligned. Coordinate a low-watermark snapshot/CDC handoff, monitor connector slot and Kafka lag, use Flink Iceberg's two-phase commits, dedupe stable source primary keys/version, pin catalog compatibility, and rehearse checkpoint rollback plus late schema events.
When to reach for it
- Assemble a production-shaped CDC path from databases through Kafka and Flink into Iceberg tables.
- Choose CDC because it provides this capability: A database-to-log event feed that captures source mutations with transaction order and source identity.
- Keep evidence for End-to-end lag at "source commit or LSN time to Iceberg snapshot" so the last production stage-Commit table - Iceberg transaction, offset alignment, audit and replay-remains testable.
When to avoid or be careful
- A bootstrap gap loses changes, Debezium restart can retain slots, Kafka EOS does not span Iceberg, and a Flink checkpoint after an external table commit can cause duplicate MERGEs unless the sink transaction key is aligned.
- Do not conflate Flink with CDC. The second concept contributes different behavior: A stateful processor that transforms CDC streams and coordinates checkpoints with compatible sink commits.
- Release only after this guardrail is in place: Coordinate a low-watermark snapshot/CDC handoff, monitor connector slot and Kafka lag, use Flink Iceberg's two-phase commits, dedupe stable source primary keys/version, pin catalog compatibility, and rehearse checkpoint rollback plus late schema events.
CDC / Flink / Iceberg - roles, limits, and operating cost
Strengths: A database-to-log event feed that captures source mutations with transaction order and source identity. An end-to-end CDC path snapshots a source, streams committed log changes through Kafka, enriches/windows them in Flink, and commits idempotent row changes into an Iceberg snapshot with checkpoints and replay controls.
Watch out: A bootstrap gap loses changes, Debezium restart can retain slots, Kafka EOS does not span Iceberg, and a Flink checkpoint after an external table commit can cause duplicate MERGEs unless the sink transaction key is aligned.
Strengths: A stateful processor that transforms CDC streams and coordinates checkpoints with compatible sink commits. In this workflow it supports: Process state - Flink event-time/enrichment with checkpoints.
Watch out: The operating cost is real: WAL/binlog ahead of durable connector offset.
Strengths: A snapshot-based table target whose data/delete files are atomically referenced for analytical consumers. Its output can be checked with Checkpoint/table snapshot.
Watch out: Operating guardrail: Coordinate a low-watermark snapshot/CDC handoff, monitor connector slot and Kafka lag, use Flink Iceberg's two-phase commits, dedupe stable source primary keys/version, pin catalog compatibility, and rehearse checkpoint rollback plus late schema events.
Interview signals & numbers to know
When this topic comes up
- “Where is the failure boundary for CDC, and how would End-to-end lag reveal it?”
- “Why is Flink distinct from this behavior: a snapshot-based table target whose data/delete files are atomically referenced for analytical consumers?”
- Production clue: A bootstrap gap loses changes, Debezium restart can retain slots, Kafka EOS does not span Iceberg, and a Flink checkpoint after an external table commit can cause duplicate MERGEs unless the sink transaction key is aligned.
- Design probe: Coordinate a low-watermark snapshot/CDC handoff, monitor connector slot and Kafka lag, use Flink Iceberg's two-phase commits, dedupe stable source primary keys/version, pin catalog compatibility, and rehearse checkpoint rollback plus late schema events.
Benchmarks & rules of thumb
- End-to-end lag
- source commit or LSN time to Iceberg snapshot
- Source slot retention
- WAL/binlog ahead of durable connector offset
- Checkpoint/table snapshot
- offset state and Iceberg commit recover to one aligned version
Common mistakes & follow-ups
Common interview mistakes
- A bootstrap gap loses changes, Debezium restart can retain slots, Kafka EOS does not span Iceberg, and a Flink checkpoint after an external table commit can cause duplicate MERGEs unless the sink transaction key is aligned.
- Reporting success from a job exit code without checking End-to-end lag and Source slot retention.
- Treating this example as complete without replay, rollback, or access boundaries: Debezium emits
(lsn,txid,table,pk,before,after)to a keyed topic; Flink emits to Iceberg keyed bypk, commits table files on checkpoint, and resumes Kafka offsets/state together when the checkpoint/catalog transaction is recoverable.
Likely interviewer follow-ups
- How would you prove this contract instead of only checking that the command ran: A database-to-log event feed that captures source mutations with transaction order and source identity.
- What does the recovery plan do when this occurs? A bootstrap gap loses changes, Debezium restart can retain slots, Kafka EOS does not span Iceberg, and a Flink checkpoint after an external table commit can cause duplicate MERGEs unless the sink transaction key is aligned.
- When is CDC insufficient for Source slot retention, and what does adding Flink cost in End-to-end lag?
Knowledge check
Put it into practice
Practice related interview Q&A
Apply End-to-End Real-Time CDC → Kafka → Flink → Iceberg Pipeline with data engineer interview Q&A and hands-on practice.