apache/cassandra · error · IllegalArgumentException

Unknown cache name: ${cacheName}

Error message

Unknown cache name: ${cacheName}

What it means

NodeProbe.getCacheMetric (via the cache MBean switch) only recognizes KeyCache, RowCache, CounterCache, PermissionsCache and RolesCache. Any other cache name reaches the default branch and throws IllegalArgumentException.

Source

Thrown at src/java/org/apache/cassandra/tools/NodeProbe.java:771

        cacheService.invalidateRowCache();
    }

    public AuthCacheMBean getAuthCacheMBean(String cacheName)
    {
        switch (cacheName)
        {
            case PasswordAuthenticator.CredentialsCacheMBean.CACHE_NAME:
                return ccProxy;
            case AuthorizationProxy.JmxPermissionsCacheMBean.CACHE_NAME:
                return jpcProxy;
            case NetworkPermissionsCacheMBean.CACHE_NAME:
                return npcProxy;
            case PermissionsCacheMBean.CACHE_NAME:
                return pcProxy;
            case RolesCacheMBean.CACHE_NAME:
                return rcProxy;
            default:
                throw new IllegalArgumentException("Unknown cache name: " + cacheName);
        }
    }

    public void drain() throws IOException, InterruptedException, ExecutionException
    {
        ssProxy.drain();
    }

    public Map<String, String> getTokenToEndpointMap(boolean withPort)
    {
        return withPort ? ssProxy.getTokenToEndpointWithPortMap() : ssProxy.getTokenToEndpointMap();
    }

    public List<String> getLiveNodes(boolean withPort)
    {
        return withPort ? ssProxy.getLiveNodesWithPort() : ssProxy.getLiveNodes();
    }

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Use an exact cache name: KeyCache, RowCache, CounterCache, PermissionsCache, or RolesCache
  2. Fix case sensitivity in scripts (names are case-sensitive constants)
  3. Check Cassandra version docs for which caches exist in your release

Example fix

// before
nodetool setcachecapacity keycache 512
// after
nodetool setcachecapacity KeyCache 512
Defensive patterns

Strategy: validation

Validate before calling

Set<String> valid = Set.of("KeyCache","RowCache","CounterCache","PermissionsCache","RolesCache");
if (!valid.contains(cacheName))
    throw new IllegalArgumentException("Unknown cache name: " + cacheName);

Try / catch

try {
    probe.setCacheCapacity(cacheName, capacityInMB);
} catch (IllegalArgumentException e) {
    System.err.println("Use one of: KeyCache, RowCache, CounterCache, PermissionsCache, RolesCache");
}

Prevention

When it happens

Trigger: Calling nodetool cachecapacity/clear/disable/etc. (NodeProbe cache methods) with a cacheName string that is not one of the five known CACHE_NAME constants — typically a typo like 'keycache' or 'row_cache' instead of 'KeyCache'/'RowCache'.

Common situations: Typo in a script using lowercase names; referencing a cache removed in newer Cassandra versions; assuming a custom cache exists.

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


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/938d9590dc891232. Report an issue: GitHub.