fix: Backport FLINK-40093 patch so paused idle source splits resume - #388
Merged
Conversation
Signed-off-by: Marvin Froeder <marvin@datasqrl.com>
ferenc-csaky
approved these changes
Aug 26, 2026
ferenc-csaky
enabled auto-merge (squash)
August 26, 2026 12:33
ferenc-csaky
added a commit
that referenced
this pull request
Aug 26, 2026
…388) Co-authored-by: Ferenc Csaky <ferenc@datasqrl.com>
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.
Problem
FLINK-40093 is a race between watermark alignment and source idleness detection. When a split is paused by alignment,
pauseOrResumeSplitsalso suspends its idleness timer — but with a low idle timeout and low allowed watermark drift, the split can be marked idle before that happens. From then on:The split has records and never emits them again.
The fix is released in Flink 2.2.2 / 2.3.1 / 2.4.0. We pin
flink.versionto2.3.0and 2.3.1 is not out yet.Change
Vendor the two patched
flink-runtimeclasses intoflink-sql-runner, following the existingAvroDeserializationSchemaprecedent:org/apache/flink/streaming/api/operators/SourceOperator.java— thecurrentlyIdleSplitscheck moves inside the "watermark too far ahead" branch, so idle splits are still skipped when pausing (preserving their idle status) but can be resumed. They stay idle until they emit their next record.org/apache/flink/runtime/metrics/groups/InternalSourceSplitMetricGroup.java— the paused/idle race is benign now, so theWARNbecomesINFO.Both files are byte-identical to upstream commit
2a2d3590onrelease-2.3(the backport of apache/flink#28689). The 2.3.0 versions they replace are in turn byte-identical to that commit's parent, so there is no local merge to carry — the git blob hashes match upstream exactly, and spotless leaves them untouched (**/org/apache/flink/**is already routed to the AOSP + Flink-import-order config and excluded from the license plugin).flink-runtimeis added as aprovideddependency to compile them.providedalso wins nearest-definition over any transitivecompilescope, so upstreamflink-runtimeclasses are not bundled into the uber jar — verified thatorg/apache/flink/streaming/api/operators/andorg/apache/flink/runtime/metrics/groups/contain only our classes.Why this takes effect
Flink's
constructFlinkClassPathforcesflink-dist*.jarto the end of the classpath; everything else in/opt/flink/libcomes first.sql-runner.uber.jaris already there, so these classes shadow the unpatched originals. Confirmed on the built image:Guard test
SourceOperatorPatchTestasserts two things:CliRunner, i.e. shadowing is intact — this is what breaks if the dependency scope or shade config regresses;EnvironmentInformation.getVersion()is still2.3.0, so the build fails on the version bump with instructions to delete the patch.Behavioural correctness of the race fix rides on upstream's
SourceOperatorSplitWatermarkAlignmentTest#testPausedIdleSplitsCanBeResumedByAlignmentCheck, which is not vendored here.Removal
On the bump to Flink 2.3.1+: delete the two vendored sources, their
package-info.javafiles,SourceOperatorPatchTest, and theflink-runtimeprovided dependency. The version assertion fails the build on that bump, so it cannot be silently forgotten.Verification
mvn test— full reactor green.mvn install -Pfast— uber jar and image build; patched classes present, no upstream collisions in those packages.Not covered: an end-to-end reproduction of the original hang against the real workload.