PostgreSQL
Setup and operations reference for the PostgreSQL CDC source: logical replication setup, slot and publication management, WAL retention, and FAQs.
PostgreSQL is supported as a CDC source for capturing inserts, updates, and deletes at row granularity. Nilus's CDC engine reads the Write-Ahead Log (WAL) through a logical replication slot and streams decoded row changes. Nilus persists the last acknowledged Log Sequence Number (LSN) in its REST-backed offset store so a restart resumes from exactly where the previous run left off.
Nilus connects to PostgreSQL through a DataOS depot resolved with pipeline type: cdc. The depot keeps host, port, credentials, and TLS material outside the pipeline manifest.
Connectivity
DataOS depot
dataos://mypostgresdepot
Host, port, credentials, and TLS material are resolved from the depot definition.
Defaults applied by Nilus:
plugin.name = pgoutput(the recommended decoding plugin for PostgreSQL ≥ 10)topic.prefix = cdc(override per pipeline; the prefix is also used as the sink table prefix)Each change event is emitted with the new row state and timestamp metadata; deletes preserve the original primary key.
Requirements
These requirements must be satisfied at the database before Nilus can run a PostgreSQL CDC pipeline.
Logical replication enabled
wal_level must be logical and the cluster must have enough sender / slot capacity:
ALTER SYSTEM SET wal_level = logical;
ALTER SYSTEM SET max_wal_senders = 10;
ALTER SYSTEM SET max_replication_slots = 10;
-- Restart PostgreSQL after the first wal_level change.Cloud-managed PostgreSQL flavors expose the same setting through their parameter groups:
Connection user privileges
The Nilus connection user needs:
LOGINandREPLICATIONattributes.SELECTon every captured table.CREATEon the database if Nilus is allowed to create the publication automatically.
Table-level expectations
Captured tables must have a
PRIMARY KEY. Without one, updates and deletes cannot be reliably correlated.For tables without a primary key but where you still need full delete semantics, set
REPLICA IDENTITY FULLon the table.UNLOGGEDtables are not supported. Logical decoding never sees their writes.Schema changes (
ALTER TABLE, etc.) are detected by the connector and reflected in the sink schema on the next event.
Replication slot lifecycle
Each Nilus pipeline must use a unique
slot.name.The replication slot is created on first start and is not dropped automatically on pipeline deletion. WAL files referenced by an inactive slot accumulate on disk until the slot is removed manually.
For
pgoutput, Nilus also expects a publication. Either pre-create one or setpublication.autocreate.mode = filteredso the engine creates the right publication for the include list.
Core concepts
Logical replication primitive
PostgreSQL's logical replication exposes row-level changes through replication slots and a decoding plugin.
Nilus uses
pgoutput(the in-tree plugin since PostgreSQL 10), which is the recommended choice for new deployments.Only changes to tables with primary keys (or
REPLICA IDENTITY FULL) are emitted in their full shape.
WAL, LSN, and replay position
The WAL is PostgreSQL's transaction log. Every committed change is identified by an LSN.
Nilus tracks the last acknowledged LSN per replication slot so PostgreSQL knows when WAL files are safe to discard.
LSN feedback flows continuously while events are processed and through heartbeats during idle periods.
Snapshot phase
On first start (or any time the connector decides a snapshot is needed) Nilus connects through JDBC and reads the captured tables consistently.
The snapshot emits one event per row with
op = rand establishes the baseline schema in the sink.After the snapshot completes, the connector switches to streaming mode.
Streaming phase
The connector reads decoded WAL records through the replication slot.
Decoded messages contain only row data; the connector merges them with the cached schema captured during snapshot or refreshed on
ALTER TABLE.Heartbeat messages keep the slot's
restart_lsnadvancing on idle databases.
Replication slot retention
The slot prevents PostgreSQL from discarding WAL needed by the last acknowledged LSN.
When Nilus is paused or stopped, the slot's
restart_lsndoes not advance andpg_walgrows.Monitor slot lag with
pg_replication_slotsandpg_wal_lsn_diff(pg_current_wal_lsn(), restart_lsn).
Partitioned tables
Partitioned tables require a small amount of extra setup so individual partitions are captured. See Working with partitioned tables.
Change event shape
PostgreSQL-specific fields surfaced through the source block:
lsn, Log Sequence Number of the WAL entry.txId, PostgreSQL transaction ID; every change in the same transaction shares it.sequence, Per-transaction ordering helper.xmin, Optional, present only when the connector can expose snapshot visibility.
op values: r (read during snapshot), c (insert), u (update), d (delete).
Sample Nilus config
The following example uses a DataOS depot for connectivity, captures a single schema, and writes change events to a Lakehouse sink in flatten mode.
The depot referenced as dataos://mypostgresdepot resolves connection details (host, port, credentials, TLS) from its DataOS definition; no inline secret projection is needed in the manifest above.
CDC options
These are the most useful CDC connector properties for PostgreSQL. They go under source.cdc in the Nilus manifest.
plugin.name
pgoutput (Nilus default)
Logical decoding plugin. Use pgoutput on PostgreSQL ≥ 10 unless you have a specific reason to switch to decoderbufs.
slot.name
No default
Name of the logical replication slot. Must be unique per pipeline and follow PostgreSQL's slot naming rules (lowercase, underscores).
publication.name
dbz_publication
Name of the publication used by pgoutput. Set explicitly so multiple Nilus pipelines do not collide.
publication.autocreate.mode
all_tables
When filtered, the engine creates a publication that exactly matches the include list. Recommended when the connection user has CREATE privilege.
topic.prefix
cdc (Nilus default)
Logical namespace for this pipeline. Must be unique across CDC pipelines. Nilus also uses it as the sink table prefix.
schema.include.list
No default
Comma-separated regex / literals matching schemas to include. Mutually exclusive with schema.exclude.list.
schema.exclude.list
No default
Inverse of schema.include.list.
table.include.list
No default
Comma-separated schema.table patterns to include. Mutually exclusive with table.exclude.list.
table.exclude.list
No default
Inverse of table.include.list.
column.include.list
No default
schema.table.column patterns to include in change event values.
column.exclude.list
No default
Inverse of column.include.list.
snapshot.mode
initial
Snapshot behavior on first start. initial snapshots when no offset is recorded; always re-snapshots every start; never skips snapshots; initial_only snapshots and stops; when_needed snapshots when the recorded offset is no longer available.
heartbeat.interval.ms
0 (off)
Periodic heartbeats keep restart_lsn advancing on idle databases. Recommended: 60000.
max.batch.size
2048
Maximum number of change events processed per batch.
max.queue.size
8192
Maximum buffered change events before back-pressure kicks in.
include.unknown.datatypes
false
When true, columns with unsupported types are emitted as binary instead of dropped.
offset.flush.interval.ms
60000
How often offsets are persisted to the Nilus REST offset store. Does not control how often LSN feedback is sent, that flows continuously while events are being processed.
Behavior and capabilities
Pipeline mode: PostgreSQL CDC runs as a
cdcsource.Treat
topic.prefixandslot.nameas a stable identity. Once a pipeline is in production, changing them effectively starts a new pipeline (and orphans the old slot).Always set
publication.nameexplicitly so it is obvious which publication belongs to which pipeline; rely onpublication.autocreate.mode = filteredto keep it scoped to the include list.Monitor replication-slot lag (
pg_replication_slots.restart_lsn,pg_stat_replication) and alert on growth. Inactive slots can fillpg_walquickly.Use
heartbeat.interval.ms = 60000for low-traffic databases so LSN feedback continues during idle periods.For schema changes, prefer additive migrations. Drops, type changes, and primary-key changes can require restarting the connector with a fresh snapshot.
Capture only what you need, avoid
schema.include.list = publicon busy clusters when one or two tables would do.
Troubleshooting
Symptom: Pipeline starts but no change events arrive.
Cause:
wal_levelis notlogical, the connection user lacksREPLICATION, or the publication is missing.Recovery: Run
SHOW wal_level;,SELECT * FROM pg_publication WHERE pubname = '<publication.name>';, and re-run the privilege grants above.
Symptom:
pg_waldirectory grows quickly while the pipeline is paused or stopped.Cause: The replication slot is inactive but still anchored to a stale
restart_lsn.Recovery: Restart Nilus so consumption resumes, or drop the slot if it is no longer needed:
SELECT pg_drop_replication_slot('<slot>');.
Symptom: Connector cannot resume; logs report a missing LSN.
Cause: WAL referenced by the slot was rotated out before consumption resumed.
Recovery: Recreate the slot (a fresh snapshot will run), then size WAL retention so the worst-case downtime fits inside it.
Symptom: Updates / deletes show empty
beforeblocks.Cause: The captured table has no primary key and the default
REPLICA IDENTITYis in effect.Recovery: Add a primary key, or set
ALTER TABLE <table> REPLICA IDENTITY FULL;for tables that genuinely cannot have one.
Symptom: Connector fails to start with a publication conflict.
Cause: Two Nilus pipelines share the same publication name.
Recovery: Set unique
publication.namevalues per pipeline and recreate the publication, or usepublication.autocreate.mode = filteredso each pipeline owns its own.
FAQs
Related docs
DataOS Lakehouse destinations: see the AWS-backed, Azure-backed, or GCP-backed variants for writing CDC change events into a Lakehouse.
Last updated
Was this helpful?