apache/cassandra · error · IllegalArgumentException
Cannot perform any operations against virtual keyspace " +…
Error message
Cannot perform any operations against virtual keyspace " + keyspaceName
What it means
Keyspace.verifyKeyspaceIsValid(keyspaceName) rejects names registered in the VirtualKeyspaceRegistry with IllegalArgumentException 'Cannot perform any operations against virtual keyspace <name>'. Virtual keyspaces (system_views, system_virtual_schema) are in-memory, non-persisted views that cannot accept writes or DDL, so operations targeting them are refused.
Solutions
- Skip virtual keyspaces: filter out names present in VirtualKeyspaceRegistry (system_views, system_virtual_schema) before performing operations.
- Query the virtual tables only via SELECT (CQL queries are read-only there); never target them with writes/DDL/snapshots.
- Use Schema.instance.getKeyspaces() excluding VirtualKeyspaceRegistry entries when enumerating keyspaces for batch operations.
Example fix
// before
Keyspace.open(ksName); // fails for system_views
// after
if (VirtualKeyspaceRegistry.instance.getKeyspaceNullable(ksName) == null)
Keyspace.open(ksName); Defensive patterns
Strategy: validation
Validate before calling
if (VirtualKeyspaceRegistry.instance.getKeyspaceNullable(ksName) != null)
throw new IllegalArgumentException(ksName + " is a virtual keyspace; read-only via CQL SELECT");
Type guard
static boolean isVirtualKeyspace(String ks) {
return VirtualKeyspaceRegistry.instance.getKeyspaceNullable(ks) != null;
}
Try / catch
try {
Keyspace.getValidKeyspace(ksName);
} catch (IllegalArgumentException e) {
if (e.getMessage().startsWith("Cannot perform any operations against virtual keyspace"))
return; // skip virtual keyspaces in batch jobs
throw e;
}
Prevention
- Filter out system_views and system_virtual_schema when iterating keyspaces for admin operations.
- Treat virtual-keyspace tables as read-only monitoring endpoints only.
- Use Schema.instance.getKeyspaces() minus VirtualKeyspaceRegistry entries for operation lists.
When it happens
Trigger: Calling getValidKeyspace/verifyKeyspaceIsValid with 'system_views' or another virtual keyspace before operations like writes, schema changes, or snapshots; tooling that enumerates all keyspaces (including virtual) and then performs real operations on each.
Common situations: Scripts iterating over `DESCRIBE KEYSPACES` output that includes virtual keyspaces; monitoring tooling querying virtual tables but attempting admin operations; mistakenly treating virtual keyspace tables as regular tables for backup/restore.
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
- appendAll() can only be called on non-frozen collections
- Can not initialize cluster with empty cluster identifier
- Can't abort bootstrap for - it does not exist in cluster…
- e.getMessage()
- Invalid element selection
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/d7dc07d117ba9475.
Report an issue: GitHub.
Appendix: source
Thrown at src/java/org/apache/cassandra/db/Keyspace.java:230
if (cfs == null)
throw new IllegalArgumentException(String.format("Unknown CF %s %s", id, columnFamilyStores));
return cfs;
}
public ColumnFamilyStore getIfExists(TableId id)
{
return columnFamilyStores.get(id);
}
public boolean hasColumnFamilyStore(TableId id)
{
return columnFamilyStores.containsKey(id);
}
public static void verifyKeyspaceIsValid(String keyspaceName)
{
if (null != VirtualKeyspaceRegistry.instance.getKeyspaceNullable(keyspaceName))
throw new IllegalArgumentException("Cannot perform any operations against virtual keyspace " + keyspaceName);
if (!Schema.instance.getKeyspaces().contains(keyspaceName))
throw new IllegalArgumentException("Keyspace " + keyspaceName + " does not exist");
}
public static Keyspace getValidKeyspace(String keyspaceName)
{
verifyKeyspaceIsValid(keyspaceName);
return Keyspace.open(keyspaceName);
}
/**
* @return A list of open SSTableReaders
*/
public List<SSTableReader> getAllSSTables(SSTableSet sstableSet)
{
List<SSTableReader> list = new ArrayList<>(columnFamilyStores.size());
for (ColumnFamilyStore cfStore : columnFamilyStores.values())View on GitHub (pinned to 88fd0f6a0e)