Change data capture from PostgreSQL with Debezium

Debezium reads committed PostgreSQL row changes through logical decoding and publishes them to Kafka. This page covers the settings, snapshot and slot decisions, and the failure points that decide whether the pipeline stays safe.

On this page

How Debezium captures PostgreSQL changes for Kafka

A team that needs row-level changes from PostgreSQL in Kafka should not poll tables for changed rows. The supported method is the Debezium PostgreSQL connector, which reads committed changes through logical decoding using the pgoutput plug-in on PostgreSQL 10 and later. On first connection, the connector takes a consistent snapshot of all schemas it is configured to capture, so downstream consumers start from a known state. After the snapshot, it streams committed inserts, updates and deletes from the write-ahead log as they happen. The Debezium PostgreSQL connector documentation describes the snapshot modes and the change event format, which the team should read before choosing how the connector starts.

Kafka runs as a separate platform with its own sizing, security, retention and upgrade decisions, and this page does not cover it. What it covers is the PostgreSQL side and the connector: the server settings Debezium needs, the replication slot it creates and holds, and the snapshot and capture behavior that follows from them. Before any connector is configured, the team should confirm that the PostgreSQL major version is one still in support, that wal_level can be set to logical on the target server, and that max_wal_senders and max_replication_slots leave headroom for the connector and for any other replication consumers already in use. Changing wal_level requires a server restart, so the window for that change belongs in the plan.

The sections that follow set out the settings, the snapshot choices, the known gaps and the slot monitoring that keeps an idle or stalled connector from filling the disk. The most important operational fact to carry forward is that the replication slot retains WAL until the connector confirms it has read it, so a connector that is paused, failing or removed can grow the database's storage use without any change in application traffic. Teams should decide who owns that alert before the connector goes live.

What you need before connecting Debezium to PostgreSQL

Debezium reads PostgreSQL changes through logical decoding, so the database, the Kafka cluster and the Kafka Connect runtime all have to be ready before the connector is configured. The cards below cover the checks to complete first, in the order most teams hit them. Confirm exact Debezium and Connect versions against the connector documentation before you plan the build.

PostgreSQL version and logical decoding

The Debezium PostgreSQL connector uses the pgoutput plug-in on PostgreSQL 10 and later, so any supported PostgreSQL major version in the current support window fits this requirement. Supported versions today are 14 through 18, and 13 and earlier are unsupported. Set wal_level to logical before first start, and confirm that managed or hosted PostgreSQL services you use expose the same setting. Changing wal_level requires a restart, so plan it as a maintenance step.

PostgreSQL versioning policy

Replication slot and sender settings

Debezium needs max_wal_senders and max_replication_slots set high enough for the connector slot, any other replicas and any tools that already hold slots. Count every slot you plan to create, including test and staging connectors, because an idle slot keeps WAL on disk. Decide who owns slot monitoring before go-live. Retained WAL growth from an unread slot is the most common cause of disk exhaustion in CDC setups.

Kafka and Kafka Connect versions

Kafka 4.x runs in KRaft mode only, so a ZooKeeper-based cluster must migrate before the upgrade. Clusters older than 3.3.x should move to 3.9.x before 4.x. Choose a Kafka release from the supported list, then confirm that the Debezium release you select supports that Kafka and Connect version. Kafka Connect hosts the connector, so its version drives the connector choice more than the broker version does.

Kafka upgrade notes

Java runtime for brokers and Connect

Since Kafka 4.0, brokers, Kafka Connect and tools require Java 17. Clients and Kafka Streams applications that consume the change topics need at least Java 11. Check the JVM on every Connect worker host, including the containers built from your image pipeline, because an older base image is a common reason a worker fails at startup. Record the chosen JDK build in your build standards so upgrades follow the same path.

Replication role and network path

Create a dedicated database role for the connector with the replication privilege and read access only to the tables in scope. Confirm that pg_hba.conf allows that role to connect in replication mode from the Connect worker addresses, and that firewalls allow the PostgreSQL port from those hosts. Connect workers also need network access to every Kafka broker listener they use. Test each path from the worker host itself, not from an administrator workstation.

TLS and certificate requirements

Decide which links are encrypted before the connector is configured: Connect to PostgreSQL, Connect to Kafka and any schema registry. Kafka supports SSL/TLS on listeners and SASL mechanisms including SCRAM-SHA-512 and OAUTHBEARER, so confirm which one your cluster exposes to Connect. Make sure the certificate chain is trusted by the worker truststore and that renewal has an owner. Expired certificates often stop a connector after a working deployment, so add certificate expiry to your monitoring.

Kafka security overview

Configuration sequence for the Debezium connector

This sequence takes a PostgreSQL database from default settings to a Debezium connector that streams committed row changes into Kafka, with a check at each step so that a failure is found at the step that caused it. The end state is a verified replication slot, a completed first snapshot and a tested change event for each row operation.

  1. Set wal_level to logical

    The database owner or DBA sets wal_level to logical in postgresql.conf (or through ALTER SYSTEM) and sets max_wal_senders and max_replication_slots to values that leave room for the connector plus any existing replicas. Changing wal_level requires a server restart, so schedule it with the team that owns the database. Confirm the change with SHOW wal_level; and check that the slot and sender limits are above the number of consumers you expect. Done means the server restarted cleanly and all three settings return the values you planned.

  2. Create a dedicated replication user

    Create a separate login role for the connector with the replication attribute and SELECT privileges only on the tables and schemas it will capture, rather than reusing an application or administrator account. Use SCRAM password authentication and limit the role to the database and host addresses it needs in pg_hba.conf. Confirm the role can connect and read the captured tables, and that it can create replication slots, by logging in as that role and running a test query. Done means the login succeeds from the Kafka Connect host and nowhere else you did not intend.

  3. Choose the publication and pgoutput setup

    Decide whether the connector creates its own publication or whether your team creates one ahead of time that lists only the tables in scope. The Debezium PostgreSQL connector uses the pgoutput plug-in on PostgreSQL 10 and later, so no extra decoding plug-in has to be installed on the server. Record which tables are included, because a table missing from the publication will not produce change events. Confirm the publication with \dRp+ in psql and check that each in-scope table appears in it. Done means the list of captured tables matches the data owners' agreed scope.

  4. Deploy the connector with its snapshot mode

    Deploy the Debezium connector configuration in Kafka Connect, naming the database, the replication user, the publication and the topic prefix, and select a snapshot mode that matches your recovery needs. On the first connection the connector takes a consistent snapshot of all schemas it is configured to capture before it streams committed changes, so confirm the snapshot mode and table filters before starting. Review the connector status through the Kafka Connect REST API and confirm it reports RUNNING for both the connector and its task. Done means the connector is running and no task has failed during startup.

  5. Verify the replication slot

    On the PostgreSQL side, query pg_replication_slots to confirm that the connector's logical slot exists, uses the pgoutput plug-in, is active and points at the expected database. Record the baseline value of the slot's retained WAL so you can see whether it grows later. An inactive slot keeps WAL on disk until the consumer reads it or the slot is dropped, so this is the moment to set a monitoring alert on retained WAL size. Done means the slot is active and you have a documented baseline to compare against.

  6. Confirm the first snapshot in Kafka

    Consume the topic for one captured table and check that the initial snapshot produced read events for the existing rows, with the row count matching a count taken on the source at the same time. Compare the schema of the change events with the table definition, including data types and whether generated columns appear. Generated column values are not captured by pgoutput, so record any generated column as a known gap in the data contract. Done means the snapshot row count matches the source and the schema reviewed by the data owner has no unexpected fields.

  7. Test inserts, updates and deletes end to end

    In a non-production environment, run a controlled insert, update and delete against a test row in a captured table, then read the topic and confirm each operation arrives as a separate change event with the expected before and after values, as your configuration defines them. Repeat the test after any change to the publication or table list. Confirm the connector offset advances and that the slot's retained WAL drops after consumption. Done means all three events arrive in order and the slot is being drained.

Why unused replication slots fill the disk

A replication slot holds WAL until its consumer confirms it has read that WAL. The Debezium connector creates a logical slot on the source database, and PostgreSQL keeps every WAL segment the slot still needs, even if no connector is running. A connector that is paused for maintenance, has failed on a schema or network error, or was deleted from Kafka Connect without dropping its slot will leave that slot behind. WAL then accumulates in the data directory or the WAL volume until the disk fills, and a full disk can stop the primary. This is a source-side risk that Kafka monitoring will not reveal, so the database team needs to own it.

Monitor the slot itself. Query pg_replication_slots for each logical slot and check whether active is false, and compare restart_lsn or confirmed_flush_lsn with the current WAL position using pg_current_wal_lsn() and pg_wal_lsn_diff() to measure retained bytes. Alert on both the lag and the free space on the WAL volume, and watch the Debezium connector's status in Kafka Connect so a stalled connector is caught before its lag grows. If a connector is removed on purpose, drop its slot with pg_drop_replication_slot() after confirming no consumer still needs it. If a connector stalls, fix the consumer first, since dropping the slot discards the change history it has not yet read and forces a new snapshot to recover.

Retention behavior depends on the PostgreSQL version and configuration in use, so confirm it before setting alert thresholds. Check the max_slot_wal_keep_size setting, which caps how much WAL a slot can retain, and find out whether your version and configuration enforce that cap and what happens to a slot that exceeds it. Ask your DBA to document the WAL volume size, the expected change rate and the alert levels, and test the pause, restart and removal procedures in a non-production environment. The Debezium PostgreSQL connector documentation is the place to confirm connector-side behavior for the version you run.

Choosing an initial snapshot mode

When the captured tables are new or small and have no meaningful history to backfill, the initial snapshot is usually the least of your concerns. The connector reads the current state once, then follows the change stream from that point. Your main decisions are which tables and schemas to include and whether consumers need the existing rows at all. If downstream systems only need changes from now on, a mode that skips the initial data copy keeps the first run short and avoids loading rows nobody will use.

  • Include only needed tables: Each table you add increases snapshot work, so list schemas and tables explicitly.
  • Decide whether consumers need existing rows: If they do, a full snapshot is the simplest path to a complete state.
  • Start from the current position: A no-data style start limits the first run to new changes.
  • Plan a manual backfill for gaps: If you skip the copy, decide how missing history will reach the target.
  • Keep the slot in view: Even a small snapshot creates a replication slot that must be monitored from the first day.

Confirm with your consumers which rows they need on day one, and write that requirement down before choosing the mode.

How PostgreSQL types and changes map to Kafka events

This table compares how each PostgreSQL row operation, data type and schema change appears in the Debezium event stream. Read it before designing consumers, since the key, the row images and the missing generated columns decide what downstream code can rely on. The main takeaway is that consumers should not assume every column arrives with every event.

ElementWhat Debezium emitsWhat consumers must handle
InsertEvent with an op of c, and an after image holding the new rowNo before image; treat the event as the first known state of the row
UpdateEvent with an op of u, with before and after images when the replica identity provides the old valuesOld values may be absent unless the table's replica identity is set to capture full old rows; confirm this per table
DeleteEvent with an op of d, with the before image of the deleted rowTombstone handling depends on configuration; plan compaction and downstream deletes around it
Snapshot readEvent with an op of r, emitted during the initial consistent snapshotSnapshot rows can overlap with streamed changes; make consumers idempotent on the primary key
Message keyPrimary key columns of the source table, serialized as the Kafka message keyTables without a primary key need an explicit key setting or they lose per-row ordering; confirm before go-live
Generated columnspgoutput does not send generated column valuesCompute the value downstream or re-read it from PostgreSQL; do not treat a missing column as a null
Transaction metadataOptional transaction boundary events, when enabled in the connector configurationUse them to group changes by commit; confirm the topic name and ordering behavior in the connector docs
Schema changesSchema history is tracked so events match the table definition at the time of each changePlan consumer schema evolution and test column additions and type changes before they reach production

Securing the replication user, the topic path and the data

A CDC pipeline has three places where access can leak: the database role that reads the WAL, the Kafka topics that carry change events, and the event payloads themselves. The cards below cover each path in turn, so the team can confirm who can read, write and see what before the connector goes live.

Least-privilege replication role

Create a dedicated login role for the connector with the replication attribute and SELECT only on the tables it captures. Avoid superuser and table owner rights, since the connector needs to read rows and the replication slot, not change schema. Check that the role cannot write to captured tables and that grants cover every schema in the include list, including tables added later. Document who approves changes to this grant set.

Debezium PostgreSQL docs

pg_hba.conf limited to the connector host

Add a hostssl entry in pg_hba.conf that matches only the replication role, the connector's source address and the database names it needs, with SCRAM-SHA-256 as the method. A replication entry for the connector should not allow any other host or user. Confirm that the connector cannot reach databases outside its scope, and that changes to this file go through review.

TLS between Connect and PostgreSQL

Require TLS on the connection from Kafka Connect to PostgreSQL, using sslmode=verify-full with the CA certificate mounted into the Connect worker. Plan certificate renewal before expiry, because a failed handshake stops capture and the slot keeps accumulating WAL. Confirm that the server certificate names the host the connector uses and that the worker trusts only your internal CA.

Credential storage for the connector

Keep the replication role password out of connector JSON and version control. Use a Kafka Connect config provider or your secrets manager to inject the value at runtime, and restrict who can read connector configs through the Connect REST API. Plan rotation: changing the password requires updating the connector config and restarting the task, so schedule it as a planned change.

Kafka SASL or SSL and topic ACLs

Give the connector its own Kafka principal authenticated with SASL (for example SCRAM-SHA-512) or mutual TLS, and grant it write access only to its topics and schema history topic. Downstream consumers get read access on specific topics, not on the prefix. Confirm the authorization model you run: in KRaft clusters the StandardAuthorizer stores ACLs in the metadata log, and resources without ACLs are denied to non-super users unless allow.everyone.if.no.acl.found is set. Verify that setting is not true by accident.

Kafka authorization docs

Sensitive columns in change events

Change events carry full before and after row images, so a captured email, card token or health field appears in every topic consumer's data. Exclude sensitive columns with the column include or exclude settings, or mask them in a transform before they reach Kafka. Also decide retention for topics that hold these events, and who can read them. Note that generated columns are not captured by pgoutput, so do not assume a derived sensitive value is covered by the source column rule.

How change events flow from PostgreSQL to Kafka

The flow starts with committed changes written to the write-ahead log on the PostgreSQL primary. A logical replication slot holds those changes until the Debezium connector inside Kafka Connect reads them through the pgoutput plug-in and confirms them. On first start, the connector takes a snapshot of the tables before streaming, and it publishes each table's changes to its own Kafka topic. Check the trust boundaries at each arrow: the database network, the Connect workers and the Kafka cluster should each have only the access their role requires, and the slot's lag should be watched because an unread slot keeps WAL on the primary's disk.

Change events move from the WAL through a slot and Debezium into Kafka topics.

Common Debezium and PostgreSQL failures and their fixes

This table lists the failures teams most often hit when running the Debezium PostgreSQL connector, with the likely cause, a diagnostic check and the fix for each. Use it as a first-response guide, then confirm exact messages and settings against your own versions and logs.

FailureLikely causeDiagnostic checkFix
wal_level not set to logicalThe PostgreSQL server still runs with the default replication level, so logical decoding cannot start.Run SHOW wal_level on the primary and confirm the connector can read it.Set wal_level to logical in postgresql.conf or through ALTER SYSTEM, then restart PostgreSQL as the setting requires.
Insufficient replication settingsmax_wal_senders or max_replication_slots is too low for the connectors and standbys already using them.Compare SHOW max_wal_senders and SHOW max_replication_slots with the slots and senders in use.Raise both values with headroom for each connector, then restart and reconnect the connector.
Unused slot filling the diskThe connector stopped or was deleted while its replication slot stayed behind, so WAL is retained indefinitely.List pg_replication_slots and check active status and restart_lsn, then measure WAL directory growth.Restart the connector to resume consumption. If it will not return, drop the orphaned slot after confirming nothing needs it, and alert on slot lag.
Slot growth during connector outageConsumption stopped for a long period while the database kept writing, so retained WAL grows with write volume.Compare confirmed_flush_lsn with the current WAL position over time.Restore the connector quickly, size WAL disk for expected outage windows, and set monitoring thresholds on retained WAL.
Missing values for generated columnspgoutput does not send values for generated columns, so downstream consumers see nulls or no value.Inspect a change event for the generated column and compare it with the table definition.Compute the value downstream from source columns, or copy it into a regular column with a trigger or application write. Confirm the approach with the consuming team.
Snapshot timeouts or long initial snapshotA large table or slow disk makes the consistent snapshot run past connector or network timeouts.Check connector logs for the snapshot phase, table sizes and I/O load during the snapshot.Tune snapshot settings for the connector version, snapshot fewer tables per run where supported, and schedule the first run outside peak load.
Permission errors on the replication roleThe role lacks the replication attribute, SELECT on captured tables, or rights needed for the publication and snapshot.Review the role attributes and grants, and check the connector error for the object it could not access.Grant the replication attribute and the minimum SELECT rights on captured tables, then confirm pg_hba.conf allows replication connections from the connector host.
Publication or table filter mismatchThe publication excludes tables the connector expects, or the table include list does not match the schema names.List the publication members and compare them with the connector table include list.Align the publication with the include list, and recreate the publication only after confirming no other consumer depends on it.
Kafka Connect version mismatchThe Debezium connector, Kafka Connect runtime and Java version do not match, or the Kafka brokers are on a release the connector does not support.Check the Connect worker version, connector plugin version, and the Java runtime against the Kafka upgrade notes.Install a connector build that matches your Connect release, upgrade Java where required, and plan Kafka upgrades so brokers and Connect move in a supported order.

Questions teams ask before running Debezium on PostgreSQL

What drives the cost and effort of a PostgreSQL to Kafka CDC pipeline?

The main drivers are the number of source databases and tables, how many row changes they produce, how many downstream consumers depend on the topics, and how much of the platform already exists. Cost has two parts: one-time work (design, connector configuration, snapshot planning, testing, runbooks) and recurring work (monitoring, connector and Kafka upgrades, schema changes, and on-call response). Your own engineers, a partner and any cloud or licensing charges for Kafka hosting are paid separately. Kafka itself is Apache-2.0 licensed with no paid edition from the project, so most spend goes to people and infrastructure. Ask any quote to list each component, who performs it, and which parts recur after handover.

How long does a first Debezium setup and initial snapshot take?

The setup itself depends on how ready the database and Kafka environment are, and the initial snapshot depends on data volume, table count, network throughput and how much write load the source carries during the snapshot. Debezium takes a consistent snapshot of all schemas on first connection, then switches to streaming committed changes through logical decoding. Large tables, slow disks and busy primaries all extend the snapshot window, and so does any need to rerun it. Ask for a timeline that separates environment preparation, a snapshot rehearsal against a copy of production size data, and the production cutover, and confirm which steps depend on your change approval process.

What does a CDC pipeline need from the database and platform teams?

The database team must enable logical decoding by setting wal_level to logical, sizing max_wal_senders and max_replication_slots for the connectors, and granting a replication-capable role with the least privilege needed on the tables in scope. The platform team must provide Kafka topics, network paths, TLS and SASL authentication, ACLs, Kafka Connect capacity, and monitoring. Both teams share responsibility for replication slot monitoring, since an unread slot keeps WAL on disk. Agree early on who owns the slot, who approves configuration changes that require a restart, and how a stalled consumer is escalated.

Can an internal team run Debezium on PostgreSQL by itself?

Yes, if the team already operates PostgreSQL replication and Kafka, has someone comfortable with logical decoding, and can staff on-call for a service that stops when a slot or connector fails. The skills gap usually sits in replication slot behavior, snapshot modes, generated column handling and Kafka Connect operations rather than in the connector configuration itself. A partner is most useful for the first design, the snapshot rehearsal, the runbooks and the upgrade plan, after which the internal team can operate the service. Ask any proposal to name which tasks transfer to your team and what knowledge transfer and documentation it includes.

How do PostgreSQL, Debezium and Kafka upgrades affect the connector?

Each upgrade touches the connector differently. PostgreSQL minor releases replace executables and restart the server, which interrupts the connector until it reconnects. PostgreSQL major upgrades need planning, because logical replication slots and the connector's expectations about the source must survive the change, so test the connector against the new major version before cutover. Kafka 4.0 supports only KRaft mode and requires Java 17 for brokers and Kafka Connect, so clusters still on ZooKeeper must migrate first. Kafka's time-based release plan supports rolling upgrades from each release in the past year to the latest version. Confirm the supported Debezium and Kafka Connect combinations for your target versions before scheduling.

How do I size WAL retention so unused replication slots do not fill the disk?

WAL is retained for a replication slot until its consumer confirms it has read those changes, so a stopped or lagging connector can make the primary keep growing its WAL directory until the disk is full. Size retention against the disk you have, not the average write rate: measure WAL generation at peak, decide how long a connector outage must be survivable, and add headroom for a full snapshot. Alert on slot lag in bytes, on free space in the WAL volume, and on connectors in a failed state. Keep a documented procedure for dropping a slot you no longer need, and confirm with your PostgreSQL version and your monitoring stack how that lag is reported.

Which PostgreSQL versions are still supported for a new Debezium deployment?

According to the PostgreSQL versioning policy, versions 14 through 18 were supported at the time of this page, with version 14 ending November 12, 2026 and version 18 supported to November 14, 2030. Debezium's PostgreSQL connector uses pgoutput on PostgreSQL 10 and later. Choose a major version that will still be supported for the life of the pipeline, and plan the next major upgrade before the current one reaches end of life. Confirm the current support dates on the official policy page before you commit to a version.

How DeployOpen scopes and delivers a Debezium integration

DeployOpen plans, builds, tests, documents and supports Debezium change data capture from PostgreSQL inside your own infrastructure. The work starts with a written scope covering source settings, replication slots, the Kafka side and the consuming systems, so your data, security and platform teams review the same plan before any database setting changes.

How we scope

  • Inventory the PostgreSQL versions, hosting model and tables that will be captured, including any generated columns that need a separate plan.
  • Agree the wal_level, max_wal_senders and max_replication_slots settings and who approves changes to the production primary.
  • Define the Kafka topics, consumers, snapshot approach and disk headroom for unused replication slots in a fixed-scope written agreement.

How we build

  • Configure the Debezium PostgreSQL connector with the pgoutput plug-in and a dedicated replication role with least-privilege grants.
  • Run the initial snapshot in a rehearsal environment first, then measure lag, slot growth and connector recovery after restarts.
  • Test the failure paths we expect, including a connector outage, a Kafka broker restart and a schema change on a captured table.

How we hand over

  • Deliver configuration files, connector settings, role definitions and the topic and schema inventory kept in your own version control.
  • Document runbooks for replication slot monitoring, disk alert thresholds, snapshot restarts and the procedure to drop an abandoned slot.
  • Walk your operations and data teams through the runbooks and record the open items that remain on your side.

How we support

  • Ongoing support, upgrades and continuous testing are available as a retainer, scoped to the Debezium, Kafka and PostgreSQL versions you run.
  • Review Debezium and Kafka upgrade notes before each planned change, including Kafka's Java and KRaft requirements for the target release.
  • Confirm with your team which support window, escalation path and change approval process apply before the retainer starts.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.