MartijnVisser opened a new pull request, #29024:
URL: https://github.com/apache/flink/pull/29024

   ## What is the purpose of the change
   
   When a subpartition of `StatusWatermarkValve` reactivates after idleness and 
rejoins the aligned set, the min watermark across aligned subpartitions is not 
re-derived. This breaks the invariant that the aligned min equals the last 
output watermark, which two guards (`subpartitionStatus.watermark == 
lastOutputWatermark`) silently rely on, with two symptoms:
   
   1. The all-idle flush-to-max from FLINK-7728 is skipped when the last 
subpartition to become idle is unaligned (went idle, resumed, only partially 
caught up), making the final watermark dependent on the order in which inputs 
became idle — the exact defect FLINK-7728 was created to fix. This also 
diverges from `CombinedWatermarkStatus`, which flushes unconditionally since 
FLINK-38454.
   2. A subpartition that reactivates as the only aligned subpartition has its 
watermark stalled indefinitely, until an even larger watermark arrives on that 
subpartition — no all-idle transition involved.
   
   ## Brief change log
   
   - Re-derive (and possibly emit) the min watermark at the end of the 
idle→active branch, after the ACTIVE status is emitted so downstream inputs do 
not drop the watermark while they still consider the input idle
   - Flush the max watermark unconditionally when all subpartitions become idle 
(the flush helper already only emits when the max advances past the last output 
watermark, so monotonicity is unaffected)
   - Drop the equivalent guard on the partial-idle min re-derivation for the 
same reason
   - Document the invariants of the aligned-subpartition set on 
`alignedSubpartitionStatuses`
   
   ## Verifying this change
   
   This change added tests and can be verified as follows:
   
   - Added 
`testMultipleInputFlushMaxWatermarkOnceAllInputsBecomeIdleWithUnalignedLastChannel`,
 reproducing the order-dependent all-idle flush (fails on master: emits only 
`WatermarkStatus(IDLE)` instead of `Watermark(100)`)
   - Added 
`testWatermarkAdvancesWhenReactivatedChannelBecomesOnlyAlignedChannel` and 
`testRealignmentAfterResumeActiveEmitsNewMinWatermark`, reproducing the stalled 
watermark on realignment (fail on master: no watermark emitted)
   - All pre-existing tests in `StatusWatermarkValveTest` are unaffected; also 
verified green: `OneInputStreamTaskTest`, `TwoInputStreamTaskTest`, 
`WatermarkOutputMultiplexerTest`, `SourceOperatorSplitWatermarkAlignmentTest`
   - Each commit passes the valve test suite individually (red-green verified 
per commit)
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): no
     - The public API, i.e., is any changed class annotated with 
`@Public(Evolving)`: no
     - The serializers: no
     - The runtime per-record code paths (performance sensitive): no (only 
watermark-status transition paths; the added re-derivation is O(1), the 
unconditional flush is O(#subpartitions) once per all-idle transition, next to 
an existing O(#subpartitions) scan on the same path)
     - Anything that affects deployment or recovery: JobManager (and its 
components), Checkpointing, Kubernetes/Yarn, ZooKeeper: no
     - The S3 file system connector: no
   
   ## Documentation
   
     - Does this pull request introduce a new feature? no
     - If yes, how is the feature documented? not applicable
   
   Note on behavior: jobs that previously ended with a lower watermark 
depending on idle-arrival order will now deterministically receive the flushed 
max watermark (timers/windows in that range fire); a release note is proposed 
on the JIRA ticket.
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes (please specify the tool below)
   
   Generated-by: Claude Code (claude-fable-5)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to