apache/cassandra · error · IOException
Corrupt value length %d encountered, as it exceeds the maxim
Error message
Corrupt value length %d encountered, as it exceeds the maximum of %d, which is set via max_value_size in cassandra.yaml
What it means
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.
Source
Thrown at src/java/org/apache/cassandra/db/marshal/AbstractType.java:664
public byte[] readArray(DataInputPlus in, int maxValueSize) throws IOException
{
return read(ByteArrayAccessor.instance, in, maxValueSize);
}
public <V> V read(ValueAccessor<V> accessor, DataInputPlus in, int maxValueSize) throws IOException
{
int length = valueLengthIfFixed;
if (length >= 0)
return accessor.read(in, length);
else
{
int l = in.readUnsignedVInt32();
if (l < 0)
throw new IOException("Corrupt (negative) value length encountered");
if (l > maxValueSize)
throw new IOException(String.format("Corrupt value length %d encountered, as it exceeds the maximum of %d, " +
"which is set via max_value_size in cassandra.yaml",
l, maxValueSize));
return accessor.read(in, l);
}
}
public void skipValue(DataInputPlus in) throws IOException
{
int length = valueLengthIfFixed;
if (length >= 0)
in.skipBytesFully(length);
else
ByteBufferUtil.skipWithVIntLength(in);
}
public final boolean referencesUserType(ByteBuffer name)
{View on GitHub (pinned to 88fd0f6a0e)
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.
Example fix
# cassandra.yaml — if large values are legitimate # before max_value_size: 256 # after (mb) max_value_size: 512
Defensive patterns
Strategy: validation
Validate before calling
int max = DatabaseDescriptor.getMaxValueSize();
if (declaredLength > max) throw new IllegalArgumentException("value length " + declaredLength + " exceeds max_value_size " + max); Try / catch
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; } Prevention
- 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.
When it happens
Trigger: read/readBuffer/readArray on a stream whose VInt length field decodes to a value larger than the configured maxValueSize.
Common situations: 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.
Understand the failure class
Background: payload too large / request exceeds maximum size: why libraries cap bytes and how to fix oversize payloads — this error's family across 50 libraries.
Related errors
- Corrupt flags value for clustering prefix (isStatic flag set
- Unable to deserialize payload for minimum_client_driver_vers
- Unable to deserialize minimum_client_driver_versions_disallo
- Corrupt (negative) value length encountered
- Corrupt clustering value length %d encountered, as it exceed
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/af0a63b7fbafe215.
Report an issue: GitHub.