Repository navigation
feat(debezium): close CDC gaps when a connector is recreated - #2650
Closed
Arsenii-Malov wants to merge 3 commits into
Closed
Arsenii-Malov wants to merge 3 commits into
Arsenii-Malov wants to merge 3 commits into
Conversation
Contributor
🦩 Flamingo Code ReviewNot reviewed yet. Reviews start when you ask, so the reviewer reads this pull request when it is ready, not when it is opened. When it is ready:
Or comment Updated 2026-10-13 10:44 UTC · workflow run |
Arsenii-Malov
force-pushed
the
feature/debezium-gap-recovery
branch
from
October 13, 2026 12:48
64cbf40 to
84cac9f
Compare
Arsenii-Malov
force-pushed
the
feature/debezium-gap-recovery
branch
from
October 15, 2026 10:44
84cac9f to
3080215
Compare
Arsenii-Malov
force-pushed
the
feature/debezium-gap-recovery
branch
from
October 22, 2026 15:54
3080215 to
77dc6a6
Compare
Carry the old version's offsets into the new one (create STOPPED, PATCH offsets, resume). When the source history is gone, start no_data and refill only the outage window with an incremental snapshot signalled over Kafka. Checkpoint offsets every health tick so a vanished connector can be restored too. Behind openframe.debezium.recovery.gap.enabled.
- Drift recreate stops the old version, hands its offsets to the new one and resumes the old version if the recreate fails. - A base recreated again within the tracker window starts clean (no_data plus backfill) instead of carrying offsets that may be the cause. - A handed-over version that fails to resume is deleted so the next tick retries. - Unfilled gaps raise a GAP_UNFILLED ConnectorAlert; recovery alerts are scoped to their own types so a healthy tick never resolves it. - Signal topic retention and segment.ms follow backfill-expiry, enforced on an existing topic too, so a clean start does not replay old backfills. - MySQL gap bound is FROM_UNIXTIME(epoch), correct in any session time zone. - Restore from checkpoint goes through the recreation rate limit. - A backfill needs the kafka channel enabled, not only its topic. - Port to Spring Boot 4 / Jackson 3 after the rebase.
…view - prepare the signal topic best-effort; the signal is sent even if the broker refuses the retention change - hand offsets over only when their partition matches the new topic.prefix, otherwise start fresh with a backfill - delete the new version when its backfill cannot be saved, so a failed drift leaves one live version - log "Connector left STOPPED" when the cleanup delete does not remove the version, for the Grafana rule - inject the Kafka clients of the signal publisher and cover the send path with unit tests - add a MySQL IT: a config drift on an initial-snapshot spec resumes from the old GTID without a snapshot
Arsenii-Malov
force-pushed
the
feature/debezium-gap-recovery
branch
from
October 22, 2026 17:42
77dc6a6 to
61a3305
Compare
Contributor
|
Closing as stale: no activity for over a week. Reopen if still needed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ClickUp task: CU-17tkuw5wzkz Debezium: close CDC gaps when a connector is recreated
Why
Every time a Debezium connector is recreated as
<base>_vN+1(recovery or config drift) it gets a clean offset namespace. Withsnapshot.mode: initialthat re-dumps the whole source (≈2.4M MeshCentral events, 60 days of Fleet activities); withno_data(saas-shared #2551) it silently loses everything written while the old version was down.What
Behind
openframe.debezium.recovery.gap.enabled(off unless configured; tenants unaffected):STOPPED, gets the old version's offsets viaPATCH /connectors/{name}/offsets, then resumed: no gap, no snapshot. If the resume fails the new version is deleted so the next tick retries (aSTOPPEDconnector looks healthy to every check).PUT /stop) before its offsets are read and is resumed again if the recreate fails.no_data+ backfill from the last known position), so offsets that cause the failure are not carried forever.ChangeStreamHistoryLost, purged binlog) the new version startsno_data, and once it isRUNNINGanexecute-snapshot(INCREMENTAL) signal is sent over the connector's Kafka signal channel for the outage window only:{"_id": {"$gte": ObjectId(<last offset sec − margin>)}}– walks the_idindex.backfillmap ({from}→FROM_UNIXTIME(<epoch>), right in any session time zone forTIMESTAMPcolumns); tables without a filter are re-read whole. Runsread.onlyon GTID, no signal table.GAP_UNFILLEDConnectorAlertthat a healthy tick never resolves; recovery alerts are now scoped to their own types.retention.msandsegment.msfollowbackfill-expiry(also enforced on an auto-created topic), so a version started without offsets – which reads the topic from the beginning – does not replay old backfills.topic.prefix; otherwise the version starts fresh and the window is backfilled.STOPPEDversion,[DEBEZIUM] Connector left STOPPEDis logged for the alert. Signal-topic preparation is best-effort, the signal is sent even if the broker refuses the retention change.connector_checkpoints; a connector that vanished from Kafka Connect is restored from a fresh checkpoint (handover, or backfill if the position is gone), within the recreation rate limit. Pending backfills live inconnector_backfills(survive pod restarts / shedlock moving the tick).no_data; the spec'ssnapshot.modeonly governs the very first creation and is ignored in drift comparison.RestTemplatenow uses the JDK client (the defaultHttpURLConnectioncannot sendPATCH). Built on Spring Boot 4 / Jackson 3 (rebased onto chore(deps): upgrade to Spring Boot 4.1.1, Java 25 and Jackson 3 #2534).Tests
Module had no tests before. Unit tests for every new class plus ITs against a real
quay.io/debezium/connect:3.3.2(Kafka Connect 4.1.0, same as prod) with Kafka, a Mongo replica set and MySQL 8 with GTID in docker:op=r);snapshot.mode: initial(as Fleet): the new version resumes from the old GTID, no row is snapshotted again (the same test fails with the old recreate path: the table is re-snapshotted);topic.prefix;STOPPEDcreate +PATCHoffsets round-trip.Unit tests 117/117 and ITs 9/9 green on JDK 25. PIT on changed lines: 252/252 killed, no survivors, no uncovered mutations (the Kafka send path has unit tests through injectable
SignalKafkaClients). Downstream saas-shared (management, infra) and saas-tenant (management, tenant-stream) build and pass their tests against this branch installed as999-SNAPSHOT.Rollout
Safe to merge on its own: without the flag the only change in behaviour is the JDK HTTP client towards Kafka Connect. Merge → lib release → bump in flamingo-stack/openframe-saas-shared#2555 (connector signal keys + flag together).
Change-Set: feature-debezium-gap-recovery
Change set
flamingo-stack/openframe-oss-lib#2534: these pull requests are one change, reviewed together.Linked work
Linked by the
Depends-On/Change-Setlines in these descriptions; this block is maintained by the hub.