[FLINK-39645][connector-base] Preserve restored HybridSource splits during snapshot#28191
Open
YuanHanzhong wants to merge 2 commits into
Open
Conversation
spuru9
reviewed
May 18, 2026
| assertAndClearSourceReaderFinishedEvent(readerContext, -1); | ||
| reader.handleSourceEvents(new SwitchSourceEvent(0, source, false)); | ||
|
|
||
| MockSourceSplit mockSplit = new MockSourceSplit(0, 0, 2147483647); |
Contributor
There was a problem hiding this comment.
nit: Use Integer.MAX_VALUE rather than the magic literal 2147483647
Contributor
Author
There was a problem hiding this comment.
Good catch, thanks. I switched this to Integer.MAX_VALUE and reran the focused HybridSourceReader test:
./mvnw -pl flink-connectors/flink-connector-base -DskipITs -Dtest=HybridSourceReaderTest#testReaderRecoverySnapshotBeforeSwitchSourceEvent -Dsurefire.failIfNoSpecifiedTests=false test
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.
What is the purpose of the change
HybridSourceReadercan be checkpointed during recovery after restoredHybridSourceSplitinstances were added back, but before theSwitchSourceEventcreates the underlying reader. In that windowcurrentReaderis stillnull, andsnapshotState()previously snapshotted an empty list. A second failure from that checkpoint would then lose the recovered splits.This keeps the already-restored hybrid splits in the checkpoint state until the source switch hands them to the underlying reader.
Brief change log
HybridSourceSplitstate before the recoverySwitchSourceEvent.restoredSplitswhensnapshotState()runs before a current reader exists.Verifying this change
./mvnw -pl flink-connectors/flink-connector-base -DskipITs -Dtest=HybridSourceReaderTest#testReaderRecoverySnapshotBeforeSwitchSourceEvent -Dsurefire.failIfNoSpecifiedTests=false test./mvnw -pl flink-connectors/flink-connector-base -DskipITs -Dtest=HybridSourceReaderTest -Dsurefire.failIfNoSpecifiedTests=false test./mvnw -pl flink-connectors/flink-connector-base -DskipITs testgit diff --check