[flink] Fix $binlog update pairing across log splits#2880
Draft
luoyuxia wants to merge 7 commits intoapache:release-0.9from
Draft
[flink] Fix $binlog update pairing across log splits#2880luoyuxia wants to merge 7 commits intoapache:release-0.9from
luoyuxia wants to merge 7 commits intoapache:release-0.9from
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves correctness of the Flink $binlog virtual table conversion by preventing UPDATE_BEFORE/UPDATE_AFTER pairing from being corrupted when records from multiple log splits are interleaved within the same source reader.
Changes:
- Add per-split buffering in
BinlogRowConverterand a split-awaretoBinlogRowData(record, splitId)overload. - Propagate split context to
BinlogDeserializationSchemaviaFlinkRecordEmitter(using a newSourceSplitState.splitId()accessor). - Add a unit test covering cross-split interleaving behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| fluss-flink/fluss-flink-common/src/test/java/org/apache/fluss/flink/utils/BinlogRowConverterTest.java | Adds a test ensuring interleaved splits don’t cross-pair update before/after images. |
| fluss-flink/fluss-flink-common/src/main/java/org/apache/fluss/flink/utils/BinlogRowConverter.java | Switches update buffering from a single slot to a per-split map and adds a split-aware conversion API. |
| fluss-flink/fluss-flink-common/src/main/java/org/apache/fluss/flink/source/split/SourceSplitState.java | Adds a splitId() accessor to avoid reconstructing split objects just to get the id. |
| fluss-flink/fluss-flink-common/src/main/java/org/apache/fluss/flink/source/emitter/FlinkRecordEmitter.java | Sets the current split id into the binlog deserializer before deserializing log records. |
| fluss-flink/fluss-flink-common/src/main/java/org/apache/fluss/flink/source/deserializer/BinlogDeserializationSchema.java | Tracks the current split id and routes records to the split-aware converter method. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...-flink/fluss-flink-common/src/main/java/org/apache/fluss/flink/utils/BinlogRowConverter.java
Show resolved
Hide resolved
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.
Purpose
Linked issue: close #2879
When one Flink
SourceReaderprocesses records from multiple log splits,$binlogcan interleave
UPDATE_BEFORE/UPDATE_AFTERrecords from different splits.The previous implementation kept only one global pending
UPDATE_BEFORErecord,which could be overwritten by another split and then fail with:
Brief change log
UPDATE_BEFOREstate per split instead of using one global buffer;$binlog;UPDATE_BEFOREandUPDATE_AFTERonly within the same split;BinlogRowConverterTest.Tests
BinlogRowConverterTest#testCrossSplitInterleavingDoesNotCorruptAlso verify in production env
API and Format
No API or storage format changes.
Documentation
No.