Why a checklist
A Debezium connector looks finished once events show up in Kafka. The failures come weeks later. A paused connector leaves a logical slot that holds WAL until the disk fills. A table without a primary key quietly emits updates with no "before" image. A failover loses the slot, and with it every change since the last snapshot. Go through these items before go-live and again after every major change.
1. Server prerequisites
-
wal_level = logicalis set. A change needs a restart, or a parameter change on managed services (rds.logical_replication = 1on RDS/Aurora;wal_levelin the server parameters on Azure Flexible Server). -
max_replication_slotsandmax_wal_sendershave headroom for every connector, plus physical replicas, plus one spare for re-creation. - The connector user has
REPLICATION(orrds_replicationon RDS) andSELECTon the captured tables, and is not a superuser.
SHOW wal_level;
SELECT rolname, rolreplication FROM pg_roles WHERE rolname = 'debezium';
2. Slot safety: WAL can't grow without limit
-
max_slot_wal_keep_sizeis set (PG 13+). Without it, a stalled connector can fillpg_waland stop the primary. - You alert on retained WAL per slot and on
wal_statusreachingunreservedorlost. - On PG 18, decide whether
idle_replication_slot_timeoutsuits you. It invalidates slots that have been inactive too long.
ALTER SYSTEM SET max_slot_wal_keep_size = '200GB'; -- size to disk headroom
SELECT pg_reload_conf();
SELECT slot_name, plugin, active, wal_status,
pg_size_pretty(pg_wal_lsn_diff(pg_current_wal_lsn(), restart_lsn)) AS retained,
pg_size_pretty(safe_wal_size) AS safe_left
FROM pg_replication_slots WHERE slot_type = 'logical';
Caution
max_slot_wal_keep_sizeprotects the primary by invalidating the slot. If the slot is lost, the connector has to re-snapshot. Size the limit so that a weekend outage of Kafka Connect fits inside it, and alert long before it's reached.
3. Publication scope
-
plugin.name = pgoutputis set. It ships with PostgreSQL and needs no extension. - The publication is created by the DBA, listing explicit tables, with
publication.autocreate.mode = disabled. Alternatively, usefilteredso Debezium limits it totable.include.list. Avoidall_tableson shared databases, because it needs elevated rights and decodes everything. - There's a process for adding tables: alter the publication and the connector's include list together.
CREATE PUBLICATION dbz_orders FOR TABLE app.orders, app.order_lines, app.customers;
ALTER PUBLICATION dbz_orders ADD TABLE app.payments;
SELECT * FROM pg_publication_tables WHERE pubname = 'dbz_orders';
plugin.name=pgoutput
slot.name=dbz_orders
publication.name=dbz_orders
publication.autocreate.mode=disabled
table.include.list=app.orders,app.order_lines,app.customers,app.payments
4. Replica identity and TOAST
- Every captured table has a primary key, or a deliberate
REPLICA IDENTITY. - You know which tables need full "before" images.
REPLICA IDENTITY FULLgives them, at the cost of more WAL and slower updates and deletes. - Consumers handle unchanged TOASTed columns. When a large
text/jsonbvalue didn't change and the identity isn'tFULL, Debezium emits a placeholder (unavailable.value.placeholder, default__debezium_unavailable_value) in place of the value.
-- Tables in the publication without a primary key
SELECT pt.schemaname, pt.tablename, c.relreplident
FROM pg_publication_tables pt
JOIN pg_class c ON c.relname = pt.tablename
JOIN pg_namespace n ON n.oid = c.relnamespace AND n.nspname = pt.schemaname
WHERE pt.pubname = 'dbz_orders'
AND NOT EXISTS (SELECT 1 FROM pg_index i WHERE i.indrelid = c.oid AND i.indisprimary);
-- relreplident: d = default (PK), f = full, i = index, n = nothing
ALTER TABLE app.audit_log REPLICA IDENTITY FULL;
Tables without a primary key and with REPLICA IDENTITY DEFAULT can't publish updates or deletes. PostgreSQL rejects those statements on the source once the table is in a publication that replicates updates. That's an outage, not a CDC gap, so check before you add the table.
5. Heartbeats for low-traffic databases
-
heartbeat.interval.msis set, so the connector confirms progress even when the captured tables are quiet. - If the captured database is quiet but others on the server are busy,
heartbeat.action.querywrites to a small heartbeat table that is in the publication. Otherwise the slot'sconfirmed_flush_lsnnever moves and WAL builds up.
CREATE TABLE IF NOT EXISTS app.dbz_heartbeat (id int PRIMARY KEY, ts timestamptz);
ALTER PUBLICATION dbz_orders ADD TABLE app.dbz_heartbeat;
heartbeat.interval.ms=10000
heartbeat.action.query=INSERT INTO app.dbz_heartbeat (id, ts) VALUES (1, now()) ON CONFLICT (id) DO UPDATE SET ts = excluded.ts
6. Snapshots
-
snapshot.modeis chosen on purpose.initialsnapshots once, then streams.no_datastreams only (namedneverin older releases, check your version).when_neededre-snapshots if offsets are no longer valid. - You know how long the initial snapshot of the largest table takes, and a long-running snapshot transaction is acceptable on the primary. It holds back vacuum's xmin horizon while it runs.
- Incremental (signal-based) snapshots are set up, with a signal table, so you can backfill new or repaired tables without restarting from scratch.
7. Failover and upgrades
- You know what happens to the slot on failover. Before PG 17, logical slots don't exist on physical standbys, so after a promotion the connector has no slot and must re-snapshot (or you accept a gap).
- On PG 17+, failover slots are set up. Create the slot with
failover = true(recent Debezium versions expose aslot.failoveroption; check your version's documentation). On the standby, setsync_replication_slots = on,hot_standby_feedback = on, adbnameinprimary_conninfo, and list the standby's physical slot insynchronized_standby_slotson the primary. - The managed-service behaviour is documented for your platform. Some services preserve logical slots across HA failover, others don't, and the details change between releases.
- Major-version upgrades have a plan.
pg_upgradebefore PG 17 doesn't carry logical slots over, so plan a controlled stop, upgrade, re-create and re-snapshot (or a no-data restart with a verified LSN).
-- PG 17+: confirm the slot is synced on the standby
SELECT slot_name, failover, synced, inactive_since FROM pg_replication_slots;
8. Monitoring
| Signal | Source | Alert when |
|---|---|---|
| Retained WAL per slot | pg_replication_slots | Above 50% of max_slot_wal_keep_size |
| Slot inactive | active = false | Longer than the connector restart time |
| Decoding spill to disk | pg_stat_replication_slots.spill_bytes (PG 14+) | Rising steadily. Consider raising logical_decoding_work_mem |
| Connector lag | Debezium MilliSecondsBehindSource JMX metric | Above your freshness SLO |
| Connector task state | Kafka Connect REST /connectors/<name>/status | Any FAILED task |
curl -s http://connect:8083/connectors/pg-orders/status | jq '.tasks[].state'
9. Decommissioning
- Deleting a connector doesn't drop its slot. Drop the slot explicitly, after the connector is gone.
SELECT pg_drop_replication_slot('dbz_orders');
DROP PUBLICATION dbz_orders;
Warning
An orphaned logical slot is the most common cause of
pg_walfilling up on CDC sources. Make "drop slot" a mandatory step in your connector removal runbook.
Prevent it next time
- Keep the publication, replica identity changes and connector configuration in the same repository, and review them together.
- Rehearse a failover with the connector running in staging at least once per major version.
- Track retained WAL per slot on the same dashboard as disk free space.
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