apache/cassandra · error · InvalidRequestException
Truncation is not supported by table %s
Error message
Truncation is not supported by table %s
What it means
AbstractLazyVirtualTable.truncate rejects TRUNCATE statements because lazily-computed virtual tables have no persisted data to remove. Throwing InvalidRequestException makes the read-only contract explicit instead of silently no-op'ing the TRUNCATE.
Source
Thrown at src/java/org/apache/cassandra/db/virtual/AbstractLazyVirtualTable.java:780
catch (InternalTimeoutException ignore)
{
if (onTimeout != OnTimeout.BEST_EFFORT || collector.isEmpty())
throw new ReadTimeoutException(ONE, 0, 1, false);
ClientWarn.instance.warn("Ran out of time. Returning best effort.");
}
return collector.finish();
}
@Override
public void apply(PartitionUpdate update)
{
throw new InvalidRequestException("Modification is not supported by table " + metadata);
}
@Override
public void truncate()
{
throw new InvalidRequestException("Truncation is not supported by table " + metadata);
}
@Override
public String toString()
{
return metadata().toString();
}
static Object[] composePartitionKeys(DecoratedKey decoratedKey, TableMetadata metadata)
{
if (metadata.partitionKeyColumns().size() == 1)
return new Object[] { metadata.partitionKeyType.compose(decoratedKey.getKey()) };
ByteBuffer[] split = ((CompositeType)metadata.partitionKeyType).split(decoratedKey.getKey());
Object[] result = new Object[split.length];
for (int i = 0 ; i < split.length ; ++i)
result[i] = metadata.partitionKeyColumns().get(i).type.compose(split[i]);
return result;View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Remove TRUNCATE of virtual tables from scripts/harnesses — their contents are derived from live JVM state
- Reset the underlying runtime state via nodetool or configuration instead
- If the table is truly mutable, it must be an AbstractMutableLazyVirtualTable-backed table; verify which implementation backs the target table
Example fix
// before TRUNCATE system_views.threads; // after // virtual tables cannot be truncated; skip tables where // metadata().isVirtual() is true in cleanup code
Defensive patterns
Strategy: validation
Validate before calling
if (metadata.isVirtual()) throw new UnsupportedOperationException("cannot truncate virtual table"); Try / catch
try { session.execute("TRUNCATE " + table); } catch (InvalidRequestException e) { if (e.getMessage().startsWith("Truncation is not supported")) skipTable(table); else throw e; } Prevention
- Exclude virtual tables from truncate/reset lists in test harnesses
- Check table virtuality before emitting TRUNCATE
When it happens
Trigger: Running `TRUNCATE <virtual_table>` on any read-only virtual table, e.g. `TRUNCATE system_views.threads` or `TRUNCATE system.local`.
Common situations: Cleanup scripts that truncate staging/test tables applied blindly to system_views; test harnesses resetting table contents without excluding virtual tables.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Modification is not supported by table %s
- Cannot TRUNCATE materialized view directly; must truncate ba
- Operator %s not supported for txn_id
- %s does not support complex column updates
- Unknown keyspace: '" + keyspaceName + "'
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/3db622b4a4311ac5.
Report an issue: GitHub.