Est.

CDC Pipeline Failure Recovery: 7 Patterns Every Data Engineer Should Know

Master seven recovery patterns to fix CDC pipeline failures without downtime or data loss.

· 6 min read
Cover illustration for “CDC Pipeline Failure Recovery and Resumption Patterns”
Change Data Capture · October 19, 2026 · 6 min read · 1,362 words

CDC pipeline failure recovery depends on knowing which durability boundary failed. The source log, replication slot, connector offset, transport, and sink each demand a distinct recovery pattern. Reliable resumption comes from matching the response to that boundary and making replay safe, rather than treating every failure as a reason to restart or re-snapshot. Here are seven patterns that separate robust pipelines from brittle ones.

1. Detect Silent Failures Before They Reach Your Dashboards

A connector falls behind, times out on a subset of tables, recovers, and logs the timeout as a warning. By morning, every dashboard shows green, throughput looks normal, and no alert has fired. Yet a data gap has already formed. This is the most dangerous CDC failure mode.

Reliable detection requires three independent signals:

  • Database-level WAL slot lag: Query the gap between pg_current_wal_lsn() and the slot's restart_lsn through pg_replication_slots. This shows retention pressure before it raises downstream latency.
  • End-to-end latency: Measure from source commit to destination arrival. Use rate-of-change or percentile thresholds rather than averages, which can smooth over gradual deterioration.
  • Dead-letter queue (DLQ) activity: A DLQ event almost always points to schema-driven deserialization failure or a downstream write constraint rejection. Sustained record counts matter more than isolated spikes.

Route these signals by severity: low slot-lag alerts to Slack, high end-to-end latency pages PagerDuty, and a DLQ rate above baseline opens an incident automatically. Halodoc's 2026 account puts manual CDC recovery at anywhere from 15 minutes to several hours. Early detection is the prerequisite for every recovery pattern below.

2. Treat the Replication Slot as Your Pipeline's Single Point of Failure

In PostgreSQL, the replication slot guarantees WAL retention for a specific consumer. But that same guarantee makes an inactive slot an anchor that blocks WAL cleanup and can fill your disk, blocking new writes and causing application downtime.

Key risks to monitor:

  • The quiet-table trap: A slot decodes the entire database's WAL but advances only when the consumer processes changes for its subscribed tables. Idle tables stall the slot while WAL grows.
  • Failover slot loss: On PostgreSQL versions older than 17, physical failover destroys the slot because slots on the primary are not carried over to the promoted standby.
  • The retention cap trade-off: max_slot_wal_keep_size defaults to -1 (unlimited retention). Setting a cap protects disk space but can invalidate a lagged slot at checkpoint time.

Managed solutions like Artie handle slot lifecycle automatically, monitoring lag, alerting on retention pressure, and recreating slots safely after failover events, so your team is not left chasing WAL growth at 2 a.m.

3. Resume from a Valid Offset When the Slot Survives

Clean resumption is the lowest-cost recovery path. When the replication slot remains intact and WAL has been retained far enough back, the connector reads its stored offset, locates the matching LSN, and resumes without data loss or a re-snapshot.

Before resuming, verify all of the following:

  • The slot still exists and is active.
  • confirmed_flush_lsn is consistent with the connector's last acknowledged position.
  • The consumer is reconnecting to the same cluster.
  • The timeline has not changed through a failover.

If any of these conditions fail, do not assume a clean resume is safe. The common silent failure is divergence between the stored offset and the slot's confirmed_flush_lsn. Compare those watermarks before consumption starts and stop and alert if they disagree.

A configurable rewind buffer adds a safety margin. Re-consuming the last known committed window covers completeness at the cost of duplicate processing. Halodoc's design principle favors completeness over duplicate risk because downstream systems handle idempotency better than gaps.

4. Recover Gracefully from a Dropped or Invalidated Slot

A dropped or invalidated slot removes the valid WAL position needed for ordinary resumption. Major PostgreSQL version upgrades, manual administrative actions, and retention-cap invalidation can all cause this. The recovery decision must begin with the missing interval.

  1. Establish the gap between the connector's last acknowledged confirmed_flush_lsn and the current WAL position.
  2. Create a new slot with pg_create_logical_replication_slot() using the appropriate plugin (pgoutput for most production setups). This retains WAL from the current position forward only.
  3. Decide between targeted backfill and a full re-snapshot based on gap size, table mutability, and the downstream reconciliation burden.

Automation must respect this decision tree. Halodoc's recovery model checks that the task is failed rather than already recovering, classifies the error as recoverable, and only then calculates and applies a safe checkpoint. A restart is an outcome of diagnosis, not a first response.

Artie automates this triage entirely. Its platform classifies failures, determines the appropriate recovery path, and executes slot recreation or backfill without requiring manual CLI intervention, cutting recovery time from hours to minutes.

5. Avoid Re-Snapshots When Schema Changes Break the Consumer

Adding, removing, or renaming a column can break deserialization and divert destination-bound events to the DLQ, even when the replication slot is healthy and WAL lag is zero. A full re-snapshot is not automatically the right repair.

On a large table, a re-snapshot is expensive and blocks slot advancement during the load window. If CDC then resumes from a stale confirmed_flush_lsn, intermediate updates from before the snapshot may overwrite the snapshot's newer values.

Better alternatives include:

  • Checkpoint reset: Databricks' Lakeflow documentation describes a pattern that preserves existing table data, resets only the affected streaming flows' checkpoints, and resumes incrementally without re-ingesting the full table.
  • Schema registries and versioned schemas: Let compatibility-aware consumers handle missing or added fields gracefully, giving source and pipeline teams a shared coordination point.
  • Automatic schema evolution: Managed CDC services like Artie detect and propagate schema changes before delivering events, eliminating raw Avro or Protobuf deserialization failures at the pipeline layer entirely. This means schema changes that would have triggered a DLQ flood and a manual re-snapshot are handled automatically, with no downtime and no data loss.

6. Make the Sink Idempotent So Any Replay Is Safe

Every replay-based recovery depends on the sink accepting the same event more than once without corrupting state. Without that property, a rewind buffer can fill a gap but cause the same event to have an effect more than once. The realistic production target is at-least-once delivery with an idempotent or deduplicating sink. A pipeline-level promise of exactly-once behavior is not a substitute for safe destination writes.

Patterns that work:

  • Warehouse MERGE or UPSERT semantics: Keying the write on the source row's primary key lets repeated applications of the same event produce the same current state, provided the event carries the full row image.
  • Immutable transaction history alongside a mutable aggregate: The aggregate serves fast reads, while the history supplies a durable record from which to replay and explain drift.

Patterns that are unsafe in replay paths:

  • Operations that increment a count or update an accumulator without checking prior application.
  • Appending to an array without deduplication logic.

Artie applies MERGE semantics natively to supported destinations, meaning replayed events are idempotent by default. Teams get the safety of exactly-once effective writes without having to build and maintain custom deduplication logic in their warehouse.

7. Automate Recovery Decisions Without Creating New Failure Modes

Automation lets the system respond faster, but an unchecked restart loop can hide unrecoverable failures, cause retry storms, or interfere with work that needs human judgment. The governing principle should be: alert first, act second.

Safe automation follows these rules:

  • Scope to incremental tasks only. Full-load tasks require human review because choosing between re-snapshot and backfill depends on context the system cannot infer alone.
  • Confirm the task is still failed before acting, rather than interrupting a manual fix already in progress.
  • Classify errors before restarting. Only known recoverable patterns, including binary log rotation, transient network failure, and memory exhaustion on a batch, should trigger an automated restart. Unknown or unclassified errors go to a human.
  • Add a reconciliation layer. Halodoc compares row-count and checksum results from source and destination because the connector can miss some gaps even when recovery appears successful.

Maintaining eligibility rules, error classifications, slot-monitoring queries, and schema-evolution handling is significant ongoing infrastructure work. Artie absorbs that cost as a managed real-time replication service, keeping error classifications and recovery logic up to date as new failure patterns emerge, so your team can focus on the data rather than the pipeline keeping it moving.

Sources

  1. Building Self-Healing Data Pipelines at Halodoc

More in Change Data Capture