Schedule icon
If icon
Fail icon
Query icon
Script icon
Docker icon
Log icon

Audit PostgreSQL CDC Replica Parity Before Cutover

Audit PostgreSQL CDC source-to-replica parity by key, with a read-only scan, bounded reports, and a fail-closed cutover check.

Categories
Data

Compare public.customers with its Debezium replica cdc.customers_live before cutover.

How it works

  1. Stop source writes, drain CDC, and confirm the cutover_ready input.
  2. JDBC inventories check row limits, tombstones, and CDC metadata.
  3. Python compares rows using read-only repeatable-read snapshots and server-side cursors, rechecking CDC metadata inside the replica snapshot.
  4. An If blocks on differences or unexpected empty tables. Duplicate or non-integer keys and query errors fail the scan.

What you get

  • Exact missing, extra, changed, and matched counts; no automatic repair.
  • Bounded JSON evidence: sample IDs and changed field names, never values.
  • A failed execution on drift, unsafe inputs, or query errors.

Who it's for

Data engineers and database operators verifying CDC cutover readiness.

Why orchestrate this with Kestra

Tie JDBC inventories, the row scan, report, and cutover gate to one execution.

Prerequisites

  • Kestra with PostgreSQL JDBC and Python Script plugins and Docker access.
  • Source public.customers and target cdc.customers_live with matching types for id, email, full_name, plan, notes, updated_at. The cdc.customers base table also needs _cdc_lsn and _cdc_deleted. Use a unique integer primary key id.
  • SELECT-only users, reachable from JDBC and the Python container.
  • Pause writes and drain CDC first. Independent snapshots are not atomic; active writes can yield transient differences or a false match. The operator must enforce this window; cutover_ready is only an acknowledgement.

Secrets

  • CDC_SOURCE_JDBC_URL, CDC_SOURCE_USER, CDC_SOURCE_PASSWORD: Source JDBC URL and read-only credentials.
  • CDC_REPLICA_JDBC_URL, CDC_REPLICA_USER, CDC_REPLICA_PASSWORD: Target JDBC URL and read-only credentials.
  • CDC_SOURCE_DSN, CDC_REPLICA_DSN: libpq PostgreSQL connection URIs for Python, without credentials. Configure JDBC and libpq TLS separately; use libpq sslmode=verify-full with a trusted CA. Each pair must reach the same database; source and replica must be separate databases.

Quick start

  1. Provision the target with the linked CDC blueprint, or adapt both queries.
  2. Configure eight secrets; check container connectivity.
  3. Stop writes, drain CDC, and execute with cutover_ready=true. The default blocks.
  4. Inspect cdc-parity-report.json; investigate differences and rerun.
  5. Resume writes only after the cutover is complete. The schedule is disabled; enable only in an enforced maintenance window with cutover_ready=true in trigger inputs.

How to extend

Add columns to both queries and FIELDS, or archive reports.

Links

Orchestrate with Kestra
Orchestrate Postgres with Kestra
Share this Blueprint
See How

New to Kestra?

Use blueprints to kickstart your first workflows.