We are designing a change data capture (CDC) bridge that must handle:
- Ordering: ensuring that the order of events is preserved, especially when there are multiple sources or when events are processed in parallel.
- Schema evolution: the structure of the data (tables) might change over time (add/drop columns, change data types, etc.) and the CDC system must adapt.
- Reorgs: reorganization of the source data (like table splits, merges, or moving data between tables) and how the CDC system tracks changes after such operations.
We assume the CDC bridge is reading from a transactional database (like PostgreSQL, MySQL, etc.) and publishing change events to a message queue (like Kafka) or a stream processing system.
Let's break down the design:
-
Ordering:
- In a single database, the order of changes is typically determined by the transaction commit order (e.g., LSN in PostgreSQL, or binlog position in MySQL). However, when we have multiple tables or even multiple databases, we need a global order.
- We can use the transaction log (WAL) which provides a total order of changes across the entire database. The CDC bridge reads the WAL and emits events in that order.
- But if we have multiple sources (multiple databases), we need a way to order events across sources. We can assign a source ID and then use a combination of source ID and the WAL position (or transaction ID) to order events. However, note that different databases may have different clocks. So we might rely on the ingestion time at the CDC bridge if we are reading from multiple sources and then order by that, but that might break the causal ordering if the bridge is distributed.
Alternatively, we can design the CDC bridge to read from one source at a time and then have a separate process that merges the streams by the source's WAL position and a globally synchronized clock? That's complex.
Another approach: if the sources are independent and we don't need cross-source ordering, then we can keep the ordering per source and let the consumer handle the global ordering if needed.
However, the requirement says "ordering", so we assume we need a total order of all events.
Let's assume we have a single source database (or we are reading from multiple but they are part of the same logical database cluster that provides a global WAL). If we are reading from multiple independent databases, then we might need to use a timestamp from the transaction (if available) and then break ties with the source ID and some sequence number. But note: transaction timestamps might not be strictly monotonic across databases.
Alternatively, we can use a two-phase approach:
- Each CDC instance (for a source) emits events with a locally ordered sequence (based on WAL) and a source identifier.
- Then we have a separate ordering service that takes these streams and orders them by:
a) A global timestamp (if we can get a synchronized clock across sources, e.g., using TrueTime or hybrid logical clocks) and then by source ID and local sequence.
b) Or by having each source assign a globally unique increasing ID (like a hybrid of source ID and a local sequence that is globally coordinated?).
Since this is complex, maybe we assume that the CDC bridge is for a single database that provides a total order (like a single WAL). Then the problem is simpler.
-
Schema evolution:
- The database schema changes over time (DDL operations). The CDC bridge must adapt to these changes and reflect them in the emitted events.
- There are two aspects:
a) The structure of the change event: when a table's schema changes, the change events for that table should reflect the new schema. But note: old events (before the schema change) are in the old format. We need to version the event schema.
b) The way the CDC bridge reads the WAL: after a DDL, the way the WAL represents the data might change (e.g., a column is added, so the new rows have an extra field in the WAL). The CDC bridge must be able to decode both old and new formats.
How to handle:
- We can have a schema registry (like Confluent Schema Registry) for the change events. The CDC bridge will emit events with a schema ID that corresponds to the table's schema at the time of the change.
- For the WAL decoding, we need to maintain a mapping of the table's schema at each point in time. This can be done by:
- Listening to DDL events in the WAL and updating the internal schema cache.
- When reading a change event from the WAL, we use the schema that was in effect at the time of the transaction (which we can get from the WAL if it includes the DDL, or we can track the schema changes ourselves by watching the WAL for DDLs).
However, note that the WAL might not directly include the schema for every row change. It might only include the data in a binary format that is tied to the current schema. So we need to know the schema at the time of the WAL record.
In PostgreSQL, for example, the WAL includes the data in a binary format that is specific to the table's layout at the time of the transaction. We can decode it if we know the table's OID and the column definitions at that time.
So the CDC bridge must:
- Track schema changes (by reading DDL events from the WAL) and maintain a history of schemas per table.
- When processing a WAL record for a table, look up the schema for that table at the WAL position (or LSN) of the record.
This is non-trivial because we have to store the schema history and be able to retrieve it quickly.
-
Reorgs:
- Reorganization of the source data: for example, splitting a table into two, merging two tables, or moving data from one table to another.
- From the CDC perspective, we are reading the WAL, so we will see the DDL that does the reorganization and then the subsequent changes on the new tables.
- The challenge is that the logical table (as seen by the application) might change, but the CDC bridge is emitting events for physical tables. We might want to map the physical tables to the logical entity.
For example, if we split table A into B and C, then after the split, changes to B and C should be considered as changes to the original logical entity (maybe A). But note: the application might now write to B and C separately.
There are two approaches:
a) Emit events for the physical tables and let the consumer figure out the logical mapping. This requires the consumer to be aware of the reorganization.
b) The CDC bridge maintains a mapping of the logical table to the current physical tables and emits events for the logical table. But note: after a split, we have two physical tables for one logical table? Then we might need to emit two different types of events? Or we emit events for the logical table and include a field that indicates which part (B or C) changed? This is application-specific.
Alternatively, we can treat each physical table as a separate stream and let the consumer handle the logical view. But then the consumer must be aware of the reorg.
Another idea: we can have a configuration that defines the logical tables and how they map to physical tables over time. This configuration would be updated when a reorg happens.
Example:
Initially: logical table "order" -> physical table "orders"
After split: logical table "order" -> physical tables "order_header" and "order_line"
Then when we see a change on "order_header", we emit an event for logical table "order" with a type that indicates it's a header change? But what about the order lines? We might need to emit two types of events.
Alternatively, we can emit events for the physical tables and then have a separate process that merges them into the logical view. But that merging might be complex (e.g., when we split, we have to combine header and line events to reconstruct the original order?).
Given the complexity, it might be better to let the consumer handle the reorgs. However, the requirement says the CDC bridge must handle reorgs, so we need to design for it.
Proposed solution for reorgs:
- The CDC bridge maintains a mapping from logical table names to physical tables. This mapping is updated when a DDL that affects the mapping (like a split) is detected.
- The mapping can be provided by the user (via configuration) or automatically detected by the CDC bridge by analyzing the DDL. But automatic detection is hard because the DDL might be arbitrary.
Since automatic detection of the logical mapping is very difficult, we might require the user to specify the mapping. For example, when a table is split, the user can provide a configuration that says:
reorgs:
- at LSN: 12345
from: orders
to: [order_headers, order_lines]
Then, after LSN 12345, the CDC bridge will emit events for the logical table "orders" by merging events from "order_headers" and "order_lines"? But note: the application might now write to both tables independently, and we want to emit events for the same logical table. How do we merge?
Alternatively, we can emit two separate streams for the two physical tables and then have a separate process that combines them. But then the CDC bridge would be emitting two streams for one logical table? That breaks the one-stream-per-logical-table idea.
Let's think: the goal of the CDC bridge is to capture changes and make them available in a structured way. The consumer might want to have a stream of changes for the logical table "orders". After the split, we have two physical tables. We can:
Option 1: Emit two separate topics/streams: one for headers and one for lines. Then the consumer must join them. But note: the original "orders" table had both header and line in one row? That doesn't make sense because a typical order has a header and multiple lines. So the split is normalizing the data.
Option 2: The CDC bridge could emit events for the logical table by reconstructing the original row? But after split, we cannot reconstruct the original row because the lines are in a separate table and we don't know which lines belong to which order without a foreign key.
Given the complexity, I think we should leave the reorg handling to the consumer. The CDC bridge should just emit events for the physical tables and let the consumer handle the logical view.
However, the requirement says the CDC bridge must handle reorgs. So maybe we interpret it as: the CDC bridge must not break when a reorg happens and must continue to capture changes correctly. That is, it must adapt to the new schema and continue.
So for reorgs, we just need to make sure that when a table is dropped and replaced by two new tables, the CDC bridge will start emitting events for the new tables and stop for the old one. And the consumer must be aware that the old table is gone and new tables are there.
But note: the consumer might be expecting events for the old table and then suddenly for the new tables. That's a breaking change.
Therefore, maybe we need a way to tell the consumer that the table has been reorganized. We can emit a special event (like a schema change event) that indicates the reorg.
Alternatively, we can have a configuration that maps the old table to the new tables, and the CDC bridge will emit events for the old table name but with the data from the new tables? That would be confusing because the old table name might not exist anymore.
Given the time, let's simplify:
We design the CDC bridge to:
- Emit events for each physical table that is being tracked.
- When a DDL that drops a table or renames a table occurs, we stop emitting for that table (or continue under the new name).
- We do not attempt to merge multiple physical tables into one logical table. That is left to the consumer.
But then the requirement of handling reorgs might be satisfied by just continuing to capture changes without data loss, even if the table structure changes.
So for reorgs, we just need to handle the DDL that changes the physical structure and update our schema mapping accordingly.
However, note that if a table is split, the original table is gone and two new tables appear. The CDC bridge will see the DROP of the old table and the CREATE of the new ones. We must start tracking the new tables and stop the old one.
We can have a configuration that specifies which tables to track. If we are tracking by a pattern (like all tables in a schema) then we will automatically start tracking the new tables. But if we are tracking by specific table names, then we need to update the configuration.
So the reorg handling might require a way to update the configuration automatically or manually.
Given the complexity, I think we should focus on:
- Ordering: within a single database, we use the WAL order. For multiple databases, we need a global ordering mechanism (like a centralized sequencer or using a hybrid logical clock). But let's assume one database for now.
- Schema evolution: we track schema changes via WAL and update our schema for the table. We emit events with the schema that was in effect at the time of the change.
- Reorgs: we treat DDL that changes the table structure (including drop, rename, create) as schema changes. We update our internal mapping of tables to schemas. We stop tracking tables that are dropped and start tracking new tables that are created (if they match our configuration).
We do not attempt to merge multiple tables into one. The consumer must handle that.
-
Putting it all together:
We design the CDC bridge as follows:
Components:
- WAL reader: reads the WAL (or binlog) in order.
- DDL processor: processes DDL events to update:
a) The schema history for the table (by OID)
b) The current table name for the OID
c) The set of tables we are tracking (if we are tracking by pattern, then we add new tables that match the pattern)
- Change event emitter: for each row change, it looks up the current schema for the table (by OID) and the current table name, and emits an event with:
- The table name (as per the current mapping)
- The operation (insert, update, delete)
- The data (with the schema that was in effect at the time of the change? Or the current schema? We need to use the schema at the time of the change, which might be different if there was a schema change in between? But note: the WAL record for a row change is generated with the schema at the time of the transaction. So if we have the correct schema for that table at that WAL position, we can decode the binary data.
How to get the schema at the time of the change?
We maintain a history of schemas per table (by OID) and associate each schema with a range of LSNs (or the LSN at which the schema change occurred). Then for a row change at LSN X, we find the latest schema change for that table that occurred at or before LSN X.
But note: the WAL might not have the full column definitions for every row change. In PostgreSQL, for example, the WAL record for a row change includes the tuple data in the format of the table at that time. We need the column definitions to decode that binary data.
So we must have the correct column definitions for the table at the time of the row change.
How to build the history?
We start with the initial schema for each table (when we start reading). Then we update the schema for a table when we see a DDL that changes that table (ALTER TABLE). We record the LSN of the DDL and the new schema.
Then, for a row change at LSN X, we look for the most recent DDL for that table with DDL LSN <= X. If there is none, we use the initial schema.
- The emitted event will have:
- source: (source identifier, if multiple sources)
- timestamp: the transaction commit timestamp (if available) or the WAL LSN (as a proxy for time)
- table: the current table name (at the time of processing, which is the same as at the time of the event because we process in order and update on DDL before row changes in the same transaction)
- operation: I/U/D
- data: the row data, serialized according to the schema that was in effect at the time of the change (which we get from the history)
But note: the schema we use for serialization must be the one at the time of the change. However, we are using the current mapping for table name. The table name might have changed due to a rename, but the OID is the same. So we are using the current table name for the OID, which is the name at the time of processing. But if the event happened before the rename, then at the time of processing we haven't seen the rename, so the current name is the old name. So it matches.
So we are safe.
Architecture Overview
Source DB → CDC Connector → CDC Bridge → Message Queue → Consumers
│ │
└─Schema Registry────┘
1. Ordering Guarantees
Source-Level Ordering
Ordering Strategy:
- Monotonic Transaction ID: Use database-native transaction identifiers
(PostgreSQL LSN, MySQL GTID) as the primary ordering key
- Hybrid Logical Clocks (HLC): For multi-source scenarios, combine
physical time with logical counters
- Transaction Boundary Tracking: Group events by transaction commit LSN
Implementation:
class OrderedEvent:
def __init__(self, source_id: str, lsn: int, tx_id: str,
commit_ts: datetime, sequence: int):
self.source_id = source_id # For multi-source
self.lsn = lsn # Log Sequence Number (PostgreSQL)
self.tx_id = tx_id # Transaction ID
self.commit_ts = commit_ts # Commit timestamp
self.sequence = sequence # Per-transaction sequence
def __lt__(self, other):
# Primary: LSN (monotonic per source)
if self.lsn != other.lsn:
return self.lsn < other.lsn
# Secondary: Sequence within transaction
return self.sequence < other.sequence
Multi-Source Ordering:
class GlobalOrderer:
def __init__(self):
self.per_source_last_lsn = defaultdict(int)
self.hlc_clocks = {} # Hybrid Logical Clocks per source
def order_events(self, events: List[OrderedEvent]) -> List[OrderedEvent]:
# Use HLC for cross-source ordering
# Format: (hlc_timestamp, source_id, lsn)
return sorted(events, key=lambda e: (
e.hlc_timestamp, e.source_id, e.lsn
))
2. Schema Evolution Handling
Schema Registry Integration
Schema Management:
- Central Schema Registry: Confluent Schema Registry or custom
- Schema Versioning: Every table gets a versioned schema
- Compatibility Rules: BACKWARD, FORWARD, FULL
- Schema Evolution Strategies:
* Additive only (safe)
* Type widening (safe)
* Column rename (with alias mapping)
* Column drop (with tombstone markers)
Schema Evolution Handler:
class SchemaEvolutionHandler:
def __init__(self, schema_registry: SchemaRegistry):
self.registry = schema_registry
self.table_schemas = {} # (table_id, lsn) → Avro/Protobuf schema
self.column_renames = defaultdict(dict) # Track renames
def get_schema_for_event(self, table: str, lsn: int,
event_data: dict) -> EnrichedEvent:
# 1. Find schema version effective at this LSN
schema_version = self._find_schema_version(table, lsn)
current_schema = self.registry.get_schema(schema_version)
# 2. Apply column renames if any
renamed_data = self._apply_renames(table, lsn, event_data)
# 3. Validate against schema (with missing columns as null)
validated_data = self._validate_and_fill_missing(
renamed_data, current_schema
)
return EnrichedEvent(
data=validated_data,
schema_id=schema_version,
schema=current_schema
)
def handle_ddl_event(self, ddl_event: DDLEvent):
"""Process DDL and update schema registry"""
if ddl_event.operation == "ALTER_TABLE_ADD_COLUMN":
new_schema = self._extend_schema(
ddl_event.table, ddl_event.column, ddl_event.data_type
)
self._register_new_version(ddl_event.table, new_schema)
elif ddl_event.operation == "ALTER_TABLE_RENAME_COLUMN":
# Record rename mapping without changing schema
self.column_renames[ddl_event.table][ddl_event.old_name] = \
ddl_event.new_name
Schema Compatibility Matrix:
Evolution Type | Backward Compatible | Forward Compatible | Strategy
----------------------|-------------------|-------------------|---------
Add column (nullable) | Yes | Yes | Direct
Add column (required) | No | Yes | Deferred default
Rename column | With alias map | With alias map | Track mapping
Change type (widen) | Yes (int→long) | Yes | Coercion
Change type (narrow) | No | No | Reject
Drop column | No | Yes | Tombstone in payload
3. Reorganization (Reorg) Handling
Reorganization Types
- Table Split:
orders → order_headers + order_lines
- Table Merge:
user_profiles + user_settings → users
- Table Rename:
old_table → new_table
- Column Migration: Move column between tables
- Partitioning Change: Range → Hash partitioning
Reorg Tracking System
class ReorgTracker:
def __init__(self):
self.reorg_history = [] # (from_table, to_table, lsn, type)
self.table_mappings = defaultdict(dict) # Logical table → Physical tables
self.parent_child_relations = {} # For splits/merges
def register_reorg(self, ddl_event: DDLEvent):
"""Detect and register reorganization operations"""
reorg_type = self._detect_reorg_type(ddl_event)
if reorg_type == "SPLIT":
self._handle_split(ddl_event)
elif reorg_type == "MERGE":
self._handle_merge(ddl_event)
elif reorg_type == "RENAME":
self._handle_rename(ddl_event)
def _handle_split(self, ddl_event):
"""orders → [order_headers, order_lines]"""
parent_table = ddl_event.table
child_tables = ddl_event.parameters.get('new_tables', [])
# Record relationship
for child in child_tables:
self.parent_child_relations[child] = parent_table
# Create logical view
self.table_mappings[parent_table] = {
'type': 'SPLIT',
'children': child_tables,
'effective_lsn': ddl_event.lsn
}
def resolve_logical_table(self, physical_table: str, lsn: int) -> str:
"""Resolve physical table to logical table name"""
# Check if this physical table is a child of a split
if physical_table in self.parent_child_relations:
return self.parent_child_relations[physical_table]
# Check direct mappings
for logical, mapping in self.table_mappings.items():
if mapping['type'] == 'SPLIT' and \
physical_table in mapping['children']:
return logical
return physical_table # No mapping needed
Reorg-Aware Event Emission
class ReorgAwareEmitter:
def __init__(self, reorg_tracker: ReorgTracker):
self.reorg_tracker = reorg_tracker
def emit_event(self, raw_event: RawChangeEvent):
physical_table = raw_event.table
lsn = raw_event.lsn
# 1. Resolve to logical table
logical_table = self.reorg_tracker.resolve_logical_table(
physical_table, lsn
)
# 2. Add reorg metadata
enriched_event = EnrichedEvent(
table=logical_table,
physical_table=physical_table,
operation=raw_event.operation,
data=raw_event.data,
reorg_info=self._get_reorg_info(physical_table, lsn),
lsn=lsn
)
return enriched_event
def _get_reorg_info(self, table: str, lsn: int) -> dict:
"""Get reorg context for this event"""
info = {
'is_split_child': table in self.reorg_tracker.parent_child_relations,
'parent_table': self.reorg_tracker.parent_child_relations.get(table),
'effective_from_lsn': None
}
# Check if table is part of a split
for logical, mapping in self.reorg_tracker.table_mappings.items():
if mapping['type'] == 'SPLIT' and table in mapping['children']:
info['partition_of'] = logical
info['effective_from_lsn'] = mapping['effective_lsn']
break
return info
4. Unified Event Format
{
"metadata": {
"source": "postgres-main",
"source_type": "postgresql",
"lsn": 123456789,
"transaction_id": "tx_abc123",
"commit_timestamp": "2024-01-15T10:30:00Z",
"schema_id": "orders-v3",
"table": "orders",
"physical_table": "order_headers",
"operation": "INSERT|UPDATE|DELETE",
"reorg": {
"type": "SPLIT",
"parent_table": "orders",
"effective_from_lsn": 123450000
}
},
"payload": {
"before": { ... }, // Null for INSERT
"after": { ... }, // Null for DELETE
"changed_fields": ["status", "amount"] // For UPDATE
},
"ordering": {
"hlc_timestamp": "2024-01-15T10:30:00.123Z#5",
"global_sequence": 987654321
}
}
5. State Management & Recovery
Checkpointing
class CheckpointManager:
def __init__(self, storage_backend: StorageBackend):
self.storage = storage_backend
self.current_checkpoint = {}
def update_checkpoint(self, source_id: str, lsn: int,
tx_id: str, timestamp: datetime):
checkpoint = {
'source_id': source_id,
'lsn': lsn,
'tx_id': tx_id,
'timestamp': timestamp.isoformat(),
'updated_at': datetime.utcnow().isoformat()
}
self.storage.save(f"checkpoint/{source_id}", checkpoint)
self.current_checkpoint[source_id] = checkpoint
def get_checkpoint(self, source_id: str) -> Optional[Checkpoint]:
data = self.storage.load(f"checkpoint/{source_id}")
return Checkpoint.from_dict(data) if data else None
Exactly-Once Semantics
Delivery Guarantees:
- At-Least-Once: Default (with idempotent producers)
- Exactly-Once: Requires:
* Idempotent producer (Kafka)
* Transactional writes (only for same partition)
* Consumer offset management with schema registry
- Handling duplicates:
* Use (source_id, lsn) as deduplication ID
* Store processed LSNs in compacted topic
6. Configuration & Deployment
Bridge Configuration
bridge:
sources:
- id: postgres-main
type: postgresql
connection:
host: db.example.com
port: 5432
database: main
replication:
slot_name: cdc_bridge_slot
start_lsn: "0/16B6B0" # Optional, else from checkpoint
tables:
include: ["orders.*", "users"]
exclude: ["audit_log"]
destination:
type: kafka
bootstrap_servers: ["kafka1:9092", "kafka2:9092"]
topic_prefix: "cdc-"
replication_factor: 3
processing:
batch_size: 1000
max_batch_ms: 100
ordering_timeout_ms: 5000
schema_registry:
url: "http://schema-registry:8081"
compatibility: "BACKWARD"
reorg:
auto_detect: true
config_file: "reorg_mappings.yaml"
monitoring:
metrics_port: 9090
healthcheck_path: "/health"
Reorg Configuration File
reorg_mappings:
- from_table: "orders"
to_tables: ["order_headers", "order_lines"]
type: "SPLIT"
effective_date: "2024-01-01"
split_condition:
header_columns: ["order_id", "customer_id", "status"]
line_columns: ["line_id", "order_id", "product_id", "quantity"]
- from_tables: ["user_profiles", "user_settings"]
to_table: "users"
type: "MERGE"
join_key: "user_id"
7. Failure Handling & Monitoring
Error Handling Strategies
class ErrorHandler:
def __init__(self):
self.dlq_topic = "cdc-dlq"
self.retry_policy = {
'max_retries': 3,
'backoff_ms': [1000, 5000, 30000]
}
def handle_error(self, event: EnrichedEvent, error: Exception):
if self._is_retryable(error):
# Send to retry topic with delay
self.send_to_retry(event, error)
else:
# Send to dead letter queue
self.send_to_dlq(event, error)
def send_to_dlq(self, event: EnrichedEvent, error: Exception):
dlq_event = {
'original_event': event.to_dict(),
'error': str(error),
'error_type': type(error).__name__,
'timestamp': datetime.utcnow().isoformat()
}
self.kafka_producer.send(self.dlq_topic, dlq_event)
Key Metrics
Metrics to Monitor:
- cdc.events.total: Total events processed
- cdc.events.per_second: Throughput
- cdc.lag.seconds: Lag between source commit and CDC emission
- cdc.schema.changes: Schema evolution events
- cdc.reorgs.detected: Reorganization operations
- cdc.errors.total: Error count
- cdl.dlq.size: Dead letter queue size
- cdc.checkpoint.age: Seconds since last checkpoint
8. Consumer Compatibility
Schema Evolution Support for Consumers
// Consumer example with schema evolution handling
public class CDCConsumer {
private SchemaRegistry client;
private Map<String, Schema> schemaCache = new HashMap<>();
public void process(byte[] message) {
// 1. Extract schema ID from message
SchemaId schemaId = extractSchemaId(message);
// 2. Get schema (with caching)
Schema schema = schemaCache.computeIfAbsent(
schemaId,
id -> client.getSchema(id)
);
// 3. Deserialize with schema
GenericRecord record = new GenericDatumReader(schema)
.read(null, decoder);
// 4. Handle missing/renamed fields gracefully
Map<String, Object> data = new HashMap<>();
for (Field field : schema.getFields()) {
Object value = record.get(field.name());
if (value != null) {
data.put(field.name(), value);
}
}
// 5. Process business logic
processBusinessEvent(data);
}
}
9. Deployment Considerations
Scalability
- Partitioning Strategy: Hash by primary key for ordering
- Parallelism: One connector instance per source table/partition
- Backpressure: Use queue depth metrics to scale consumers
High Availability
HA Configuration:
- Connector instances: 3+ with leader election
- Kafka: Replication factor 3, min.insync.replicas=2
- Checkpoint storage: Distributed (ZooKeeper/etcd)
- Schema registry: Clustered mode
Security
Security:
- Encryption: TLS for all connections
- Authentication:
* DB: SSL certs + user/password
* Kafka: SASL/SCRAM
- Authorization: RBAC on topics
- Secrets: Vault integration
10. Testing Strategy
Test Scenarios
-
Ordering Tests
- Concurrent transactions across tables
- Multi-source ordering with HLC
- Transaction rollback handling
-
Schema Evolution Tests
- Add/drop/rename columns
- Type changes (safe and unsafe)
- DDL during high-traffic periods
-
Reorg Tests
- Table splits with ongoing writes
- Table merges with foreign keys
- Rename during transactions
-
Failure Tests
- Network partitions
- Schema registry outage
- Kafka broker failures
- Database failover
Summary
This CDC bridge design provides:
- Strong Ordering: Through LSN + HLC + transaction grouping
- Schema Evolution: Via schema registry with compatibility checks and rename tracking
- Reorg Handling: Automatic detection with logical→physical table mapping
- Resilience: Checkpointing, DLQ, retry policies
- Observability: Comprehensive metrics and health checks
- Consumer Compatibility: Graceful handling of schema changes
The key innovation is the logical table abstraction that hides physical reorganization from consumers while maintaining ordering guarantees through careful LSN tracking and schema evolution management.
Trade-offs Made:
- Slight latency increase for cross-source ordering (HLC sync)
- Increased metadata storage for reorg tracking
- Complexity in schema compatibility validation
- Need for coordinated deployments during major reorgs
This design assumes a single logical database as source. For multi-database scenarios, implement a global ordering service or use event-time ordering with bounded lateness.