apache/flink · error · IllegalStateException
Window {window} is not in in-flight window set.
Error message
Window {window} is not in in-flight window set. What it means
In TwoOutputWindowProcessOperator, after addWindow returns the post-merge representative window (actualWindow), getStateWindow(actualWindow) must yield the state window holding its contents; null means the in-flight window set is inconsistent with addWindow's contract and IllegalStateException is thrown. As elsewhere, the message reports the originally assigned 'window', not the actualWindow used in the failed lookup.
Source
Thrown at flink-datastream/src/main/java/org/apache/flink/datastream/impl/extension/window/operators/TwoOutputWindowProcessOperator.java:316
// merge the merged state windows into the newly resulting
// state window
windowMergingState.mergeNamespaces(
stateWindowResult, mergedStateWindows);
}
});
// drop if the window is already late
if (WindowUtils.isWindowLate(
actualWindow, windowAssigner, internalTimerService, allowedLateness)) {
mergingWindows.retireWindow(actualWindow);
continue;
}
isSkippedElement = false;
W stateWindow = mergingWindows.getStateWindow(actualWindow);
if (stateWindow == null) {
throw new IllegalStateException(
"Window " + window + " is not in in-flight window set.");
}
windowState.setCurrentNamespace(stateWindow);
mainCollector.setTimestamp(window.maxTimestamp());
sideCollector.setTimestamp(window.maxTimestamp());
windowFunctionContext.setWindow(window);
windowProcessFunction.onRecord(
element.getValue(),
mainCollector,
sideCollector,
partitionedContext,
windowFunctionContext);
triggerContext.setKey(key);
triggerContext.setWindow(actualWindow);
TriggerResult triggerResult = triggerContext.onElement(element);View on GitHub (pinned to 2f3c205e92)
Solutions
- Fix any earlier exception in the same task logs first.
- Audit custom window equals()/hashCode() against the window serializer.
- Use a fresh checkpoint chain after changing assigner/window semantics.
- Report invariant breaks without user-code involvement as Flink bugs with full context.
Defensive patterns
Strategy: try-catch
Try / catch
try {
env.execute("two-output-session-job");
} catch (Exception e) {
if (e instanceof IllegalStateException
&& String.valueOf(e.getMessage()).contains("not in in-flight window set")) {
haltWithDiagnostics(jobId, lastCheckpoint, e); // do not blind-restart
}
throw e;
} Prevention
- Treat user-function exceptions in two-output window jobs as state-corrupting
- Custom windows: keep equals()/hashCode() serializer-consistent
- Fresh checkpoint chain after any assigner change
- Note the misleading message: it prints the assigned window, lookup used actualWindow
When it happens
Trigger: A record's session merge completes but the 'merging-window-set' has no mapping for the returned window: half-applied state from an earlier exception, restore-state mismatch with the window serializer/assigner, or an extension bug.
Common situations: Custom windows with equals/hashCode inconsistent with serialization; savepoint restore across assigner changes; exceptions from two-output window functions during merges; version skew.
Related errors
- Window {window} is not in in-flight window set.
- Window {window} is not in in-flight window set.
- Window {window} is not in in-flight window set.
- The window uses a merging assigner, but the window state is
- The end timestamp of an event-time window cannot become earl
AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14).
Data as JSON: /api/errors/ac67bade12cada34.
Report an issue: GitHub.