apache/cassandra · error · UnsupportedOperationException
Setting capacity of NopCache is not permitted as this cache
Error message
Setting capacity of NopCache is not permitted as this cache is disabled. Check your yaml settings if you want to enable it.
What it means
NopCache is a disabled no-op cache; it intentionally performs nothing and must never be given a nonzero capacity, since that would imply it caches data it does not store. setCapacity throws UnsupportedOperationException for any nonzero value; passing 0 is accepted silently. The message points at yaml settings because this cache is selected when the corresponding cache type is disabled in config.
Source
Thrown at src/java/org/apache/cassandra/cache/NopCacheProvider.java:41
public class NopCacheProvider implements CacheProvider<RowCacheKey, IRowCacheEntry>
{
public ICache<RowCacheKey, IRowCacheEntry> create()
{
return new NopCache();
}
private static class NopCache implements ICache<RowCacheKey, IRowCacheEntry>
{
public long capacity()
{
return 0;
}
public void setCapacity(long capacity)
{
if (capacity != 0)
{
throw new UnsupportedOperationException("Setting capacity of " + NopCache.class.getSimpleName()
+ " is not permitted as this cache is disabled. Check your yaml settings if you want to enable it.");
}
}
public void put(RowCacheKey key, IRowCacheEntry value)
{
}
public boolean putIfAbsent(RowCacheKey key, IRowCacheEntry value)
{
return false;
}
public boolean replace(RowCacheKey key, IRowCacheEntry old, IRowCacheEntry value)
{
return false;
}
View on GitHub (pinned to 88fd0f6a0e)
Solutions
- If you actually want the cache, enable it in cassandra.yaml (e.g. row_cache_size_in_mb > 0 and the correct cache implementation) and restart the node so a real cache (SerializingCache) is created instead of NopCache.
- If the cache is intentionally disabled, call setCapacity(0) or do not call it at all.
- In generic code that resizes caches, catch UnsupportedOperationException or skip caches that are disabled.
- Check yaml keys such as row_cache_size_in_mb / key_cache_size_in_mb match the enabled cache types.
Example fix
// before cacheService.setRowCacheCapacity(rowCacheSizeInMb); // throws when row cache is disabled (NopCache) // after // cassandra.yaml: enable the cache first // row_cache_size_in_mb: 256 // then restart the node and resize at runtime
Defensive patterns
Strategy: validation
Validate before calling
// before resizing, confirm the cache is actually enabled
if (cache instanceof org.apache.cassandra.cache.NopCache && capacity != 0) {
throw new IllegalStateException("Cache disabled in yaml; enable it in cassandra.yaml before resizing");
} Type guard
boolean isCacheEnabled(ICache<?,?> c) { return !(c instanceof org.apache.cassandra.cache.NopCache); } Try / catch
try {
cache.setCapacity(capacity);
} catch (UnsupportedOperationException e) {
logger.warn("Cache disabled: {}", e.getMessage()); // enable in yaml + restart
} Prevention
- Enable the cache in cassandra.yaml before attempting runtime resize.
- Pass 0 (or skip the call) when the cache is intentionally disabled.
- Check NopCacheProvider/NopCache type before generic resize loops.
- Keep yaml cache sizes consistent with enabled cache types.
When it happens
Trigger: Calling NopCache.setCapacity(c) with c != 0, typically via JMX CacheService mbeans or code that resizes caches at runtime (e.g. CacheService.setRowCacheCapacity), or when a user enables capacity in cassandra.yaml while the cache implementation resolved to NopCache.
Common situations: Operators increasing row/key cache size via JMX (nodetool setcachecapacity paths) on a node where that cache is disabled in cassandra.yaml; misconfigured yaml that disables a cache but still sets its max size; automated tuning scripts applying capacity to all caches.
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
- Chunk cache size cannot be changed.
- prepared_statements_cache_size option was set incorrectly to
- key_cache_size option was set incorrectly to '<value>', supp
- counter_cache_size option was set incorrectly to '<value>',
- paxos_cache_size option was set incorrectly to '<value>', su
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/ab416af10d44939b.
Report an issue: GitHub.