apache/flink · error · IllegalStateException
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.
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 is not in in-flight window set.
- Window is not in in-flight window set.
- Window is not in in-flight window set.
- The end timestamp of a processing-time window cannot become…
- The end timestamp of an event-time window cannot become…
AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14).
Data as JSON: /api/errors/ac67bade12cada34.
Report an issue: GitHub.
Appendix: 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)