If icon
Log icon
Exit icon
Set icon
Capture icon
Fail icon
Get icon
Script icon
Docker icon
SlackIncomingWebhook icon
Pause icon
Switch icon
Loop icon
Query icon
Delete icon
FileTransform icon
DeduplicateItems icon
FilterItems icon
Batch icon
Schedule icon

Gate MySQL Debezium CDC Loads on Schema Changes with Approval

Hold Debezium MySQL CDC batches when DDL changes a watched table. Approve, apply the DDL to the target, verify the schema, then upsert the rows.

Categories
Data

A MySQL schema change can break a downstream copy in silence. This flow replicates watched tables with Debezium and holds the load when DDL changes one of them.

How it works

  1. A Schedule runs the flow every five minutes.
  2. With no pending batch, the Debezium MySQL Capture task reads new binlog events. The flow saves the batch as pending in KV.
  3. The plugin does not emit DDL events. A Python script compares the Debezium schema history before and after the capture and marks each watched change as additive or breaking.
  4. With watched DDL, the flow sends a Slack message and pauses. APPLY_DDL_AND_LOAD runs the DDL on the target. LOAD_ONLY is for a target that you changed by hand. The target columns must then match the source.
  5. Per table, the flow keeps the last event per primary key and loads an upsert and a delete with the JDBC Batch task.
  6. The pending batch is deleted only after the load. After a failure or an approval timeout, the next run retries it before it reads new events.

What you get

  • No load into a table whose schema changed without review.
  • No skipped events, and an idempotent load.
  • Optional automatic apply of additive columns.
  • A KV checkpoint with the decision and the applied DDL.

Who it's for

  • Data and platform engineers who run MySQL CDC.
  • On-call owners of a downstream MySQL copy.

Why orchestrate this with Kestra

  • Pause with onResume inputs gives an audited approval step.
  • KV state, retries, concurrency and alerts are declared in YAML.

Prerequisites

  • MySQL with binlog_format ROW and binlog_row_image FULL. Keep binary logs longer than the approval timeout.
  • A Debezium user with SELECT, RELOAD, SHOW DATABASES, REPLICATION SLAVE, REPLICATION CLIENT and LOCK TABLES.
  • Target tables with the same primary keys. The target user needs DML, ALTER, CREATE, DROP and INDEX.
  • A Docker task runner.

Secrets

  • MYSQL_CDC_USERNAME and MYSQL_CDC_PASSWORD: Debezium user on the source.
  • TARGET_DB_USERNAME and TARGET_DB_PASSWORD: user that writes to the target.
  • SLACK_WEBHOOK_URL: webhook for decisions and failures.

Quick start

  1. Create the secrets and edit includedTables in the capture task.
  2. Execute the flow once. The first run loads a snapshot.
  3. Run an ALTER on a watched table, then resume the paused execution with a decision.
  4. Enable the schedule.

How to extend

  • Send the decision to Microsoft Teams.
  • Load a second target after the schema check.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.