feat: Add Adaptive Kafka watermark generator#346
Open
ferenc-csaky wants to merge 3 commits into
Open
Conversation
f5dd621 to
0c3a726
Compare
ferenc-csaky
commented
Jun 1, 2026
95f82a6 to
7125130
Compare
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.
Summary
Adds adaptive Kafka source watermarks for
SOURCE_WATERMARK()and introduces opt-in idle watermark advancement for sparse Kafka streams.The adaptive source watermark strategy estimates out-of-orderness from observed Kafka record timestamps and emits source watermarks once enough records have been observed. Idle advancement is disabled by default and can be enabled explicitly for sources where it is safe to advance event time during periods with no records.
Changes
Added adaptive source-watermark configuration:
scan.source-watermark.min-recordsscan.source-watermark.min-out-of-ordernessscan.source-watermark.max-out-of-ordernessscan.source-watermark.out-of-orderness-quantileAdded opt-in idle source-watermark advancement:
scan.source-watermark.idle-advance-timeoutscan.source-watermark.idle-advance-safety-marginscan.source-watermark.idle-advance-broker-check-timeoutscan.source-watermark.idle-advance-broker-check-ttlIdle advancement remains disabled by default.
Idle advancement only proceeds when the Kafka readiness check confirms all explicit source topics use
LogAppendTime.Broker/topic readiness checks fail on errors, missing configs, topic-pattern sources, empty topic lists, or non-
LogAppendTimetopics.Readiness checks are cached for
10 sby default to avoid checking Kafka every watermark period.Reuses one lazy transient Kafka
AdminClientper source checker/subtask to avoid repeated cold AdminClient bootstrap overhead.Applies Flink
withIdleness(...)only when idle advancement is disabled. When idle advancement is enabled, the source watermark generator must remain active so it can emit wall-clock-derived watermarks.Exposes source-watermark options for both:
kafka-safeupsert-kafka-safeAdded focused unit test coverage for:
Added Kafka source-watermark integration test coverage for:
Safety Notes
Idle advancement is intentionally opt-in because advancing event time during source silence can mark later bursty traffic as late.
When enabled, idle advancement emits conservative wall-clock-derived watermarks using:
The final -1 preserves Flink’s exclusive watermark boundary so records exactly on the boundary remain on time.
Validation
Passed: