{"record":{"id":"ac67bade12cada34","repo":"apache/flink","slug":"window-window-is-not-in-in-flight-window-set-ac67ba","errorCode":null,"errorMessage":"Window {window} is not in in-flight window set.","messagePattern":"Window (.+?) is not in in-flight window set\\.","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"flink-datastream/src/main/java/org/apache/flink/datastream/impl/extension/window/operators/TwoOutputWindowProcessOperator.java","lineNumber":316,"sourceCode":"\n                                        // merge the merged state windows into the newly resulting\n                                        // state window\n                                        windowMergingState.mergeNamespaces(\n                                                stateWindowResult, mergedStateWindows);\n                                    }\n                                });\n\n                // drop if the window is already late\n                if (WindowUtils.isWindowLate(\n                        actualWindow, windowAssigner, internalTimerService, allowedLateness)) {\n                    mergingWindows.retireWindow(actualWindow);\n                    continue;\n                }\n                isSkippedElement = false;\n\n                W stateWindow = mergingWindows.getStateWindow(actualWindow);\n                if (stateWindow == null) {\n                    throw new IllegalStateException(\n                            \"Window \" + window + \" is not in in-flight window set.\");\n                }\n\n                windowState.setCurrentNamespace(stateWindow);\n                mainCollector.setTimestamp(window.maxTimestamp());\n                sideCollector.setTimestamp(window.maxTimestamp());\n                windowFunctionContext.setWindow(window);\n                windowProcessFunction.onRecord(\n                        element.getValue(),\n                        mainCollector,\n                        sideCollector,\n                        partitionedContext,\n                        windowFunctionContext);\n\n                triggerContext.setKey(key);\n                triggerContext.setWindow(actualWindow);\n\n                TriggerResult triggerResult = triggerContext.onElement(element);","sourceCodeStart":298,"sourceCodeEnd":334,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-datastream/src/main/java/org/apache/flink/datastream/impl/extension/window/operators/TwoOutputWindowProcessOperator.java#L298-L334","documentation":"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.","triggerScenarios":"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.","commonSituations":"Custom windows with equals/hashCode inconsistent with serialization; savepoint restore across assigner changes; exceptions from two-output window functions during merges; version skew.","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."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    env.execute(\"two-output-session-job\");\n} catch (Exception e) {\n    if (e instanceof IllegalStateException\n            && String.valueOf(e.getMessage()).contains(\"not in in-flight window set\")) {\n        haltWithDiagnostics(jobId, lastCheckpoint, e); // do not blind-restart\n    }\n    throw e;\n}","preventionTips":["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"],"tags":["flink","datastream-v2","windowing","session-windows","two-output","merging-window-set","state-consistency"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}