Change Data Capture (CDC): Postgres WAL → Debezium → Kafka topics → fan-out (Elasticsearch search index, Snowflake DWH, PaymentService, NotificationService). Demonstrates logical replication slots with pgoutput plugin, initial snapshot + streaming switchover, transactional outbox pattern for atomic business events, replication slot growth disaster (Debezium down → WAL накапливается → диск Postgres переполняется), and schema evolution via ALTER TABLE. Includes ADRs on CDC vs dual-write vs sync API call (ADR-001) and replication slot growth multi-layer protection (ADR-002).
CDC переносит committed changes, но не создаёт автоматически «exact replica». Нужно определить snapshot/stream boundary, transaction ordering scope, keys, DDL evolution, delete/tombstone semantics, offset durability и log retention.
| Компонент | Ответственность |
|---|---|
| Source Application | Пишет authoritative business transactions only to source DB. |
| Source PostgreSQL | Коммитит rows и WAL; остаётся source of truth. |
| Logical Slot and WAL | Удерживает required log position; может заполнить disk при lag. |
| CDC Connector | Делает snapshot, читает LSN, schemas and transaction metadata. |
| Partitioned Change Topics | Хранит change events with stable keys and replay offsets. |
| Idempotent Projection Consumer | Подключается к topics и conditional-applies source versions. |
| Target Projection | Хранит last applied source position/version per key. |
| CDC Health and Schema Gate | Следит за lag/disk, DDL compatibility, offsets и reconciliation. |
The connector records LSN P and scans a consistent snapshot. After snapshot completion it streams from P; overlap can duplicate a row change and must be deduplicated by key/version.
Проверяемый исход: No committed update between snapshot and streaming is missed.
Offset persistence can lag published/applied work. Restart replays a suffix. The target compares source position/version and keeps one logical state transition.
Проверяемый исход: At-least-once delivery does not become duplicate business rows.
A DDL change can alter event schemas and old/new values. The schema gate verifies consumer compatibility before production rollout; missing primary keys or replica identity are explicit blockers.
Проверяемый исход: Incompatible DDL pauses/fails the pipeline visibly instead of silently dropping fields or misidentifying rows.
A stopped connector prevents the slot from advancing, so WAL accumulates. The source database can run out of disk if operations only watch broker lag.
Проверяемый исход: Alerts trigger throttling, recovery or deliberate resnapshot/drop decision before disk exhaustion; no silent slot deletion.
Числа выше — учебные inputs или размерностные формулы. Их нельзя выдавать за benchmark или SLA конкретного продукта.
[CONCEPT]database-migration-strategies
[CONCEPT]exactly-once-semantics
Диаграмма показывает причинные границы и recovery contracts, а не скрытую реализацию конкретного managed-сервиса. Любая stronger guarantee действует только в явно названной transaction/checkpoint/acknowledgement boundary.
Введите числа или выберите пресет