You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "twalthr (via GitHub)" <gi...@apache.org> on 2025/09/30 08:29:01 UTC
[PR] [FLINK-38454][core] Fix inconsistent idle behavior between StatusWatermarkValve and CombinedWatermarkStatus [flink]
twalthr opened a new pull request, #27066:
URL: https://github.com/apache/flink/pull/27066
## What is the purpose of the change
Both StatusWatermarkValve and CombinedWatermarkStatus derive watermarks and deal with idle inputs (from input channel or input split respectively). However, cases where all inputs are marked as idle are handled differently. In both cases, the maximum watermark should be derived from all idle inputs.
If all splits are idle, we should flush all watermarks, which effectively means emitting the maximum watermark.
Otherwise, there could be a race condition between splits when idleness is triggered.
E.g., split 1 of 2 emits 5 and goes into idle, split 2 of 2 emits 4 and goes into idle. If split 2 is idle first, watermark 5 wins. If split 1 is idle first, watermark 4 wins. But if both are idle, we should conclude on 5.
## Brief change log
- Update CombinedWatermarkStatus and the idleness emission afterwards
## Verifying this change
This change is already covered by existing tests in WatermarkOutputMultiplexerTest.
Additional tests have been added:
- WatermarkOutputMultiplexerTest.whenAllImmediateOutputsBecomeIdleWatermarkAdvances
- WatermarkOutputMultiplexerTest.whenAllDeferredOutputsEmitAndIdleWatermarkAdvances
## 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): yes
- 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? JavaDocs
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-38454][core] Fix inconsistent idle behavior between StatusWatermarkValve and CombinedWatermarkStatus [flink]
Posted by "twalthr (via GitHub)" <gi...@apache.org>.
twalthr merged PR #27066:
URL: https://github.com/apache/flink/pull/27066
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-38454][core] Fix inconsistent idle behavior between StatusWatermarkValve and CombinedWatermarkStatus [flink]
Posted by "dawidwys (via GitHub)" <gi...@apache.org>.
dawidwys commented on code in PR #27066:
URL: https://github.com/apache/flink/pull/27066#discussion_r2390424481
##########
flink-core/src/main/java/org/apache/flink/api/common/eventtime/CombinedWatermarkStatus.java:
##########
@@ -57,34 +55,51 @@ public void add(PartialWatermark element) {
}
/**
- * Checks whether we need to update the combined watermark.
+ * Checks whether we need to update the combined watermark. It can update {@link #isIdle()}
+ * status.
*
- * <p><b>NOTE:</b>It can update {@link #isIdle()} status.
+ * <p><b>NOTE:</b>The logic here should be kept in sync with {@code StatusWatermarkValve}.
*
* @return true, if the combined watermark changed
*/
public boolean updateCombinedWatermark() {
- long minimumOverAllOutputs = Long.MAX_VALUE;
-
- // if we don't have any outputs minimumOverAllOutputs is not valid, it's still
- // at its initial Long.MAX_VALUE state and we must not emit that
+ // if we don't have any outputs, we should not emit
if (partialWatermarks.isEmpty()) {
return false;
}
+ long maximumOverAllOutputs = Long.MIN_VALUE;
+ long minimumOverAllActiveOutputs = Long.MAX_VALUE;
+
boolean allIdle = true;
for (PartialWatermark partialWatermark : partialWatermarks) {
+ final long watermark = partialWatermark.getWatermark();
+ maximumOverAllOutputs = Math.max(maximumOverAllOutputs, watermark);
if (!partialWatermark.isIdle()) {
- minimumOverAllOutputs =
- Math.min(minimumOverAllOutputs, partialWatermark.getWatermark());
+ minimumOverAllActiveOutputs = Math.min(minimumOverAllActiveOutputs, watermark);
allIdle = false;
}
}
this.idle = allIdle;
- if (!allIdle && minimumOverAllOutputs > combinedWatermark) {
- combinedWatermark = minimumOverAllOutputs;
+ final long combinedWatermark;
+ if (allIdle) {
+ // If all splits are idle, we should flush all watermarks, which effectively
+ // means emitting the maximum watermark.
Review Comment:
nit: is the comment correct? You emit a maximumOverAllOutputs, which is rarely the maximum watermark (Long.MAX_WATERMARK) or did you mean maximum watermark over all inputs?
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-38454][core] Fix inconsistent idle behavior between StatusWatermarkValve and CombinedWatermarkStatus [flink]
Posted by "flinkbot (via GitHub)" <gi...@apache.org>.
flinkbot commented on PR #27066:
URL: https://github.com/apache/flink/pull/27066#issuecomment-3350687446
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "c816a283802500a99899335c21e77da878a827a0",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "c816a283802500a99899335c21e77da878a827a0",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* c816a283802500a99899335c21e77da878a827a0 UNKNOWN
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run azure` re-run the last Azure build
</details>
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-38454][core] Fix inconsistent idle behavior between StatusWatermarkValve and CombinedWatermarkStatus [flink]
Posted by "twalthr (via GitHub)" <gi...@apache.org>.
twalthr commented on code in PR #27066:
URL: https://github.com/apache/flink/pull/27066#discussion_r2391274467
##########
flink-core/src/main/java/org/apache/flink/api/common/eventtime/CombinedWatermarkStatus.java:
##########
@@ -57,34 +55,51 @@ public void add(PartialWatermark element) {
}
/**
- * Checks whether we need to update the combined watermark.
+ * Checks whether we need to update the combined watermark. It can update {@link #isIdle()}
+ * status.
*
- * <p><b>NOTE:</b>It can update {@link #isIdle()} status.
+ * <p><b>NOTE:</b>The logic here should be kept in sync with {@code StatusWatermarkValve}.
*
* @return true, if the combined watermark changed
*/
public boolean updateCombinedWatermark() {
- long minimumOverAllOutputs = Long.MAX_VALUE;
-
- // if we don't have any outputs minimumOverAllOutputs is not valid, it's still
- // at its initial Long.MAX_VALUE state and we must not emit that
+ // if we don't have any outputs, we should not emit
if (partialWatermarks.isEmpty()) {
return false;
}
+ long maximumOverAllOutputs = Long.MIN_VALUE;
+ long minimumOverAllActiveOutputs = Long.MAX_VALUE;
+
boolean allIdle = true;
for (PartialWatermark partialWatermark : partialWatermarks) {
+ final long watermark = partialWatermark.getWatermark();
+ maximumOverAllOutputs = Math.max(maximumOverAllOutputs, watermark);
if (!partialWatermark.isIdle()) {
- minimumOverAllOutputs =
- Math.min(minimumOverAllOutputs, partialWatermark.getWatermark());
+ minimumOverAllActiveOutputs = Math.min(minimumOverAllActiveOutputs, watermark);
allIdle = false;
}
}
this.idle = allIdle;
- if (!allIdle && minimumOverAllOutputs > combinedWatermark) {
- combinedWatermark = minimumOverAllOutputs;
+ final long combinedWatermark;
+ if (allIdle) {
+ // If all splits are idle, we should flush all watermarks, which effectively
+ // means emitting the maximum watermark.
Review Comment:
I meant over all inputs, let me correct this.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org