{"record":{"id":"2bb5e62c0db059c2","repo":"apache/cassandra","slug":"unknown-stream-session-s-d","errorCode":null,"errorMessage":"unknown stream session: %s - %d","messagePattern":"unknown stream session: (.+?) - (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/streaming/messages/IncomingStreamMessage.java","lineNumber":41,"sourceCode":"import org.apache.cassandra.db.ColumnFamilyStore;\nimport org.apache.cassandra.io.util.DataInputPlus;\nimport org.apache.cassandra.streaming.IncomingStream;\nimport org.apache.cassandra.streaming.StreamManager;\nimport org.apache.cassandra.streaming.StreamReceiveException;\nimport org.apache.cassandra.streaming.StreamSession;\nimport org.apache.cassandra.streaming.StreamingChannel;\nimport org.apache.cassandra.streaming.StreamingDataOutputPlus;\n\npublic class IncomingStreamMessage extends StreamMessage\n{\n    public static Serializer<IncomingStreamMessage> serializer = new Serializer<IncomingStreamMessage>()\n    {\n        public IncomingStreamMessage deserialize(DataInputPlus input, int version) throws IOException\n        {\n            StreamMessageHeader header = StreamMessageHeader.serializer.deserialize(input, version);\n            StreamSession session = StreamManager.instance.findSession(header.sender, header.planId, header.sessionIndex, header.sendByFollower);\n            if (session == null)\n                throw new IllegalStateException(String.format(\"unknown stream session: %s - %d\", header.planId, header.sessionIndex));\n            ColumnFamilyStore cfs = ColumnFamilyStore.getIfExists(header.tableId);\n            if (cfs == null)\n                throw new StreamReceiveException(session, \"CF \" + header.tableId + \" was dropped during streaming\");\n\n            try\n            {\n                IncomingStream incomingData = cfs.getStreamManager().prepareIncomingStream(session, header);\n                incomingData.read(input, version);\n\n                return new IncomingStreamMessage(incomingData, header);\n            }\n            catch (Throwable t)\n            {\n                if (t instanceof StreamReceiveException)\n                    throw (StreamReceiveException) t;\n                // make sure to wrap so the caller always has access to the session to call onError\n                throw new StreamReceiveException(session, t);\n            }","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/streaming/messages/IncomingStreamMessage.java#L23-L59","documentation":"When deserializing an incoming IncomingStreamMessage, the receiver looks up the stream session identified by the header's planId/sessionIndex via StreamManager.instance.findSession. If no session matches, it throws IllegalStateException because streaming data arrived for a session this node does not know about; the incoming bytes cannot be attributed to any live transfer.","triggerScenarios":"A peer sends stream data referencing a planId/sessionIndex that was already finished, failed, cancelled, or never registered on this node — e.g. message arrives after the local session timed out or was aborted, or the node restarted mid-stream.","commonSituations":"Long-running streaming exceeding timeouts so the receiver's session is dropped while sender keeps sending; node restart during streaming; orphaned sender retries after a failed stream session; mismatched cluster state after bootstrap/decommission interruption.","solutions":["Re-initiate streaming from the sender so a new session/planId is negotiated (e.g. re-run repair or nodetool rebuild)","Check both nodes' logs for the earlier session failure/timeout that removed the session and fix that root cause (timeouts, dropped sessions, GC pauses)","Ensure cluster clocks and stream_manager settings are consistent; verify no node restart occurred mid-stream","If streaming persistently fails, run nodetool cleanup/repair after fixing connectivity and retry the operation"],"exampleFix":"// after 'unknown stream session' during repair\nnodetool repair -pr <keyspace> <table>   // restart the operation; a fresh session/planId is created","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { deliverStream(header, input); }\ncatch (IllegalStateException e) {\n    if (e.getMessage().startsWith(\"unknown stream session\")) {\n        logger.warn(\"stale stream data for {}, asking peer to resend\", header.planId);\n        requestStreamRestart(header.planId);\n    } else throw e;\n}","preventionTips":["Avoid restarting nodes mid-stream; check nodetool netstats before maintenance","Keep streaming timeouts generous for large transfers","After any stream failure, always re-run the operation to create a fresh session rather than pushing more data","Monitor for session timeouts in logs during repairs/bootstraps"],"tags":["streaming","session","deserialization"],"backgroundTag":"record-not-found","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}