Skip to main content

CDC Sink for PostgreSQL: Overview

Connection string

Create a SqlConnectionString with FactoryName set to "Npgsql".

store.Maintenance.Send(new PutConnectionStringOperation<SqlConnectionString>(
new SqlConnectionString
{
Name = "MyPostgresConnection",
FactoryName = "Npgsql",
ConnectionString = "Host=myserver;Port=5432;Database=mydb;Username=cdc_user;Password=..."
}));

How it works

CDC Sink uses PostgreSQL logical replication to receive a continuous stream of row-level changes without polling.

Key PostgreSQL concepts:

  • Replication slot
    A server-side object that tracks how far CDC Sink has read in the logical replication stream.
    It also causes PostgreSQL to retain the required WAL segments until CDC Sink confirms receipt.
  • Publication
    Defines which tables are included in the replication stream. CDC Sink creates or reuses a publication for the configured tables when the PostgreSQL user in the connection string has sufficient permissions.
  • WAL (Write-Ahead Log)
    The durable log PostgreSQL uses as the source for logical replication.
    If a CDC Sink task is inactive or paused while its replication slot exists, WAL segments can accumulate.

Prerequisites

Before creating a CDC Sink task for PostgreSQL, verify the source database settings, permissions, and table requirements. See Prerequisites Checklist for the full list, including:

  • PostgreSQL version 10 or later
  • WAL level set to logical
  • Sufficient max_replication_slots and max_wal_senders
  • A PostgreSQL user with REPLICATION privilege and SELECT on each table CDC Sink will read
  • REPLICA IDENTITY configuration for embedded tables whose join columns are not part of the primary key

PostgreSQL-specific settings

Use CdcSinkConfiguration.Postgres when you want to specify the PostgreSQL replication slot and publication names explicitly:

Postgres = new CdcSinkPostgresSettings
{
SlotName = "my_slot",
PublicationName = "my_publication"
}

If either name is omitted, the CDC Sink task generates it when the task is created: rvn_cdc_s_{taskId} for the slot and rvn_cdc_p_{taskId} for the publication. The names are stored with the task and do not change on later updates.

To let the CDC Sink task create the PostgreSQL slot and publication itself, the PostgreSQL user configured in the CDC Sink connection string must have sufficient permissions.

See Initial Setup for details.

Task configuration

Most CDC Sink task configuration is shared across supported source database engines.
See Configuration Reference for the full API, including table mappings, delete behavior, patches, and PostgreSQL-specific settings.

For PostgreSQL, SourceTableSchema defaults to "public" when omitted.