Skip to content

support for binlog compressed payload (zstd) — streaming refactor#178

Closed
alexpacio wants to merge 1 commit into
osheroff:masterfrom
alexpacio:mysql-binlog-zstd-compression-refactor
Closed

support for binlog compressed payload (zstd) — streaming refactor#178
alexpacio wants to merge 1 commit into
osheroff:masterfrom
alexpacio:mysql-binlog-zstd-compression-refactor

Conversation

@alexpacio

Copy link
Copy Markdown

Refactor of #177 with a cleaner structure (supersedes it).

Transparently unpacks TRANSACTION_PAYLOAD events (ZSTD / NONE) and re-emits their
inner events as ordinary top-level events, so consumers keep seeing QUERY,
TABLE_MAP, row and commit events. Decompression is streamed/iterated with bounded
memory, so a transaction whose compressed or uncompressed image exceeds the 2GB
byte[] limit (or spans 16MB packets) is handled.

What changed vs #177

The per-payload streaming state machine no longer lives inline in EventDeserializer.
It moved into a dedicated TransactionPayloadEventBuffer held by EventDeserializer:
nextEvent() simply drains the buffer (hasPending() / next()) before reading the
stream, and hands a TRANSACTION_PAYLOAD off via open(...). This shrank
EventDeserializer's diff vs master from +211 to +38 lines.

Also: a custom TRANSACTION_PAYLOAD deserializer now falls back to whole-payload
materialization (previously it threw).

Tests

Contract + unit tests pass, including the end-to-end BinaryLogFileReaderIntegrationTest
decoding the real mysql-bin.compressed resource (5 → 8 top-level events, no
TRANSACTION_PAYLOAD leaking through), no-prefetch streaming, restamped inner-event
coordinates, >2GB payload handling, and cross-packet reads. The MySQL-backed
integration tests need a live server to run.

🤖 Generated with Claude Code

…oadEventBuffer

Transparently unpacks zstd/none-compressed TRANSACTION_PAYLOAD events, re-emitting
their inner events as ordinary top-level events. Decompression is streamed/iterated
with bounded memory, so transactions whose compressed or uncompressed image exceeds
the 2GB byte[] limit (or spans 16MB packets) are handled.

The per-payload streaming state machine now lives in a dedicated
TransactionPayloadEventBuffer held by EventDeserializer, instead of inline in
EventDeserializer (nextEvent simply drains the buffer before reading the stream).
Custom TRANSACTION_PAYLOAD deserializers fall back to whole-payload materialization.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@alexpacio alexpacio force-pushed the mysql-binlog-zstd-compression-refactor branch from bf8af64 to df73a95 Compare June 15, 2026 10:32
@alexpacio

Copy link
Copy Markdown
Author

@osheroff i've refactored it using claude in a dedicated single commit and in a separate branch based on your last suggestion. However I can't go touching manually the code more than that as I am definitely not able to handle the code manually, I'm not a java developer.

@osheroff

osheroff commented Jun 15, 2026 via email

Copy link
Copy Markdown
Owner

@alexpacio alexpacio closed this Jun 16, 2026
@alexpacio

Copy link
Copy Markdown
Author

Superseeded by #179

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants