{"record":{"id":"c81b241193d63c68","repo":"apache/cassandra","slug":"s-something-is-seriously-wrong-with-the-calculate","errorCode":null,"errorMessage":"%s something is seriously wrong with the calculated stream control message's size: %d bytes, type is %s","messagePattern":"(.+?) something is seriously wrong with the calculated stream control message's size: (.+?) bytes, type is (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/streaming/async/StreamingMultiplexedChannel.java","lineNumber":234,"sourceCode":"        if (message instanceof OutgoingStreamMessage)\n        {\n            if (session.isPreview())\n                throw new RuntimeException(\"Cannot send stream data messages for preview streaming sessions\");\n            if (logger.isDebugEnabled())\n                logger.debug(\"{} Sending {}\", createLogTag(session), message);\n\n            InetAddressAndPort connectTo = factory.supportsPreferredIp() ? SystemKeyspace.getPreferredIP(to) : to;\n            return fileTransferExecutor.submit(new FileStreamTask((OutgoingStreamMessage) message, connectTo));\n        }\n\n        try\n        {\n            Future<?> promise = channel.send(outSupplier -> {\n                // we anticipate that the control messages are rather small, so allocating a ByteBuf shouldn't  blow out of memory.\n                long messageSize = serializedSize(message, messagingVersion);\n                if (messageSize > 1 << 30)\n                {\n                    throw new IllegalStateException(format(\"%s something is seriously wrong with the calculated stream control message's size: %d bytes, type is %s\",\n                                                           createLogTag(session, controlChannel.id()), messageSize, message.type));\n                }\n                try (StreamingDataOutputPlus out = outSupplier.apply((int) messageSize))\n                {\n                    StreamMessage.serialize(message, out, messagingVersion, session);\n                }\n            });\n            promise.addListener(future -> onMessageComplete(future, message));\n            return promise;\n        }\n        catch (Exception e)\n        {\n            close();\n            session.onError(e);\n            return ImmediateFuture.failure(e);\n        }\n    }\n","sourceCodeStart":216,"sourceCodeEnd":252,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/streaming/async/StreamingMultiplexedChannel.java#L216-L252","documentation":"StreamingMultiplexedChannel.sendMessage guards the send path for stream control messages: before allocating a buffer it computes the serialized size of the control message and refuses to send anything larger than 1GB, since control messages are expected to be small. Throwing IllegalStateException here means the calculated serialized size is absurd, indicating a corrupted or pathological message or serialization bug rather than a normal streaming condition.","triggerScenarios":"Calling sendControlMessage -> sendMessage with a StreamMessage whose serialized size (computed via serializedSize(message, messagingVersion)) exceeds 1 << 30 bytes; typically caused by a message carrying a huge collection (e.g. a StreamSummary or PrepareMessage listing an enormous number of sessions/streams) or a bug in the serializer's size calculation.","commonSituations":"Streaming tens of thousands of tables/ranges in a single stream plan so the Prepare/Summary control message balloons past 1GB; version skew where messagingVersion-dependent size calculation disagrees with the peer; driver/internal bugs in StreamMessage.serialize size accounting.","solutions":["Reduce the size of the streaming plan: split large repairs/streaming operations into smaller batches so each control message stays well under 1GB","Verify both nodes run compatible Cassandra versions and messagingVersion so serializedSize calculations match on both sides","Inspect the message type logged to identify which control message (Prepare/Summary/etc.) is oversized and check its contents for pathological data (huge table counts, many ranges)","If reproducible with a normal-sized plan, file/inspect for a serializer bug in StreamMessage.serialize size accounting"],"exampleFix":"// before: one giant stream plan\nStorageService.instance.stream(hugeRangesPerTable);\n// after: chunk the requests into bounded batches\nfor (List<Range<Token>> batch : partition(ranges, MAX_RANGES_PER_PLAN))\n    StorageService.instance.stream(batch);","handlingStrategy":"validation","validationCode":"long size = serializedSize(message, messagingVersion);\nif (size > (1 << 30)) throw new IllegalArgumentException(\"stream control message too large: \" + size);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep stream plans small; partition large range/table sets into multiple sessions","Keep messaging versions aligned across the cluster so size calculations match","Log message type and size before sending large control messages in custom tooling"],"tags":["streaming","serialization","memory"],"backgroundTag":"value-out-of-range","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}