{"record":{"id":"3ad7f1b15b12f884","repo":"apache/flink","slug":"window-window-is-not-in-in-flight-window-set-3ad7f1","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/TwoInputNonBroadcastWindowProcessOperator.java","lineNumber":346,"sourceCode":"                                        // state window\n                                        leftWindowMergingState.mergeNamespaces(\n                                                stateWindowResult, mergedStateWindows);\n                                        rightWindowMergingState.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                leftWindowState.setCurrentNamespace(stateWindow);\n                collector.setTimestamp(window.maxTimestamp());\n                windowFunctionContext.setWindow(window);\n                windowProcessFunction.onRecord1(\n                        element.getValue(), collector, partitionedContext, windowFunctionContext);\n\n                triggerContext.setKey(key);\n                triggerContext.setWindow(actualWindow);\n\n                TriggerResult triggerResult =\n                        triggerContext.onElement(\n                                new StreamRecord<>(\n                                        TaggedUnion.one(element.getValue()),\n                                        element.getTimestamp()));\n","sourceCodeStart":328,"sourceCodeEnd":364,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-datastream/src/main/java/org/apache/flink/datastream/impl/extension/window/operators/TwoInputNonBroadcastWindowProcessOperator.java#L328-L364","documentation":"In TwoInputNonBroadcastWindowProcessOperator.onRecord1, after MergingWindowSet.addWindow(...) returns the post-merge representative window (actualWindow) and the late check passes, getStateWindow(actualWindow) must return the state window holding the contents. A null result violates the in-flight window set invariant: addWindow guaranteed a mapping that the set no longer contains. The message prints the originally assigned 'window' rather than 'actualWindow', so the named window can be misleading.","triggerScenarios":"getStateWindow(actualWindow) == null after addWindow returned actualWindow for a left-input record: a prior merge/callback threw after mutating state, the restored 'merging-window-set' state does not match the current window serializer or assigner (equals/hashCode mismatch), or an internal bug in the @Experimental two-input window extension.","commonSituations":"Custom window types with equals()/hashCode() inconsistent with the serializer; savepoints restored across changed session gaps/window classes; user exceptions on the merge path leaving partial updates; checkpoint compatibility across Flink versions.","solutions":["Look for an earlier exception in the same task's logs (user function, trigger, MergeFunction) and fix that root cause first.","Audit custom window types: equals()/hashCode() must agree with the window serializer used by the 'merging-window-set' state.","Never restore state produced under a different assigner configuration; start a new checkpoint chain when the window semantics change.","If no user code is involved, file a Flink JIRA with job graph, assigner, backend and checkpoint history instead of retrying the job."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    env.execute(\"two-input-session-job\");\n} catch (Exception e) {\n    if (e instanceof IllegalStateException\n            && String.valueOf(e.getMessage()).contains(\"not in in-flight window set\")) {\n        // invariant break after addWindow: alert with checkpoint id, halt restart loop\n        alertAndHalt(lastCheckpointId, e);\n    }\n    throw e;\n}","preventionTips":["Fix exceptions thrown from either input's window/merge path immediately","Keep window equals()/hashCode() aligned with the serializer","Verify savepoint compatibility before restoring two-input session jobs","Note the message names the pre-merge window; check the post-merge representative when debugging"],"tags":["flink","datastream-v2","windowing","session-windows","two-input","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"}