LLM WikiAccess-protected knowledge portal

WIKI

BTS — Binlog Transfer System Quality Improvement (CDC)

AI Summary Purpose Capture durable knowledge about improving BTS Binlog Transfer System , the mechanism that ships database changes from the company's master DB to customer on premise DBs, and the move from file based Binlog Shipping toward

경로ai/wiki/projects/bts.md
카테고리Project
태그#binlog #bts #cdc #data-pipeline #infra #monitoring #mysql #project #projects #wiki

# BTS — Binlog Transfer System Quality Improvement (CDC)

AI Summary

Purpose:

mechanism that ships database changes from the company's master DB to customer on-premise DBs, and the move from file-based Binlog Shipping toward event-level Change Data Capture (CDC).

Key points:

data exceeds ~5MB), serves them over HTTP/FTP, and each customer Updater downloads and imports whole binlog files.

event forces re-download/re-import of the entire file; partial-failure position is hard to track; per-customer batch times differ; selective re-processing is impossible.

enabling selective retry and structured (JSON) output.

process, direct JSON file output, no Kafka needed) over Debezium+Kafka (more scalable but heavier), Canal (weak file output), and a raw mysqlbinlog parser.

Transaction_payload events) is NOT supported by Maxwell. This blocked Maxwell, so the team built a custom Python CDC Collector instead.

decompression, handles MySQL 8.4's removal of SHOW MASTER STATUS (falls back to SHOW BINARY LOG STATUS), supports resumable state, and emits JSONL with a per-binlog-file counter reset for full sequence integrity.

Relevant when:

selection, MySQL 8.4 compatibility, or the customer Updater.

Do not read full document unless:

retry/checkpoint design.

Linked documents:

Open Questions

not stated as fully shipped. Needs confirmation.

implemented or still proposed. Needs confirmation.

deployed.

Details

Problem

Binlog Shipping treats a binlog file as the unit of work. One file holds many events, so a single failing event blocks the whole file and forces a full re-download/re-import. There is no event-level checkpoint, so recovery position is unclear, and per-customer batch schedules add operational complexity.

CDC evaluation

CDC parses the binlog into structured per-row change events (insert/update/ delete) with metadata (schema, binlog position, timestamp), allowing event-level retry and offset-based checkpoints.

Tool comparison outcome:

JSON file output, low memory, simple ops. Best match for a file-based, pull-style delivery model rather than real-time streaming.

infra and higher operational complexity.

rejected.

rejected initially.

Decisive constraint (MySQL 8.4)

binlog_transaction_compression wraps events in ZSTD-compressed Transaction_payload events. Maxwell does not support this → Maxwell rejected. The team pivoted to a custom Python CDC Collector.

Custom Python CDC Collector

then recursively parse the internal WRITE/UPDATE/DELETE row events.

SHOW BINARY LOG STATUS. DB connection + position lookup is separated from stream init to bypass library internals.

binlog_position, in-transaction offset, and total_row_count. On restart, open the stream at saved (file, pos) and skip offset events to resume exactly.

number within the current binlog file (reset to 1 on file rotation); offset = event order within a transaction block (reset to 0 per transaction); file_sequence = output filename sequence (reset to 0 on file rotation). On MySQL rotation, flush+close the current output file and reset.

count, offset, type (upsert/delete), table, schema, ts, rows.

Customer-side design (proposed)

with Upsert (INSERT → REPLACE/ON DUPLICATE to fix INSERT-conflict issues).

Queue. A cdc_checkpoint table tracks source_file/source_offset with a UNIQUE key to prevent duplicate import and to resume from last offset.

Why this matters (durable lesson)

CDC tool selection must verify source-DB feature compatibility first: MySQL 8.4 ZSTD binlog compression silently breaks Maxwell. A thin custom collector on pymysqlreplication + zstandard is a viable fallback when off-the-shelf CDC tools lag the DB version.

연결 문서