When to use this
Use an incremental snapshot when streaming is healthy but one or more tables need their rows emitted again:
- A table was added to
table.include.listand has no history downstream. - A sink lost or corrupted some rows.
- A consumer bug wrote bad values and the topic no longer holds the originals.
Don't use it when the replication slot is gone or its WAL has been removed. Streaming must work first, because the snapshot depends on it.
How it works, and why it matters
The connector reads the table in primary key order, one chunk at a time, while streaming continues. Around each chunk it writes watermarks to a signal table and reads them back from the WAL. Rows in the chunk whose keys also appear in streamed events between the watermarks are dropped, since the streamed event is newer. What remains is emitted with op: "r".
Operational consequences:
- Each chunk waits for the stream. If the connector is 20 minutes behind, a chunk cannot close until the stream reaches its watermark. A lagging connector makes the snapshot crawl.
- It adds WAL for its watermarks, and load on the source for its reads.
- It doesn't emit deletes for rows that vanished from the source earlier. Orphans in the sink stay there.
- It re-emits current state only. Consumers see
revents, not the missed history.
Step 1: Pre-checks
Connector and slot
CONNECT=http://connect:8083
curl -s $CONNECT/connectors/orders-cdc/status \
| jq '{connector: .connector.state, tasks: [.tasks[] | {id, state}]}'
curl -s $CONNECT/connectors/orders-cdc/config \
| jq 'with_entries(select(.key | test("signal|snapshot|table.include|publication|slot|read.only|topic.prefix")))'
SELECT slot_name, active, wal_status,
pg_size_pretty(pg_wal_lsn_diff(pg_current_wal_lsn(), confirmed_flush_lsn)) AS behind
FROM pg_replication_slots
WHERE slot_name = 'orders_cdc';
Warning
Don't start if
wal_statusisunreservedorlost, or if the slot is far behind. Fix the lag first, or the snapshot adds more load to a connector that already can't keep up.
Primary key and size
SELECT a.attname
FROM pg_index i
JOIN pg_attribute a ON a.attrelid = i.indrelid AND a.attnum = ANY(i.indkey)
WHERE i.indrelid = 'public.orders'::regclass AND i.indisprimary;
SELECT reltuples::bigint AS estimated_rows,
pg_size_pretty(pg_total_relation_size(oid)) AS size
FROM pg_class WHERE oid = 'public.orders'::regclass;
With no primary key, use the surrogate-key field to name a suitable column. It should be unique, not null and indexed.
Signal table
CREATE TABLE IF NOT EXISTS public.debezium_signal (
id VARCHAR(42) PRIMARY KEY,
type VARCHAR(32) NOT NULL,
data VARCHAR(2048) NULL
);
GRANT SELECT, INSERT ON public.debezium_signal TO debezium;
The columns must be named id, type and data. With the insert_delete watermarking strategy, also grant DELETE.
The connector sees source-channel signals and watermarks through replication, so confirm the table is in the publication:
SELECT schemaname, tablename FROM pg_publication_tables
WHERE pubname = 'dbz_publication'
AND tablename IN ('debezium_signal', 'orders');
-- If missing, and the publication isn't FOR ALL TABLES:
ALTER PUBLICATION dbz_publication ADD TABLE public.debezium_signal;
Step 2: Configure the connector
{
"signal.data.collection": "public.debezium_signal",
"signal.enabled.channels": "source,kafka",
"signal.kafka.topic": "orders-cdc-signal",
"signal.kafka.bootstrap.servers": "broker1:9092",
"incremental.snapshot.chunk.size": "8192",
"notification.enabled.channels": "log"
}
signal.data.collectionis case-sensitive and inschema.tableform.- The Kafka signal topic must have one partition. It is optional, and useful when you can't insert into the source.
- Chunk size is 1024 rows by default. Bigger chunks mean fewer watermark round trips and more heap per chunk.
A PUT to /connectors/<name>/config replaces the entire configuration, so merge first:
curl -s $CONNECT/connectors/orders-cdc/config > current.json
jq -s '.[0] * .[1]' current.json overlay.json > new.json
curl -s -X PUT -H 'Content-Type: application/json' \
--data @new.json $CONNECT/connectors/orders-cdc/config | jq '.name'
Warning
current.jsoncan contain credentials. Restrict it and delete it afterwards. The PUT restarts the connector's tasks, so expect a short streaming pause.
Read-only sources
Recent versions support read.only=true with PostgreSQL 13 or later. Watermarking then doesn't write to a signal table, and signals come from another channel such as Kafka. Check that your version's connector documentation lists it.
Step 3: Trigger
INSERT INTO public.debezium_signal (id, type, data) VALUES (
'resync-orders-20261125-1',
'execute-snapshot',
'{"data-collections": ["public.orders"], "type": "incremental"}'
);
To resend only part of the table:
INSERT INTO public.debezium_signal (id, type, data) VALUES (
'resync-orders-20261125-2',
'execute-snapshot',
'{"data-collections": ["public.orders"],
"type": "incremental",
"additional-conditions": [
{"data-collection": "public.orders",
"filter": "updated_at >= ''2026-11-20'' AND updated_at < ''2026-11-25''"}]}'
);
data-collections entries are regular expressions, so a loose pattern can match more tables than intended. Put an index behind any filter column, or each chunk query may scan heavily.
Through Kafka, the message key must equal topic.prefix:
echo 'orders|{"type":"execute-snapshot","data":{"data-collections":["public.orders"],"type":"INCREMENTAL"}}' \
| kafka-console-producer.sh --bootstrap-server broker1:9092 \
--topic orders-cdc-signal --property parse.key=true --property key.separator='|'
Step 4: Watch it
Use the logged notifications (started, in progress, table scan completed, completed), then the slot query from Step 1. Estimate the duration from measured chunks, not from table size:
remaining time = remaining rows / chunk size x seconds per chunk
| Observation | Cause | Action |
|---|---|---|
| Nothing happens after the insert | Table not in publication, wrong case, source channel off | Fix and insert a new row with a new id |
| Signal logged, no rows | Regex matches nothing, or table not captured | Check table.include.list and the pattern |
NO_PRIMARY_KEY notification | No usable key | Use surrogate-key |
| Chunks slow, database idle | Stream lag delays watermarks | Clear lag; raise chunk size |
| Chunks slow, database busy | Poor plan for keyset query | Check pg_stat_activity, run ANALYZE |
| Heap pressure on the worker | Chunk too large for wide rows | Lower chunk size |
| Sink lag grows | Sink can't absorb the r volume | Pause, let it drain, resume |
Step 5: Pause, resume or stop
INSERT INTO public.debezium_signal VALUES ('pause-1', 'pause-snapshot', '{}');
INSERT INTO public.debezium_signal VALUES ('resume-1', 'resume-snapshot', '{}');
INSERT INTO public.debezium_signal VALUES ('stop-1', 'stop-snapshot',
'{"data-collections": ["public.orders"], "type": "incremental"}');
Progress is held with the connector offsets, so a task restart resumes near the last completed chunk. Consumers must tolerate a chunk being emitted again.
Caution
The PostgreSQL connector doesn't support schema changes while an incremental snapshot is running. Freeze DDL on the table, or stop the snapshot first.
Step 6: Verify and repair deletes
Compare counts and checksums over stable key ranges that nobody is updating. Then find orphans, for example with the source keys loaded into a staging table in the warehouse:
SELECT s.order_id
FROM warehouse.orders s
LEFT JOIN staging.source_order_keys k ON k.order_id = s.order_id
WHERE k.order_id IS NULL;
Check each candidate against the source before deleting it. Rows inserted after the key extract look the same.
Prevent it next time
- Create and test the signal table when the connector is first deployed.
- Make every sink an idempotent upsert that accepts
op = r. - Alert on slot lag, and don't start a snapshot above that threshold.
- Set
incremental.snapshot.watermarking.strategy=insert_deleteif signal rows pile up, or purge them between snapshots. - Schedule reconciliation, including orphan detection, rather than waiting for a user report.
Get the weekly HubDatAI email
One email a week with everything new: posts, learning sessions and videos. Free, no spam, unsubscribe in one click. What you get