{"record":{"id":"4d14e901f79a726b","repo":"apache/flink","slug":"window-window-is-not-in-in-flight-window-set-4d14e9","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/OneInputWindowProcessOperator.java","lineNumber":307,"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                outputCollector.setTimestamp(window.maxTimestamp());\n                windowFunctionContext.setWindow(window);\n                windowProcessFunction.onRecord(\n                        element.getValue(),\n                        outputCollector,\n                        partitionedContext,\n                        windowFunctionContext);\n\n                triggerContext.setKey(key);\n                triggerContext.setWindow(actualWindow);\n\n                TriggerResult triggerResult = triggerContext.onElement(element);\n\n                if (triggerResult.isFire()) {","sourceCodeStart":289,"sourceCodeEnd":325,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-datastream/src/main/java/org/apache/flink/datastream/impl/extension/window/operators/OneInputWindowProcessOperator.java#L289-L325","documentation":"After MergingWindowSet.addWindow(...) returns the post-merge representative window (actualWindow) and the lateness check passes, OneInputWindowProcessOperator looks up the state window holding that window's contents via getStateWindow(actualWindow). A null result means the in-flight window set has no mapping for a window that addWindow just returned - an internal invariant violation indicating inconsistent 'merging-window-set' state. Note the message prints the originally assigned 'window' while the lookup used 'actualWindow', so the reported window can be misleading.","triggerScenarios":"getStateWindow(actualWindow) returns null after addWindow promised a mapping. Reached when a previous merge callback or user function threw after mutating state (half-applied update), when the restored 'merging-window-set' state does not match the current assigner/window serializer (equals/hashCode mismatch), or via bugs in the @Experimental window extension itself.","commonSituations":"Custom window types whose equals()/hashCode() disagree with the window serializer so map lookups miss; restoring a savepoint taken with a different session gap or window class; exceptions from user code near the merge path leaving partial updates; Flink version skew between checkpoint producer and consumer.","solutions":["Check the task logs for an earlier exception (user WindowProcessFunction, trigger, MergeFunction) - the half-applied state update is the root cause; fix that first.","If the window type is custom, verify its equals() and hashCode() are consistent with the window serializer used for the 'merging-window-set' state.","Do not restore state taken with a different window assigner configuration (changed session gap/size or window class); start a fresh checkpoint chain instead.","Otherwise capture job graph, assigner, backend and checkpoint history and file a Flink JIRA; do not blind-retry as restart loops will re-hit the same inconsistent state."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// the throw happens inside the task; surface it with context instead of blind restarts\ntry {\n    env.execute(\"session-job\");\n} catch (IllegalStateException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"not in in-flight window set\")) {\n        // invariant break: capture job id + last checkpoint, alert, and stop\n        throw new IllegalStateException(\"window set inconsistent - see checkpoint \" + lastCpId, e);\n    }\n    throw e;\n}","preventionTips":["Treat any exception from window/merge user code as fatal for state consistency - fix it before the window set desyncs","Keep window equals()/hashCode() consistent with the window serializer","Never restore savepoints across assigner changes; start a new checkpoint chain","Watch for this message during restore tests; it indicates corrupted in-flight window state"],"tags":["flink","datastream-v2","windowing","session-windows","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"}