You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
In TriggerRunner, avoid reading the set of finished subtriggers when no subtrigger ever finishes. #17961
For a trigger expression, TriggerRunner tracks which of the subexpressions have finished to track which subexpression is the currently active trigger that determines when output is permitted. For some triggers (such as the default trigger) this information is not needed. The reads and writes of this data can be elided.
Imported from Jira BEAM-30. Original Jira may contain additional context.
Reported by: kenn.
No I don't think anyone is working on it. It is a pretty niche issue that has been sitting here for a very very long time. But it probably still applies! It may not make any difference to a real-world pipeline, actually... but I must have filed it for some reason 😅 . Feel free to take a look if you like.
Hi @kennknowles, I've cloned the repo and traced this on current master (36fd8ac).
Problem TriggerStateMachineRunner.isFinishedSetNeeded() only skips the FINISHED_BITS state for DefaultTriggerStateMachine (the TODO next to it). Other trees whose bitset is always empty between calls still read that state on every element and every shouldFire.
What I found while tracing
Under Repeatedly.forever(...) with once-style children (AfterPane, AfterProcessingTime, AfterWatermark.pastEndOfWindow(), and AfterFirst/AfterAll of those), a child's bit is set and then cleared by resetTree() in the same onFire. onMerge only sets it if a merging window already had it set, so nothing is ever stored.
"The root never finishes" isn't enough on its own:
AfterWatermark with late firings never finishes, but the early child's bit records the early → late switch across calls.
AfterEach keeps earlier children's bits between firings.
flowchart TD
S["isFinishedSetNeeded()"] --> D{"root is DefaultTrigger?"}
D -- "yes" --> SKIP["skip FINISHED_BITS (as today)"]
D -- "no" --> W{"useNewWindowOptimization?"}
W -- "yes" --> NEED["read/write bitset (as today)"]
W -- "no" --> T{"can any node keep a bit set between calls?"}
T -- "no: Repeatedly over once-style triggers" --> SKIP
T -- "yes or unknown: OrFinally, AfterEach, late AfterWatermark" --> NEED
Loading
Proposed approach
Add a conservative recursive check in the runner (no public API change). It returns "not needed" only for the safe shapes above and "needed" for everything else.
Keep the current behaviour whenever useNewWindowOptimization is on.
In TriggerStateMachineRunnerTest, assert that Repeatedly.forever(AfterPane...) never touches FINISHED_BITS, and that AfterEach, orFinally and early/late AfterWatermark behave as before. Run ReduceFnRunnerTest as a regression check.
Does that rule match what you had in mind? I saw @Moemenmohamed24 asked about this in July. If they're not working on it, can I take this issue?
Activity
Moemenmohamed24 commentedon Jul 22, 2026
Hi ! @kennknowles Is anyone working on this?
kennknowles commentedon Jul 23, 2026
No I don't think anyone is working on it. It is a pretty niche issue that has been sitting here for a very very long time. But it probably still applies! It may not make any difference to a real-world pipeline, actually... but I must have filed it for some reason 😅 . Feel free to take a look if you like.
rokadepiyush49-rgb commentedon Nov 20, 2026
Hi @kennknowles, I've cloned the repo and traced this on current master (
36fd8ac).Problem
TriggerStateMachineRunner.isFinishedSetNeeded()only skips theFINISHED_BITSstate forDefaultTriggerStateMachine(the TODO next to it). Other trees whose bitset is always empty between calls still read that state on every element and everyshouldFire.What I found while tracing
Repeatedly.forever(...)with once-style children (AfterPane,AfterProcessingTime,AfterWatermark.pastEndOfWindow(), andAfterFirst/AfterAllof those), a child's bit is set and then cleared byresetTree()in the sameonFire.onMergeonly sets it if a merging window already had it set, so nothing is ever stored.AfterWatermarkwith late firings never finishes, but the early child's bit records the early → late switch across calls.AfterEachkeeps earlier children's bits between firings.isNew()uses this state to tell whether a window has been seen before whenuseNewWindowOptimizationis on. Skipping it for more triggers would quietly turn that optimisation off for them.flowchart TD S["isFinishedSetNeeded()"] --> D{"root is DefaultTrigger?"} D -- "yes" --> SKIP["skip FINISHED_BITS (as today)"] D -- "no" --> W{"useNewWindowOptimization?"} W -- "yes" --> NEED["read/write bitset (as today)"] W -- "no" --> T{"can any node keep a bit set between calls?"} T -- "no: Repeatedly over once-style triggers" --> SKIP T -- "yes or unknown: OrFinally, AfterEach, late AfterWatermark" --> NEEDProposed approach
useNewWindowOptimizationis on.TriggerStateMachineRunnerTest, assert thatRepeatedly.forever(AfterPane...)never touchesFINISHED_BITS, and thatAfterEach,orFinallyand early/lateAfterWatermarkbehave as before. RunReduceFnRunnerTestas a regression check.Does that rule match what you had in mind? I saw @Moemenmohamed24 asked about this in July. If they're not working on it, can I take this issue?
Anurag-S1ngh commentedon Nov 25, 2026
I saw @rokadepiyush49-rgb's earlier interest. There has been no assignment, follow-up, or PR, so I'll take this one.
.take-issue