Contributing to Debezium: Fixing Logical Replication at Scale
Zalando contributed two configuration options to Debezium's PostgreSQL connector, released in 3.4.0.Final. They restore the pgjdbc keepalive flush that prevents runaway WAL growth on low-activity databases and resolve the offset/slot LSN mismatch that made it unsafe with durable offset stores. The first option, `lsn.flush.mode` (manual, connector, connector_and_driver), lets the JDBC driver advance the replication slot past unmonitored WAL activity. The second, `offset.mismatch.strategy` (no_validation, trust_offset, trust_slot, trust_greater_lsn), controls whether Debezium trusts the stored offset or the slot on startup, both with backward-compatible mapping from the deprecated booleans. The recommended setup is connector_and_driver with trust_greater_lsn for persistent offset stores, which avoids dummy heartbeat writes and full re-syncs.
Related posts
- Patching the PostgreSQL JDBC Driver
Zalando Engineering mediumAdeptPostgres logical replication slots for clients watching low-traffic tables never advance, so the server retains all WAL generated by other tables until disk fills and the node goes read-only. Zalando fixed this upstream in PgJDBC: the driver now tracks the last received and last confirmed replication LSNs, and when they match and a KeepAlive message reports a higher server LSN, it confirms that LSN, safely advancing the slot without skipping relevant events. The fix, merged for PgJDBC 42.7.0, removes the need for the common dummy-write workaround and was validated by comparing WAL size graphs before and after a patched Debezium image rollout across hundreds of event streams.
- Fan-out from Postgres with Change Data Capture using Debezium and Upstash Redis
Neon mediumAdept
Streaming committed Postgres changes from the write-ahead log via a logical replication slot avoids the dual-write problem, where an application writes to the database and a message broker separately and can leave them inconsistent. LISTEN/NOTIFY doesn't fix this because it is only at-most-once. The guide configures Debezium Server to read Neon's WAL using pgoutput, with an initial snapshot and file-based offset tracking, and to sink change events into an Upstash Redis stream. A Node.js consumer then uses XREADGROUP consumer groups and XACK to get at-least-once fan-out that can resume after restarts.
- Event-driven architectures using Neon and Sequin
Neon mediumAdept
Sequin offers a lighter alternative to Debezium plus Kafka for change data capture on Neon Postgres, using a logical replication slot to build a strictly ordered "Sequence" of table rows that consumers can read, rewind and replay without copying data into a separate system. Setup covers enabling logical replication in Neon, creating a pgoutput replication slot and a publication, defining a Sequence with a sort column, and creating a pull consumer group with optional SQL filters and a chosen start position. Consumers fetch batches over an HTTP receive endpoint and acknowledge them with ack tokens, and Sequin redelivers rows until they are acknowledged.
- A Guide to Logical Replication and CDC in PostgreSQL with Airbyte
Neon mediumAdept
PostgreSQL logical replication builds on the write-ahead log: logical decoding turns byte-level WAL records into row-level INSERT/UPDATE/DELETE changes, and replication slots track each subscriber's LSN while retaining WAL until it is consumed. Unlike physical replication, logical replication can filter tables, rows and columns but does not replicate schema or DDL, so additive schema changes should be applied to subscribers first. Postgres-to-Postgres setup uses wal_level=logical, a replication role, publications and subscriptions, while Airbyte's CDC connector moves data into warehouses such as BigQuery or Snowflake, including from Neon. Tuning wal_compression, max_wal_size and min_wal_size helps limit WAL buildup between syncs.
- Blocking cutovers to save replication slots
PlanetScale mediumAdeptPlanetScale Postgres blocks planned cutovers (resizes, parameter changes, maintenance) when logical replication slots aren't synchronized to the replica being promoted, because vanilla Postgres will promote a replica without the slot and silently break CDC consumers. To make slots promotion-ready, create them with failover = true (or ALTER_REPLICATION_SLOT ... (FAILOVER true)) and set hot_standby_feedback and sync_replication_slots to on. The operator detects misconfiguration, alerts users, waits for slots to be ready, and manages synchronized_standby_slots. Enabling hot_standby_feedback pins the primary's vacuum horizon and can add bloat, which is why both settings are off by default.