apache/cassandra · error · IOException
Invalid compression dictionary kind: %s
Error message
Invalid compression dictionary kind: %s
What it means
CompressionDictionary.deserialize reads a dictionary from a stream: the first field is an ordinal indexing the Kind enum. If the ordinal is negative or beyond the number of known kinds, the stream is corrupted, written by an incompatible/newer version, or truncated, so an IOException is thrown rather than indexing out of bounds.
Source
Thrown at src/java/org/apache/cassandra/db/compression/CompressionDictionary.java:231
* @throws IOException on any I/O exception when reading from the file
*/
@Nullable
static CompressionDictionary deserialize(DataInput input, @Nullable CompressionDictionaryManager manager) throws IOException
{
int kindOrdinal;
try
{
kindOrdinal = input.readByte();
}
catch (EOFException eof)
{
// no dictionary
return null;
}
if (kindOrdinal < 0 || kindOrdinal >= Kind.values().length)
{
throw new IOException("Invalid compression dictionary kind: " + kindOrdinal);
}
Kind kind = Kind.values()[kindOrdinal];
long id = input.readLong();
DictId dictId = new DictId(kind, id);
if (manager != null)
{
CompressionDictionary dictionary = manager.get(dictId);
if (dictionary != null)
{
return dictionary;
}
}
int length = input.readInt();
byte[] dict = new byte[length];
input.readFully(dict);
int checksum = input.readInt();View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Verify the dictionary file/table data is intact and complete (check file sizes, re-transfer).
- Ensure the node version supports the dictionary kind that wrote the data; align cluster versions.
- Regenerate the dictionary (e.g. re-create zstd dictionary training) if the source is unrecoverable.
- Restore the affected SSTables/files from backup.
Example fix
null
Defensive patterns
Strategy: try-catch
Try / catch
try {
dict = CompressionDictionary.deserialize(input, manager);
} catch (IOException e) {
if (e.getMessage().startsWith("Invalid compression dictionary kind")) { retransferOrRegenerateDictionary(); }
else throw e;
} Prevention
- Keep cluster node versions aligned for zstd dictionary features
- Verify file integrity (checksums) when copying dictionary files between nodes
- Back up dictionary files and system tables before upgrades
When it happens
Trigger: Reading a serialized compression dictionary (dictionary file or system table blob) whose kind ordinal byte/int falls outside [0, Kind.values().length).
Common situations: Upgrading/downgrading between Cassandra versions with different Kind sets, corrupted SSTable or dictionary files, hand-edited or partially written files.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- %s compression dictionary is not created for dict id %s
- Dictionary length mismatch for %s dict id %d. Expected: %d,
- compressed_read_ahead_buffer_size must be at least 256KiB (s
- Not enough bytes to deserialize collection
- Corrupt flags value for clustering prefix (isStatic flag set
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/4841ef275fe58005.
Report an issue: GitHub.