{"record":{"id":"af0a63b7fbafe215","repo":"apache/cassandra","slug":"corrupt-value-length-d-encountered-as-it-exceeds","errorCode":null,"errorMessage":"Corrupt value length %d encountered, as it exceeds the maximum of %d, which is set via max_value_size in cassandra.yaml","messagePattern":"Corrupt value length (.+?) encountered, as it exceeds the maximum of (.+?), which is set via max_value_size in cassandra\\.yaml","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/db/marshal/AbstractType.java","lineNumber":664,"sourceCode":"    public byte[] readArray(DataInputPlus in, int maxValueSize) throws IOException\n    {\n        return read(ByteArrayAccessor.instance, in, maxValueSize);\n    }\n\n    public <V> V read(ValueAccessor<V> accessor, DataInputPlus in, int maxValueSize) throws IOException\n    {\n        int length = valueLengthIfFixed;\n\n        if (length >= 0)\n            return accessor.read(in, length);\n        else\n        {\n            int l = in.readUnsignedVInt32();\n            if (l < 0)\n                throw new IOException(\"Corrupt (negative) value length encountered\");\n\n            if (l > maxValueSize)\n                throw new IOException(String.format(\"Corrupt value length %d encountered, as it exceeds the maximum of %d, \" +\n                                                    \"which is set via max_value_size in cassandra.yaml\",\n                                                    l, maxValueSize));\n\n            return accessor.read(in, l);\n        }\n    }\n\n    public void skipValue(DataInputPlus in) throws IOException\n    {\n        int length = valueLengthIfFixed;\n        if (length >= 0)\n            in.skipBytesFully(length);\n        else\n            ByteBufferUtil.skipWithVIntLength(in);\n    }\n\n    public final boolean referencesUserType(ByteBuffer name)\n    {","sourceCodeStart":646,"sourceCodeEnd":682,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/marshal/AbstractType.java#L646-L682","documentation":"During AbstractType.read, a decoded value length exceeding maxValueSize (from max_value_size in cassandra.yaml, default 256MB) is rejected as corrupt with this IOException. It protects against OOM from bogus or malicious length headers.","triggerScenarios":"read/readBuffer/readArray on a stream whose VInt length field decodes to a value larger than the configured maxValueSize.","commonSituations":"Corrupted length bytes in SSTables/commitlog; operator lowered max_value_size while large legacy values exist on disk; streaming data written by a node with a larger max_value_size than the reader.","solutions":["Verify data integrity (nodetool scrub/verify) and repair from replicas; the length is likely corrupt.","If values are legitimately large, raise max_value_size in cassandra.yaml consistently across all nodes and restart.","Check that all nodes in the cluster use the same max_value_size before streaming."],"exampleFix":"# cassandra.yaml — if large values are legitimate\n# before\nmax_value_size: 256\n# after (mb)\nmax_value_size: 512","handlingStrategy":"validation","validationCode":"int max = DatabaseDescriptor.getMaxValueSize();\nif (declaredLength > max) throw new IllegalArgumentException(\"value length \" + declaredLength + \" exceeds max_value_size \" + max);","typeGuard":null,"tryCatchPattern":"catch (IOException e) { if (e.getMessage().contains(\"max_value_size\")) log.error(\"value exceeds max_value_size; check cassandra.yaml or data corruption\"); throw e; }","preventionTips":["Keep max_value_size identical on every node before streaming or repair.","Model row values to stay well under the configured limit.","Investigate large-length errors as likely corruption first (scrub/verify), config change second."],"tags":["io","deserialization","config","payload-size"],"backgroundTag":"payload-too-large","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}