Skip to content

[BP-1.20][FLINK-39481][task] Execute deferrable mails when finishing an operator#28650

Merged
MartijnVisser merged 2 commits into
apache:release-1.20from
MartijnVisser:FLINK-39481-1.20
Jul 6, 2026
Merged

[BP-1.20][FLINK-39481][task] Execute deferrable mails when finishing an operator#28650
MartijnVisser merged 2 commits into
apache:release-1.20from
MartijnVisser:FLINK-39481-1.20

Conversation

@MartijnVisser

Copy link
Copy Markdown
Contributor

What is the purpose of the change

Backport of #28608 to release-1.20.

An interrupted timer-firing chain defers its continuation (and the downstream watermark emission) to a deferrable mail. The operator-finish drain skipped deferrable mails, so EndOfData could overtake the deferred watermark and downstream operators never received it, losing the state of windows that only fire on it (FLINK-39481, observed as WindowDistinctAggregateITCase exactly-once data loss after restore).

The fix executes deferrable mails when finishing an operator.

Brief change log

Cherry-pick of 83055ae and bbc688c from master. The production fix applied cleanly (on release-1.20 the task/mailbox classes live under flink-streaming-java, and the master-only urgent-mails context was dropped from the TaskMailboxImpl hunks).

The new test needed a port to the release-1.20 API: there is no useInterruptibleTimers hook and no execution.checkpointing.unaligned.interruptible-timers.enabled option on this branch; interruptible timers are operator-opt-in. The test operator therefore follows the branch-native pattern of the neighboring operator in the same test class (implements YieldingOperator, wires a MailboxWatermarkProcessor in open()/processWatermark), and the 2.x-only config lines are dropped. The ported test still exercises the fixed path: the release-1.20 MailboxWatermarkProcessor submits its watermark continuation with MailOptions.deferrable(), which is exactly the mail the fix now drains at operator finish.

Verifying this change

StreamOperatorWrapperTest, MailboxExecutorImplTest and UnalignedCheckpointsInterruptibleTimersTest (including the new testDeferredWatermarkIsEmittedBeforeEndOfData, the red-green test for this fix) pass on this branch. WindowDistinctAggregateStressITCase is included in the cherry-pick and is validated by CI.

Does this pull request potentially affect one of the following parts:

Same as #28608: no dependencies, no public API, no serializers, no per-record code paths; touches the operator-finish path of the task lifecycle.

Documentation

  • Does this pull request introduce a new feature? no

Was generative AI tooling used to co-author this PR?
  • Yes (Claude Fable 5)

Generated-by: Claude Fable 5

Since FLINK-35528 the continuation mail of an interrupted timer-firing chain
is deferrable and hidden from tryYield(). The finish drain in
StreamOperatorWrapper therefore skipped it, so a task reaching end of input
mid-firing forwarded EndOfData before the pending watermark, and downstream
operators discarded the state of windows that only fire on that watermark.
Restore the pre-FLINK-35528 behaviour by draining with a new yield variant
that matches deferrable mails by their original priority, used only in that
place.

Generated-by: Claude Code (Fable 5)
(cherry picked from commit 83055ae)
… of input

Exercises the full SQL pipeline (two-phase split-distinct window aggregation
on RocksDB) under backpressure with the configuration in which all CI
failures of WindowDistinctAggregateITCase occurred, comparing repeated
checkpoint/failure/restore/end-of-input rounds against a golden run within a
fixed time budget. Without the FLINK-39481 fix this loses the trailing
window family in roughly one of three executions.

Generated-by: Claude Code (Fable 5)
(cherry picked from commit bbc688c)
@flinkbot

flinkbot commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run azure re-run the last Azure build

@MartijnVisser MartijnVisser merged commit 6e98363 into apache:release-1.20 Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants