Quick revision
The short answer
Add the table to table.include.list and run an incremental snapshot by sending an execute-snapshot signal of type incremental for public.shipments through a signal table (or a Kafka signal channel). Debezium reads the table in primary-key chunks while streaming continues, and wraps each chunk in low and high watermarks written to the signal table; any streamed change for a key in the chunk that arrives between the watermarks replaces the buffered snapshot row. Consumers must treat every event, including op r, as an upsert by key.
What to remember
In this answer, we added shipments to table.include.list and triggered an incremental snapshot with an execute-snapshot signal through a signal table, so streaming for the other tables never stopped. The table is read in primary-key chunks, progress is kept in the connector offsets, and low and high watermarks let streamed changes replace buffered snapshot rows so stale reads never win. Consumers must treat op r events as upserts by key, and we sized chunks, topic and database load for 500 million rows while watching replication slot lag.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
Add the table to table.include.list and run an incremental snapshot by sending an execute-snapshot signal of type incremental for public.shipments through a signal table (or a Kafka signal channel). Debezium reads the table in primary-key chunks while streaming continues, and wraps each chunk in low and high watermarks written to the signal table; any streamed change for a key in the chunk that arrives between the watermarks replaces the buffered snapshot row. Consumers must treat every event, including op r, as an upsert by key.
Why this question is asked
Adding a large table to a running CDC pipeline used to mean an unpleasant choice: stop streaming and take a long initial snapshot, or build a one-off copy job and hope it lines up with the change stream. Interviewers ask this scenario because Debezium's incremental snapshots solve it neatly, and the interesting part is how they avoid a stale snapshot row overwriting a newer change. In this answer, we will set up signalling, trigger the snapshot, look at how chunks and watermarks keep snapshot and live events consistent, explain what consumers must do, and plan capacity for 500 million rows.
1A Quick Recap: Why the Old Snapshot Is Not an Option
When a Debezium connector starts for the first time, it normally takes an initial snapshot: it reads every captured table with a consistent read, emits each row as an op r event, and then switches to streaming changes from the write-ahead log. For a new 500-million-row table, a blocking snapshot of this kind would hold back streaming for the other 20 tables for about 10 hours, so every consumer would see 10 hours of lag. We need a way to read the new table while streaming continues.
2Setting Up Signalling and Triggering the Snapshot
Debezium accepts commands, called signals, through channels. The original channel is a signal table in the captured database: we insert a row and the connector sees it arrive through the change stream. A Kafka topic can also be a signal channel. We first add shipments to the capture list and name the signal table.
Adding the table to table.include.list makes Debezium stream its changes from now on; the signal fills in the existing rows. The signal table must itself be captured, because the connector learns about signals, and later its own watermarks, by seeing them in the change stream. Progress of the snapshot is stored in the connector's offsets, so if the connector restarts halfway, it resumes from the last completed chunk rather than starting over.
3How Chunks and Watermarks Avoid Mixing Up Rows
The table is read in primary-key order, one chunk at a time, while streaming continues. The danger is obvious: Debezium reads shipment 42 with status PACKED, and a moment later an update sets it to SHIPPED. If the snapshot row were emitted after the update, consumers would end up with the stale status.
Debezium prevents this with a watermark technique. Before reading a chunk, it writes a low watermark row into the signal table. It reads the chunk, for example ids 1 to 20,000, into memory. Then it writes a high watermark row. Both watermark rows come back through the change stream in commit order. Any streamed change for a key in the chunk that appears between the low and high watermarks is newer than, or as new as, the snapshot read, so Debezium emits the streamed event and removes that key from the buffered chunk. When the high watermark arrives, it emits the remaining buffered rows as op r events. A snapshot row therefore never overwrites a change that happened after it was read.
8 messages in order. Play them, or step through them one at a time.
Streamed changes inside the window win over the buffered snapshot rows.
4What Consumers Must Do
Snapshot rows arrive with op r and are interleaved with live c, u and d events for the same table on the same topic. A consumer might see a live update for shipment 900,000 hours before the snapshot reaches its chunk, then later receive its op r row; the r row is no older than the update, because of the watermarks, but it is still a second event for the same key. So consumers must treat every event as an upsert by key and be idempotent: apply the latest state per key and never assume that r means first sight. A consumer that inserts on r and fails on duplicate keys will break.
5Planning Capacity for 500 Million Rows
Five hundred million rows is a large backfill even when it does not block streaming. With the default chunk size of 1,024 rows, that is about 490,000 chunks, each with two watermark writes and a query, so we raise the chunk size, for example to 20,000, after testing the query cost. At, say, 20,000 rows per second the snapshot takes about 7 hours, during which the database serves sustained primary-key range reads and Kafka receives a burst of perhaps 250 GB if rows average 500 bytes.
We prepare the target topic first: enough partitions for consumers to keep up, compaction if consumers want latest-state semantics, and retention that does not drop data before slower consumers read it. We run it in quieter hours, tell the consuming teams, and watch replication slot lag on PostgreSQL while it runs, because if the connector falls behind, the slot holds WAL on the database disk until it catches up.
6Follow-up questions
What are read-only incremental snapshots, and when do you need them?
The standard incremental snapshot writes watermark rows to a signal table, so it needs write access to the source database. When the connector reads from a read-only replica or is not allowed to write, read-only incremental snapshots use positions from the database's own replication state instead of written rows to mark the window, and signals arrive through the Kafka channel. Support depends on the connector and version, so check yours.
Can we snapshot only part of the table?
Yes. The execute-snapshot signal accepts a filter condition for a data collection in recent Debezium versions, so we can snapshot, for example, only shipments from the last year. Check the exact field name for your version.
How do we stop or pause an incremental snapshot?
Debezium has pause-snapshot, resume-snapshot and stop-snapshot signals for incremental snapshots, sent through the same channels, which help if the database comes under pressure.
7Conclusion
In this answer, we added shipments to table.include.list and triggered an incremental snapshot with an execute-snapshot signal through a signal table, so streaming for the other tables never stopped. The table is read in primary-key chunks, progress is kept in the connector offsets, and low and high watermarks let streamed changes replace buffered snapshot rows so stale reads never win. Consumers must treat op r events as upserts by key, and we sized chunks, topic and database load for 500 million rows while watching replication slot lag.
Open with
I would not take a blocking snapshot. I would add public.shipments to table.include.list so its changes start streaming, and then run an incremental snapshot. That needs signalling: a signal table named in signal.data.collection, which must itself be captured, and optionally a Kafka signal channel.
Then, if they want more
I insert an execute-snapshot signal with data-collections set to public.shipments and type incremental. Debezium then reads the table in primary-key order in chunks, 1024 rows by default, which I would raise after testing, while streaming continues, and it keeps progress in the connector offsets so it resumes after a restart.
To avoid mixing up snapshot rows and live changes, for each chunk it writes a low watermark row to the signal table, reads the chunk into memory, and writes a high watermark.
Those watermarks come back through the change stream, and any streamed change for a key in the chunk that arrives between them replaces the buffered snapshot row, so a stale read never overwrites a newer change. The remaining rows are emitted as op r.
Consumers must treat every event as an upsert by key and be idempotent, because snapshot rows interleave with live events. Finally I would plan capacity: sustained reads on the database, a big burst into Kafka, topic partitions and retention set first, quieter hours, and watching replication slot lag throughout.
About this answer
- Last updated
- 13 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- Apache Kafka documentation
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Stopping streaming for a full snapshot would take about 10 hours, which is not...": https://scrivio-interview-library.netlify.app/spring-boot/kafka-streams-connect/adfd7f6389/